babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. private _useInstancing;
  11254. /**
  11255. * An event triggered when the manager is disposed.
  11256. */
  11257. onDisposeObservable: Observable<SpriteManager>;
  11258. private _onDisposeObserver;
  11259. /**
  11260. * Callback called when the manager is disposed
  11261. */
  11262. set onDispose(callback: () => void);
  11263. private _capacity;
  11264. private _fromPacked;
  11265. private _spriteTexture;
  11266. private _epsilon;
  11267. private _scene;
  11268. private _vertexData;
  11269. private _buffer;
  11270. private _vertexBuffers;
  11271. private _spriteBuffer;
  11272. private _indexBuffer;
  11273. private _effectBase;
  11274. private _effectFog;
  11275. private _vertexBufferSize;
  11276. /**
  11277. * Gets or sets the unique id of the sprite
  11278. */
  11279. uniqueId: number;
  11280. /**
  11281. * Gets the array of sprites
  11282. */
  11283. get children(): Sprite[];
  11284. /**
  11285. * Gets the hosting scene
  11286. */
  11287. get scene(): Scene;
  11288. /**
  11289. * Gets the capacity of the manager
  11290. */
  11291. get capacity(): number;
  11292. /**
  11293. * Gets or sets the spritesheet texture
  11294. */
  11295. get texture(): Texture;
  11296. set texture(value: Texture);
  11297. private _blendMode;
  11298. /**
  11299. * Blend mode use to render the particle, it can be any of
  11300. * the static Constants.ALPHA_x properties provided in this class.
  11301. * Default value is Constants.ALPHA_COMBINE
  11302. */
  11303. get blendMode(): number;
  11304. set blendMode(blendMode: number);
  11305. /** Disables writing to the depth buffer when rendering the sprites.
  11306. * It can be handy to disable depth writing when using textures without alpha channel
  11307. * and setting some specific blend modes.
  11308. */
  11309. disableDepthWrite: boolean;
  11310. /**
  11311. * Creates a new sprite manager
  11312. * @param name defines the manager's name
  11313. * @param imgUrl defines the sprite sheet url
  11314. * @param capacity defines the maximum allowed number of sprites
  11315. * @param cellSize defines the size of a sprite cell
  11316. * @param scene defines the hosting scene
  11317. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11318. * @param samplingMode defines the smapling mode to use with spritesheet
  11319. * @param fromPacked set to false; do not alter
  11320. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11321. */
  11322. constructor(
  11323. /** defines the manager's name */
  11324. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11325. /**
  11326. * Returns the string "SpriteManager"
  11327. * @returns "SpriteManager"
  11328. */
  11329. getClassName(): string;
  11330. private _makePacked;
  11331. private _appendSpriteVertex;
  11332. private _checkTextureAlpha;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11339. * @returns null if no hit or a PickingInfo
  11340. */
  11341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11342. /**
  11343. * Intersects the sprites with a ray
  11344. * @param ray defines the ray to intersect with
  11345. * @param camera defines the current active camera
  11346. * @param predicate defines a predicate used to select candidate sprites
  11347. * @returns null if no hit or a PickingInfo array
  11348. */
  11349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11350. /**
  11351. * Render all child sprites
  11352. */
  11353. render(): void;
  11354. /**
  11355. * Release associated resources
  11356. */
  11357. dispose(): void;
  11358. /**
  11359. * Serializes the sprite manager to a JSON object
  11360. * @param serializeTexture defines if the texture must be serialized as well
  11361. * @returns the JSON object
  11362. */
  11363. serialize(serializeTexture?: boolean): any;
  11364. /**
  11365. * Parses a JSON object to create a new sprite manager.
  11366. * @param parsedManager The JSON object to parse
  11367. * @param scene The scene to create the sprite managerin
  11368. * @param rootUrl The root url to use to load external dependencies like texture
  11369. * @returns the new sprite manager
  11370. */
  11371. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11372. /**
  11373. * Creates a sprite manager from a snippet saved in a remote file
  11374. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11375. * @param url defines the url to load from
  11376. * @param scene defines the hosting scene
  11377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11378. * @returns a promise that will resolve to the new sprite manager
  11379. */
  11380. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11381. /**
  11382. * Creates a sprite manager from a snippet saved by the sprite editor
  11383. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11384. * @param scene defines the hosting scene
  11385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11386. * @returns a promise that will resolve to the new sprite manager
  11387. */
  11388. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11389. }
  11390. }
  11391. declare module "babylonjs/Misc/gradients" {
  11392. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11393. /** Interface used by value gradients (color, factor, ...) */
  11394. export interface IValueGradient {
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number;
  11399. }
  11400. /** Class used to store color4 gradient */
  11401. export class ColorGradient implements IValueGradient {
  11402. /**
  11403. * Gets or sets the gradient value (between 0 and 1)
  11404. */
  11405. gradient: number;
  11406. /**
  11407. * Gets or sets first associated color
  11408. */
  11409. color1: Color4;
  11410. /**
  11411. * Gets or sets second associated color
  11412. */
  11413. color2?: Color4 | undefined;
  11414. /**
  11415. * Creates a new color4 gradient
  11416. * @param gradient gets or sets the gradient value (between 0 and 1)
  11417. * @param color1 gets or sets first associated color
  11418. * @param color2 gets or sets first second color
  11419. */
  11420. constructor(
  11421. /**
  11422. * Gets or sets the gradient value (between 0 and 1)
  11423. */
  11424. gradient: number,
  11425. /**
  11426. * Gets or sets first associated color
  11427. */
  11428. color1: Color4,
  11429. /**
  11430. * Gets or sets second associated color
  11431. */
  11432. color2?: Color4 | undefined);
  11433. /**
  11434. * Will get a color picked randomly between color1 and color2.
  11435. * If color2 is undefined then color1 will be used
  11436. * @param result defines the target Color4 to store the result in
  11437. */
  11438. getColorToRef(result: Color4): void;
  11439. }
  11440. /** Class used to store color 3 gradient */
  11441. export class Color3Gradient implements IValueGradient {
  11442. /**
  11443. * Gets or sets the gradient value (between 0 and 1)
  11444. */
  11445. gradient: number;
  11446. /**
  11447. * Gets or sets the associated color
  11448. */
  11449. color: Color3;
  11450. /**
  11451. * Creates a new color3 gradient
  11452. * @param gradient gets or sets the gradient value (between 0 and 1)
  11453. * @param color gets or sets associated color
  11454. */
  11455. constructor(
  11456. /**
  11457. * Gets or sets the gradient value (between 0 and 1)
  11458. */
  11459. gradient: number,
  11460. /**
  11461. * Gets or sets the associated color
  11462. */
  11463. color: Color3);
  11464. }
  11465. /** Class used to store factor gradient */
  11466. export class FactorGradient implements IValueGradient {
  11467. /**
  11468. * Gets or sets the gradient value (between 0 and 1)
  11469. */
  11470. gradient: number;
  11471. /**
  11472. * Gets or sets first associated factor
  11473. */
  11474. factor1: number;
  11475. /**
  11476. * Gets or sets second associated factor
  11477. */
  11478. factor2?: number | undefined;
  11479. /**
  11480. * Creates a new factor gradient
  11481. * @param gradient gets or sets the gradient value (between 0 and 1)
  11482. * @param factor1 gets or sets first associated factor
  11483. * @param factor2 gets or sets second associated factor
  11484. */
  11485. constructor(
  11486. /**
  11487. * Gets or sets the gradient value (between 0 and 1)
  11488. */
  11489. gradient: number,
  11490. /**
  11491. * Gets or sets first associated factor
  11492. */
  11493. factor1: number,
  11494. /**
  11495. * Gets or sets second associated factor
  11496. */
  11497. factor2?: number | undefined);
  11498. /**
  11499. * Will get a number picked randomly between factor1 and factor2.
  11500. * If factor2 is undefined then factor1 will be used
  11501. * @returns the picked number
  11502. */
  11503. getFactor(): number;
  11504. }
  11505. /**
  11506. * Helper used to simplify some generic gradient tasks
  11507. */
  11508. export class GradientHelper {
  11509. /**
  11510. * Gets the current gradient from an array of IValueGradient
  11511. * @param ratio defines the current ratio to get
  11512. * @param gradients defines the array of IValueGradient
  11513. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11514. */
  11515. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11516. }
  11517. }
  11518. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11519. import { Nullable } from "babylonjs/types";
  11520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11521. import { Scene } from "babylonjs/scene";
  11522. module "babylonjs/Engines/thinEngine" {
  11523. interface ThinEngine {
  11524. /**
  11525. * Creates a raw texture
  11526. * @param data defines the data to store in the texture
  11527. * @param width defines the width of the texture
  11528. * @param height defines the height of the texture
  11529. * @param format defines the format of the data
  11530. * @param generateMipMaps defines if the engine should generate the mip levels
  11531. * @param invertY defines if data must be stored with Y axis inverted
  11532. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11533. * @param compression defines the compression used (null by default)
  11534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11535. * @returns the raw texture inside an InternalTexture
  11536. */
  11537. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11538. /**
  11539. * Update a raw texture
  11540. * @param texture defines the texture to update
  11541. * @param data defines the data to store in the texture
  11542. * @param format defines the format of the data
  11543. * @param invertY defines if data must be stored with Y axis inverted
  11544. */
  11545. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11546. /**
  11547. * Update a raw texture
  11548. * @param texture defines the texture to update
  11549. * @param data defines the data to store in the texture
  11550. * @param format defines the format of the data
  11551. * @param invertY defines if data must be stored with Y axis inverted
  11552. * @param compression defines the compression used (null by default)
  11553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11554. */
  11555. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11556. /**
  11557. * Creates a new raw cube texture
  11558. * @param data defines the array of data to use to create each face
  11559. * @param size defines the size of the textures
  11560. * @param format defines the format of the data
  11561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11562. * @param generateMipMaps defines if the engine should generate the mip levels
  11563. * @param invertY defines if data must be stored with Y axis inverted
  11564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11565. * @param compression defines the compression used (null by default)
  11566. * @returns the cube texture as an InternalTexture
  11567. */
  11568. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11569. /**
  11570. * Update a raw cube texture
  11571. * @param texture defines the texture to udpdate
  11572. * @param data defines the data to store
  11573. * @param format defines the data format
  11574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11575. * @param invertY defines if data must be stored with Y axis inverted
  11576. */
  11577. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11578. /**
  11579. * Update a raw cube texture
  11580. * @param texture defines the texture to udpdate
  11581. * @param data defines the data to store
  11582. * @param format defines the data format
  11583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @param compression defines the compression used (null by default)
  11586. */
  11587. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11588. /**
  11589. * Update a raw cube texture
  11590. * @param texture defines the texture to udpdate
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the compression used (null by default)
  11596. * @param level defines which level of the texture to update
  11597. */
  11598. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11599. /**
  11600. * Creates a new raw cube texture from a specified url
  11601. * @param url defines the url where the data is located
  11602. * @param scene defines the current scene
  11603. * @param size defines the size of the textures
  11604. * @param format defines the format of the data
  11605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11606. * @param noMipmap defines if the engine should avoid generating the mip levels
  11607. * @param callback defines a callback used to extract texture data from loaded data
  11608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11609. * @param onLoad defines a callback called when texture is loaded
  11610. * @param onError defines a callback called if there is an error
  11611. * @returns the cube texture as an InternalTexture
  11612. */
  11613. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11614. /**
  11615. * Creates a new raw cube texture from a specified url
  11616. * @param url defines the url where the data is located
  11617. * @param scene defines the current scene
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param noMipmap defines if the engine should avoid generating the mip levels
  11622. * @param callback defines a callback used to extract texture data from loaded data
  11623. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11624. * @param onLoad defines a callback called when texture is loaded
  11625. * @param onError defines a callback called if there is an error
  11626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @returns the cube texture as an InternalTexture
  11629. */
  11630. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11631. /**
  11632. * Creates a new raw 3D texture
  11633. * @param data defines the data used to create the texture
  11634. * @param width defines the width of the texture
  11635. * @param height defines the height of the texture
  11636. * @param depth defines the depth of the texture
  11637. * @param format defines the format of the texture
  11638. * @param generateMipMaps defines if the engine must generate mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11641. * @param compression defines the compressed used (can be null)
  11642. * @param textureType defines the compressed used (can be null)
  11643. * @returns a new raw 3D texture (stored in an InternalTexture)
  11644. */
  11645. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11646. /**
  11647. * Update a raw 3D texture
  11648. * @param texture defines the texture to update
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw 3D texture
  11656. * @param texture defines the texture to update
  11657. * @param data defines the data to store
  11658. * @param format defines the data format
  11659. * @param invertY defines if data must be stored with Y axis inverted
  11660. * @param compression defines the used compression (can be null)
  11661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11662. */
  11663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11664. /**
  11665. * Creates a new raw 2D array texture
  11666. * @param data defines the data used to create the texture
  11667. * @param width defines the width of the texture
  11668. * @param height defines the height of the texture
  11669. * @param depth defines the number of layers of the texture
  11670. * @param format defines the format of the texture
  11671. * @param generateMipMaps defines if the engine must generate mip levels
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11674. * @param compression defines the compressed used (can be null)
  11675. * @param textureType defines the compressed used (can be null)
  11676. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11677. */
  11678. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11679. /**
  11680. * Update a raw 2D array texture
  11681. * @param texture defines the texture to update
  11682. * @param data defines the data to store
  11683. * @param format defines the data format
  11684. * @param invertY defines if data must be stored with Y axis inverted
  11685. */
  11686. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11687. /**
  11688. * Update a raw 2D array texture
  11689. * @param texture defines the texture to update
  11690. * @param data defines the data to store
  11691. * @param format defines the data format
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @param compression defines the used compression (can be null)
  11694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11695. */
  11696. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11697. }
  11698. }
  11699. }
  11700. declare module "babylonjs/Materials/Textures/rawTexture" {
  11701. import { Texture } from "babylonjs/Materials/Textures/texture";
  11702. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11703. import { Nullable } from "babylonjs/types";
  11704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11705. import { Scene } from "babylonjs/scene";
  11706. /**
  11707. * Raw texture can help creating a texture directly from an array of data.
  11708. * This can be super useful if you either get the data from an uncompressed source or
  11709. * if you wish to create your texture pixel by pixel.
  11710. */
  11711. export class RawTexture extends Texture {
  11712. /**
  11713. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11714. */
  11715. format: number;
  11716. /**
  11717. * Instantiates a new RawTexture.
  11718. * Raw texture can help creating a texture directly from an array of data.
  11719. * This can be super useful if you either get the data from an uncompressed source or
  11720. * if you wish to create your texture pixel by pixel.
  11721. * @param data define the array of data to use to create the texture
  11722. * @param width define the width of the texture
  11723. * @param height define the height of the texture
  11724. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11725. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11726. * @param generateMipMaps define whether mip maps should be generated or not
  11727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11730. */
  11731. constructor(data: ArrayBufferView, width: number, height: number,
  11732. /**
  11733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11734. */
  11735. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11736. /**
  11737. * Updates the texture underlying data.
  11738. * @param data Define the new data of the texture
  11739. */
  11740. update(data: ArrayBufferView): void;
  11741. /**
  11742. * Creates a luminance texture from some data.
  11743. * @param data Define the texture data
  11744. * @param width Define the width of the texture
  11745. * @param height Define the height of the texture
  11746. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11750. * @returns the luminance texture
  11751. */
  11752. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11753. /**
  11754. * Creates a luminance alpha texture from some data.
  11755. * @param data Define the texture data
  11756. * @param width Define the width of the texture
  11757. * @param height Define the height of the texture
  11758. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11762. * @returns the luminance alpha texture
  11763. */
  11764. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11765. /**
  11766. * Creates an alpha texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the alpha texture
  11775. */
  11776. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a RGB texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11787. * @returns the RGB alpha texture
  11788. */
  11789. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11790. /**
  11791. * Creates a RGBA texture from some data.
  11792. * @param data Define the texture data
  11793. * @param width Define the width of the texture
  11794. * @param height Define the height of the texture
  11795. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11800. * @returns the RGBA texture
  11801. */
  11802. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11803. /**
  11804. * Creates a R texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the R texture
  11814. */
  11815. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. }
  11817. }
  11818. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11819. import { Scene } from "babylonjs/scene";
  11820. import { ISceneComponent } from "babylonjs/sceneComponent";
  11821. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11822. module "babylonjs/abstractScene" {
  11823. interface AbstractScene {
  11824. /**
  11825. * The list of procedural textures added to the scene
  11826. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11827. */
  11828. proceduralTextures: Array<ProceduralTexture>;
  11829. }
  11830. }
  11831. /**
  11832. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11833. * in a given scene.
  11834. */
  11835. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11836. /**
  11837. * The component name helpfull to identify the component in the list of scene components.
  11838. */
  11839. readonly name: string;
  11840. /**
  11841. * The scene the component belongs to.
  11842. */
  11843. scene: Scene;
  11844. /**
  11845. * Creates a new instance of the component for the given scene
  11846. * @param scene Defines the scene to register the component in
  11847. */
  11848. constructor(scene: Scene);
  11849. /**
  11850. * Registers the component in a given scene
  11851. */
  11852. register(): void;
  11853. /**
  11854. * Rebuilds the elements related to this component in case of
  11855. * context lost for instance.
  11856. */
  11857. rebuild(): void;
  11858. /**
  11859. * Disposes the component and the associated ressources.
  11860. */
  11861. dispose(): void;
  11862. private _beforeClear;
  11863. }
  11864. }
  11865. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11867. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11868. module "babylonjs/Engines/thinEngine" {
  11869. interface ThinEngine {
  11870. /**
  11871. * Creates a new render target cube texture
  11872. * @param size defines the size of the texture
  11873. * @param options defines the options used to create the texture
  11874. * @returns a new render target cube texture stored in an InternalTexture
  11875. */
  11876. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11877. }
  11878. }
  11879. }
  11880. declare module "babylonjs/Shaders/procedural.vertex" {
  11881. /** @hidden */
  11882. export var proceduralVertexShader: {
  11883. name: string;
  11884. shader: string;
  11885. };
  11886. }
  11887. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11888. import { Observable } from "babylonjs/Misc/observable";
  11889. import { Nullable } from "babylonjs/types";
  11890. import { Scene } from "babylonjs/scene";
  11891. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11892. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11893. import { Effect } from "babylonjs/Materials/effect";
  11894. import { Texture } from "babylonjs/Materials/Textures/texture";
  11895. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11896. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11897. import "babylonjs/Shaders/procedural.vertex";
  11898. /**
  11899. * 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.
  11900. * This is the base class of any Procedural texture and contains most of the shareable code.
  11901. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11902. */
  11903. export class ProceduralTexture extends Texture {
  11904. isCube: boolean;
  11905. /**
  11906. * Define if the texture is enabled or not (disabled texture will not render)
  11907. */
  11908. isEnabled: boolean;
  11909. /**
  11910. * Define if the texture must be cleared before rendering (default is true)
  11911. */
  11912. autoClear: boolean;
  11913. /**
  11914. * Callback called when the texture is generated
  11915. */
  11916. onGenerated: () => void;
  11917. /**
  11918. * Event raised when the texture is generated
  11919. */
  11920. onGeneratedObservable: Observable<ProceduralTexture>;
  11921. /** @hidden */
  11922. _generateMipMaps: boolean;
  11923. /** @hidden **/
  11924. _effect: Effect;
  11925. /** @hidden */
  11926. _textures: {
  11927. [key: string]: Texture;
  11928. };
  11929. /** @hidden */
  11930. protected _fallbackTexture: Nullable<Texture>;
  11931. private _size;
  11932. private _currentRefreshId;
  11933. private _frameId;
  11934. private _refreshRate;
  11935. private _vertexBuffers;
  11936. private _indexBuffer;
  11937. private _uniforms;
  11938. private _samplers;
  11939. private _fragment;
  11940. private _floats;
  11941. private _ints;
  11942. private _floatsArrays;
  11943. private _colors3;
  11944. private _colors4;
  11945. private _vectors2;
  11946. private _vectors3;
  11947. private _matrices;
  11948. private _fallbackTextureUsed;
  11949. private _fullEngine;
  11950. private _cachedDefines;
  11951. private _contentUpdateId;
  11952. private _contentData;
  11953. /**
  11954. * Instantiates a new procedural texture.
  11955. * 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.
  11956. * This is the base class of any Procedural texture and contains most of the shareable code.
  11957. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11958. * @param name Define the name of the texture
  11959. * @param size Define the size of the texture to create
  11960. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11961. * @param scene Define the scene the texture belongs to
  11962. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11963. * @param generateMipMaps Define if the texture should creates mip maps or not
  11964. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11965. */
  11966. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11967. /**
  11968. * The effect that is created when initializing the post process.
  11969. * @returns The created effect corresponding the the postprocess.
  11970. */
  11971. getEffect(): Effect;
  11972. /**
  11973. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11974. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11975. */
  11976. getContent(): Nullable<ArrayBufferView>;
  11977. private _createIndexBuffer;
  11978. /** @hidden */
  11979. _rebuild(): void;
  11980. /**
  11981. * Resets the texture in order to recreate its associated resources.
  11982. * This can be called in case of context loss
  11983. */
  11984. reset(): void;
  11985. protected _getDefines(): string;
  11986. /**
  11987. * Is the texture ready to be used ? (rendered at least once)
  11988. * @returns true if ready, otherwise, false.
  11989. */
  11990. isReady(): boolean;
  11991. /**
  11992. * Resets the refresh counter of the texture and start bak from scratch.
  11993. * Could be useful to regenerate the texture if it is setup to render only once.
  11994. */
  11995. resetRefreshCounter(): void;
  11996. /**
  11997. * Set the fragment shader to use in order to render the texture.
  11998. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11999. */
  12000. setFragment(fragment: any): void;
  12001. /**
  12002. * Define the refresh rate of the texture or the rendering frequency.
  12003. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12004. */
  12005. get refreshRate(): number;
  12006. set refreshRate(value: number);
  12007. /** @hidden */
  12008. _shouldRender(): boolean;
  12009. /**
  12010. * Get the size the texture is rendering at.
  12011. * @returns the size (texture is always squared)
  12012. */
  12013. getRenderSize(): number;
  12014. /**
  12015. * Resize the texture to new value.
  12016. * @param size Define the new size the texture should have
  12017. * @param generateMipMaps Define whether the new texture should create mip maps
  12018. */
  12019. resize(size: number, generateMipMaps: boolean): void;
  12020. private _checkUniform;
  12021. /**
  12022. * Set a texture in the shader program used to render.
  12023. * @param name Define the name of the uniform samplers as defined in the shader
  12024. * @param texture Define the texture to bind to this sampler
  12025. * @return the texture itself allowing "fluent" like uniform updates
  12026. */
  12027. setTexture(name: string, texture: Texture): ProceduralTexture;
  12028. /**
  12029. * Set a float in the shader.
  12030. * @param name Define the name of the uniform as defined in the shader
  12031. * @param value Define the value to give to the uniform
  12032. * @return the texture itself allowing "fluent" like uniform updates
  12033. */
  12034. setFloat(name: string, value: number): ProceduralTexture;
  12035. /**
  12036. * Set a int in the shader.
  12037. * @param name Define the name of the uniform as defined in the shader
  12038. * @param value Define the value to give to the uniform
  12039. * @return the texture itself allowing "fluent" like uniform updates
  12040. */
  12041. setInt(name: string, value: number): ProceduralTexture;
  12042. /**
  12043. * Set an array of floats in the shader.
  12044. * @param name Define the name of the uniform as defined in the shader
  12045. * @param value Define the value to give to the uniform
  12046. * @return the texture itself allowing "fluent" like uniform updates
  12047. */
  12048. setFloats(name: string, value: number[]): ProceduralTexture;
  12049. /**
  12050. * Set a vec3 in the shader from a Color3.
  12051. * @param name Define the name of the uniform as defined in the shader
  12052. * @param value Define the value to give to the uniform
  12053. * @return the texture itself allowing "fluent" like uniform updates
  12054. */
  12055. setColor3(name: string, value: Color3): ProceduralTexture;
  12056. /**
  12057. * Set a vec4 in the shader from a Color4.
  12058. * @param name Define the name of the uniform as defined in the shader
  12059. * @param value Define the value to give to the uniform
  12060. * @return the texture itself allowing "fluent" like uniform updates
  12061. */
  12062. setColor4(name: string, value: Color4): ProceduralTexture;
  12063. /**
  12064. * Set a vec2 in the shader from a Vector2.
  12065. * @param name Define the name of the uniform as defined in the shader
  12066. * @param value Define the value to give to the uniform
  12067. * @return the texture itself allowing "fluent" like uniform updates
  12068. */
  12069. setVector2(name: string, value: Vector2): ProceduralTexture;
  12070. /**
  12071. * Set a vec3 in the shader from a Vector3.
  12072. * @param name Define the name of the uniform as defined in the shader
  12073. * @param value Define the value to give to the uniform
  12074. * @return the texture itself allowing "fluent" like uniform updates
  12075. */
  12076. setVector3(name: string, value: Vector3): ProceduralTexture;
  12077. /**
  12078. * Set a mat4 in the shader from a MAtrix.
  12079. * @param name Define the name of the uniform as defined in the shader
  12080. * @param value Define the value to give to the uniform
  12081. * @return the texture itself allowing "fluent" like uniform updates
  12082. */
  12083. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12084. /**
  12085. * Render the texture to its associated render target.
  12086. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12087. */
  12088. render(useCameraPostProcess?: boolean): void;
  12089. /**
  12090. * Clone the texture.
  12091. * @returns the cloned texture
  12092. */
  12093. clone(): ProceduralTexture;
  12094. /**
  12095. * Dispose the texture and release its asoociated resources.
  12096. */
  12097. dispose(): void;
  12098. }
  12099. }
  12100. declare module "babylonjs/Particles/baseParticleSystem" {
  12101. import { Nullable } from "babylonjs/types";
  12102. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12104. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12105. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12106. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12107. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12108. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12109. import { Texture } from "babylonjs/Materials/Textures/texture";
  12110. import { Color4 } from "babylonjs/Maths/math.color";
  12111. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12112. import { Animation } from "babylonjs/Animations/animation";
  12113. import { Scene } from "babylonjs/scene";
  12114. /**
  12115. * This represents the base class for particle system in Babylon.
  12116. * 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.
  12117. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12118. * @example https://doc.babylonjs.com/babylon101/particles
  12119. */
  12120. export class BaseParticleSystem {
  12121. /**
  12122. * Source color is added to the destination color without alpha affecting the result
  12123. */
  12124. static BLENDMODE_ONEONE: number;
  12125. /**
  12126. * Blend current color and particle color using particle’s alpha
  12127. */
  12128. static BLENDMODE_STANDARD: number;
  12129. /**
  12130. * Add current color and particle color multiplied by particle’s alpha
  12131. */
  12132. static BLENDMODE_ADD: number;
  12133. /**
  12134. * Multiply current color with particle color
  12135. */
  12136. static BLENDMODE_MULTIPLY: number;
  12137. /**
  12138. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12139. */
  12140. static BLENDMODE_MULTIPLYADD: number;
  12141. /**
  12142. * List of animations used by the particle system.
  12143. */
  12144. animations: Animation[];
  12145. /**
  12146. * Gets or sets the unique id of the particle system
  12147. */
  12148. uniqueId: number;
  12149. /**
  12150. * The id of the Particle system.
  12151. */
  12152. id: string;
  12153. /**
  12154. * The friendly name of the Particle system.
  12155. */
  12156. name: string;
  12157. /**
  12158. * Snippet ID if the particle system was created from the snippet server
  12159. */
  12160. snippetId: string;
  12161. /**
  12162. * The rendering group used by the Particle system to chose when to render.
  12163. */
  12164. renderingGroupId: number;
  12165. /**
  12166. * The emitter represents the Mesh or position we are attaching the particle system to.
  12167. */
  12168. emitter: Nullable<AbstractMesh | Vector3>;
  12169. /**
  12170. * The maximum number of particles to emit per frame
  12171. */
  12172. emitRate: number;
  12173. /**
  12174. * If you want to launch only a few particles at once, that can be done, as well.
  12175. */
  12176. manualEmitCount: number;
  12177. /**
  12178. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12179. */
  12180. updateSpeed: number;
  12181. /**
  12182. * The amount of time the particle system is running (depends of the overall update speed).
  12183. */
  12184. targetStopDuration: number;
  12185. /**
  12186. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12187. */
  12188. disposeOnStop: boolean;
  12189. /**
  12190. * Minimum power of emitting particles.
  12191. */
  12192. minEmitPower: number;
  12193. /**
  12194. * Maximum power of emitting particles.
  12195. */
  12196. maxEmitPower: number;
  12197. /**
  12198. * Minimum life time of emitting particles.
  12199. */
  12200. minLifeTime: number;
  12201. /**
  12202. * Maximum life time of emitting particles.
  12203. */
  12204. maxLifeTime: number;
  12205. /**
  12206. * Minimum Size of emitting particles.
  12207. */
  12208. minSize: number;
  12209. /**
  12210. * Maximum Size of emitting particles.
  12211. */
  12212. maxSize: number;
  12213. /**
  12214. * Minimum scale of emitting particles on X axis.
  12215. */
  12216. minScaleX: number;
  12217. /**
  12218. * Maximum scale of emitting particles on X axis.
  12219. */
  12220. maxScaleX: number;
  12221. /**
  12222. * Minimum scale of emitting particles on Y axis.
  12223. */
  12224. minScaleY: number;
  12225. /**
  12226. * Maximum scale of emitting particles on Y axis.
  12227. */
  12228. maxScaleY: number;
  12229. /**
  12230. * Gets or sets the minimal initial rotation in radians.
  12231. */
  12232. minInitialRotation: number;
  12233. /**
  12234. * Gets or sets the maximal initial rotation in radians.
  12235. */
  12236. maxInitialRotation: number;
  12237. /**
  12238. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12239. */
  12240. minAngularSpeed: number;
  12241. /**
  12242. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12243. */
  12244. maxAngularSpeed: number;
  12245. /**
  12246. * The texture used to render each particle. (this can be a spritesheet)
  12247. */
  12248. particleTexture: Nullable<Texture>;
  12249. /**
  12250. * The layer mask we are rendering the particles through.
  12251. */
  12252. layerMask: number;
  12253. /**
  12254. * This can help using your own shader to render the particle system.
  12255. * The according effect will be created
  12256. */
  12257. customShader: any;
  12258. /**
  12259. * By default particle system starts as soon as they are created. This prevents the
  12260. * automatic start to happen and let you decide when to start emitting particles.
  12261. */
  12262. preventAutoStart: boolean;
  12263. private _noiseTexture;
  12264. /**
  12265. * Gets or sets a texture used to add random noise to particle positions
  12266. */
  12267. get noiseTexture(): Nullable<ProceduralTexture>;
  12268. set noiseTexture(value: Nullable<ProceduralTexture>);
  12269. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12270. noiseStrength: Vector3;
  12271. /**
  12272. * Callback triggered when the particle animation is ending.
  12273. */
  12274. onAnimationEnd: Nullable<() => void>;
  12275. /**
  12276. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12277. */
  12278. blendMode: number;
  12279. /**
  12280. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12281. * to override the particles.
  12282. */
  12283. forceDepthWrite: boolean;
  12284. /** 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 */
  12285. preWarmCycles: number;
  12286. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12287. preWarmStepOffset: number;
  12288. /**
  12289. * 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)
  12290. */
  12291. spriteCellChangeSpeed: number;
  12292. /**
  12293. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12294. */
  12295. startSpriteCellID: number;
  12296. /**
  12297. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12298. */
  12299. endSpriteCellID: number;
  12300. /**
  12301. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12302. */
  12303. spriteCellWidth: number;
  12304. /**
  12305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12306. */
  12307. spriteCellHeight: number;
  12308. /**
  12309. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12310. */
  12311. spriteRandomStartCell: boolean;
  12312. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12313. translationPivot: Vector2;
  12314. /** @hidden */
  12315. protected _isAnimationSheetEnabled: boolean;
  12316. /**
  12317. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12318. */
  12319. beginAnimationOnStart: boolean;
  12320. /**
  12321. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12322. */
  12323. beginAnimationFrom: number;
  12324. /**
  12325. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12326. */
  12327. beginAnimationTo: number;
  12328. /**
  12329. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12330. */
  12331. beginAnimationLoop: boolean;
  12332. /**
  12333. * Gets or sets a world offset applied to all particles
  12334. */
  12335. worldOffset: Vector3;
  12336. /**
  12337. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12338. */
  12339. get isAnimationSheetEnabled(): boolean;
  12340. set isAnimationSheetEnabled(value: boolean);
  12341. /**
  12342. * Get hosting scene
  12343. * @returns the scene
  12344. */
  12345. getScene(): Nullable<Scene>;
  12346. /**
  12347. * You can use gravity if you want to give an orientation to your particles.
  12348. */
  12349. gravity: Vector3;
  12350. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12351. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12352. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12353. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12354. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12355. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12356. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12357. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12358. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12359. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12360. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12361. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12362. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12363. /**
  12364. * Defines the delay in milliseconds before starting the system (0 by default)
  12365. */
  12366. startDelay: number;
  12367. /**
  12368. * Gets the current list of drag gradients.
  12369. * You must use addDragGradient and removeDragGradient to udpate this list
  12370. * @returns the list of drag gradients
  12371. */
  12372. getDragGradients(): Nullable<Array<FactorGradient>>;
  12373. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12374. limitVelocityDamping: number;
  12375. /**
  12376. * Gets the current list of limit velocity gradients.
  12377. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12378. * @returns the list of limit velocity gradients
  12379. */
  12380. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12381. /**
  12382. * Gets the current list of color gradients.
  12383. * You must use addColorGradient and removeColorGradient to udpate this list
  12384. * @returns the list of color gradients
  12385. */
  12386. getColorGradients(): Nullable<Array<ColorGradient>>;
  12387. /**
  12388. * Gets the current list of size gradients.
  12389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12390. * @returns the list of size gradients
  12391. */
  12392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12393. /**
  12394. * Gets the current list of color remap gradients.
  12395. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12396. * @returns the list of color remap gradients
  12397. */
  12398. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12399. /**
  12400. * Gets the current list of alpha remap gradients.
  12401. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12402. * @returns the list of alpha remap gradients
  12403. */
  12404. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of life time gradients.
  12407. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12408. * @returns the list of life time gradients
  12409. */
  12410. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12411. /**
  12412. * Gets the current list of angular speed gradients.
  12413. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12414. * @returns the list of angular speed gradients
  12415. */
  12416. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of velocity gradients.
  12419. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12420. * @returns the list of velocity gradients
  12421. */
  12422. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of start size gradients.
  12425. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12426. * @returns the list of start size gradients
  12427. */
  12428. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of emit rate gradients.
  12431. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12432. * @returns the list of emit rate gradients
  12433. */
  12434. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12438. */
  12439. get direction1(): Vector3;
  12440. set direction1(value: Vector3);
  12441. /**
  12442. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12443. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12444. */
  12445. get direction2(): Vector3;
  12446. set direction2(value: Vector3);
  12447. /**
  12448. * 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.
  12449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12450. */
  12451. get minEmitBox(): Vector3;
  12452. set minEmitBox(value: Vector3);
  12453. /**
  12454. * 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.
  12455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12456. */
  12457. get maxEmitBox(): Vector3;
  12458. set maxEmitBox(value: Vector3);
  12459. /**
  12460. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12461. */
  12462. color1: Color4;
  12463. /**
  12464. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12465. */
  12466. color2: Color4;
  12467. /**
  12468. * Color the particle will have at the end of its lifetime
  12469. */
  12470. colorDead: Color4;
  12471. /**
  12472. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12473. */
  12474. textureMask: Color4;
  12475. /**
  12476. * The particle emitter type defines the emitter used by the particle system.
  12477. * It can be for example box, sphere, or cone...
  12478. */
  12479. particleEmitterType: IParticleEmitterType;
  12480. /** @hidden */
  12481. _isSubEmitter: boolean;
  12482. /**
  12483. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12484. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12485. */
  12486. billboardMode: number;
  12487. protected _isBillboardBased: boolean;
  12488. /**
  12489. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12490. */
  12491. get isBillboardBased(): boolean;
  12492. set isBillboardBased(value: boolean);
  12493. /**
  12494. * The scene the particle system belongs to.
  12495. */
  12496. protected _scene: Nullable<Scene>;
  12497. /**
  12498. * The engine the particle system belongs to.
  12499. */
  12500. protected _engine: ThinEngine;
  12501. /**
  12502. * Local cache of defines for image processing.
  12503. */
  12504. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12505. /**
  12506. * Default configuration related to image processing available in the standard Material.
  12507. */
  12508. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12509. /**
  12510. * Gets the image processing configuration used either in this material.
  12511. */
  12512. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12513. /**
  12514. * Sets the Default image processing configuration used either in the this material.
  12515. *
  12516. * If sets to null, the scene one is in use.
  12517. */
  12518. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12519. /**
  12520. * Attaches a new image processing configuration to the Standard Material.
  12521. * @param configuration
  12522. */
  12523. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12524. /** @hidden */
  12525. protected _reset(): void;
  12526. /** @hidden */
  12527. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12528. /**
  12529. * Instantiates a particle system.
  12530. * 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.
  12531. * @param name The name of the particle system
  12532. */
  12533. constructor(name: string);
  12534. /**
  12535. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12538. * @returns the emitter
  12539. */
  12540. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12541. /**
  12542. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12543. * @param radius The radius of the hemisphere to emit from
  12544. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12545. * @returns the emitter
  12546. */
  12547. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12548. /**
  12549. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12550. * @param radius The radius of the sphere to emit from
  12551. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12552. * @returns the emitter
  12553. */
  12554. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12555. /**
  12556. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12557. * @param radius The radius of the sphere to emit from
  12558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12560. * @returns the emitter
  12561. */
  12562. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12563. /**
  12564. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12565. * @param radius The radius of the emission cylinder
  12566. * @param height The height of the emission cylinder
  12567. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12568. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12569. * @returns the emitter
  12570. */
  12571. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12572. /**
  12573. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12574. * @param radius The radius of the cylinder to emit from
  12575. * @param height The height of the emission cylinder
  12576. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12579. * @returns the emitter
  12580. */
  12581. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12584. * @param radius The radius of the cone to emit from
  12585. * @param angle The base angle of the cone
  12586. * @returns the emitter
  12587. */
  12588. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12589. /**
  12590. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12593. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12594. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12595. * @returns the emitter
  12596. */
  12597. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12598. }
  12599. }
  12600. declare module "babylonjs/Particles/subEmitter" {
  12601. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12602. import { Scene } from "babylonjs/scene";
  12603. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12604. /**
  12605. * Type of sub emitter
  12606. */
  12607. export enum SubEmitterType {
  12608. /**
  12609. * Attached to the particle over it's lifetime
  12610. */
  12611. ATTACHED = 0,
  12612. /**
  12613. * Created when the particle dies
  12614. */
  12615. END = 1
  12616. }
  12617. /**
  12618. * Sub emitter class used to emit particles from an existing particle
  12619. */
  12620. export class SubEmitter {
  12621. /**
  12622. * the particle system to be used by the sub emitter
  12623. */
  12624. particleSystem: ParticleSystem;
  12625. /**
  12626. * Type of the submitter (Default: END)
  12627. */
  12628. type: SubEmitterType;
  12629. /**
  12630. * 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)
  12631. * Note: This only is supported when using an emitter of type Mesh
  12632. */
  12633. inheritDirection: boolean;
  12634. /**
  12635. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12636. */
  12637. inheritedVelocityAmount: number;
  12638. /**
  12639. * Creates a sub emitter
  12640. * @param particleSystem the particle system to be used by the sub emitter
  12641. */
  12642. constructor(
  12643. /**
  12644. * the particle system to be used by the sub emitter
  12645. */
  12646. particleSystem: ParticleSystem);
  12647. /**
  12648. * Clones the sub emitter
  12649. * @returns the cloned sub emitter
  12650. */
  12651. clone(): SubEmitter;
  12652. /**
  12653. * Serialize current object to a JSON object
  12654. * @returns the serialized object
  12655. */
  12656. serialize(): any;
  12657. /** @hidden */
  12658. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12659. /**
  12660. * Creates a new SubEmitter from a serialized JSON version
  12661. * @param serializationObject defines the JSON object to read from
  12662. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12663. * @param rootUrl defines the rootUrl for data loading
  12664. * @returns a new SubEmitter
  12665. */
  12666. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12667. /** Release associated resources */
  12668. dispose(): void;
  12669. }
  12670. }
  12671. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12672. /** @hidden */
  12673. export var imageProcessingDeclaration: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12679. /** @hidden */
  12680. export var imageProcessingFunctions: {
  12681. name: string;
  12682. shader: string;
  12683. };
  12684. }
  12685. declare module "babylonjs/Shaders/particles.fragment" {
  12686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12689. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12691. /** @hidden */
  12692. export var particlesPixelShader: {
  12693. name: string;
  12694. shader: string;
  12695. };
  12696. }
  12697. declare module "babylonjs/Shaders/particles.vertex" {
  12698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12699. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12700. /** @hidden */
  12701. export var particlesVertexShader: {
  12702. name: string;
  12703. shader: string;
  12704. };
  12705. }
  12706. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12707. import { Nullable } from "babylonjs/types";
  12708. import { Plane } from "babylonjs/Maths/math";
  12709. /**
  12710. * Interface used to define entities containing multiple clip planes
  12711. */
  12712. export interface IClipPlanesHolder {
  12713. /**
  12714. * Gets or sets the active clipplane 1
  12715. */
  12716. clipPlane: Nullable<Plane>;
  12717. /**
  12718. * Gets or sets the active clipplane 2
  12719. */
  12720. clipPlane2: Nullable<Plane>;
  12721. /**
  12722. * Gets or sets the active clipplane 3
  12723. */
  12724. clipPlane3: Nullable<Plane>;
  12725. /**
  12726. * Gets or sets the active clipplane 4
  12727. */
  12728. clipPlane4: Nullable<Plane>;
  12729. /**
  12730. * Gets or sets the active clipplane 5
  12731. */
  12732. clipPlane5: Nullable<Plane>;
  12733. /**
  12734. * Gets or sets the active clipplane 6
  12735. */
  12736. clipPlane6: Nullable<Plane>;
  12737. }
  12738. }
  12739. declare module "babylonjs/Materials/thinMaterialHelper" {
  12740. import { Effect } from "babylonjs/Materials/effect";
  12741. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12742. /**
  12743. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12744. *
  12745. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12746. *
  12747. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12748. */
  12749. export class ThinMaterialHelper {
  12750. /**
  12751. * Binds the clip plane information from the holder to the effect.
  12752. * @param effect The effect we are binding the data to
  12753. * @param holder The entity containing the clip plane information
  12754. */
  12755. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12756. }
  12757. }
  12758. declare module "babylonjs/Particles/particleSystem" {
  12759. import { Nullable } from "babylonjs/types";
  12760. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12761. import { Observable } from "babylonjs/Misc/observable";
  12762. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12763. import { Effect } from "babylonjs/Materials/effect";
  12764. import { IDisposable } from "babylonjs/scene";
  12765. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12766. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12767. import { Particle } from "babylonjs/Particles/particle";
  12768. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12769. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12770. import "babylonjs/Shaders/particles.fragment";
  12771. import "babylonjs/Shaders/particles.vertex";
  12772. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12773. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12774. import { Scene } from "babylonjs/scene";
  12775. /**
  12776. * This represents a particle system in Babylon.
  12777. * 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.
  12778. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12779. * @example https://doc.babylonjs.com/babylon101/particles
  12780. */
  12781. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12782. /**
  12783. * Billboard mode will only apply to Y axis
  12784. */
  12785. static readonly BILLBOARDMODE_Y: number;
  12786. /**
  12787. * Billboard mode will apply to all axes
  12788. */
  12789. static readonly BILLBOARDMODE_ALL: number;
  12790. /**
  12791. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12792. */
  12793. static readonly BILLBOARDMODE_STRETCHED: number;
  12794. /**
  12795. * This function can be defined to provide custom update for active particles.
  12796. * This function will be called instead of regular update (age, position, color, etc.).
  12797. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12798. */
  12799. updateFunction: (particles: Particle[]) => void;
  12800. private _emitterWorldMatrix;
  12801. /**
  12802. * This function can be defined to specify initial direction for every new particle.
  12803. * It by default use the emitterType defined function
  12804. */
  12805. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12806. /**
  12807. * This function can be defined to specify initial position for every new particle.
  12808. * It by default use the emitterType defined function
  12809. */
  12810. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12811. /**
  12812. * @hidden
  12813. */
  12814. _inheritedVelocityOffset: Vector3;
  12815. /**
  12816. * An event triggered when the system is disposed
  12817. */
  12818. onDisposeObservable: Observable<IParticleSystem>;
  12819. private _onDisposeObserver;
  12820. /**
  12821. * Sets a callback that will be triggered when the system is disposed
  12822. */
  12823. set onDispose(callback: () => void);
  12824. private _particles;
  12825. private _epsilon;
  12826. private _capacity;
  12827. private _stockParticles;
  12828. private _newPartsExcess;
  12829. private _vertexData;
  12830. private _vertexBuffer;
  12831. private _vertexBuffers;
  12832. private _spriteBuffer;
  12833. private _indexBuffer;
  12834. private _effect;
  12835. private _customEffect;
  12836. private _cachedDefines;
  12837. private _scaledColorStep;
  12838. private _colorDiff;
  12839. private _scaledDirection;
  12840. private _scaledGravity;
  12841. private _currentRenderId;
  12842. private _alive;
  12843. private _useInstancing;
  12844. private _started;
  12845. private _stopped;
  12846. private _actualFrame;
  12847. private _scaledUpdateSpeed;
  12848. private _vertexBufferSize;
  12849. /** @hidden */
  12850. _currentEmitRateGradient: Nullable<FactorGradient>;
  12851. /** @hidden */
  12852. _currentEmitRate1: number;
  12853. /** @hidden */
  12854. _currentEmitRate2: number;
  12855. /** @hidden */
  12856. _currentStartSizeGradient: Nullable<FactorGradient>;
  12857. /** @hidden */
  12858. _currentStartSize1: number;
  12859. /** @hidden */
  12860. _currentStartSize2: number;
  12861. private readonly _rawTextureWidth;
  12862. private _rampGradientsTexture;
  12863. private _useRampGradients;
  12864. /** Gets or sets a matrix to use to compute projection */
  12865. defaultProjectionMatrix: Matrix;
  12866. /** Gets or sets a boolean indicating that ramp gradients must be used
  12867. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12868. */
  12869. get useRampGradients(): boolean;
  12870. set useRampGradients(value: boolean);
  12871. /**
  12872. * 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.
  12873. * 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: [])
  12874. */
  12875. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12876. private _subEmitters;
  12877. /**
  12878. * @hidden
  12879. * If the particle systems emitter should be disposed when the particle system is disposed
  12880. */
  12881. _disposeEmitterOnDispose: boolean;
  12882. /**
  12883. * The current active Sub-systems, this property is used by the root particle system only.
  12884. */
  12885. activeSubSystems: Array<ParticleSystem>;
  12886. /**
  12887. * Specifies if the particles are updated in emitter local space or world space
  12888. */
  12889. isLocal: boolean;
  12890. private _rootParticleSystem;
  12891. /**
  12892. * Gets the current list of active particles
  12893. */
  12894. get particles(): Particle[];
  12895. /**
  12896. * Gets the number of particles active at the same time.
  12897. * @returns The number of active particles.
  12898. */
  12899. getActiveCount(): number;
  12900. /**
  12901. * Returns the string "ParticleSystem"
  12902. * @returns a string containing the class name
  12903. */
  12904. getClassName(): string;
  12905. /**
  12906. * Gets a boolean indicating that the system is stopping
  12907. * @returns true if the system is currently stopping
  12908. */
  12909. isStopping(): boolean;
  12910. /**
  12911. * Gets the custom effect used to render the particles
  12912. * @param blendMode Blend mode for which the effect should be retrieved
  12913. * @returns The effect
  12914. */
  12915. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12916. /**
  12917. * Sets the custom effect used to render the particles
  12918. * @param effect The effect to set
  12919. * @param blendMode Blend mode for which the effect should be set
  12920. */
  12921. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12922. /** @hidden */
  12923. private _onBeforeDrawParticlesObservable;
  12924. /**
  12925. * Observable that will be called just before the particles are drawn
  12926. */
  12927. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12928. /**
  12929. * Gets the name of the particle vertex shader
  12930. */
  12931. get vertexShaderName(): string;
  12932. /**
  12933. * Instantiates a particle system.
  12934. * 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.
  12935. * @param name The name of the particle system
  12936. * @param capacity The max number of particles alive at the same time
  12937. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12938. * @param customEffect a custom effect used to change the way particles are rendered by default
  12939. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12940. * @param epsilon Offset used to render the particles
  12941. */
  12942. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12943. private _addFactorGradient;
  12944. private _removeFactorGradient;
  12945. /**
  12946. * Adds a new life time gradient
  12947. * @param gradient defines the gradient to use (between 0 and 1)
  12948. * @param factor defines the life time factor to affect to the specified gradient
  12949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12950. * @returns the current particle system
  12951. */
  12952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12953. /**
  12954. * Remove a specific life time gradient
  12955. * @param gradient defines the gradient to remove
  12956. * @returns the current particle system
  12957. */
  12958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12959. /**
  12960. * Adds a new size gradient
  12961. * @param gradient defines the gradient to use (between 0 and 1)
  12962. * @param factor defines the size factor to affect to the specified gradient
  12963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12964. * @returns the current particle system
  12965. */
  12966. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12967. /**
  12968. * Remove a specific size gradient
  12969. * @param gradient defines the gradient to remove
  12970. * @returns the current particle system
  12971. */
  12972. removeSizeGradient(gradient: number): IParticleSystem;
  12973. /**
  12974. * Adds a new color remap gradient
  12975. * @param gradient defines the gradient to use (between 0 and 1)
  12976. * @param min defines the color remap minimal range
  12977. * @param max defines the color remap maximal range
  12978. * @returns the current particle system
  12979. */
  12980. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12981. /**
  12982. * Remove a specific color remap gradient
  12983. * @param gradient defines the gradient to remove
  12984. * @returns the current particle system
  12985. */
  12986. removeColorRemapGradient(gradient: number): IParticleSystem;
  12987. /**
  12988. * Adds a new alpha remap gradient
  12989. * @param gradient defines the gradient to use (between 0 and 1)
  12990. * @param min defines the alpha remap minimal range
  12991. * @param max defines the alpha remap maximal range
  12992. * @returns the current particle system
  12993. */
  12994. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12995. /**
  12996. * Remove a specific alpha remap gradient
  12997. * @param gradient defines the gradient to remove
  12998. * @returns the current particle system
  12999. */
  13000. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13001. /**
  13002. * Adds a new angular speed gradient
  13003. * @param gradient defines the gradient to use (between 0 and 1)
  13004. * @param factor defines the angular speed to affect to the specified gradient
  13005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13006. * @returns the current particle system
  13007. */
  13008. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13009. /**
  13010. * Remove a specific angular speed gradient
  13011. * @param gradient defines the gradient to remove
  13012. * @returns the current particle system
  13013. */
  13014. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13015. /**
  13016. * Adds a new velocity gradient
  13017. * @param gradient defines the gradient to use (between 0 and 1)
  13018. * @param factor defines the velocity to affect to the specified gradient
  13019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13020. * @returns the current particle system
  13021. */
  13022. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13023. /**
  13024. * Remove a specific velocity gradient
  13025. * @param gradient defines the gradient to remove
  13026. * @returns the current particle system
  13027. */
  13028. removeVelocityGradient(gradient: number): IParticleSystem;
  13029. /**
  13030. * Adds a new limit velocity gradient
  13031. * @param gradient defines the gradient to use (between 0 and 1)
  13032. * @param factor defines the limit velocity value to affect to the specified gradient
  13033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13034. * @returns the current particle system
  13035. */
  13036. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13037. /**
  13038. * Remove a specific limit velocity gradient
  13039. * @param gradient defines the gradient to remove
  13040. * @returns the current particle system
  13041. */
  13042. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13043. /**
  13044. * Adds a new drag gradient
  13045. * @param gradient defines the gradient to use (between 0 and 1)
  13046. * @param factor defines the drag value to affect to the specified gradient
  13047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13048. * @returns the current particle system
  13049. */
  13050. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13051. /**
  13052. * Remove a specific drag gradient
  13053. * @param gradient defines the gradient to remove
  13054. * @returns the current particle system
  13055. */
  13056. removeDragGradient(gradient: number): IParticleSystem;
  13057. /**
  13058. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param factor defines the emit rate value to affect to the specified gradient
  13061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13062. * @returns the current particle system
  13063. */
  13064. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13065. /**
  13066. * Remove a specific emit rate gradient
  13067. * @param gradient defines the gradient to remove
  13068. * @returns the current particle system
  13069. */
  13070. removeEmitRateGradient(gradient: number): IParticleSystem;
  13071. /**
  13072. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13073. * @param gradient defines the gradient to use (between 0 and 1)
  13074. * @param factor defines the start size value to affect to the specified gradient
  13075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13076. * @returns the current particle system
  13077. */
  13078. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13079. /**
  13080. * Remove a specific start size gradient
  13081. * @param gradient defines the gradient to remove
  13082. * @returns the current particle system
  13083. */
  13084. removeStartSizeGradient(gradient: number): IParticleSystem;
  13085. private _createRampGradientTexture;
  13086. /**
  13087. * Gets the current list of ramp gradients.
  13088. * You must use addRampGradient and removeRampGradient to udpate this list
  13089. * @returns the list of ramp gradients
  13090. */
  13091. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13092. /** Force the system to rebuild all gradients that need to be resync */
  13093. forceRefreshGradients(): void;
  13094. private _syncRampGradientTexture;
  13095. /**
  13096. * Adds a new ramp gradient used to remap particle colors
  13097. * @param gradient defines the gradient to use (between 0 and 1)
  13098. * @param color defines the color to affect to the specified gradient
  13099. * @returns the current particle system
  13100. */
  13101. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13102. /**
  13103. * Remove a specific ramp gradient
  13104. * @param gradient defines the gradient to remove
  13105. * @returns the current particle system
  13106. */
  13107. removeRampGradient(gradient: number): ParticleSystem;
  13108. /**
  13109. * Adds a new color gradient
  13110. * @param gradient defines the gradient to use (between 0 and 1)
  13111. * @param color1 defines the color to affect to the specified gradient
  13112. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13113. * @returns this particle system
  13114. */
  13115. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13116. /**
  13117. * Remove a specific color gradient
  13118. * @param gradient defines the gradient to remove
  13119. * @returns this particle system
  13120. */
  13121. removeColorGradient(gradient: number): IParticleSystem;
  13122. private _fetchR;
  13123. protected _reset(): void;
  13124. private _resetEffect;
  13125. private _createVertexBuffers;
  13126. private _createIndexBuffer;
  13127. /**
  13128. * Gets the maximum number of particles active at the same time.
  13129. * @returns The max number of active particles.
  13130. */
  13131. getCapacity(): number;
  13132. /**
  13133. * Gets whether there are still active particles in the system.
  13134. * @returns True if it is alive, otherwise false.
  13135. */
  13136. isAlive(): boolean;
  13137. /**
  13138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13139. * @returns True if it has been started, otherwise false.
  13140. */
  13141. isStarted(): boolean;
  13142. private _prepareSubEmitterInternalArray;
  13143. /**
  13144. * Starts the particle system and begins to emit
  13145. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13146. */
  13147. start(delay?: number): void;
  13148. /**
  13149. * Stops the particle system.
  13150. * @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.
  13151. */
  13152. stop(stopSubEmitters?: boolean): void;
  13153. /**
  13154. * Remove all active particles
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * @hidden (for internal use only)
  13159. */
  13160. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13161. /**
  13162. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13163. * Its lifetime will start back at 0.
  13164. */
  13165. recycleParticle: (particle: Particle) => void;
  13166. private _stopSubEmitters;
  13167. private _createParticle;
  13168. private _removeFromRoot;
  13169. private _emitFromParticle;
  13170. private _update;
  13171. /** @hidden */
  13172. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13173. /** @hidden */
  13174. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13175. /**
  13176. * Fill the defines array according to the current settings of the particle system
  13177. * @param defines Array to be updated
  13178. * @param blendMode blend mode to take into account when updating the array
  13179. */
  13180. fillDefines(defines: Array<string>, blendMode: number): void;
  13181. /**
  13182. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13183. * @param uniforms Uniforms array to fill
  13184. * @param attributes Attributes array to fill
  13185. * @param samplers Samplers array to fill
  13186. */
  13187. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13188. /** @hidden */
  13189. private _getEffect;
  13190. /**
  13191. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13192. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13193. */
  13194. animate(preWarmOnly?: boolean): void;
  13195. private _appendParticleVertices;
  13196. /**
  13197. * Rebuilds the particle system.
  13198. */
  13199. rebuild(): void;
  13200. /**
  13201. * Is this system ready to be used/rendered
  13202. * @return true if the system is ready
  13203. */
  13204. isReady(): boolean;
  13205. private _render;
  13206. /**
  13207. * Renders the particle system in its current state.
  13208. * @returns the current number of particles
  13209. */
  13210. render(): number;
  13211. /**
  13212. * Disposes the particle system and free the associated resources
  13213. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13214. */
  13215. dispose(disposeTexture?: boolean): void;
  13216. /**
  13217. * Clones the particle system.
  13218. * @param name The name of the cloned object
  13219. * @param newEmitter The new emitter to use
  13220. * @returns the cloned particle system
  13221. */
  13222. clone(name: string, newEmitter: any): ParticleSystem;
  13223. /**
  13224. * Serializes the particle system to a JSON object
  13225. * @param serializeTexture defines if the texture must be serialized as well
  13226. * @returns the JSON object
  13227. */
  13228. serialize(serializeTexture?: boolean): any;
  13229. /** @hidden */
  13230. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13231. /** @hidden */
  13232. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13233. /**
  13234. * Parses a JSON object to create a particle system.
  13235. * @param parsedParticleSystem The JSON object to parse
  13236. * @param sceneOrEngine The scene or the engine to create the particle system in
  13237. * @param rootUrl The root url to use to load external dependencies like texture
  13238. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13239. * @returns the Parsed particle system
  13240. */
  13241. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13242. }
  13243. }
  13244. declare module "babylonjs/Particles/particle" {
  13245. import { Nullable } from "babylonjs/types";
  13246. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13247. import { Color4 } from "babylonjs/Maths/math.color";
  13248. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13249. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13250. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13251. /**
  13252. * A particle represents one of the element emitted by a particle system.
  13253. * This is mainly define by its coordinates, direction, velocity and age.
  13254. */
  13255. export class Particle {
  13256. /**
  13257. * The particle system the particle belongs to.
  13258. */
  13259. particleSystem: ParticleSystem;
  13260. private static _Count;
  13261. /**
  13262. * Unique ID of the particle
  13263. */
  13264. id: number;
  13265. /**
  13266. * The world position of the particle in the scene.
  13267. */
  13268. position: Vector3;
  13269. /**
  13270. * The world direction of the particle in the scene.
  13271. */
  13272. direction: Vector3;
  13273. /**
  13274. * The color of the particle.
  13275. */
  13276. color: Color4;
  13277. /**
  13278. * The color change of the particle per step.
  13279. */
  13280. colorStep: Color4;
  13281. /**
  13282. * Defines how long will the life of the particle be.
  13283. */
  13284. lifeTime: number;
  13285. /**
  13286. * The current age of the particle.
  13287. */
  13288. age: number;
  13289. /**
  13290. * The current size of the particle.
  13291. */
  13292. size: number;
  13293. /**
  13294. * The current scale of the particle.
  13295. */
  13296. scale: Vector2;
  13297. /**
  13298. * The current angle of the particle.
  13299. */
  13300. angle: number;
  13301. /**
  13302. * Defines how fast is the angle changing.
  13303. */
  13304. angularSpeed: number;
  13305. /**
  13306. * Defines the cell index used by the particle to be rendered from a sprite.
  13307. */
  13308. cellIndex: number;
  13309. /**
  13310. * The information required to support color remapping
  13311. */
  13312. remapData: Vector4;
  13313. /** @hidden */
  13314. _randomCellOffset?: number;
  13315. /** @hidden */
  13316. _initialDirection: Nullable<Vector3>;
  13317. /** @hidden */
  13318. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13319. /** @hidden */
  13320. _initialStartSpriteCellID: number;
  13321. /** @hidden */
  13322. _initialEndSpriteCellID: number;
  13323. /** @hidden */
  13324. _currentColorGradient: Nullable<ColorGradient>;
  13325. /** @hidden */
  13326. _currentColor1: Color4;
  13327. /** @hidden */
  13328. _currentColor2: Color4;
  13329. /** @hidden */
  13330. _currentSizeGradient: Nullable<FactorGradient>;
  13331. /** @hidden */
  13332. _currentSize1: number;
  13333. /** @hidden */
  13334. _currentSize2: number;
  13335. /** @hidden */
  13336. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13337. /** @hidden */
  13338. _currentAngularSpeed1: number;
  13339. /** @hidden */
  13340. _currentAngularSpeed2: number;
  13341. /** @hidden */
  13342. _currentVelocityGradient: Nullable<FactorGradient>;
  13343. /** @hidden */
  13344. _currentVelocity1: number;
  13345. /** @hidden */
  13346. _currentVelocity2: number;
  13347. /** @hidden */
  13348. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13349. /** @hidden */
  13350. _currentLimitVelocity1: number;
  13351. /** @hidden */
  13352. _currentLimitVelocity2: number;
  13353. /** @hidden */
  13354. _currentDragGradient: Nullable<FactorGradient>;
  13355. /** @hidden */
  13356. _currentDrag1: number;
  13357. /** @hidden */
  13358. _currentDrag2: number;
  13359. /** @hidden */
  13360. _randomNoiseCoordinates1: Vector3;
  13361. /** @hidden */
  13362. _randomNoiseCoordinates2: Vector3;
  13363. /** @hidden */
  13364. _localPosition?: Vector3;
  13365. /**
  13366. * Creates a new instance Particle
  13367. * @param particleSystem the particle system the particle belongs to
  13368. */
  13369. constructor(
  13370. /**
  13371. * The particle system the particle belongs to.
  13372. */
  13373. particleSystem: ParticleSystem);
  13374. private updateCellInfoFromSystem;
  13375. /**
  13376. * Defines how the sprite cell index is updated for the particle
  13377. */
  13378. updateCellIndex(): void;
  13379. /** @hidden */
  13380. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13381. /** @hidden */
  13382. _inheritParticleInfoToSubEmitters(): void;
  13383. /** @hidden */
  13384. _reset(): void;
  13385. /**
  13386. * Copy the properties of particle to another one.
  13387. * @param other the particle to copy the information to.
  13388. */
  13389. copyTo(other: Particle): void;
  13390. }
  13391. }
  13392. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13393. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13394. import { Effect } from "babylonjs/Materials/effect";
  13395. import { Particle } from "babylonjs/Particles/particle";
  13396. import { Nullable } from "babylonjs/types";
  13397. import { Scene } from "babylonjs/scene";
  13398. /**
  13399. * Particle emitter represents a volume emitting particles.
  13400. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13401. */
  13402. export interface IParticleEmitterType {
  13403. /**
  13404. * Called by the particle System when the direction is computed for the created particle.
  13405. * @param worldMatrix is the world matrix of the particle system
  13406. * @param directionToUpdate is the direction vector to update with the result
  13407. * @param particle is the particle we are computed the direction for
  13408. * @param isLocal defines if the direction should be set in local space
  13409. */
  13410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13411. /**
  13412. * Called by the particle System when the position is computed for the created particle.
  13413. * @param worldMatrix is the world matrix of the particle system
  13414. * @param positionToUpdate is the position vector to update with the result
  13415. * @param particle is the particle we are computed the position for
  13416. * @param isLocal defines if the position should be set in local space
  13417. */
  13418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13419. /**
  13420. * Clones the current emitter and returns a copy of it
  13421. * @returns the new emitter
  13422. */
  13423. clone(): IParticleEmitterType;
  13424. /**
  13425. * Called by the GPUParticleSystem to setup the update shader
  13426. * @param effect defines the update shader
  13427. */
  13428. applyToShader(effect: Effect): void;
  13429. /**
  13430. * Returns a string to use to update the GPU particles update shader
  13431. * @returns the effect defines string
  13432. */
  13433. getEffectDefines(): string;
  13434. /**
  13435. * Returns a string representing the class name
  13436. * @returns a string containing the class name
  13437. */
  13438. getClassName(): string;
  13439. /**
  13440. * Serializes the particle system to a JSON object.
  13441. * @returns the JSON object
  13442. */
  13443. serialize(): any;
  13444. /**
  13445. * Parse properties from a JSON object
  13446. * @param serializationObject defines the JSON object
  13447. * @param scene defines the hosting scene
  13448. */
  13449. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13450. }
  13451. }
  13452. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13453. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13454. import { Effect } from "babylonjs/Materials/effect";
  13455. import { Particle } from "babylonjs/Particles/particle";
  13456. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13457. /**
  13458. * Particle emitter emitting particles from the inside of a box.
  13459. * It emits the particles randomly between 2 given directions.
  13460. */
  13461. export class BoxParticleEmitter implements IParticleEmitterType {
  13462. /**
  13463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13464. */
  13465. direction1: Vector3;
  13466. /**
  13467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13468. */
  13469. direction2: Vector3;
  13470. /**
  13471. * 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.
  13472. */
  13473. minEmitBox: Vector3;
  13474. /**
  13475. * 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.
  13476. */
  13477. maxEmitBox: Vector3;
  13478. /**
  13479. * Creates a new instance BoxParticleEmitter
  13480. */
  13481. constructor();
  13482. /**
  13483. * Called by the particle System when the direction is computed for the created particle.
  13484. * @param worldMatrix is the world matrix of the particle system
  13485. * @param directionToUpdate is the direction vector to update with the result
  13486. * @param particle is the particle we are computed the direction for
  13487. * @param isLocal defines if the direction should be set in local space
  13488. */
  13489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13490. /**
  13491. * Called by the particle System when the position is computed for the created particle.
  13492. * @param worldMatrix is the world matrix of the particle system
  13493. * @param positionToUpdate is the position vector to update with the result
  13494. * @param particle is the particle we are computed the position for
  13495. * @param isLocal defines if the position should be set in local space
  13496. */
  13497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13498. /**
  13499. * Clones the current emitter and returns a copy of it
  13500. * @returns the new emitter
  13501. */
  13502. clone(): BoxParticleEmitter;
  13503. /**
  13504. * Called by the GPUParticleSystem to setup the update shader
  13505. * @param effect defines the update shader
  13506. */
  13507. applyToShader(effect: Effect): void;
  13508. /**
  13509. * Returns a string to use to update the GPU particles update shader
  13510. * @returns a string containng the defines string
  13511. */
  13512. getEffectDefines(): string;
  13513. /**
  13514. * Returns the string "BoxParticleEmitter"
  13515. * @returns a string containing the class name
  13516. */
  13517. getClassName(): string;
  13518. /**
  13519. * Serializes the particle system to a JSON object.
  13520. * @returns the JSON object
  13521. */
  13522. serialize(): any;
  13523. /**
  13524. * Parse properties from a JSON object
  13525. * @param serializationObject defines the JSON object
  13526. */
  13527. parse(serializationObject: any): void;
  13528. }
  13529. }
  13530. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13531. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13532. import { Effect } from "babylonjs/Materials/effect";
  13533. import { Particle } from "babylonjs/Particles/particle";
  13534. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13535. /**
  13536. * Particle emitter emitting particles from the inside of a cone.
  13537. * It emits the particles alongside the cone volume from the base to the particle.
  13538. * The emission direction might be randomized.
  13539. */
  13540. export class ConeParticleEmitter implements IParticleEmitterType {
  13541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13542. directionRandomizer: number;
  13543. private _radius;
  13544. private _angle;
  13545. private _height;
  13546. /**
  13547. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13548. */
  13549. radiusRange: number;
  13550. /**
  13551. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13552. */
  13553. heightRange: number;
  13554. /**
  13555. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13556. */
  13557. emitFromSpawnPointOnly: boolean;
  13558. /**
  13559. * Gets or sets the radius of the emission cone
  13560. */
  13561. get radius(): number;
  13562. set radius(value: number);
  13563. /**
  13564. * Gets or sets the angle of the emission cone
  13565. */
  13566. get angle(): number;
  13567. set angle(value: number);
  13568. private _buildHeight;
  13569. /**
  13570. * Creates a new instance ConeParticleEmitter
  13571. * @param radius the radius of the emission cone (1 by default)
  13572. * @param angle the cone base angle (PI by default)
  13573. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13574. */
  13575. constructor(radius?: number, angle?: number,
  13576. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13577. directionRandomizer?: number);
  13578. /**
  13579. * Called by the particle System when the direction is computed for the created particle.
  13580. * @param worldMatrix is the world matrix of the particle system
  13581. * @param directionToUpdate is the direction vector to update with the result
  13582. * @param particle is the particle we are computed the direction for
  13583. * @param isLocal defines if the direction should be set in local space
  13584. */
  13585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13586. /**
  13587. * Called by the particle System when the position is computed for the created particle.
  13588. * @param worldMatrix is the world matrix of the particle system
  13589. * @param positionToUpdate is the position vector to update with the result
  13590. * @param particle is the particle we are computed the position for
  13591. * @param isLocal defines if the position should be set in local space
  13592. */
  13593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13594. /**
  13595. * Clones the current emitter and returns a copy of it
  13596. * @returns the new emitter
  13597. */
  13598. clone(): ConeParticleEmitter;
  13599. /**
  13600. * Called by the GPUParticleSystem to setup the update shader
  13601. * @param effect defines the update shader
  13602. */
  13603. applyToShader(effect: Effect): void;
  13604. /**
  13605. * Returns a string to use to update the GPU particles update shader
  13606. * @returns a string containng the defines string
  13607. */
  13608. getEffectDefines(): string;
  13609. /**
  13610. * Returns the string "ConeParticleEmitter"
  13611. * @returns a string containing the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Serializes the particle system to a JSON object.
  13616. * @returns the JSON object
  13617. */
  13618. serialize(): any;
  13619. /**
  13620. * Parse properties from a JSON object
  13621. * @param serializationObject defines the JSON object
  13622. */
  13623. parse(serializationObject: any): void;
  13624. }
  13625. }
  13626. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13627. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13628. import { Effect } from "babylonjs/Materials/effect";
  13629. import { Particle } from "babylonjs/Particles/particle";
  13630. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13631. /**
  13632. * Particle emitter emitting particles from the inside of a cylinder.
  13633. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13634. */
  13635. export class CylinderParticleEmitter implements IParticleEmitterType {
  13636. /**
  13637. * The radius of the emission cylinder.
  13638. */
  13639. radius: number;
  13640. /**
  13641. * The height of the emission cylinder.
  13642. */
  13643. height: number;
  13644. /**
  13645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13646. */
  13647. radiusRange: number;
  13648. /**
  13649. * How much to randomize the particle direction [0-1].
  13650. */
  13651. directionRandomizer: number;
  13652. /**
  13653. * Creates a new instance CylinderParticleEmitter
  13654. * @param radius the radius of the emission cylinder (1 by default)
  13655. * @param height the height of the emission cylinder (1 by default)
  13656. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13657. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13658. */
  13659. constructor(
  13660. /**
  13661. * The radius of the emission cylinder.
  13662. */
  13663. radius?: number,
  13664. /**
  13665. * The height of the emission cylinder.
  13666. */
  13667. height?: number,
  13668. /**
  13669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13670. */
  13671. radiusRange?: number,
  13672. /**
  13673. * How much to randomize the particle direction [0-1].
  13674. */
  13675. directionRandomizer?: number);
  13676. /**
  13677. * Called by the particle System when the direction is computed for the created particle.
  13678. * @param worldMatrix is the world matrix of the particle system
  13679. * @param directionToUpdate is the direction vector to update with the result
  13680. * @param particle is the particle we are computed the direction for
  13681. * @param isLocal defines if the direction should be set in local space
  13682. */
  13683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13684. /**
  13685. * Called by the particle System when the position is computed for the created particle.
  13686. * @param worldMatrix is the world matrix of the particle system
  13687. * @param positionToUpdate is the position vector to update with the result
  13688. * @param particle is the particle we are computed the position for
  13689. * @param isLocal defines if the position should be set in local space
  13690. */
  13691. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13692. /**
  13693. * Clones the current emitter and returns a copy of it
  13694. * @returns the new emitter
  13695. */
  13696. clone(): CylinderParticleEmitter;
  13697. /**
  13698. * Called by the GPUParticleSystem to setup the update shader
  13699. * @param effect defines the update shader
  13700. */
  13701. applyToShader(effect: Effect): void;
  13702. /**
  13703. * Returns a string to use to update the GPU particles update shader
  13704. * @returns a string containng the defines string
  13705. */
  13706. getEffectDefines(): string;
  13707. /**
  13708. * Returns the string "CylinderParticleEmitter"
  13709. * @returns a string containing the class name
  13710. */
  13711. getClassName(): string;
  13712. /**
  13713. * Serializes the particle system to a JSON object.
  13714. * @returns the JSON object
  13715. */
  13716. serialize(): any;
  13717. /**
  13718. * Parse properties from a JSON object
  13719. * @param serializationObject defines the JSON object
  13720. */
  13721. parse(serializationObject: any): void;
  13722. }
  13723. /**
  13724. * Particle emitter emitting particles from the inside of a cylinder.
  13725. * It emits the particles randomly between two vectors.
  13726. */
  13727. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13728. /**
  13729. * The min limit of the emission direction.
  13730. */
  13731. direction1: Vector3;
  13732. /**
  13733. * The max limit of the emission direction.
  13734. */
  13735. direction2: Vector3;
  13736. /**
  13737. * Creates a new instance CylinderDirectedParticleEmitter
  13738. * @param radius the radius of the emission cylinder (1 by default)
  13739. * @param height the height of the emission cylinder (1 by default)
  13740. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13741. * @param direction1 the min limit of the emission direction (up vector by default)
  13742. * @param direction2 the max limit of the emission direction (up vector by default)
  13743. */
  13744. constructor(radius?: number, height?: number, radiusRange?: number,
  13745. /**
  13746. * The min limit of the emission direction.
  13747. */
  13748. direction1?: Vector3,
  13749. /**
  13750. * The max limit of the emission direction.
  13751. */
  13752. direction2?: Vector3);
  13753. /**
  13754. * Called by the particle System when the direction is computed for the created particle.
  13755. * @param worldMatrix is the world matrix of the particle system
  13756. * @param directionToUpdate is the direction vector to update with the result
  13757. * @param particle is the particle we are computed the direction for
  13758. */
  13759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13760. /**
  13761. * Clones the current emitter and returns a copy of it
  13762. * @returns the new emitter
  13763. */
  13764. clone(): CylinderDirectedParticleEmitter;
  13765. /**
  13766. * Called by the GPUParticleSystem to setup the update shader
  13767. * @param effect defines the update shader
  13768. */
  13769. applyToShader(effect: Effect): void;
  13770. /**
  13771. * Returns a string to use to update the GPU particles update shader
  13772. * @returns a string containng the defines string
  13773. */
  13774. getEffectDefines(): string;
  13775. /**
  13776. * Returns the string "CylinderDirectedParticleEmitter"
  13777. * @returns a string containing the class name
  13778. */
  13779. getClassName(): string;
  13780. /**
  13781. * Serializes the particle system to a JSON object.
  13782. * @returns the JSON object
  13783. */
  13784. serialize(): any;
  13785. /**
  13786. * Parse properties from a JSON object
  13787. * @param serializationObject defines the JSON object
  13788. */
  13789. parse(serializationObject: any): void;
  13790. }
  13791. }
  13792. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13793. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13794. import { Effect } from "babylonjs/Materials/effect";
  13795. import { Particle } from "babylonjs/Particles/particle";
  13796. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13797. /**
  13798. * Particle emitter emitting particles from the inside of a hemisphere.
  13799. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13800. */
  13801. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13802. /**
  13803. * The radius of the emission hemisphere.
  13804. */
  13805. radius: number;
  13806. /**
  13807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13808. */
  13809. radiusRange: number;
  13810. /**
  13811. * How much to randomize the particle direction [0-1].
  13812. */
  13813. directionRandomizer: number;
  13814. /**
  13815. * Creates a new instance HemisphericParticleEmitter
  13816. * @param radius the radius of the emission hemisphere (1 by default)
  13817. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13819. */
  13820. constructor(
  13821. /**
  13822. * The radius of the emission hemisphere.
  13823. */
  13824. radius?: number,
  13825. /**
  13826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13827. */
  13828. radiusRange?: number,
  13829. /**
  13830. * How much to randomize the particle direction [0-1].
  13831. */
  13832. directionRandomizer?: number);
  13833. /**
  13834. * Called by the particle System when the direction is computed for the created particle.
  13835. * @param worldMatrix is the world matrix of the particle system
  13836. * @param directionToUpdate is the direction vector to update with the result
  13837. * @param particle is the particle we are computed the direction for
  13838. * @param isLocal defines if the direction should be set in local space
  13839. */
  13840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13841. /**
  13842. * Called by the particle System when the position is computed for the created particle.
  13843. * @param worldMatrix is the world matrix of the particle system
  13844. * @param positionToUpdate is the position vector to update with the result
  13845. * @param particle is the particle we are computed the position for
  13846. * @param isLocal defines if the position should be set in local space
  13847. */
  13848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13849. /**
  13850. * Clones the current emitter and returns a copy of it
  13851. * @returns the new emitter
  13852. */
  13853. clone(): HemisphericParticleEmitter;
  13854. /**
  13855. * Called by the GPUParticleSystem to setup the update shader
  13856. * @param effect defines the update shader
  13857. */
  13858. applyToShader(effect: Effect): void;
  13859. /**
  13860. * Returns a string to use to update the GPU particles update shader
  13861. * @returns a string containng the defines string
  13862. */
  13863. getEffectDefines(): string;
  13864. /**
  13865. * Returns the string "HemisphericParticleEmitter"
  13866. * @returns a string containing the class name
  13867. */
  13868. getClassName(): string;
  13869. /**
  13870. * Serializes the particle system to a JSON object.
  13871. * @returns the JSON object
  13872. */
  13873. serialize(): any;
  13874. /**
  13875. * Parse properties from a JSON object
  13876. * @param serializationObject defines the JSON object
  13877. */
  13878. parse(serializationObject: any): void;
  13879. }
  13880. }
  13881. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13882. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13883. import { Effect } from "babylonjs/Materials/effect";
  13884. import { Particle } from "babylonjs/Particles/particle";
  13885. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13886. /**
  13887. * Particle emitter emitting particles from a point.
  13888. * It emits the particles randomly between 2 given directions.
  13889. */
  13890. export class PointParticleEmitter implements IParticleEmitterType {
  13891. /**
  13892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13893. */
  13894. direction1: Vector3;
  13895. /**
  13896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13897. */
  13898. direction2: Vector3;
  13899. /**
  13900. * Creates a new instance PointParticleEmitter
  13901. */
  13902. constructor();
  13903. /**
  13904. * Called by the particle System when the direction is computed for the created particle.
  13905. * @param worldMatrix is the world matrix of the particle system
  13906. * @param directionToUpdate is the direction vector to update with the result
  13907. * @param particle is the particle we are computed the direction for
  13908. * @param isLocal defines if the direction should be set in local space
  13909. */
  13910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13911. /**
  13912. * Called by the particle System when the position is computed for the created particle.
  13913. * @param worldMatrix is the world matrix of the particle system
  13914. * @param positionToUpdate is the position vector to update with the result
  13915. * @param particle is the particle we are computed the position for
  13916. * @param isLocal defines if the position should be set in local space
  13917. */
  13918. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13919. /**
  13920. * Clones the current emitter and returns a copy of it
  13921. * @returns the new emitter
  13922. */
  13923. clone(): PointParticleEmitter;
  13924. /**
  13925. * Called by the GPUParticleSystem to setup the update shader
  13926. * @param effect defines the update shader
  13927. */
  13928. applyToShader(effect: Effect): void;
  13929. /**
  13930. * Returns a string to use to update the GPU particles update shader
  13931. * @returns a string containng the defines string
  13932. */
  13933. getEffectDefines(): string;
  13934. /**
  13935. * Returns the string "PointParticleEmitter"
  13936. * @returns a string containing the class name
  13937. */
  13938. getClassName(): string;
  13939. /**
  13940. * Serializes the particle system to a JSON object.
  13941. * @returns the JSON object
  13942. */
  13943. serialize(): any;
  13944. /**
  13945. * Parse properties from a JSON object
  13946. * @param serializationObject defines the JSON object
  13947. */
  13948. parse(serializationObject: any): void;
  13949. }
  13950. }
  13951. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13952. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13953. import { Effect } from "babylonjs/Materials/effect";
  13954. import { Particle } from "babylonjs/Particles/particle";
  13955. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13956. /**
  13957. * Particle emitter emitting particles from the inside of a sphere.
  13958. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13959. */
  13960. export class SphereParticleEmitter implements IParticleEmitterType {
  13961. /**
  13962. * The radius of the emission sphere.
  13963. */
  13964. radius: number;
  13965. /**
  13966. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13967. */
  13968. radiusRange: number;
  13969. /**
  13970. * How much to randomize the particle direction [0-1].
  13971. */
  13972. directionRandomizer: number;
  13973. /**
  13974. * Creates a new instance SphereParticleEmitter
  13975. * @param radius the radius of the emission sphere (1 by default)
  13976. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13977. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13978. */
  13979. constructor(
  13980. /**
  13981. * The radius of the emission sphere.
  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. * Called by the particle System when the direction is computed for the created particle.
  13994. * @param worldMatrix is the world matrix of the particle system
  13995. * @param directionToUpdate is the direction vector to update with the result
  13996. * @param particle is the particle we are computed the direction for
  13997. * @param isLocal defines if the direction should be set in local space
  13998. */
  13999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14000. /**
  14001. * Called by the particle System when the position is computed for the created particle.
  14002. * @param worldMatrix is the world matrix of the particle system
  14003. * @param positionToUpdate is the position vector to update with the result
  14004. * @param particle is the particle we are computed the position for
  14005. * @param isLocal defines if the position should be set in local space
  14006. */
  14007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14008. /**
  14009. * Clones the current emitter and returns a copy of it
  14010. * @returns the new emitter
  14011. */
  14012. clone(): SphereParticleEmitter;
  14013. /**
  14014. * Called by the GPUParticleSystem to setup the update shader
  14015. * @param effect defines the update shader
  14016. */
  14017. applyToShader(effect: Effect): void;
  14018. /**
  14019. * Returns a string to use to update the GPU particles update shader
  14020. * @returns a string containng the defines string
  14021. */
  14022. getEffectDefines(): string;
  14023. /**
  14024. * Returns the string "SphereParticleEmitter"
  14025. * @returns a string containing the class name
  14026. */
  14027. getClassName(): string;
  14028. /**
  14029. * Serializes the particle system to a JSON object.
  14030. * @returns the JSON object
  14031. */
  14032. serialize(): any;
  14033. /**
  14034. * Parse properties from a JSON object
  14035. * @param serializationObject defines the JSON object
  14036. */
  14037. parse(serializationObject: any): void;
  14038. }
  14039. /**
  14040. * Particle emitter emitting particles from the inside of a sphere.
  14041. * It emits the particles randomly between two vectors.
  14042. */
  14043. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14044. /**
  14045. * The min limit of the emission direction.
  14046. */
  14047. direction1: Vector3;
  14048. /**
  14049. * The max limit of the emission direction.
  14050. */
  14051. direction2: Vector3;
  14052. /**
  14053. * Creates a new instance SphereDirectedParticleEmitter
  14054. * @param radius the radius of the emission sphere (1 by default)
  14055. * @param direction1 the min limit of the emission direction (up vector by default)
  14056. * @param direction2 the max limit of the emission direction (up vector by default)
  14057. */
  14058. constructor(radius?: number,
  14059. /**
  14060. * The min limit of the emission direction.
  14061. */
  14062. direction1?: Vector3,
  14063. /**
  14064. * The max limit of the emission direction.
  14065. */
  14066. direction2?: Vector3);
  14067. /**
  14068. * Called by the particle System when the direction is computed for the created particle.
  14069. * @param worldMatrix is the world matrix of the particle system
  14070. * @param directionToUpdate is the direction vector to update with the result
  14071. * @param particle is the particle we are computed the direction for
  14072. */
  14073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14074. /**
  14075. * Clones the current emitter and returns a copy of it
  14076. * @returns the new emitter
  14077. */
  14078. clone(): SphereDirectedParticleEmitter;
  14079. /**
  14080. * Called by the GPUParticleSystem to setup the update shader
  14081. * @param effect defines the update shader
  14082. */
  14083. applyToShader(effect: Effect): void;
  14084. /**
  14085. * Returns a string to use to update the GPU particles update shader
  14086. * @returns a string containng the defines string
  14087. */
  14088. getEffectDefines(): string;
  14089. /**
  14090. * Returns the string "SphereDirectedParticleEmitter"
  14091. * @returns a string containing the class name
  14092. */
  14093. getClassName(): string;
  14094. /**
  14095. * Serializes the particle system to a JSON object.
  14096. * @returns the JSON object
  14097. */
  14098. serialize(): any;
  14099. /**
  14100. * Parse properties from a JSON object
  14101. * @param serializationObject defines the JSON object
  14102. */
  14103. parse(serializationObject: any): void;
  14104. }
  14105. }
  14106. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14108. import { Effect } from "babylonjs/Materials/effect";
  14109. import { Particle } from "babylonjs/Particles/particle";
  14110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14111. import { Nullable } from "babylonjs/types";
  14112. /**
  14113. * Particle emitter emitting particles from a custom list of positions.
  14114. */
  14115. export class CustomParticleEmitter implements IParticleEmitterType {
  14116. /**
  14117. * Gets or sets the position generator that will create the inital position of each particle.
  14118. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14119. */
  14120. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14121. /**
  14122. * Gets or sets the destination generator that will create the final destination of each particle.
  14123. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14124. */
  14125. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14126. /**
  14127. * Creates a new instance CustomParticleEmitter
  14128. */
  14129. constructor();
  14130. /**
  14131. * Called by the particle System when the direction is computed for the created particle.
  14132. * @param worldMatrix is the world matrix of the particle system
  14133. * @param directionToUpdate is the direction vector to update with the result
  14134. * @param particle is the particle we are computed the direction for
  14135. * @param isLocal defines if the direction should be set in local space
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14138. /**
  14139. * Called by the particle System when the position is computed for the created particle.
  14140. * @param worldMatrix is the world matrix of the particle system
  14141. * @param positionToUpdate is the position vector to update with the result
  14142. * @param particle is the particle we are computed the position for
  14143. * @param isLocal defines if the position should be set in local space
  14144. */
  14145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14146. /**
  14147. * Clones the current emitter and returns a copy of it
  14148. * @returns the new emitter
  14149. */
  14150. clone(): CustomParticleEmitter;
  14151. /**
  14152. * Called by the GPUParticleSystem to setup the update shader
  14153. * @param effect defines the update shader
  14154. */
  14155. applyToShader(effect: Effect): void;
  14156. /**
  14157. * Returns a string to use to update the GPU particles update shader
  14158. * @returns a string containng the defines string
  14159. */
  14160. getEffectDefines(): string;
  14161. /**
  14162. * Returns the string "PointParticleEmitter"
  14163. * @returns a string containing the class name
  14164. */
  14165. getClassName(): string;
  14166. /**
  14167. * Serializes the particle system to a JSON object.
  14168. * @returns the JSON object
  14169. */
  14170. serialize(): any;
  14171. /**
  14172. * Parse properties from a JSON object
  14173. * @param serializationObject defines the JSON object
  14174. */
  14175. parse(serializationObject: any): void;
  14176. }
  14177. }
  14178. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14179. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Particle } from "babylonjs/Particles/particle";
  14182. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14183. import { Nullable } from "babylonjs/types";
  14184. import { Scene } from "babylonjs/scene";
  14185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14186. /**
  14187. * Particle emitter emitting particles from the inside of a box.
  14188. * It emits the particles randomly between 2 given directions.
  14189. */
  14190. export class MeshParticleEmitter implements IParticleEmitterType {
  14191. private _indices;
  14192. private _positions;
  14193. private _normals;
  14194. private _storedNormal;
  14195. private _mesh;
  14196. /**
  14197. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14198. */
  14199. direction1: Vector3;
  14200. /**
  14201. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14202. */
  14203. direction2: Vector3;
  14204. /**
  14205. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14206. */
  14207. useMeshNormalsForDirection: boolean;
  14208. /** Defines the mesh to use as source */
  14209. get mesh(): Nullable<AbstractMesh>;
  14210. set mesh(value: Nullable<AbstractMesh>);
  14211. /**
  14212. * Creates a new instance MeshParticleEmitter
  14213. * @param mesh defines the mesh to use as source
  14214. */
  14215. constructor(mesh?: Nullable<AbstractMesh>);
  14216. /**
  14217. * Called by the particle System when the direction is computed for the created particle.
  14218. * @param worldMatrix is the world matrix of the particle system
  14219. * @param directionToUpdate is the direction vector to update with the result
  14220. * @param particle is the particle we are computed the direction for
  14221. * @param isLocal defines if the direction should be set in local space
  14222. */
  14223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14224. /**
  14225. * Called by the particle System when the position is computed for the created particle.
  14226. * @param worldMatrix is the world matrix of the particle system
  14227. * @param positionToUpdate is the position vector to update with the result
  14228. * @param particle is the particle we are computed the position for
  14229. * @param isLocal defines if the position should be set in local space
  14230. */
  14231. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14232. /**
  14233. * Clones the current emitter and returns a copy of it
  14234. * @returns the new emitter
  14235. */
  14236. clone(): MeshParticleEmitter;
  14237. /**
  14238. * Called by the GPUParticleSystem to setup the update shader
  14239. * @param effect defines the update shader
  14240. */
  14241. applyToShader(effect: Effect): void;
  14242. /**
  14243. * Returns a string to use to update the GPU particles update shader
  14244. * @returns a string containng the defines string
  14245. */
  14246. getEffectDefines(): string;
  14247. /**
  14248. * Returns the string "BoxParticleEmitter"
  14249. * @returns a string containing the class name
  14250. */
  14251. getClassName(): string;
  14252. /**
  14253. * Serializes the particle system to a JSON object.
  14254. * @returns the JSON object
  14255. */
  14256. serialize(): any;
  14257. /**
  14258. * Parse properties from a JSON object
  14259. * @param serializationObject defines the JSON object
  14260. * @param scene defines the hosting scene
  14261. */
  14262. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14263. }
  14264. }
  14265. declare module "babylonjs/Particles/EmitterTypes/index" {
  14266. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14267. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14268. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14269. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14270. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14271. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14272. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14273. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14274. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14275. }
  14276. declare module "babylonjs/Particles/IParticleSystem" {
  14277. import { Nullable } from "babylonjs/types";
  14278. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14279. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14281. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14282. import { Scene } from "babylonjs/scene";
  14283. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14284. import { Effect } from "babylonjs/Materials/effect";
  14285. import { Observable } from "babylonjs/Misc/observable";
  14286. import { Animation } from "babylonjs/Animations/animation";
  14287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14288. /**
  14289. * Interface representing a particle system in Babylon.js.
  14290. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14291. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14292. */
  14293. export interface IParticleSystem {
  14294. /**
  14295. * List of animations used by the particle system.
  14296. */
  14297. animations: Animation[];
  14298. /**
  14299. * The id of the Particle system.
  14300. */
  14301. id: string;
  14302. /**
  14303. * The name of the Particle system.
  14304. */
  14305. name: string;
  14306. /**
  14307. * The emitter represents the Mesh or position we are attaching the particle system to.
  14308. */
  14309. emitter: Nullable<AbstractMesh | Vector3>;
  14310. /**
  14311. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14312. */
  14313. isBillboardBased: boolean;
  14314. /**
  14315. * The rendering group used by the Particle system to chose when to render.
  14316. */
  14317. renderingGroupId: number;
  14318. /**
  14319. * The layer mask we are rendering the particles through.
  14320. */
  14321. layerMask: number;
  14322. /**
  14323. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14324. */
  14325. updateSpeed: number;
  14326. /**
  14327. * The amount of time the particle system is running (depends of the overall update speed).
  14328. */
  14329. targetStopDuration: number;
  14330. /**
  14331. * The texture used to render each particle. (this can be a spritesheet)
  14332. */
  14333. particleTexture: Nullable<BaseTexture>;
  14334. /**
  14335. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14336. */
  14337. blendMode: number;
  14338. /**
  14339. * Minimum life time of emitting particles.
  14340. */
  14341. minLifeTime: number;
  14342. /**
  14343. * Maximum life time of emitting particles.
  14344. */
  14345. maxLifeTime: number;
  14346. /**
  14347. * Minimum Size of emitting particles.
  14348. */
  14349. minSize: number;
  14350. /**
  14351. * Maximum Size of emitting particles.
  14352. */
  14353. maxSize: number;
  14354. /**
  14355. * Minimum scale of emitting particles on X axis.
  14356. */
  14357. minScaleX: number;
  14358. /**
  14359. * Maximum scale of emitting particles on X axis.
  14360. */
  14361. maxScaleX: number;
  14362. /**
  14363. * Minimum scale of emitting particles on Y axis.
  14364. */
  14365. minScaleY: number;
  14366. /**
  14367. * Maximum scale of emitting particles on Y axis.
  14368. */
  14369. maxScaleY: number;
  14370. /**
  14371. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14372. */
  14373. color1: Color4;
  14374. /**
  14375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14376. */
  14377. color2: Color4;
  14378. /**
  14379. * Color the particle will have at the end of its lifetime.
  14380. */
  14381. colorDead: Color4;
  14382. /**
  14383. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14384. */
  14385. emitRate: number;
  14386. /**
  14387. * You can use gravity if you want to give an orientation to your particles.
  14388. */
  14389. gravity: Vector3;
  14390. /**
  14391. * Minimum power of emitting particles.
  14392. */
  14393. minEmitPower: number;
  14394. /**
  14395. * Maximum power of emitting particles.
  14396. */
  14397. maxEmitPower: number;
  14398. /**
  14399. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14400. */
  14401. minAngularSpeed: number;
  14402. /**
  14403. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14404. */
  14405. maxAngularSpeed: number;
  14406. /**
  14407. * Gets or sets the minimal initial rotation in radians.
  14408. */
  14409. minInitialRotation: number;
  14410. /**
  14411. * Gets or sets the maximal initial rotation in radians.
  14412. */
  14413. maxInitialRotation: number;
  14414. /**
  14415. * The particle emitter type defines the emitter used by the particle system.
  14416. * It can be for example box, sphere, or cone...
  14417. */
  14418. particleEmitterType: Nullable<IParticleEmitterType>;
  14419. /**
  14420. * Defines the delay in milliseconds before starting the system (0 by default)
  14421. */
  14422. startDelay: number;
  14423. /**
  14424. * 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
  14425. */
  14426. preWarmCycles: number;
  14427. /**
  14428. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14429. */
  14430. preWarmStepOffset: number;
  14431. /**
  14432. * 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)
  14433. */
  14434. spriteCellChangeSpeed: number;
  14435. /**
  14436. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14437. */
  14438. startSpriteCellID: number;
  14439. /**
  14440. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14441. */
  14442. endSpriteCellID: number;
  14443. /**
  14444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14445. */
  14446. spriteCellWidth: number;
  14447. /**
  14448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14449. */
  14450. spriteCellHeight: number;
  14451. /**
  14452. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14453. */
  14454. spriteRandomStartCell: boolean;
  14455. /**
  14456. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14457. */
  14458. isAnimationSheetEnabled: boolean;
  14459. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14460. translationPivot: Vector2;
  14461. /**
  14462. * Gets or sets a texture used to add random noise to particle positions
  14463. */
  14464. noiseTexture: Nullable<BaseTexture>;
  14465. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14466. noiseStrength: Vector3;
  14467. /**
  14468. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14469. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14470. */
  14471. billboardMode: number;
  14472. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14473. limitVelocityDamping: number;
  14474. /**
  14475. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14476. */
  14477. beginAnimationOnStart: boolean;
  14478. /**
  14479. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14480. */
  14481. beginAnimationFrom: number;
  14482. /**
  14483. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14484. */
  14485. beginAnimationTo: number;
  14486. /**
  14487. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14488. */
  14489. beginAnimationLoop: boolean;
  14490. /**
  14491. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14492. */
  14493. disposeOnStop: boolean;
  14494. /**
  14495. * Specifies if the particles are updated in emitter local space or world space
  14496. */
  14497. isLocal: boolean;
  14498. /** Snippet ID if the particle system was created from the snippet server */
  14499. snippetId: string;
  14500. /** Gets or sets a matrix to use to compute projection */
  14501. defaultProjectionMatrix: Matrix;
  14502. /**
  14503. * Gets the maximum number of particles active at the same time.
  14504. * @returns The max number of active particles.
  14505. */
  14506. getCapacity(): number;
  14507. /**
  14508. * Gets the number of particles active at the same time.
  14509. * @returns The number of active particles.
  14510. */
  14511. getActiveCount(): number;
  14512. /**
  14513. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14514. * @returns True if it has been started, otherwise false.
  14515. */
  14516. isStarted(): boolean;
  14517. /**
  14518. * Animates the particle system for this frame.
  14519. */
  14520. animate(): void;
  14521. /**
  14522. * Renders the particle system in its current state.
  14523. * @returns the current number of particles
  14524. */
  14525. render(): number;
  14526. /**
  14527. * Dispose the particle system and frees its associated resources.
  14528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14529. */
  14530. dispose(disposeTexture?: boolean): void;
  14531. /**
  14532. * An event triggered when the system is disposed
  14533. */
  14534. onDisposeObservable: Observable<IParticleSystem>;
  14535. /**
  14536. * Clones the particle system.
  14537. * @param name The name of the cloned object
  14538. * @param newEmitter The new emitter to use
  14539. * @returns the cloned particle system
  14540. */
  14541. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14542. /**
  14543. * Serializes the particle system to a JSON object
  14544. * @param serializeTexture defines if the texture must be serialized as well
  14545. * @returns the JSON object
  14546. */
  14547. serialize(serializeTexture: boolean): any;
  14548. /**
  14549. * Rebuild the particle system
  14550. */
  14551. rebuild(): void;
  14552. /** Force the system to rebuild all gradients that need to be resync */
  14553. forceRefreshGradients(): void;
  14554. /**
  14555. * Starts the particle system and begins to emit
  14556. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14557. */
  14558. start(delay?: number): void;
  14559. /**
  14560. * Stops the particle system.
  14561. */
  14562. stop(): void;
  14563. /**
  14564. * Remove all active particles
  14565. */
  14566. reset(): void;
  14567. /**
  14568. * Gets a boolean indicating that the system is stopping
  14569. * @returns true if the system is currently stopping
  14570. */
  14571. isStopping(): boolean;
  14572. /**
  14573. * Is this system ready to be used/rendered
  14574. * @return true if the system is ready
  14575. */
  14576. isReady(): boolean;
  14577. /**
  14578. * Returns the string "ParticleSystem"
  14579. * @returns a string containing the class name
  14580. */
  14581. getClassName(): string;
  14582. /**
  14583. * Gets the custom effect used to render the particles
  14584. * @param blendMode Blend mode for which the effect should be retrieved
  14585. * @returns The effect
  14586. */
  14587. getCustomEffect(blendMode: number): Nullable<Effect>;
  14588. /**
  14589. * Sets the custom effect used to render the particles
  14590. * @param effect The effect to set
  14591. * @param blendMode Blend mode for which the effect should be set
  14592. */
  14593. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14594. /**
  14595. * Fill the defines array according to the current settings of the particle system
  14596. * @param defines Array to be updated
  14597. * @param blendMode blend mode to take into account when updating the array
  14598. */
  14599. fillDefines(defines: Array<string>, blendMode: number): void;
  14600. /**
  14601. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14602. * @param uniforms Uniforms array to fill
  14603. * @param attributes Attributes array to fill
  14604. * @param samplers Samplers array to fill
  14605. */
  14606. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14607. /**
  14608. * Observable that will be called just before the particles are drawn
  14609. */
  14610. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14611. /**
  14612. * Gets the name of the particle vertex shader
  14613. */
  14614. vertexShaderName: string;
  14615. /**
  14616. * Adds a new color gradient
  14617. * @param gradient defines the gradient to use (between 0 and 1)
  14618. * @param color1 defines the color to affect to the specified gradient
  14619. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14620. * @returns the current particle system
  14621. */
  14622. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14623. /**
  14624. * Remove a specific color gradient
  14625. * @param gradient defines the gradient to remove
  14626. * @returns the current particle system
  14627. */
  14628. removeColorGradient(gradient: number): IParticleSystem;
  14629. /**
  14630. * Adds a new size gradient
  14631. * @param gradient defines the gradient to use (between 0 and 1)
  14632. * @param factor defines the size factor to affect to the specified gradient
  14633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14634. * @returns the current particle system
  14635. */
  14636. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14637. /**
  14638. * Remove a specific size gradient
  14639. * @param gradient defines the gradient to remove
  14640. * @returns the current particle system
  14641. */
  14642. removeSizeGradient(gradient: number): IParticleSystem;
  14643. /**
  14644. * Gets the current list of color gradients.
  14645. * You must use addColorGradient and removeColorGradient to udpate this list
  14646. * @returns the list of color gradients
  14647. */
  14648. getColorGradients(): Nullable<Array<ColorGradient>>;
  14649. /**
  14650. * Gets the current list of size gradients.
  14651. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14652. * @returns the list of size gradients
  14653. */
  14654. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14655. /**
  14656. * Gets the current list of angular speed gradients.
  14657. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14658. * @returns the list of angular speed gradients
  14659. */
  14660. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new angular speed gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the angular speed to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific angular speed gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Gets the current list of velocity gradients.
  14677. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14678. * @returns the list of velocity gradients
  14679. */
  14680. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Adds a new velocity gradient
  14683. * @param gradient defines the gradient to use (between 0 and 1)
  14684. * @param factor defines the velocity to affect to the specified gradient
  14685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14686. * @returns the current particle system
  14687. */
  14688. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14689. /**
  14690. * Remove a specific velocity gradient
  14691. * @param gradient defines the gradient to remove
  14692. * @returns the current particle system
  14693. */
  14694. removeVelocityGradient(gradient: number): IParticleSystem;
  14695. /**
  14696. * Gets the current list of limit velocity gradients.
  14697. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14698. * @returns the list of limit velocity gradients
  14699. */
  14700. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14701. /**
  14702. * Adds a new limit velocity gradient
  14703. * @param gradient defines the gradient to use (between 0 and 1)
  14704. * @param factor defines the limit velocity to affect to the specified gradient
  14705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14706. * @returns the current particle system
  14707. */
  14708. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14709. /**
  14710. * Remove a specific limit velocity gradient
  14711. * @param gradient defines the gradient to remove
  14712. * @returns the current particle system
  14713. */
  14714. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14715. /**
  14716. * Adds a new drag gradient
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the drag to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific drag gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeDragGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of drag gradients.
  14731. * You must use addDragGradient and removeDragGradient to udpate this list
  14732. * @returns the list of drag gradients
  14733. */
  14734. getDragGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the emit rate to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific emit rate gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeEmitRateGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of emit rate gradients.
  14751. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14752. * @returns the list of emit rate gradients
  14753. */
  14754. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14757. * @param gradient defines the gradient to use (between 0 and 1)
  14758. * @param factor defines the start size to affect to the specified gradient
  14759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14760. * @returns the current particle system
  14761. */
  14762. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14763. /**
  14764. * Remove a specific start size gradient
  14765. * @param gradient defines the gradient to remove
  14766. * @returns the current particle system
  14767. */
  14768. removeStartSizeGradient(gradient: number): IParticleSystem;
  14769. /**
  14770. * Gets the current list of start size gradients.
  14771. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14772. * @returns the list of start size gradients
  14773. */
  14774. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14775. /**
  14776. * Adds a new life time gradient
  14777. * @param gradient defines the gradient to use (between 0 and 1)
  14778. * @param factor defines the life time factor to affect to the specified gradient
  14779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14780. * @returns the current particle system
  14781. */
  14782. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14783. /**
  14784. * Remove a specific life time gradient
  14785. * @param gradient defines the gradient to remove
  14786. * @returns the current particle system
  14787. */
  14788. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14789. /**
  14790. * Gets the current list of life time gradients.
  14791. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14792. * @returns the list of life time gradients
  14793. */
  14794. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14795. /**
  14796. * Gets the current list of color gradients.
  14797. * You must use addColorGradient and removeColorGradient to udpate this list
  14798. * @returns the list of color gradients
  14799. */
  14800. getColorGradients(): Nullable<Array<ColorGradient>>;
  14801. /**
  14802. * Adds a new ramp gradient used to remap particle colors
  14803. * @param gradient defines the gradient to use (between 0 and 1)
  14804. * @param color defines the color to affect to the specified gradient
  14805. * @returns the current particle system
  14806. */
  14807. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14808. /**
  14809. * Gets the current list of ramp gradients.
  14810. * You must use addRampGradient and removeRampGradient to udpate this list
  14811. * @returns the list of ramp gradients
  14812. */
  14813. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14814. /** Gets or sets a boolean indicating that ramp gradients must be used
  14815. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14816. */
  14817. useRampGradients: boolean;
  14818. /**
  14819. * Adds a new color remap gradient
  14820. * @param gradient defines the gradient to use (between 0 and 1)
  14821. * @param min defines the color remap minimal range
  14822. * @param max defines the color remap maximal range
  14823. * @returns the current particle system
  14824. */
  14825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of color remap gradients.
  14828. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14829. * @returns the list of color remap gradients
  14830. */
  14831. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new alpha remap gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param min defines the alpha remap minimal range
  14836. * @param max defines the alpha remap maximal range
  14837. * @returns the current particle system
  14838. */
  14839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14840. /**
  14841. * Gets the current list of alpha remap gradients.
  14842. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14843. * @returns the list of alpha remap gradients
  14844. */
  14845. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14846. /**
  14847. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14850. * @returns the emitter
  14851. */
  14852. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14853. /**
  14854. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14855. * @param radius The radius of the hemisphere to emit from
  14856. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14857. * @returns the emitter
  14858. */
  14859. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14860. /**
  14861. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14862. * @param radius The radius of the sphere to emit from
  14863. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14864. * @returns the emitter
  14865. */
  14866. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14867. /**
  14868. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14869. * @param radius The radius of the sphere to emit from
  14870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14872. * @returns the emitter
  14873. */
  14874. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14875. /**
  14876. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14877. * @param radius The radius of the emission cylinder
  14878. * @param height The height of the emission cylinder
  14879. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14880. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14881. * @returns the emitter
  14882. */
  14883. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14884. /**
  14885. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14886. * @param radius The radius of the cylinder to emit from
  14887. * @param height The height of the emission cylinder
  14888. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14889. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14890. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14891. * @returns the emitter
  14892. */
  14893. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14894. /**
  14895. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14896. * @param radius The radius of the cone to emit from
  14897. * @param angle The base angle of the cone
  14898. * @returns the emitter
  14899. */
  14900. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14901. /**
  14902. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14905. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14906. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14907. * @returns the emitter
  14908. */
  14909. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14910. /**
  14911. * Get hosting scene
  14912. * @returns the scene
  14913. */
  14914. getScene(): Nullable<Scene>;
  14915. }
  14916. }
  14917. declare module "babylonjs/Meshes/transformNode" {
  14918. import { DeepImmutable } from "babylonjs/types";
  14919. import { Observable } from "babylonjs/Misc/observable";
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Camera } from "babylonjs/Cameras/camera";
  14922. import { Scene } from "babylonjs/scene";
  14923. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14924. import { Node } from "babylonjs/node";
  14925. import { Bone } from "babylonjs/Bones/bone";
  14926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14927. import { Space } from "babylonjs/Maths/math.axis";
  14928. /**
  14929. * 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.
  14930. * @see https://doc.babylonjs.com/how_to/transformnode
  14931. */
  14932. export class TransformNode extends Node {
  14933. /**
  14934. * Object will not rotate to face the camera
  14935. */
  14936. static BILLBOARDMODE_NONE: number;
  14937. /**
  14938. * Object will rotate to face the camera but only on the x axis
  14939. */
  14940. static BILLBOARDMODE_X: number;
  14941. /**
  14942. * Object will rotate to face the camera but only on the y axis
  14943. */
  14944. static BILLBOARDMODE_Y: number;
  14945. /**
  14946. * Object will rotate to face the camera but only on the z axis
  14947. */
  14948. static BILLBOARDMODE_Z: number;
  14949. /**
  14950. * Object will rotate to face the camera
  14951. */
  14952. static BILLBOARDMODE_ALL: number;
  14953. /**
  14954. * Object will rotate to face the camera's position instead of orientation
  14955. */
  14956. static BILLBOARDMODE_USE_POSITION: number;
  14957. private static _TmpRotation;
  14958. private static _TmpScaling;
  14959. private static _TmpTranslation;
  14960. private _forward;
  14961. private _forwardInverted;
  14962. private _up;
  14963. private _right;
  14964. private _rightInverted;
  14965. private _position;
  14966. private _rotation;
  14967. private _rotationQuaternion;
  14968. protected _scaling: Vector3;
  14969. protected _isDirty: boolean;
  14970. private _transformToBoneReferal;
  14971. private _isAbsoluteSynced;
  14972. private _billboardMode;
  14973. /**
  14974. * Gets or sets the billboard mode. Default is 0.
  14975. *
  14976. * | Value | Type | Description |
  14977. * | --- | --- | --- |
  14978. * | 0 | BILLBOARDMODE_NONE | |
  14979. * | 1 | BILLBOARDMODE_X | |
  14980. * | 2 | BILLBOARDMODE_Y | |
  14981. * | 4 | BILLBOARDMODE_Z | |
  14982. * | 7 | BILLBOARDMODE_ALL | |
  14983. *
  14984. */
  14985. get billboardMode(): number;
  14986. set billboardMode(value: number);
  14987. private _preserveParentRotationForBillboard;
  14988. /**
  14989. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14990. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14991. */
  14992. get preserveParentRotationForBillboard(): boolean;
  14993. set preserveParentRotationForBillboard(value: boolean);
  14994. /**
  14995. * 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
  14996. */
  14997. scalingDeterminant: number;
  14998. private _infiniteDistance;
  14999. /**
  15000. * Gets or sets the distance of the object to max, often used by skybox
  15001. */
  15002. get infiniteDistance(): boolean;
  15003. set infiniteDistance(value: boolean);
  15004. /**
  15005. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15006. * By default the system will update normals to compensate
  15007. */
  15008. ignoreNonUniformScaling: boolean;
  15009. /**
  15010. * 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
  15011. */
  15012. reIntegrateRotationIntoRotationQuaternion: boolean;
  15013. /** @hidden */
  15014. _poseMatrix: Nullable<Matrix>;
  15015. /** @hidden */
  15016. _localMatrix: Matrix;
  15017. private _usePivotMatrix;
  15018. private _absolutePosition;
  15019. private _absoluteScaling;
  15020. private _absoluteRotationQuaternion;
  15021. private _pivotMatrix;
  15022. private _pivotMatrixInverse;
  15023. protected _postMultiplyPivotMatrix: boolean;
  15024. protected _isWorldMatrixFrozen: boolean;
  15025. /** @hidden */
  15026. _indexInSceneTransformNodesArray: number;
  15027. /**
  15028. * An event triggered after the world matrix is updated
  15029. */
  15030. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15031. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15032. /**
  15033. * Gets a string identifying the name of the class
  15034. * @returns "TransformNode" string
  15035. */
  15036. getClassName(): string;
  15037. /**
  15038. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15039. */
  15040. get position(): Vector3;
  15041. set position(newPosition: Vector3);
  15042. /**
  15043. * 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)).
  15044. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15045. */
  15046. get rotation(): Vector3;
  15047. set rotation(newRotation: Vector3);
  15048. /**
  15049. * 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)).
  15050. */
  15051. get scaling(): Vector3;
  15052. set scaling(newScaling: Vector3);
  15053. /**
  15054. * 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).
  15055. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15056. */
  15057. get rotationQuaternion(): Nullable<Quaternion>;
  15058. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15059. /**
  15060. * The forward direction of that transform in world space.
  15061. */
  15062. get forward(): Vector3;
  15063. /**
  15064. * The up direction of that transform in world space.
  15065. */
  15066. get up(): Vector3;
  15067. /**
  15068. * The right direction of that transform in world space.
  15069. */
  15070. get right(): Vector3;
  15071. /**
  15072. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15073. * @param matrix the matrix to copy the pose from
  15074. * @returns this TransformNode.
  15075. */
  15076. updatePoseMatrix(matrix: Matrix): TransformNode;
  15077. /**
  15078. * Returns the mesh Pose matrix.
  15079. * @returns the pose matrix
  15080. */
  15081. getPoseMatrix(): Matrix;
  15082. /** @hidden */
  15083. _isSynchronized(): boolean;
  15084. /** @hidden */
  15085. _initCache(): void;
  15086. /**
  15087. * Flag the transform node as dirty (Forcing it to update everything)
  15088. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15089. * @returns this transform node
  15090. */
  15091. markAsDirty(property: string): TransformNode;
  15092. /**
  15093. * Returns the current mesh absolute position.
  15094. * Returns a Vector3.
  15095. */
  15096. get absolutePosition(): Vector3;
  15097. /**
  15098. * Returns the current mesh absolute scaling.
  15099. * Returns a Vector3.
  15100. */
  15101. get absoluteScaling(): Vector3;
  15102. /**
  15103. * Returns the current mesh absolute rotation.
  15104. * Returns a Quaternion.
  15105. */
  15106. get absoluteRotationQuaternion(): Quaternion;
  15107. /**
  15108. * Sets a new matrix to apply before all other transformation
  15109. * @param matrix defines the transform matrix
  15110. * @returns the current TransformNode
  15111. */
  15112. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15113. /**
  15114. * Sets a new pivot matrix to the current node
  15115. * @param matrix defines the new pivot matrix to use
  15116. * @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
  15117. * @returns the current TransformNode
  15118. */
  15119. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15120. /**
  15121. * Returns the mesh pivot matrix.
  15122. * Default : Identity.
  15123. * @returns the matrix
  15124. */
  15125. getPivotMatrix(): Matrix;
  15126. /**
  15127. * Instantiate (when possible) or clone that node with its hierarchy
  15128. * @param newParent defines the new parent to use for the instance (or clone)
  15129. * @param options defines options to configure how copy is done
  15130. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15131. * @returns an instance (or a clone) of the current node with its hiearchy
  15132. */
  15133. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15134. doNotInstantiate: boolean;
  15135. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15136. /**
  15137. * Prevents the World matrix to be computed any longer
  15138. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15139. * @returns the TransformNode.
  15140. */
  15141. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15142. /**
  15143. * Allows back the World matrix computation.
  15144. * @returns the TransformNode.
  15145. */
  15146. unfreezeWorldMatrix(): this;
  15147. /**
  15148. * True if the World matrix has been frozen.
  15149. */
  15150. get isWorldMatrixFrozen(): boolean;
  15151. /**
  15152. * Retuns the mesh absolute position in the World.
  15153. * @returns a Vector3.
  15154. */
  15155. getAbsolutePosition(): Vector3;
  15156. /**
  15157. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15158. * @param absolutePosition the absolute position to set
  15159. * @returns the TransformNode.
  15160. */
  15161. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15162. /**
  15163. * Sets the mesh position in its local space.
  15164. * @param vector3 the position to set in localspace
  15165. * @returns the TransformNode.
  15166. */
  15167. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15168. /**
  15169. * Returns the mesh position in the local space from the current World matrix values.
  15170. * @returns a new Vector3.
  15171. */
  15172. getPositionExpressedInLocalSpace(): Vector3;
  15173. /**
  15174. * Translates the mesh along the passed Vector3 in its local space.
  15175. * @param vector3 the distance to translate in localspace
  15176. * @returns the TransformNode.
  15177. */
  15178. locallyTranslate(vector3: Vector3): TransformNode;
  15179. private static _lookAtVectorCache;
  15180. /**
  15181. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15182. * @param targetPoint the position (must be in same space as current mesh) to look at
  15183. * @param yawCor optional yaw (y-axis) correction in radians
  15184. * @param pitchCor optional pitch (x-axis) correction in radians
  15185. * @param rollCor optional roll (z-axis) correction in radians
  15186. * @param space the choosen space of the target
  15187. * @returns the TransformNode.
  15188. */
  15189. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15192. * This Vector3 is expressed in the World space.
  15193. * @param localAxis axis to rotate
  15194. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15195. */
  15196. getDirection(localAxis: Vector3): Vector3;
  15197. /**
  15198. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15199. * localAxis is expressed in the mesh local space.
  15200. * result is computed in the Wordl space from the mesh World matrix.
  15201. * @param localAxis axis to rotate
  15202. * @param result the resulting transformnode
  15203. * @returns this TransformNode.
  15204. */
  15205. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15206. /**
  15207. * Sets this transform node rotation to the given local axis.
  15208. * @param localAxis the axis in local space
  15209. * @param yawCor optional yaw (y-axis) correction in radians
  15210. * @param pitchCor optional pitch (x-axis) correction in radians
  15211. * @param rollCor optional roll (z-axis) correction in radians
  15212. * @returns this TransformNode
  15213. */
  15214. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15215. /**
  15216. * Sets a new pivot point to the current node
  15217. * @param point defines the new pivot point to use
  15218. * @param space defines if the point is in world or local space (local by default)
  15219. * @returns the current TransformNode
  15220. */
  15221. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15222. /**
  15223. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15224. * @returns the pivot point
  15225. */
  15226. getPivotPoint(): Vector3;
  15227. /**
  15228. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15229. * @param result the vector3 to store the result
  15230. * @returns this TransformNode.
  15231. */
  15232. getPivotPointToRef(result: Vector3): TransformNode;
  15233. /**
  15234. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15235. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15236. */
  15237. getAbsolutePivotPoint(): Vector3;
  15238. /**
  15239. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15240. * @param result vector3 to store the result
  15241. * @returns this TransformNode.
  15242. */
  15243. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15244. /**
  15245. * Defines the passed node as the parent of the current node.
  15246. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15247. * @see https://doc.babylonjs.com/how_to/parenting
  15248. * @param node the node ot set as the parent
  15249. * @returns this TransformNode.
  15250. */
  15251. setParent(node: Nullable<Node>): TransformNode;
  15252. private _nonUniformScaling;
  15253. /**
  15254. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15255. */
  15256. get nonUniformScaling(): boolean;
  15257. /** @hidden */
  15258. _updateNonUniformScalingState(value: boolean): boolean;
  15259. /**
  15260. * Attach the current TransformNode to another TransformNode associated with a bone
  15261. * @param bone Bone affecting the TransformNode
  15262. * @param affectedTransformNode TransformNode associated with the bone
  15263. * @returns this object
  15264. */
  15265. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15266. /**
  15267. * Detach the transform node if its associated with a bone
  15268. * @returns this object
  15269. */
  15270. detachFromBone(): TransformNode;
  15271. private static _rotationAxisCache;
  15272. /**
  15273. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15274. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15275. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15276. * The passed axis is also normalized.
  15277. * @param axis the axis to rotate around
  15278. * @param amount the amount to rotate in radians
  15279. * @param space Space to rotate in (Default: local)
  15280. * @returns the TransformNode.
  15281. */
  15282. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15283. /**
  15284. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15285. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15286. * The passed axis is also normalized. .
  15287. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15288. * @param point the point to rotate around
  15289. * @param axis the axis to rotate around
  15290. * @param amount the amount to rotate in radians
  15291. * @returns the TransformNode
  15292. */
  15293. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15294. /**
  15295. * Translates the mesh along the axis vector for the passed distance in the given space.
  15296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15297. * @param axis the axis to translate in
  15298. * @param distance the distance to translate
  15299. * @param space Space to rotate in (Default: local)
  15300. * @returns the TransformNode.
  15301. */
  15302. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15303. /**
  15304. * Adds a rotation step to the mesh current rotation.
  15305. * x, y, z are Euler angles expressed in radians.
  15306. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15307. * This means this rotation is made in the mesh local space only.
  15308. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15309. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15310. * ```javascript
  15311. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15312. * ```
  15313. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15314. * 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.
  15315. * @param x Rotation to add
  15316. * @param y Rotation to add
  15317. * @param z Rotation to add
  15318. * @returns the TransformNode.
  15319. */
  15320. addRotation(x: number, y: number, z: number): TransformNode;
  15321. /**
  15322. * @hidden
  15323. */
  15324. protected _getEffectiveParent(): Nullable<Node>;
  15325. /**
  15326. * Computes the world matrix of the node
  15327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15328. * @returns the world matrix
  15329. */
  15330. computeWorldMatrix(force?: boolean): Matrix;
  15331. /**
  15332. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15333. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15334. */
  15335. resetLocalMatrix(independentOfChildren?: boolean): void;
  15336. protected _afterComputeWorldMatrix(): void;
  15337. /**
  15338. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15339. * @param func callback function to add
  15340. *
  15341. * @returns the TransformNode.
  15342. */
  15343. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15344. /**
  15345. * Removes a registered callback function.
  15346. * @param func callback function to remove
  15347. * @returns the TransformNode.
  15348. */
  15349. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15350. /**
  15351. * Gets the position of the current mesh in camera space
  15352. * @param camera defines the camera to use
  15353. * @returns a position
  15354. */
  15355. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15356. /**
  15357. * Returns the distance from the mesh to the active camera
  15358. * @param camera defines the camera to use
  15359. * @returns the distance
  15360. */
  15361. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15362. /**
  15363. * Clone the current transform node
  15364. * @param name Name of the new clone
  15365. * @param newParent New parent for the clone
  15366. * @param doNotCloneChildren Do not clone children hierarchy
  15367. * @returns the new transform node
  15368. */
  15369. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15370. /**
  15371. * Serializes the objects information.
  15372. * @param currentSerializationObject defines the object to serialize in
  15373. * @returns the serialized object
  15374. */
  15375. serialize(currentSerializationObject?: any): any;
  15376. /**
  15377. * Returns a new TransformNode object parsed from the source provided.
  15378. * @param parsedTransformNode is the source.
  15379. * @param scene the scne the object belongs to
  15380. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15381. * @returns a new TransformNode object parsed from the source provided.
  15382. */
  15383. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15384. /**
  15385. * Get all child-transformNodes of this node
  15386. * @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
  15387. * @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
  15388. * @returns an array of TransformNode
  15389. */
  15390. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15391. /**
  15392. * Releases resources associated with this transform node.
  15393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15395. */
  15396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15397. /**
  15398. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15399. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15400. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15401. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15402. * @returns the current mesh
  15403. */
  15404. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15405. private _syncAbsoluteScalingAndRotation;
  15406. }
  15407. }
  15408. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15409. /**
  15410. * Class used to override all child animations of a given target
  15411. */
  15412. export class AnimationPropertiesOverride {
  15413. /**
  15414. * Gets or sets a value indicating if animation blending must be used
  15415. */
  15416. enableBlending: boolean;
  15417. /**
  15418. * Gets or sets the blending speed to use when enableBlending is true
  15419. */
  15420. blendingSpeed: number;
  15421. /**
  15422. * Gets or sets the default loop mode to use
  15423. */
  15424. loopMode: number;
  15425. }
  15426. }
  15427. declare module "babylonjs/Bones/bone" {
  15428. import { Skeleton } from "babylonjs/Bones/skeleton";
  15429. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15430. import { Nullable } from "babylonjs/types";
  15431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15433. import { Node } from "babylonjs/node";
  15434. import { Space } from "babylonjs/Maths/math.axis";
  15435. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15436. /**
  15437. * Class used to store bone information
  15438. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15439. */
  15440. export class Bone extends Node {
  15441. /**
  15442. * defines the bone name
  15443. */
  15444. name: string;
  15445. private static _tmpVecs;
  15446. private static _tmpQuat;
  15447. private static _tmpMats;
  15448. /**
  15449. * Gets the list of child bones
  15450. */
  15451. children: Bone[];
  15452. /** Gets the animations associated with this bone */
  15453. animations: import("babylonjs/Animations/animation").Animation[];
  15454. /**
  15455. * Gets or sets bone length
  15456. */
  15457. length: number;
  15458. /**
  15459. * @hidden Internal only
  15460. * Set this value to map this bone to a different index in the transform matrices
  15461. * Set this value to -1 to exclude the bone from the transform matrices
  15462. */
  15463. _index: Nullable<number>;
  15464. private _skeleton;
  15465. private _localMatrix;
  15466. private _restPose;
  15467. private _bindPose;
  15468. private _baseMatrix;
  15469. private _absoluteTransform;
  15470. private _invertedAbsoluteTransform;
  15471. private _parent;
  15472. private _scalingDeterminant;
  15473. private _worldTransform;
  15474. private _localScaling;
  15475. private _localRotation;
  15476. private _localPosition;
  15477. private _needToDecompose;
  15478. private _needToCompose;
  15479. /** @hidden */
  15480. _linkedTransformNode: Nullable<TransformNode>;
  15481. /** @hidden */
  15482. _waitingTransformNodeId: Nullable<string>;
  15483. /** @hidden */
  15484. get _matrix(): Matrix;
  15485. /** @hidden */
  15486. set _matrix(value: Matrix);
  15487. /**
  15488. * Create a new bone
  15489. * @param name defines the bone name
  15490. * @param skeleton defines the parent skeleton
  15491. * @param parentBone defines the parent (can be null if the bone is the root)
  15492. * @param localMatrix defines the local matrix
  15493. * @param restPose defines the rest pose matrix
  15494. * @param baseMatrix defines the base matrix
  15495. * @param index defines index of the bone in the hiearchy
  15496. */
  15497. constructor(
  15498. /**
  15499. * defines the bone name
  15500. */
  15501. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15502. /**
  15503. * Gets the current object class name.
  15504. * @return the class name
  15505. */
  15506. getClassName(): string;
  15507. /**
  15508. * Gets the parent skeleton
  15509. * @returns a skeleton
  15510. */
  15511. getSkeleton(): Skeleton;
  15512. /**
  15513. * Gets parent bone
  15514. * @returns a bone or null if the bone is the root of the bone hierarchy
  15515. */
  15516. getParent(): Nullable<Bone>;
  15517. /**
  15518. * Returns an array containing the root bones
  15519. * @returns an array containing the root bones
  15520. */
  15521. getChildren(): Array<Bone>;
  15522. /**
  15523. * Gets the node index in matrix array generated for rendering
  15524. * @returns the node index
  15525. */
  15526. getIndex(): number;
  15527. /**
  15528. * Sets the parent bone
  15529. * @param parent defines the parent (can be null if the bone is the root)
  15530. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15531. */
  15532. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15533. /**
  15534. * Gets the local matrix
  15535. * @returns a matrix
  15536. */
  15537. getLocalMatrix(): Matrix;
  15538. /**
  15539. * Gets the base matrix (initial matrix which remains unchanged)
  15540. * @returns a matrix
  15541. */
  15542. getBaseMatrix(): Matrix;
  15543. /**
  15544. * Gets the rest pose matrix
  15545. * @returns a matrix
  15546. */
  15547. getRestPose(): Matrix;
  15548. /**
  15549. * Sets the rest pose matrix
  15550. * @param matrix the local-space rest pose to set for this bone
  15551. */
  15552. setRestPose(matrix: Matrix): void;
  15553. /**
  15554. * Gets the bind pose matrix
  15555. * @returns the bind pose matrix
  15556. */
  15557. getBindPose(): Matrix;
  15558. /**
  15559. * Sets the bind pose matrix
  15560. * @param matrix the local-space bind pose to set for this bone
  15561. */
  15562. setBindPose(matrix: Matrix): void;
  15563. /**
  15564. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15565. */
  15566. getWorldMatrix(): Matrix;
  15567. /**
  15568. * Sets the local matrix to rest pose matrix
  15569. */
  15570. returnToRest(): void;
  15571. /**
  15572. * Gets the inverse of the absolute transform matrix.
  15573. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15574. * @returns a matrix
  15575. */
  15576. getInvertedAbsoluteTransform(): Matrix;
  15577. /**
  15578. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15579. * @returns a matrix
  15580. */
  15581. getAbsoluteTransform(): Matrix;
  15582. /**
  15583. * Links with the given transform node.
  15584. * The local matrix of this bone is copied from the transform node every frame.
  15585. * @param transformNode defines the transform node to link to
  15586. */
  15587. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15588. /**
  15589. * Gets the node used to drive the bone's transformation
  15590. * @returns a transform node or null
  15591. */
  15592. getTransformNode(): Nullable<TransformNode>;
  15593. /** Gets or sets current position (in local space) */
  15594. get position(): Vector3;
  15595. set position(newPosition: Vector3);
  15596. /** Gets or sets current rotation (in local space) */
  15597. get rotation(): Vector3;
  15598. set rotation(newRotation: Vector3);
  15599. /** Gets or sets current rotation quaternion (in local space) */
  15600. get rotationQuaternion(): Quaternion;
  15601. set rotationQuaternion(newRotation: Quaternion);
  15602. /** Gets or sets current scaling (in local space) */
  15603. get scaling(): Vector3;
  15604. set scaling(newScaling: Vector3);
  15605. /**
  15606. * Gets the animation properties override
  15607. */
  15608. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15609. private _decompose;
  15610. private _compose;
  15611. /**
  15612. * Update the base and local matrices
  15613. * @param matrix defines the new base or local matrix
  15614. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15615. * @param updateLocalMatrix defines if the local matrix should be updated
  15616. */
  15617. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15618. /** @hidden */
  15619. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15620. /**
  15621. * Flag the bone as dirty (Forcing it to update everything)
  15622. */
  15623. markAsDirty(): void;
  15624. /** @hidden */
  15625. _markAsDirtyAndCompose(): void;
  15626. private _markAsDirtyAndDecompose;
  15627. /**
  15628. * Translate the bone in local or world space
  15629. * @param vec The amount to translate the bone
  15630. * @param space The space that the translation is in
  15631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15632. */
  15633. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15634. /**
  15635. * Set the postion of the bone in local or world space
  15636. * @param position The position to set the bone
  15637. * @param space The space that the position is in
  15638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15639. */
  15640. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15641. /**
  15642. * Set the absolute position of the bone (world space)
  15643. * @param position The position to set the bone
  15644. * @param mesh The mesh that this bone is attached to
  15645. */
  15646. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15647. /**
  15648. * Scale the bone on the x, y and z axes (in local space)
  15649. * @param x The amount to scale the bone on the x axis
  15650. * @param y The amount to scale the bone on the y axis
  15651. * @param z The amount to scale the bone on the z axis
  15652. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15653. */
  15654. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15655. /**
  15656. * Set the bone scaling in local space
  15657. * @param scale defines the scaling vector
  15658. */
  15659. setScale(scale: Vector3): void;
  15660. /**
  15661. * Gets the current scaling in local space
  15662. * @returns the current scaling vector
  15663. */
  15664. getScale(): Vector3;
  15665. /**
  15666. * Gets the current scaling in local space and stores it in a target vector
  15667. * @param result defines the target vector
  15668. */
  15669. getScaleToRef(result: Vector3): void;
  15670. /**
  15671. * Set the yaw, pitch, and roll of the bone in local or world space
  15672. * @param yaw The rotation of the bone on the y axis
  15673. * @param pitch The rotation of the bone on the x axis
  15674. * @param roll The rotation of the bone on the z axis
  15675. * @param space The space that the axes of rotation are in
  15676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15677. */
  15678. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15679. /**
  15680. * Add a rotation to the bone on an axis in local or world space
  15681. * @param axis The axis to rotate the bone on
  15682. * @param amount The amount to rotate the bone
  15683. * @param space The space that the axis is in
  15684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15685. */
  15686. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15687. /**
  15688. * Set the rotation of the bone to a particular axis angle in local or world space
  15689. * @param axis The axis to rotate the bone on
  15690. * @param angle The angle that the bone should be rotated to
  15691. * @param space The space that the axis is in
  15692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15693. */
  15694. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15695. /**
  15696. * Set the euler rotation of the bone in local of world space
  15697. * @param rotation The euler rotation that the bone should be set to
  15698. * @param space The space that the rotation is in
  15699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15700. */
  15701. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15702. /**
  15703. * Set the quaternion rotation of the bone in local of world space
  15704. * @param quat The quaternion rotation that the bone should be set to
  15705. * @param space The space that the rotation is in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. */
  15708. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15709. /**
  15710. * Set the rotation matrix of the bone in local of world space
  15711. * @param rotMat The rotation matrix that the bone should be set to
  15712. * @param space The space that the rotation is in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. */
  15715. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15716. private _rotateWithMatrix;
  15717. private _getNegativeRotationToRef;
  15718. /**
  15719. * Get the position of the bone in local or world space
  15720. * @param space The space that the returned position is in
  15721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15722. * @returns The position of the bone
  15723. */
  15724. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15725. /**
  15726. * Copy the position of the bone to a vector3 in local or world space
  15727. * @param space The space that the returned position is in
  15728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15729. * @param result The vector3 to copy the position to
  15730. */
  15731. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15732. /**
  15733. * Get the absolute position of the bone (world space)
  15734. * @param mesh The mesh that this bone is attached to
  15735. * @returns The absolute position of the bone
  15736. */
  15737. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15738. /**
  15739. * Copy the absolute position of the bone (world space) to the result param
  15740. * @param mesh The mesh that this bone is attached to
  15741. * @param result The vector3 to copy the absolute position to
  15742. */
  15743. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15744. /**
  15745. * Compute the absolute transforms of this bone and its children
  15746. */
  15747. computeAbsoluteTransforms(): void;
  15748. /**
  15749. * Get the world direction from an axis that is in the local space of the bone
  15750. * @param localAxis The local direction that is used to compute the world direction
  15751. * @param mesh The mesh that this bone is attached to
  15752. * @returns The world direction
  15753. */
  15754. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15755. /**
  15756. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15757. * @param localAxis The local direction that is used to compute the world direction
  15758. * @param mesh The mesh that this bone is attached to
  15759. * @param result The vector3 that the world direction will be copied to
  15760. */
  15761. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15762. /**
  15763. * Get the euler rotation of the bone in local or world space
  15764. * @param space The space that the rotation should be in
  15765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15766. * @returns The euler rotation
  15767. */
  15768. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15769. /**
  15770. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15771. * @param space The space that the rotation should be in
  15772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15773. * @param result The vector3 that the rotation should be copied to
  15774. */
  15775. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15776. /**
  15777. * Get the quaternion rotation of the bone in either local or world space
  15778. * @param space The space that the rotation should be in
  15779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15780. * @returns The quaternion rotation
  15781. */
  15782. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15783. /**
  15784. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15785. * @param space The space that the rotation should be in
  15786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15787. * @param result The quaternion that the rotation should be copied to
  15788. */
  15789. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15790. /**
  15791. * Get the rotation matrix of the bone in local or world space
  15792. * @param space The space that the rotation should be in
  15793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15794. * @returns The rotation matrix
  15795. */
  15796. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15797. /**
  15798. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15799. * @param space The space that the rotation should be in
  15800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15801. * @param result The quaternion that the rotation should be copied to
  15802. */
  15803. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15804. /**
  15805. * Get the world position of a point that is in the local space of the bone
  15806. * @param position The local position
  15807. * @param mesh The mesh that this bone is attached to
  15808. * @returns The world position
  15809. */
  15810. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15811. /**
  15812. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15813. * @param position The local position
  15814. * @param mesh The mesh that this bone is attached to
  15815. * @param result The vector3 that the world position should be copied to
  15816. */
  15817. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15818. /**
  15819. * Get the local position of a point that is in world space
  15820. * @param position The world position
  15821. * @param mesh The mesh that this bone is attached to
  15822. * @returns The local position
  15823. */
  15824. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15825. /**
  15826. * Get the local position of a point that is in world space and copy it to the result param
  15827. * @param position The world position
  15828. * @param mesh The mesh that this bone is attached to
  15829. * @param result The vector3 that the local position should be copied to
  15830. */
  15831. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15832. }
  15833. }
  15834. declare module "babylonjs/Animations/runtimeAnimation" {
  15835. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15836. import { Animatable } from "babylonjs/Animations/animatable";
  15837. import { Scene } from "babylonjs/scene";
  15838. /**
  15839. * Defines a runtime animation
  15840. */
  15841. export class RuntimeAnimation {
  15842. private _events;
  15843. /**
  15844. * The current frame of the runtime animation
  15845. */
  15846. private _currentFrame;
  15847. /**
  15848. * The animation used by the runtime animation
  15849. */
  15850. private _animation;
  15851. /**
  15852. * The target of the runtime animation
  15853. */
  15854. private _target;
  15855. /**
  15856. * The initiating animatable
  15857. */
  15858. private _host;
  15859. /**
  15860. * The original value of the runtime animation
  15861. */
  15862. private _originalValue;
  15863. /**
  15864. * The original blend value of the runtime animation
  15865. */
  15866. private _originalBlendValue;
  15867. /**
  15868. * The offsets cache of the runtime animation
  15869. */
  15870. private _offsetsCache;
  15871. /**
  15872. * The high limits cache of the runtime animation
  15873. */
  15874. private _highLimitsCache;
  15875. /**
  15876. * Specifies if the runtime animation has been stopped
  15877. */
  15878. private _stopped;
  15879. /**
  15880. * The blending factor of the runtime animation
  15881. */
  15882. private _blendingFactor;
  15883. /**
  15884. * The BabylonJS scene
  15885. */
  15886. private _scene;
  15887. /**
  15888. * The current value of the runtime animation
  15889. */
  15890. private _currentValue;
  15891. /** @hidden */
  15892. _animationState: _IAnimationState;
  15893. /**
  15894. * The active target of the runtime animation
  15895. */
  15896. private _activeTargets;
  15897. private _currentActiveTarget;
  15898. private _directTarget;
  15899. /**
  15900. * The target path of the runtime animation
  15901. */
  15902. private _targetPath;
  15903. /**
  15904. * The weight of the runtime animation
  15905. */
  15906. private _weight;
  15907. /**
  15908. * The ratio offset of the runtime animation
  15909. */
  15910. private _ratioOffset;
  15911. /**
  15912. * The previous delay of the runtime animation
  15913. */
  15914. private _previousDelay;
  15915. /**
  15916. * The previous ratio of the runtime animation
  15917. */
  15918. private _previousRatio;
  15919. private _enableBlending;
  15920. private _keys;
  15921. private _minFrame;
  15922. private _maxFrame;
  15923. private _minValue;
  15924. private _maxValue;
  15925. private _targetIsArray;
  15926. /**
  15927. * Gets the current frame of the runtime animation
  15928. */
  15929. get currentFrame(): number;
  15930. /**
  15931. * Gets the weight of the runtime animation
  15932. */
  15933. get weight(): number;
  15934. /**
  15935. * Gets the current value of the runtime animation
  15936. */
  15937. get currentValue(): any;
  15938. /**
  15939. * Gets the target path of the runtime animation
  15940. */
  15941. get targetPath(): string;
  15942. /**
  15943. * Gets the actual target of the runtime animation
  15944. */
  15945. get target(): any;
  15946. /**
  15947. * Gets the additive state of the runtime animation
  15948. */
  15949. get isAdditive(): boolean;
  15950. /** @hidden */
  15951. _onLoop: () => void;
  15952. /**
  15953. * Create a new RuntimeAnimation object
  15954. * @param target defines the target of the animation
  15955. * @param animation defines the source animation object
  15956. * @param scene defines the hosting scene
  15957. * @param host defines the initiating Animatable
  15958. */
  15959. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15960. private _preparePath;
  15961. /**
  15962. * Gets the animation from the runtime animation
  15963. */
  15964. get animation(): Animation;
  15965. /**
  15966. * Resets the runtime animation to the beginning
  15967. * @param restoreOriginal defines whether to restore the target property to the original value
  15968. */
  15969. reset(restoreOriginal?: boolean): void;
  15970. /**
  15971. * Specifies if the runtime animation is stopped
  15972. * @returns Boolean specifying if the runtime animation is stopped
  15973. */
  15974. isStopped(): boolean;
  15975. /**
  15976. * Disposes of the runtime animation
  15977. */
  15978. dispose(): void;
  15979. /**
  15980. * Apply the interpolated value to the target
  15981. * @param currentValue defines the value computed by the animation
  15982. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15983. */
  15984. setValue(currentValue: any, weight: number): void;
  15985. private _getOriginalValues;
  15986. private _setValue;
  15987. /**
  15988. * Gets the loop pmode of the runtime animation
  15989. * @returns Loop Mode
  15990. */
  15991. private _getCorrectLoopMode;
  15992. /**
  15993. * Move the current animation to a given frame
  15994. * @param frame defines the frame to move to
  15995. */
  15996. goToFrame(frame: number): void;
  15997. /**
  15998. * @hidden Internal use only
  15999. */
  16000. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16001. /**
  16002. * Execute the current animation
  16003. * @param delay defines the delay to add to the current frame
  16004. * @param from defines the lower bound of the animation range
  16005. * @param to defines the upper bound of the animation range
  16006. * @param loop defines if the current animation must loop
  16007. * @param speedRatio defines the current speed ratio
  16008. * @param weight defines the weight of the animation (default is -1 so no weight)
  16009. * @param onLoop optional callback called when animation loops
  16010. * @returns a boolean indicating if the animation is running
  16011. */
  16012. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16013. }
  16014. }
  16015. declare module "babylonjs/Animations/animatable" {
  16016. import { Animation } from "babylonjs/Animations/animation";
  16017. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16018. import { Nullable } from "babylonjs/types";
  16019. import { Observable } from "babylonjs/Misc/observable";
  16020. import { Scene } from "babylonjs/scene";
  16021. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16022. import { Node } from "babylonjs/node";
  16023. /**
  16024. * Class used to store an actual running animation
  16025. */
  16026. export class Animatable {
  16027. /** defines the target object */
  16028. target: any;
  16029. /** defines the starting frame number (default is 0) */
  16030. fromFrame: number;
  16031. /** defines the ending frame number (default is 100) */
  16032. toFrame: number;
  16033. /** defines if the animation must loop (default is false) */
  16034. loopAnimation: boolean;
  16035. /** defines a callback to call when animation ends if it is not looping */
  16036. onAnimationEnd?: (() => void) | null | undefined;
  16037. /** defines a callback to call when animation loops */
  16038. onAnimationLoop?: (() => void) | null | undefined;
  16039. /** defines whether the animation should be evaluated additively */
  16040. isAdditive: boolean;
  16041. private _localDelayOffset;
  16042. private _pausedDelay;
  16043. private _runtimeAnimations;
  16044. private _paused;
  16045. private _scene;
  16046. private _speedRatio;
  16047. private _weight;
  16048. private _syncRoot;
  16049. /**
  16050. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16051. * This will only apply for non looping animation (default is true)
  16052. */
  16053. disposeOnEnd: boolean;
  16054. /**
  16055. * Gets a boolean indicating if the animation has started
  16056. */
  16057. animationStarted: boolean;
  16058. /**
  16059. * Observer raised when the animation ends
  16060. */
  16061. onAnimationEndObservable: Observable<Animatable>;
  16062. /**
  16063. * Observer raised when the animation loops
  16064. */
  16065. onAnimationLoopObservable: Observable<Animatable>;
  16066. /**
  16067. * Gets the root Animatable used to synchronize and normalize animations
  16068. */
  16069. get syncRoot(): Nullable<Animatable>;
  16070. /**
  16071. * Gets the current frame of the first RuntimeAnimation
  16072. * Used to synchronize Animatables
  16073. */
  16074. get masterFrame(): number;
  16075. /**
  16076. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16077. */
  16078. get weight(): number;
  16079. set weight(value: number);
  16080. /**
  16081. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16082. */
  16083. get speedRatio(): number;
  16084. set speedRatio(value: number);
  16085. /**
  16086. * Creates a new Animatable
  16087. * @param scene defines the hosting scene
  16088. * @param target defines the target object
  16089. * @param fromFrame defines the starting frame number (default is 0)
  16090. * @param toFrame defines the ending frame number (default is 100)
  16091. * @param loopAnimation defines if the animation must loop (default is false)
  16092. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16093. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16094. * @param animations defines a group of animation to add to the new Animatable
  16095. * @param onAnimationLoop defines a callback to call when animation loops
  16096. * @param isAdditive defines whether the animation should be evaluated additively
  16097. */
  16098. constructor(scene: Scene,
  16099. /** defines the target object */
  16100. target: any,
  16101. /** defines the starting frame number (default is 0) */
  16102. fromFrame?: number,
  16103. /** defines the ending frame number (default is 100) */
  16104. toFrame?: number,
  16105. /** defines if the animation must loop (default is false) */
  16106. loopAnimation?: boolean, speedRatio?: number,
  16107. /** defines a callback to call when animation ends if it is not looping */
  16108. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16109. /** defines a callback to call when animation loops */
  16110. onAnimationLoop?: (() => void) | null | undefined,
  16111. /** defines whether the animation should be evaluated additively */
  16112. isAdditive?: boolean);
  16113. /**
  16114. * Synchronize and normalize current Animatable with a source Animatable
  16115. * This is useful when using animation weights and when animations are not of the same length
  16116. * @param root defines the root Animatable to synchronize with
  16117. * @returns the current Animatable
  16118. */
  16119. syncWith(root: Animatable): Animatable;
  16120. /**
  16121. * Gets the list of runtime animations
  16122. * @returns an array of RuntimeAnimation
  16123. */
  16124. getAnimations(): RuntimeAnimation[];
  16125. /**
  16126. * Adds more animations to the current animatable
  16127. * @param target defines the target of the animations
  16128. * @param animations defines the new animations to add
  16129. */
  16130. appendAnimations(target: any, animations: Animation[]): void;
  16131. /**
  16132. * Gets the source animation for a specific property
  16133. * @param property defines the propertyu to look for
  16134. * @returns null or the source animation for the given property
  16135. */
  16136. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16137. /**
  16138. * Gets the runtime animation for a specific property
  16139. * @param property defines the propertyu to look for
  16140. * @returns null or the runtime animation for the given property
  16141. */
  16142. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16143. /**
  16144. * Resets the animatable to its original state
  16145. */
  16146. reset(): void;
  16147. /**
  16148. * Allows the animatable to blend with current running animations
  16149. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16150. * @param blendingSpeed defines the blending speed to use
  16151. */
  16152. enableBlending(blendingSpeed: number): void;
  16153. /**
  16154. * Disable animation blending
  16155. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16156. */
  16157. disableBlending(): void;
  16158. /**
  16159. * Jump directly to a given frame
  16160. * @param frame defines the frame to jump to
  16161. */
  16162. goToFrame(frame: number): void;
  16163. /**
  16164. * Pause the animation
  16165. */
  16166. pause(): void;
  16167. /**
  16168. * Restart the animation
  16169. */
  16170. restart(): void;
  16171. private _raiseOnAnimationEnd;
  16172. /**
  16173. * Stop and delete the current animation
  16174. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16175. * @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)
  16176. */
  16177. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16178. /**
  16179. * Wait asynchronously for the animation to end
  16180. * @returns a promise which will be fullfilled when the animation ends
  16181. */
  16182. waitAsync(): Promise<Animatable>;
  16183. /** @hidden */
  16184. _animate(delay: number): boolean;
  16185. }
  16186. module "babylonjs/scene" {
  16187. interface Scene {
  16188. /** @hidden */
  16189. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16190. /** @hidden */
  16191. _processLateAnimationBindingsForMatrices(holder: {
  16192. totalWeight: number;
  16193. totalAdditiveWeight: number;
  16194. animations: RuntimeAnimation[];
  16195. additiveAnimations: RuntimeAnimation[];
  16196. originalValue: Matrix;
  16197. }): any;
  16198. /** @hidden */
  16199. _processLateAnimationBindingsForQuaternions(holder: {
  16200. totalWeight: number;
  16201. totalAdditiveWeight: number;
  16202. animations: RuntimeAnimation[];
  16203. additiveAnimations: RuntimeAnimation[];
  16204. originalValue: Quaternion;
  16205. }, refQuaternion: Quaternion): Quaternion;
  16206. /** @hidden */
  16207. _processLateAnimationBindings(): void;
  16208. /**
  16209. * Will start the animation sequence of a given target
  16210. * @param target defines the target
  16211. * @param from defines from which frame should animation start
  16212. * @param to defines until which frame should animation run.
  16213. * @param weight defines the weight to apply to the animation (1.0 by default)
  16214. * @param loop defines if the animation loops
  16215. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16216. * @param onAnimationEnd defines the function to be executed when the animation ends
  16217. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16218. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16219. * @param onAnimationLoop defines the callback to call when an animation loops
  16220. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16221. * @returns the animatable object created for this animation
  16222. */
  16223. 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;
  16224. /**
  16225. * Will start the animation sequence of a given target
  16226. * @param target defines the target
  16227. * @param from defines from which frame should animation start
  16228. * @param to defines until which frame should animation run.
  16229. * @param loop defines if the animation loops
  16230. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16231. * @param onAnimationEnd defines the function to be executed when the animation ends
  16232. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16233. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16234. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16235. * @param onAnimationLoop defines the callback to call when an animation loops
  16236. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16237. * @returns the animatable object created for this animation
  16238. */
  16239. 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;
  16240. /**
  16241. * Will start the animation sequence of a given target and its hierarchy
  16242. * @param target defines the target
  16243. * @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.
  16244. * @param from defines from which frame should animation start
  16245. * @param to defines until which frame should animation run.
  16246. * @param loop defines if the animation loops
  16247. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16248. * @param onAnimationEnd defines the function to be executed when the animation ends
  16249. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16250. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16251. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16252. * @param onAnimationLoop defines the callback to call when an animation loops
  16253. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16254. * @returns the list of created animatables
  16255. */
  16256. 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[];
  16257. /**
  16258. * Begin a new animation on a given node
  16259. * @param target defines the target where the animation will take place
  16260. * @param animations defines the list of animations to start
  16261. * @param from defines the initial value
  16262. * @param to defines the final value
  16263. * @param loop defines if you want animation to loop (off by default)
  16264. * @param speedRatio defines the speed ratio to apply to all animations
  16265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16266. * @param onAnimationLoop defines the callback to call when an animation loops
  16267. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16268. * @returns the list of created animatables
  16269. */
  16270. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16271. /**
  16272. * Begin a new animation on a given node and its hierarchy
  16273. * @param target defines the root node where the animation will take place
  16274. * @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.
  16275. * @param animations defines the list of animations to start
  16276. * @param from defines the initial value
  16277. * @param to defines the final value
  16278. * @param loop defines if you want animation to loop (off by default)
  16279. * @param speedRatio defines the speed ratio to apply to all animations
  16280. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16281. * @param onAnimationLoop defines the callback to call when an animation loops
  16282. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16283. * @returns the list of animatables created for all nodes
  16284. */
  16285. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16286. /**
  16287. * Gets the animatable associated with a specific target
  16288. * @param target defines the target of the animatable
  16289. * @returns the required animatable if found
  16290. */
  16291. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16292. /**
  16293. * Gets all animatables associated with a given target
  16294. * @param target defines the target to look animatables for
  16295. * @returns an array of Animatables
  16296. */
  16297. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16298. /**
  16299. * Stops and removes all animations that have been applied to the scene
  16300. */
  16301. stopAllAnimations(): void;
  16302. /**
  16303. * Gets the current delta time used by animation engine
  16304. */
  16305. deltaTime: number;
  16306. }
  16307. }
  16308. module "babylonjs/Bones/bone" {
  16309. interface Bone {
  16310. /**
  16311. * Copy an animation range from another bone
  16312. * @param source defines the source bone
  16313. * @param rangeName defines the range name to copy
  16314. * @param frameOffset defines the frame offset
  16315. * @param rescaleAsRequired defines if rescaling must be applied if required
  16316. * @param skelDimensionsRatio defines the scaling ratio
  16317. * @returns true if operation was successful
  16318. */
  16319. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16320. }
  16321. }
  16322. }
  16323. declare module "babylonjs/Bones/skeleton" {
  16324. import { Bone } from "babylonjs/Bones/bone";
  16325. import { Observable } from "babylonjs/Misc/observable";
  16326. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16327. import { Scene } from "babylonjs/scene";
  16328. import { Nullable } from "babylonjs/types";
  16329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16330. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16331. import { Animatable } from "babylonjs/Animations/animatable";
  16332. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16333. import { Animation } from "babylonjs/Animations/animation";
  16334. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16335. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16337. /**
  16338. * Class used to handle skinning animations
  16339. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16340. */
  16341. export class Skeleton implements IAnimatable {
  16342. /** defines the skeleton name */
  16343. name: string;
  16344. /** defines the skeleton Id */
  16345. id: string;
  16346. /**
  16347. * Defines the list of child bones
  16348. */
  16349. bones: Bone[];
  16350. /**
  16351. * Defines an estimate of the dimension of the skeleton at rest
  16352. */
  16353. dimensionsAtRest: Vector3;
  16354. /**
  16355. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16356. */
  16357. needInitialSkinMatrix: boolean;
  16358. /**
  16359. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16360. */
  16361. overrideMesh: Nullable<AbstractMesh>;
  16362. /**
  16363. * Gets the list of animations attached to this skeleton
  16364. */
  16365. animations: Array<Animation>;
  16366. private _scene;
  16367. private _isDirty;
  16368. private _transformMatrices;
  16369. private _transformMatrixTexture;
  16370. private _meshesWithPoseMatrix;
  16371. private _animatables;
  16372. private _identity;
  16373. private _synchronizedWithMesh;
  16374. private _ranges;
  16375. private _lastAbsoluteTransformsUpdateId;
  16376. private _canUseTextureForBones;
  16377. private _uniqueId;
  16378. /** @hidden */
  16379. _numBonesWithLinkedTransformNode: number;
  16380. /** @hidden */
  16381. _hasWaitingData: Nullable<boolean>;
  16382. /**
  16383. * Specifies if the skeleton should be serialized
  16384. */
  16385. doNotSerialize: boolean;
  16386. private _useTextureToStoreBoneMatrices;
  16387. /**
  16388. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16389. * Please note that this option is not available if the hardware does not support it
  16390. */
  16391. get useTextureToStoreBoneMatrices(): boolean;
  16392. set useTextureToStoreBoneMatrices(value: boolean);
  16393. private _animationPropertiesOverride;
  16394. /**
  16395. * Gets or sets the animation properties override
  16396. */
  16397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16398. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16399. /**
  16400. * List of inspectable custom properties (used by the Inspector)
  16401. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16402. */
  16403. inspectableCustomProperties: IInspectable[];
  16404. /**
  16405. * An observable triggered before computing the skeleton's matrices
  16406. */
  16407. onBeforeComputeObservable: Observable<Skeleton>;
  16408. /**
  16409. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16410. */
  16411. get isUsingTextureForMatrices(): boolean;
  16412. /**
  16413. * Gets the unique ID of this skeleton
  16414. */
  16415. get uniqueId(): number;
  16416. /**
  16417. * Creates a new skeleton
  16418. * @param name defines the skeleton name
  16419. * @param id defines the skeleton Id
  16420. * @param scene defines the hosting scene
  16421. */
  16422. constructor(
  16423. /** defines the skeleton name */
  16424. name: string,
  16425. /** defines the skeleton Id */
  16426. id: string, scene: Scene);
  16427. /**
  16428. * Gets the current object class name.
  16429. * @return the class name
  16430. */
  16431. getClassName(): string;
  16432. /**
  16433. * Returns an array containing the root bones
  16434. * @returns an array containing the root bones
  16435. */
  16436. getChildren(): Array<Bone>;
  16437. /**
  16438. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16439. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16440. * @returns a Float32Array containing matrices data
  16441. */
  16442. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16443. /**
  16444. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16446. * @returns a raw texture containing the data
  16447. */
  16448. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16449. /**
  16450. * Gets the current hosting scene
  16451. * @returns a scene object
  16452. */
  16453. getScene(): Scene;
  16454. /**
  16455. * Gets a string representing the current skeleton data
  16456. * @param fullDetails defines a boolean indicating if we want a verbose version
  16457. * @returns a string representing the current skeleton data
  16458. */
  16459. toString(fullDetails?: boolean): string;
  16460. /**
  16461. * Get bone's index searching by name
  16462. * @param name defines bone's name to search for
  16463. * @return the indice of the bone. Returns -1 if not found
  16464. */
  16465. getBoneIndexByName(name: string): number;
  16466. /**
  16467. * Creater a new animation range
  16468. * @param name defines the name of the range
  16469. * @param from defines the start key
  16470. * @param to defines the end key
  16471. */
  16472. createAnimationRange(name: string, from: number, to: number): void;
  16473. /**
  16474. * Delete a specific animation range
  16475. * @param name defines the name of the range
  16476. * @param deleteFrames defines if frames must be removed as well
  16477. */
  16478. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16479. /**
  16480. * Gets a specific animation range
  16481. * @param name defines the name of the range to look for
  16482. * @returns the requested animation range or null if not found
  16483. */
  16484. getAnimationRange(name: string): Nullable<AnimationRange>;
  16485. /**
  16486. * Gets the list of all animation ranges defined on this skeleton
  16487. * @returns an array
  16488. */
  16489. getAnimationRanges(): Nullable<AnimationRange>[];
  16490. /**
  16491. * Copy animation range from a source skeleton.
  16492. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16493. * @param source defines the source skeleton
  16494. * @param name defines the name of the range to copy
  16495. * @param rescaleAsRequired defines if rescaling must be applied if required
  16496. * @returns true if operation was successful
  16497. */
  16498. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16499. /**
  16500. * Forces the skeleton to go to rest pose
  16501. */
  16502. returnToRest(): void;
  16503. private _getHighestAnimationFrame;
  16504. /**
  16505. * Begin a specific animation range
  16506. * @param name defines the name of the range to start
  16507. * @param loop defines if looping must be turned on (false by default)
  16508. * @param speedRatio defines the speed ratio to apply (1 by default)
  16509. * @param onAnimationEnd defines a callback which will be called when animation will end
  16510. * @returns a new animatable
  16511. */
  16512. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16513. /**
  16514. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16515. * @param skeleton defines the Skeleton containing the animation range to convert
  16516. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16517. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16518. * @returns the original skeleton
  16519. */
  16520. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16521. /** @hidden */
  16522. _markAsDirty(): void;
  16523. /** @hidden */
  16524. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16525. /** @hidden */
  16526. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16527. private _computeTransformMatrices;
  16528. /**
  16529. * Build all resources required to render a skeleton
  16530. */
  16531. prepare(): void;
  16532. /**
  16533. * Gets the list of animatables currently running for this skeleton
  16534. * @returns an array of animatables
  16535. */
  16536. getAnimatables(): IAnimatable[];
  16537. /**
  16538. * Clone the current skeleton
  16539. * @param name defines the name of the new skeleton
  16540. * @param id defines the id of the new skeleton
  16541. * @returns the new skeleton
  16542. */
  16543. clone(name: string, id?: string): Skeleton;
  16544. /**
  16545. * Enable animation blending for this skeleton
  16546. * @param blendingSpeed defines the blending speed to apply
  16547. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16548. */
  16549. enableBlending(blendingSpeed?: number): void;
  16550. /**
  16551. * Releases all resources associated with the current skeleton
  16552. */
  16553. dispose(): void;
  16554. /**
  16555. * Serialize the skeleton in a JSON object
  16556. * @returns a JSON object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Creates a new skeleton from serialized data
  16561. * @param parsedSkeleton defines the serialized data
  16562. * @param scene defines the hosting scene
  16563. * @returns a new skeleton
  16564. */
  16565. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16566. /**
  16567. * Compute all node absolute transforms
  16568. * @param forceUpdate defines if computation must be done even if cache is up to date
  16569. */
  16570. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16571. /**
  16572. * Gets the root pose matrix
  16573. * @returns a matrix
  16574. */
  16575. getPoseMatrix(): Nullable<Matrix>;
  16576. /**
  16577. * Sorts bones per internal index
  16578. */
  16579. sortBones(): void;
  16580. private _sortBones;
  16581. }
  16582. }
  16583. declare module "babylonjs/Meshes/instancedMesh" {
  16584. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16585. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16586. import { Camera } from "babylonjs/Cameras/camera";
  16587. import { Node } from "babylonjs/node";
  16588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16589. import { Mesh } from "babylonjs/Meshes/mesh";
  16590. import { Material } from "babylonjs/Materials/material";
  16591. import { Skeleton } from "babylonjs/Bones/skeleton";
  16592. import { Light } from "babylonjs/Lights/light";
  16593. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16594. /**
  16595. * Creates an instance based on a source mesh.
  16596. */
  16597. export class InstancedMesh extends AbstractMesh {
  16598. private _sourceMesh;
  16599. private _currentLOD;
  16600. /** @hidden */
  16601. _indexInSourceMeshInstanceArray: number;
  16602. constructor(name: string, source: Mesh);
  16603. /**
  16604. * Returns the string "InstancedMesh".
  16605. */
  16606. getClassName(): string;
  16607. /** Gets the list of lights affecting that mesh */
  16608. get lightSources(): Light[];
  16609. _resyncLightSources(): void;
  16610. _resyncLightSource(light: Light): void;
  16611. _removeLightSource(light: Light, dispose: boolean): void;
  16612. /**
  16613. * If the source mesh receives shadows
  16614. */
  16615. get receiveShadows(): boolean;
  16616. /**
  16617. * The material of the source mesh
  16618. */
  16619. get material(): Nullable<Material>;
  16620. /**
  16621. * Visibility of the source mesh
  16622. */
  16623. get visibility(): number;
  16624. /**
  16625. * Skeleton of the source mesh
  16626. */
  16627. get skeleton(): Nullable<Skeleton>;
  16628. /**
  16629. * Rendering ground id of the source mesh
  16630. */
  16631. get renderingGroupId(): number;
  16632. set renderingGroupId(value: number);
  16633. /**
  16634. * Returns the total number of vertices (integer).
  16635. */
  16636. getTotalVertices(): number;
  16637. /**
  16638. * Returns a positive integer : the total number of indices in this mesh geometry.
  16639. * @returns the numner of indices or zero if the mesh has no geometry.
  16640. */
  16641. getTotalIndices(): number;
  16642. /**
  16643. * The source mesh of the instance
  16644. */
  16645. get sourceMesh(): Mesh;
  16646. /**
  16647. * Creates a new InstancedMesh object from the mesh model.
  16648. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16649. * @param name defines the name of the new instance
  16650. * @returns a new InstancedMesh
  16651. */
  16652. createInstance(name: string): InstancedMesh;
  16653. /**
  16654. * Is this node ready to be used/rendered
  16655. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16656. * @return {boolean} is it ready
  16657. */
  16658. isReady(completeCheck?: boolean): boolean;
  16659. /**
  16660. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16661. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16662. * @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.
  16663. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16664. */
  16665. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16666. /**
  16667. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16668. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16669. * The `data` are either a numeric array either a Float32Array.
  16670. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16671. * 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).
  16672. * Note that a new underlying VertexBuffer object is created each call.
  16673. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16674. *
  16675. * Possible `kind` values :
  16676. * - VertexBuffer.PositionKind
  16677. * - VertexBuffer.UVKind
  16678. * - VertexBuffer.UV2Kind
  16679. * - VertexBuffer.UV3Kind
  16680. * - VertexBuffer.UV4Kind
  16681. * - VertexBuffer.UV5Kind
  16682. * - VertexBuffer.UV6Kind
  16683. * - VertexBuffer.ColorKind
  16684. * - VertexBuffer.MatricesIndicesKind
  16685. * - VertexBuffer.MatricesIndicesExtraKind
  16686. * - VertexBuffer.MatricesWeightsKind
  16687. * - VertexBuffer.MatricesWeightsExtraKind
  16688. *
  16689. * Returns the Mesh.
  16690. */
  16691. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16692. /**
  16693. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16694. * If the mesh has no geometry, it is simply returned as it is.
  16695. * The `data` are either a numeric array either a Float32Array.
  16696. * No new underlying VertexBuffer object is created.
  16697. * 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.
  16698. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16699. *
  16700. * Possible `kind` values :
  16701. * - VertexBuffer.PositionKind
  16702. * - VertexBuffer.UVKind
  16703. * - VertexBuffer.UV2Kind
  16704. * - VertexBuffer.UV3Kind
  16705. * - VertexBuffer.UV4Kind
  16706. * - VertexBuffer.UV5Kind
  16707. * - VertexBuffer.UV6Kind
  16708. * - VertexBuffer.ColorKind
  16709. * - VertexBuffer.MatricesIndicesKind
  16710. * - VertexBuffer.MatricesIndicesExtraKind
  16711. * - VertexBuffer.MatricesWeightsKind
  16712. * - VertexBuffer.MatricesWeightsExtraKind
  16713. *
  16714. * Returns the Mesh.
  16715. */
  16716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16717. /**
  16718. * Sets the mesh indices.
  16719. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16720. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16721. * This method creates a new index buffer each call.
  16722. * Returns the Mesh.
  16723. */
  16724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16725. /**
  16726. * Boolean : True if the mesh owns the requested kind of data.
  16727. */
  16728. isVerticesDataPresent(kind: string): boolean;
  16729. /**
  16730. * Returns an array of indices (IndicesArray).
  16731. */
  16732. getIndices(): Nullable<IndicesArray>;
  16733. get _positions(): Nullable<Vector3[]>;
  16734. /**
  16735. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16736. * This means the mesh underlying bounding box and sphere are recomputed.
  16737. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16738. * @returns the current mesh
  16739. */
  16740. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16741. /** @hidden */
  16742. _preActivate(): InstancedMesh;
  16743. /** @hidden */
  16744. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16745. /** @hidden */
  16746. _postActivate(): void;
  16747. getWorldMatrix(): Matrix;
  16748. get isAnInstance(): boolean;
  16749. /**
  16750. * Returns the current associated LOD AbstractMesh.
  16751. */
  16752. getLOD(camera: Camera): AbstractMesh;
  16753. /** @hidden */
  16754. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16755. /** @hidden */
  16756. _syncSubMeshes(): InstancedMesh;
  16757. /** @hidden */
  16758. _generatePointsArray(): boolean;
  16759. /**
  16760. * Creates a new InstancedMesh from the current mesh.
  16761. * - name (string) : the cloned mesh name
  16762. * - newParent (optional Node) : the optional Node to parent the clone to.
  16763. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16764. *
  16765. * Returns the clone.
  16766. */
  16767. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16768. /**
  16769. * Disposes the InstancedMesh.
  16770. * Returns nothing.
  16771. */
  16772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16773. }
  16774. module "babylonjs/Meshes/mesh" {
  16775. interface Mesh {
  16776. /**
  16777. * Register a custom buffer that will be instanced
  16778. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16779. * @param kind defines the buffer kind
  16780. * @param stride defines the stride in floats
  16781. */
  16782. registerInstancedBuffer(kind: string, stride: number): void;
  16783. /**
  16784. * true to use the edge renderer for all instances of this mesh
  16785. */
  16786. edgesShareWithInstances: boolean;
  16787. /** @hidden */
  16788. _userInstancedBuffersStorage: {
  16789. data: {
  16790. [key: string]: Float32Array;
  16791. };
  16792. sizes: {
  16793. [key: string]: number;
  16794. };
  16795. vertexBuffers: {
  16796. [key: string]: Nullable<VertexBuffer>;
  16797. };
  16798. strides: {
  16799. [key: string]: number;
  16800. };
  16801. };
  16802. }
  16803. }
  16804. module "babylonjs/Meshes/abstractMesh" {
  16805. interface AbstractMesh {
  16806. /**
  16807. * Object used to store instanced buffers defined by user
  16808. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16809. */
  16810. instancedBuffers: {
  16811. [key: string]: any;
  16812. };
  16813. }
  16814. }
  16815. }
  16816. declare module "babylonjs/Materials/shaderMaterial" {
  16817. import { Nullable } from "babylonjs/types";
  16818. import { Scene } from "babylonjs/scene";
  16819. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16821. import { Mesh } from "babylonjs/Meshes/mesh";
  16822. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16824. import { Effect } from "babylonjs/Materials/effect";
  16825. import { Material } from "babylonjs/Materials/material";
  16826. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16827. /**
  16828. * Defines the options associated with the creation of a shader material.
  16829. */
  16830. export interface IShaderMaterialOptions {
  16831. /**
  16832. * Does the material work in alpha blend mode
  16833. */
  16834. needAlphaBlending: boolean;
  16835. /**
  16836. * Does the material work in alpha test mode
  16837. */
  16838. needAlphaTesting: boolean;
  16839. /**
  16840. * The list of attribute names used in the shader
  16841. */
  16842. attributes: string[];
  16843. /**
  16844. * The list of unifrom names used in the shader
  16845. */
  16846. uniforms: string[];
  16847. /**
  16848. * The list of UBO names used in the shader
  16849. */
  16850. uniformBuffers: string[];
  16851. /**
  16852. * The list of sampler names used in the shader
  16853. */
  16854. samplers: string[];
  16855. /**
  16856. * The list of defines used in the shader
  16857. */
  16858. defines: string[];
  16859. }
  16860. /**
  16861. * 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.
  16862. *
  16863. * This returned material effects how the mesh will look based on the code in the shaders.
  16864. *
  16865. * @see https://doc.babylonjs.com/how_to/shader_material
  16866. */
  16867. export class ShaderMaterial extends Material {
  16868. private _shaderPath;
  16869. private _options;
  16870. private _textures;
  16871. private _textureArrays;
  16872. private _floats;
  16873. private _ints;
  16874. private _floatsArrays;
  16875. private _colors3;
  16876. private _colors3Arrays;
  16877. private _colors4;
  16878. private _colors4Arrays;
  16879. private _vectors2;
  16880. private _vectors3;
  16881. private _vectors4;
  16882. private _matrices;
  16883. private _matrixArrays;
  16884. private _matrices3x3;
  16885. private _matrices2x2;
  16886. private _vectors2Arrays;
  16887. private _vectors3Arrays;
  16888. private _vectors4Arrays;
  16889. private _cachedWorldViewMatrix;
  16890. private _cachedWorldViewProjectionMatrix;
  16891. private _renderId;
  16892. private _multiview;
  16893. private _cachedDefines;
  16894. /** Define the Url to load snippets */
  16895. static SnippetUrl: string;
  16896. /** Snippet ID if the material was created from the snippet server */
  16897. snippetId: string;
  16898. /**
  16899. * Instantiate a new shader material.
  16900. * 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.
  16901. * This returned material effects how the mesh will look based on the code in the shaders.
  16902. * @see https://doc.babylonjs.com/how_to/shader_material
  16903. * @param name Define the name of the material in the scene
  16904. * @param scene Define the scene the material belongs to
  16905. * @param shaderPath Defines the route to the shader code in one of three ways:
  16906. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16907. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16908. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16909. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16910. * @param options Define the options used to create the shader
  16911. */
  16912. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16913. /**
  16914. * Gets the shader path used to define the shader code
  16915. * It can be modified to trigger a new compilation
  16916. */
  16917. get shaderPath(): any;
  16918. /**
  16919. * Sets the shader path used to define the shader code
  16920. * It can be modified to trigger a new compilation
  16921. */
  16922. set shaderPath(shaderPath: any);
  16923. /**
  16924. * Gets the options used to compile the shader.
  16925. * They can be modified to trigger a new compilation
  16926. */
  16927. get options(): IShaderMaterialOptions;
  16928. /**
  16929. * Gets the current class name of the material e.g. "ShaderMaterial"
  16930. * Mainly use in serialization.
  16931. * @returns the class name
  16932. */
  16933. getClassName(): string;
  16934. /**
  16935. * Specifies if the material will require alpha blending
  16936. * @returns a boolean specifying if alpha blending is needed
  16937. */
  16938. needAlphaBlending(): boolean;
  16939. /**
  16940. * Specifies if this material should be rendered in alpha test mode
  16941. * @returns a boolean specifying if an alpha test is needed.
  16942. */
  16943. needAlphaTesting(): boolean;
  16944. private _checkUniform;
  16945. /**
  16946. * Set a texture in the shader.
  16947. * @param name Define the name of the uniform samplers as defined in the shader
  16948. * @param texture Define the texture to bind to this sampler
  16949. * @return the material itself allowing "fluent" like uniform updates
  16950. */
  16951. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16952. /**
  16953. * Set a texture array in the shader.
  16954. * @param name Define the name of the uniform sampler array as defined in the shader
  16955. * @param textures Define the list of textures to bind to this sampler
  16956. * @return the material itself allowing "fluent" like uniform updates
  16957. */
  16958. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16959. /**
  16960. * Set a float in the shader.
  16961. * @param name Define the name of the uniform as defined in the shader
  16962. * @param value Define the value to give to the uniform
  16963. * @return the material itself allowing "fluent" like uniform updates
  16964. */
  16965. setFloat(name: string, value: number): ShaderMaterial;
  16966. /**
  16967. * Set a int in the shader.
  16968. * @param name Define the name of the uniform as defined in the shader
  16969. * @param value Define the value to give to the uniform
  16970. * @return the material itself allowing "fluent" like uniform updates
  16971. */
  16972. setInt(name: string, value: number): ShaderMaterial;
  16973. /**
  16974. * Set an array of floats in the shader.
  16975. * @param name Define the name of the uniform as defined in the shader
  16976. * @param value Define the value to give to the uniform
  16977. * @return the material itself allowing "fluent" like uniform updates
  16978. */
  16979. setFloats(name: string, value: number[]): ShaderMaterial;
  16980. /**
  16981. * Set a vec3 in the shader from a Color3.
  16982. * @param name Define the name of the uniform as defined in the shader
  16983. * @param value Define the value to give to the uniform
  16984. * @return the material itself allowing "fluent" like uniform updates
  16985. */
  16986. setColor3(name: string, value: Color3): ShaderMaterial;
  16987. /**
  16988. * Set a vec3 array in the shader from a Color3 array.
  16989. * @param name Define the name of the uniform as defined in the shader
  16990. * @param value Define the value to give to the uniform
  16991. * @return the material itself allowing "fluent" like uniform updates
  16992. */
  16993. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16994. /**
  16995. * Set a vec4 in the shader from a Color4.
  16996. * @param name Define the name of the uniform as defined in the shader
  16997. * @param value Define the value to give to the uniform
  16998. * @return the material itself allowing "fluent" like uniform updates
  16999. */
  17000. setColor4(name: string, value: Color4): ShaderMaterial;
  17001. /**
  17002. * Set a vec4 array in the shader from a Color4 array.
  17003. * @param name Define the name of the uniform as defined in the shader
  17004. * @param value Define the value to give to the uniform
  17005. * @return the material itself allowing "fluent" like uniform updates
  17006. */
  17007. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17008. /**
  17009. * Set a vec2 in the shader from a Vector2.
  17010. * @param name Define the name of the uniform as defined in the shader
  17011. * @param value Define the value to give to the uniform
  17012. * @return the material itself allowing "fluent" like uniform updates
  17013. */
  17014. setVector2(name: string, value: Vector2): ShaderMaterial;
  17015. /**
  17016. * Set a vec3 in the shader from a Vector3.
  17017. * @param name Define the name of the uniform as defined in the shader
  17018. * @param value Define the value to give to the uniform
  17019. * @return the material itself allowing "fluent" like uniform updates
  17020. */
  17021. setVector3(name: string, value: Vector3): ShaderMaterial;
  17022. /**
  17023. * Set a vec4 in the shader from a Vector4.
  17024. * @param name Define the name of the uniform as defined in the shader
  17025. * @param value Define the value to give to the uniform
  17026. * @return the material itself allowing "fluent" like uniform updates
  17027. */
  17028. setVector4(name: string, value: Vector4): ShaderMaterial;
  17029. /**
  17030. * Set a mat4 in the shader from a Matrix.
  17031. * @param name Define the name of the uniform as defined in the shader
  17032. * @param value Define the value to give to the uniform
  17033. * @return the material itself allowing "fluent" like uniform updates
  17034. */
  17035. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17036. /**
  17037. * Set a float32Array in the shader from a matrix array.
  17038. * @param name Define the name of the uniform as defined in the shader
  17039. * @param value Define the value to give to the uniform
  17040. * @return the material itself allowing "fluent" like uniform updates
  17041. */
  17042. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17043. /**
  17044. * Set a mat3 in the shader from a Float32Array.
  17045. * @param name Define the name of the uniform as defined in the shader
  17046. * @param value Define the value to give to the uniform
  17047. * @return the material itself allowing "fluent" like uniform updates
  17048. */
  17049. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17050. /**
  17051. * Set a mat2 in the shader from a Float32Array.
  17052. * @param name Define the name of the uniform as defined in the shader
  17053. * @param value Define the value to give to the uniform
  17054. * @return the material itself allowing "fluent" like uniform updates
  17055. */
  17056. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17057. /**
  17058. * Set a vec2 array in the shader from a number array.
  17059. * @param name Define the name of the uniform as defined in the shader
  17060. * @param value Define the value to give to the uniform
  17061. * @return the material itself allowing "fluent" like uniform updates
  17062. */
  17063. setArray2(name: string, value: number[]): ShaderMaterial;
  17064. /**
  17065. * Set a vec3 array in the shader from a number array.
  17066. * @param name Define the name of the uniform as defined in the shader
  17067. * @param value Define the value to give to the uniform
  17068. * @return the material itself allowing "fluent" like uniform updates
  17069. */
  17070. setArray3(name: string, value: number[]): ShaderMaterial;
  17071. /**
  17072. * Set a vec4 array in the shader from a number array.
  17073. * @param name Define the name of the uniform as defined in the shader
  17074. * @param value Define the value to give to the uniform
  17075. * @return the material itself allowing "fluent" like uniform updates
  17076. */
  17077. setArray4(name: string, value: number[]): ShaderMaterial;
  17078. private _checkCache;
  17079. /**
  17080. * Specifies that the submesh is ready to be used
  17081. * @param mesh defines the mesh to check
  17082. * @param subMesh defines which submesh to check
  17083. * @param useInstances specifies that instances should be used
  17084. * @returns a boolean indicating that the submesh is ready or not
  17085. */
  17086. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17087. /**
  17088. * Checks if the material is ready to render the requested mesh
  17089. * @param mesh Define the mesh to render
  17090. * @param useInstances Define whether or not the material is used with instances
  17091. * @returns true if ready, otherwise false
  17092. */
  17093. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17094. /**
  17095. * Binds the world matrix to the material
  17096. * @param world defines the world transformation matrix
  17097. * @param effectOverride - If provided, use this effect instead of internal effect
  17098. */
  17099. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17100. /**
  17101. * Binds the submesh to this material by preparing the effect and shader to draw
  17102. * @param world defines the world transformation matrix
  17103. * @param mesh defines the mesh containing the submesh
  17104. * @param subMesh defines the submesh to bind the material to
  17105. */
  17106. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17107. /**
  17108. * Binds the material to the mesh
  17109. * @param world defines the world transformation matrix
  17110. * @param mesh defines the mesh to bind the material to
  17111. * @param effectOverride - If provided, use this effect instead of internal effect
  17112. */
  17113. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17114. protected _afterBind(mesh?: Mesh): void;
  17115. /**
  17116. * Gets the active textures from the material
  17117. * @returns an array of textures
  17118. */
  17119. getActiveTextures(): BaseTexture[];
  17120. /**
  17121. * Specifies if the material uses a texture
  17122. * @param texture defines the texture to check against the material
  17123. * @returns a boolean specifying if the material uses the texture
  17124. */
  17125. hasTexture(texture: BaseTexture): boolean;
  17126. /**
  17127. * Makes a duplicate of the material, and gives it a new name
  17128. * @param name defines the new name for the duplicated material
  17129. * @returns the cloned material
  17130. */
  17131. clone(name: string): ShaderMaterial;
  17132. /**
  17133. * Disposes the material
  17134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17137. */
  17138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17139. /**
  17140. * Serializes this material in a JSON representation
  17141. * @returns the serialized material object
  17142. */
  17143. serialize(): any;
  17144. /**
  17145. * Creates a shader material from parsed shader material data
  17146. * @param source defines the JSON represnetation of the material
  17147. * @param scene defines the hosting scene
  17148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17149. * @returns a new material
  17150. */
  17151. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17152. /**
  17153. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17154. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17155. * @param url defines the url to load from
  17156. * @param scene defines the hosting scene
  17157. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17158. * @returns a promise that will resolve to the new ShaderMaterial
  17159. */
  17160. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17161. /**
  17162. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17163. * @param snippetId defines the snippet to load
  17164. * @param scene defines the hosting scene
  17165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17166. * @returns a promise that will resolve to the new ShaderMaterial
  17167. */
  17168. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17169. }
  17170. }
  17171. declare module "babylonjs/Shaders/color.fragment" {
  17172. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17173. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17174. /** @hidden */
  17175. export var colorPixelShader: {
  17176. name: string;
  17177. shader: string;
  17178. };
  17179. }
  17180. declare module "babylonjs/Shaders/color.vertex" {
  17181. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17182. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17183. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17184. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17185. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17186. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17187. /** @hidden */
  17188. export var colorVertexShader: {
  17189. name: string;
  17190. shader: string;
  17191. };
  17192. }
  17193. declare module "babylonjs/Meshes/linesMesh" {
  17194. import { Nullable } from "babylonjs/types";
  17195. import { Scene } from "babylonjs/scene";
  17196. import { Color3 } from "babylonjs/Maths/math.color";
  17197. import { Node } from "babylonjs/node";
  17198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17199. import { Mesh } from "babylonjs/Meshes/mesh";
  17200. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17201. import { Effect } from "babylonjs/Materials/effect";
  17202. import { Material } from "babylonjs/Materials/material";
  17203. import "babylonjs/Shaders/color.fragment";
  17204. import "babylonjs/Shaders/color.vertex";
  17205. /**
  17206. * Line mesh
  17207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17208. */
  17209. export class LinesMesh extends Mesh {
  17210. /**
  17211. * If vertex color should be applied to the mesh
  17212. */
  17213. readonly useVertexColor?: boolean | undefined;
  17214. /**
  17215. * If vertex alpha should be applied to the mesh
  17216. */
  17217. readonly useVertexAlpha?: boolean | undefined;
  17218. /**
  17219. * Color of the line (Default: White)
  17220. */
  17221. color: Color3;
  17222. /**
  17223. * Alpha of the line (Default: 1)
  17224. */
  17225. alpha: number;
  17226. /**
  17227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17228. * This margin is expressed in world space coordinates, so its value may vary.
  17229. * Default value is 0.1
  17230. */
  17231. intersectionThreshold: number;
  17232. private _colorShader;
  17233. private color4;
  17234. /**
  17235. * Creates a new LinesMesh
  17236. * @param name defines the name
  17237. * @param scene defines the hosting scene
  17238. * @param parent defines the parent mesh if any
  17239. * @param source defines the optional source LinesMesh used to clone data from
  17240. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17241. * When false, achieved by calling a clone(), also passing False.
  17242. * This will make creation of children, recursive.
  17243. * @param useVertexColor defines if this LinesMesh supports vertex color
  17244. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17245. */
  17246. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17247. /**
  17248. * If vertex color should be applied to the mesh
  17249. */
  17250. useVertexColor?: boolean | undefined,
  17251. /**
  17252. * If vertex alpha should be applied to the mesh
  17253. */
  17254. useVertexAlpha?: boolean | undefined);
  17255. private _addClipPlaneDefine;
  17256. private _removeClipPlaneDefine;
  17257. isReady(): boolean;
  17258. /**
  17259. * Returns the string "LineMesh"
  17260. */
  17261. getClassName(): string;
  17262. /**
  17263. * @hidden
  17264. */
  17265. get material(): Material;
  17266. /**
  17267. * @hidden
  17268. */
  17269. set material(value: Material);
  17270. /**
  17271. * @hidden
  17272. */
  17273. get checkCollisions(): boolean;
  17274. /** @hidden */
  17275. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17276. /** @hidden */
  17277. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17278. /**
  17279. * Disposes of the line mesh
  17280. * @param doNotRecurse If children should be disposed
  17281. */
  17282. dispose(doNotRecurse?: boolean): void;
  17283. /**
  17284. * Returns a new LineMesh object cloned from the current one.
  17285. */
  17286. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17287. /**
  17288. * Creates a new InstancedLinesMesh object from the mesh model.
  17289. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17290. * @param name defines the name of the new instance
  17291. * @returns a new InstancedLinesMesh
  17292. */
  17293. createInstance(name: string): InstancedLinesMesh;
  17294. }
  17295. /**
  17296. * Creates an instance based on a source LinesMesh
  17297. */
  17298. export class InstancedLinesMesh extends InstancedMesh {
  17299. /**
  17300. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17301. * This margin is expressed in world space coordinates, so its value may vary.
  17302. * Initilized with the intersectionThreshold value of the source LinesMesh
  17303. */
  17304. intersectionThreshold: number;
  17305. constructor(name: string, source: LinesMesh);
  17306. /**
  17307. * Returns the string "InstancedLinesMesh".
  17308. */
  17309. getClassName(): string;
  17310. }
  17311. }
  17312. declare module "babylonjs/Shaders/line.fragment" {
  17313. /** @hidden */
  17314. export var linePixelShader: {
  17315. name: string;
  17316. shader: string;
  17317. };
  17318. }
  17319. declare module "babylonjs/Shaders/line.vertex" {
  17320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17322. /** @hidden */
  17323. export var lineVertexShader: {
  17324. name: string;
  17325. shader: string;
  17326. };
  17327. }
  17328. declare module "babylonjs/Rendering/edgesRenderer" {
  17329. import { Nullable } from "babylonjs/types";
  17330. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17332. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17333. import { IDisposable } from "babylonjs/scene";
  17334. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17335. import "babylonjs/Shaders/line.fragment";
  17336. import "babylonjs/Shaders/line.vertex";
  17337. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17338. import { SmartArray } from "babylonjs/Misc/smartArray";
  17339. module "babylonjs/scene" {
  17340. interface Scene {
  17341. /** @hidden */
  17342. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17343. }
  17344. }
  17345. module "babylonjs/Meshes/abstractMesh" {
  17346. interface AbstractMesh {
  17347. /**
  17348. * Gets the edgesRenderer associated with the mesh
  17349. */
  17350. edgesRenderer: Nullable<EdgesRenderer>;
  17351. }
  17352. }
  17353. module "babylonjs/Meshes/linesMesh" {
  17354. interface LinesMesh {
  17355. /**
  17356. * Enables the edge rendering mode on the mesh.
  17357. * This mode makes the mesh edges visible
  17358. * @param epsilon defines the maximal distance between two angles to detect a face
  17359. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17360. * @returns the currentAbstractMesh
  17361. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17362. */
  17363. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17364. }
  17365. }
  17366. module "babylonjs/Meshes/linesMesh" {
  17367. interface InstancedLinesMesh {
  17368. /**
  17369. * Enables the edge rendering mode on the mesh.
  17370. * This mode makes the mesh edges visible
  17371. * @param epsilon defines the maximal distance between two angles to detect a face
  17372. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17373. * @returns the current InstancedLinesMesh
  17374. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17375. */
  17376. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17377. }
  17378. }
  17379. /**
  17380. * Defines the minimum contract an Edges renderer should follow.
  17381. */
  17382. export interface IEdgesRenderer extends IDisposable {
  17383. /**
  17384. * Gets or sets a boolean indicating if the edgesRenderer is active
  17385. */
  17386. isEnabled: boolean;
  17387. /**
  17388. * Renders the edges of the attached mesh,
  17389. */
  17390. render(): void;
  17391. /**
  17392. * Checks wether or not the edges renderer is ready to render.
  17393. * @return true if ready, otherwise false.
  17394. */
  17395. isReady(): boolean;
  17396. /**
  17397. * List of instances to render in case the source mesh has instances
  17398. */
  17399. customInstances: SmartArray<Matrix>;
  17400. }
  17401. /**
  17402. * Defines the additional options of the edges renderer
  17403. */
  17404. export interface IEdgesRendererOptions {
  17405. /**
  17406. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17407. * If not defined, the default value is true
  17408. */
  17409. useAlternateEdgeFinder?: boolean;
  17410. /**
  17411. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17412. * If not defined, the default value is true.
  17413. * 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)
  17414. * This option is used only if useAlternateEdgeFinder = true
  17415. */
  17416. useFastVertexMerger?: boolean;
  17417. /**
  17418. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17419. * The default value is 1e-6
  17420. * This option is used only if useAlternateEdgeFinder = true
  17421. */
  17422. epsilonVertexMerge?: number;
  17423. /**
  17424. * 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
  17425. * 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.
  17426. * This option is used only if useAlternateEdgeFinder = true
  17427. */
  17428. applyTessellation?: boolean;
  17429. /**
  17430. * 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
  17431. * The default value is 1e-6
  17432. * This option is used only if useAlternateEdgeFinder = true
  17433. */
  17434. epsilonVertexAligned?: number;
  17435. }
  17436. /**
  17437. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17438. */
  17439. export class EdgesRenderer implements IEdgesRenderer {
  17440. /**
  17441. * Define the size of the edges with an orthographic camera
  17442. */
  17443. edgesWidthScalerForOrthographic: number;
  17444. /**
  17445. * Define the size of the edges with a perspective camera
  17446. */
  17447. edgesWidthScalerForPerspective: number;
  17448. protected _source: AbstractMesh;
  17449. protected _linesPositions: number[];
  17450. protected _linesNormals: number[];
  17451. protected _linesIndices: number[];
  17452. protected _epsilon: number;
  17453. protected _indicesCount: number;
  17454. protected _lineShader: ShaderMaterial;
  17455. protected _ib: DataBuffer;
  17456. protected _buffers: {
  17457. [key: string]: Nullable<VertexBuffer>;
  17458. };
  17459. protected _buffersForInstances: {
  17460. [key: string]: Nullable<VertexBuffer>;
  17461. };
  17462. protected _checkVerticesInsteadOfIndices: boolean;
  17463. protected _options: Nullable<IEdgesRendererOptions>;
  17464. private _meshRebuildObserver;
  17465. private _meshDisposeObserver;
  17466. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17467. isEnabled: boolean;
  17468. /**
  17469. * List of instances to render in case the source mesh has instances
  17470. */
  17471. customInstances: SmartArray<Matrix>;
  17472. private static GetShader;
  17473. /**
  17474. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17475. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17476. * @param source Mesh used to create edges
  17477. * @param epsilon sum of angles in adjacency to check for edge
  17478. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17479. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17480. * @param options The options to apply when generating the edges
  17481. */
  17482. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17483. protected _prepareRessources(): void;
  17484. /** @hidden */
  17485. _rebuild(): void;
  17486. /**
  17487. * Releases the required resources for the edges renderer
  17488. */
  17489. dispose(): void;
  17490. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17491. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17492. /**
  17493. * Checks if the pair of p0 and p1 is en edge
  17494. * @param faceIndex
  17495. * @param edge
  17496. * @param faceNormals
  17497. * @param p0
  17498. * @param p1
  17499. * @private
  17500. */
  17501. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17502. /**
  17503. * push line into the position, normal and index buffer
  17504. * @protected
  17505. */
  17506. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17507. /**
  17508. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17509. */
  17510. private _tessellateTriangle;
  17511. private _generateEdgesLinesAlternate;
  17512. /**
  17513. * Generates lines edges from adjacencjes
  17514. * @private
  17515. */
  17516. _generateEdgesLines(): void;
  17517. /**
  17518. * Checks wether or not the edges renderer is ready to render.
  17519. * @return true if ready, otherwise false.
  17520. */
  17521. isReady(): boolean;
  17522. /**
  17523. * Renders the edges of the attached mesh,
  17524. */
  17525. render(): void;
  17526. }
  17527. /**
  17528. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17529. */
  17530. export class LineEdgesRenderer extends EdgesRenderer {
  17531. /**
  17532. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17533. * @param source LineMesh used to generate edges
  17534. * @param epsilon not important (specified angle for edge detection)
  17535. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17536. */
  17537. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17538. /**
  17539. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17540. */
  17541. _generateEdgesLines(): void;
  17542. }
  17543. }
  17544. declare module "babylonjs/Rendering/renderingGroup" {
  17545. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17548. import { Nullable } from "babylonjs/types";
  17549. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17550. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17551. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17552. import { Material } from "babylonjs/Materials/material";
  17553. import { Scene } from "babylonjs/scene";
  17554. /**
  17555. * This represents the object necessary to create a rendering group.
  17556. * This is exclusively used and created by the rendering manager.
  17557. * To modify the behavior, you use the available helpers in your scene or meshes.
  17558. * @hidden
  17559. */
  17560. export class RenderingGroup {
  17561. index: number;
  17562. private static _zeroVector;
  17563. private _scene;
  17564. private _opaqueSubMeshes;
  17565. private _transparentSubMeshes;
  17566. private _alphaTestSubMeshes;
  17567. private _depthOnlySubMeshes;
  17568. private _particleSystems;
  17569. private _spriteManagers;
  17570. private _opaqueSortCompareFn;
  17571. private _alphaTestSortCompareFn;
  17572. private _transparentSortCompareFn;
  17573. private _renderOpaque;
  17574. private _renderAlphaTest;
  17575. private _renderTransparent;
  17576. /** @hidden */
  17577. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17578. onBeforeTransparentRendering: () => void;
  17579. /**
  17580. * Set the opaque sort comparison function.
  17581. * If null the sub meshes will be render in the order they were created
  17582. */
  17583. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17584. /**
  17585. * Set the alpha test sort comparison function.
  17586. * If null the sub meshes will be render in the order they were created
  17587. */
  17588. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17589. /**
  17590. * Set the transparent sort comparison function.
  17591. * If null the sub meshes will be render in the order they were created
  17592. */
  17593. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17594. /**
  17595. * Creates a new rendering group.
  17596. * @param index The rendering group index
  17597. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17598. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17599. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17600. */
  17601. 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>);
  17602. /**
  17603. * Render all the sub meshes contained in the group.
  17604. * @param customRenderFunction Used to override the default render behaviour of the group.
  17605. * @returns true if rendered some submeshes.
  17606. */
  17607. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17608. /**
  17609. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17610. * @param subMeshes The submeshes to render
  17611. */
  17612. private renderOpaqueSorted;
  17613. /**
  17614. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17615. * @param subMeshes The submeshes to render
  17616. */
  17617. private renderAlphaTestSorted;
  17618. /**
  17619. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17620. * @param subMeshes The submeshes to render
  17621. */
  17622. private renderTransparentSorted;
  17623. /**
  17624. * Renders the submeshes in a specified order.
  17625. * @param subMeshes The submeshes to sort before render
  17626. * @param sortCompareFn The comparison function use to sort
  17627. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17628. * @param transparent Specifies to activate blending if true
  17629. */
  17630. private static renderSorted;
  17631. /**
  17632. * Renders the submeshes in the order they were dispatched (no sort applied).
  17633. * @param subMeshes The submeshes to render
  17634. */
  17635. private static renderUnsorted;
  17636. /**
  17637. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17638. * are rendered back to front if in the same alpha index.
  17639. *
  17640. * @param a The first submesh
  17641. * @param b The second submesh
  17642. * @returns The result of the comparison
  17643. */
  17644. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17645. /**
  17646. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17647. * are rendered back to front.
  17648. *
  17649. * @param a The first submesh
  17650. * @param b The second submesh
  17651. * @returns The result of the comparison
  17652. */
  17653. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17654. /**
  17655. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17656. * are rendered front to back (prevent overdraw).
  17657. *
  17658. * @param a The first submesh
  17659. * @param b The second submesh
  17660. * @returns The result of the comparison
  17661. */
  17662. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17663. /**
  17664. * Resets the different lists of submeshes to prepare a new frame.
  17665. */
  17666. prepare(): void;
  17667. dispose(): void;
  17668. /**
  17669. * Inserts the submesh in its correct queue depending on its material.
  17670. * @param subMesh The submesh to dispatch
  17671. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17672. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17673. */
  17674. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17675. dispatchSprites(spriteManager: ISpriteManager): void;
  17676. dispatchParticles(particleSystem: IParticleSystem): void;
  17677. private _renderParticles;
  17678. private _renderSprites;
  17679. }
  17680. }
  17681. declare module "babylonjs/Rendering/renderingManager" {
  17682. import { Nullable } from "babylonjs/types";
  17683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17685. import { SmartArray } from "babylonjs/Misc/smartArray";
  17686. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17687. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17688. import { Material } from "babylonjs/Materials/material";
  17689. import { Scene } from "babylonjs/scene";
  17690. import { Camera } from "babylonjs/Cameras/camera";
  17691. /**
  17692. * Interface describing the different options available in the rendering manager
  17693. * regarding Auto Clear between groups.
  17694. */
  17695. export interface IRenderingManagerAutoClearSetup {
  17696. /**
  17697. * Defines whether or not autoclear is enable.
  17698. */
  17699. autoClear: boolean;
  17700. /**
  17701. * Defines whether or not to autoclear the depth buffer.
  17702. */
  17703. depth: boolean;
  17704. /**
  17705. * Defines whether or not to autoclear the stencil buffer.
  17706. */
  17707. stencil: boolean;
  17708. }
  17709. /**
  17710. * This class is used by the onRenderingGroupObservable
  17711. */
  17712. export class RenderingGroupInfo {
  17713. /**
  17714. * The Scene that being rendered
  17715. */
  17716. scene: Scene;
  17717. /**
  17718. * The camera currently used for the rendering pass
  17719. */
  17720. camera: Nullable<Camera>;
  17721. /**
  17722. * The ID of the renderingGroup being processed
  17723. */
  17724. renderingGroupId: number;
  17725. }
  17726. /**
  17727. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17728. * It is enable to manage the different groups as well as the different necessary sort functions.
  17729. * This should not be used directly aside of the few static configurations
  17730. */
  17731. export class RenderingManager {
  17732. /**
  17733. * The max id used for rendering groups (not included)
  17734. */
  17735. static MAX_RENDERINGGROUPS: number;
  17736. /**
  17737. * The min id used for rendering groups (included)
  17738. */
  17739. static MIN_RENDERINGGROUPS: number;
  17740. /**
  17741. * Used to globally prevent autoclearing scenes.
  17742. */
  17743. static AUTOCLEAR: boolean;
  17744. /**
  17745. * @hidden
  17746. */
  17747. _useSceneAutoClearSetup: boolean;
  17748. private _scene;
  17749. private _renderingGroups;
  17750. private _depthStencilBufferAlreadyCleaned;
  17751. private _autoClearDepthStencil;
  17752. private _customOpaqueSortCompareFn;
  17753. private _customAlphaTestSortCompareFn;
  17754. private _customTransparentSortCompareFn;
  17755. private _renderingGroupInfo;
  17756. /**
  17757. * Instantiates a new rendering group for a particular scene
  17758. * @param scene Defines the scene the groups belongs to
  17759. */
  17760. constructor(scene: Scene);
  17761. private _clearDepthStencilBuffer;
  17762. /**
  17763. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17764. * @hidden
  17765. */
  17766. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17767. /**
  17768. * Resets the different information of the group to prepare a new frame
  17769. * @hidden
  17770. */
  17771. reset(): void;
  17772. /**
  17773. * Dispose and release the group and its associated resources.
  17774. * @hidden
  17775. */
  17776. dispose(): void;
  17777. /**
  17778. * Clear the info related to rendering groups preventing retention points during dispose.
  17779. */
  17780. freeRenderingGroups(): void;
  17781. private _prepareRenderingGroup;
  17782. /**
  17783. * Add a sprite manager to the rendering manager in order to render it this frame.
  17784. * @param spriteManager Define the sprite manager to render
  17785. */
  17786. dispatchSprites(spriteManager: ISpriteManager): void;
  17787. /**
  17788. * Add a particle system to the rendering manager in order to render it this frame.
  17789. * @param particleSystem Define the particle system to render
  17790. */
  17791. dispatchParticles(particleSystem: IParticleSystem): void;
  17792. /**
  17793. * Add a submesh to the manager in order to render it this frame
  17794. * @param subMesh The submesh to dispatch
  17795. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17796. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17797. */
  17798. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17799. /**
  17800. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17801. * This allowed control for front to back rendering or reversly depending of the special needs.
  17802. *
  17803. * @param renderingGroupId The rendering group id corresponding to its index
  17804. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17805. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17806. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17807. */
  17808. 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;
  17809. /**
  17810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17811. *
  17812. * @param renderingGroupId The rendering group id corresponding to its index
  17813. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17814. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17815. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17816. */
  17817. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17818. /**
  17819. * Gets the current auto clear configuration for one rendering group of the rendering
  17820. * manager.
  17821. * @param index the rendering group index to get the information for
  17822. * @returns The auto clear setup for the requested rendering group
  17823. */
  17824. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17825. }
  17826. }
  17827. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17828. import { SmartArray } from "babylonjs/Misc/smartArray";
  17829. import { Nullable } from "babylonjs/types";
  17830. import { Scene } from "babylonjs/scene";
  17831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17834. import { Mesh } from "babylonjs/Meshes/mesh";
  17835. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17836. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17837. import { Effect } from "babylonjs/Materials/effect";
  17838. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17840. import "babylonjs/Shaders/shadowMap.fragment";
  17841. import "babylonjs/Shaders/shadowMap.vertex";
  17842. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17843. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17844. import { Observable } from "babylonjs/Misc/observable";
  17845. /**
  17846. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17847. */
  17848. export interface ICustomShaderOptions {
  17849. /**
  17850. * Gets or sets the custom shader name to use
  17851. */
  17852. shaderName: string;
  17853. /**
  17854. * The list of attribute names used in the shader
  17855. */
  17856. attributes?: string[];
  17857. /**
  17858. * The list of unifrom names used in the shader
  17859. */
  17860. uniforms?: string[];
  17861. /**
  17862. * The list of sampler names used in the shader
  17863. */
  17864. samplers?: string[];
  17865. /**
  17866. * The list of defines used in the shader
  17867. */
  17868. defines?: string[];
  17869. }
  17870. /**
  17871. * Interface to implement to create a shadow generator compatible with BJS.
  17872. */
  17873. export interface IShadowGenerator {
  17874. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17875. id: string;
  17876. /**
  17877. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17878. * @returns The render target texture if present otherwise, null
  17879. */
  17880. getShadowMap(): Nullable<RenderTargetTexture>;
  17881. /**
  17882. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17883. * @param subMesh The submesh we want to render in the shadow map
  17884. * @param useInstances Defines wether will draw in the map using instances
  17885. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17886. * @returns true if ready otherwise, false
  17887. */
  17888. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17889. /**
  17890. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17891. * @param defines Defines of the material we want to update
  17892. * @param lightIndex Index of the light in the enabled light list of the material
  17893. */
  17894. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17895. /**
  17896. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17897. * defined in the generator but impacting the effect).
  17898. * It implies the unifroms available on the materials are the standard BJS ones.
  17899. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17900. * @param effect The effect we are binfing the information for
  17901. */
  17902. bindShadowLight(lightIndex: string, effect: Effect): void;
  17903. /**
  17904. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17905. * (eq to shadow prjection matrix * light transform matrix)
  17906. * @returns The transform matrix used to create the shadow map
  17907. */
  17908. getTransformMatrix(): Matrix;
  17909. /**
  17910. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17911. * Cube and 2D textures for instance.
  17912. */
  17913. recreateShadowMap(): void;
  17914. /**
  17915. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17916. * @param onCompiled Callback triggered at the and of the effects compilation
  17917. * @param options Sets of optional options forcing the compilation with different modes
  17918. */
  17919. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17920. useInstances: boolean;
  17921. }>): void;
  17922. /**
  17923. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17924. * @param options Sets of optional options forcing the compilation with different modes
  17925. * @returns A promise that resolves when the compilation completes
  17926. */
  17927. forceCompilationAsync(options?: Partial<{
  17928. useInstances: boolean;
  17929. }>): Promise<void>;
  17930. /**
  17931. * Serializes the shadow generator setup to a json object.
  17932. * @returns The serialized JSON object
  17933. */
  17934. serialize(): any;
  17935. /**
  17936. * Disposes the Shadow map and related Textures and effects.
  17937. */
  17938. dispose(): void;
  17939. }
  17940. /**
  17941. * Default implementation IShadowGenerator.
  17942. * This is the main object responsible of generating shadows in the framework.
  17943. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17944. */
  17945. export class ShadowGenerator implements IShadowGenerator {
  17946. /**
  17947. * Name of the shadow generator class
  17948. */
  17949. static CLASSNAME: string;
  17950. /**
  17951. * Shadow generator mode None: no filtering applied.
  17952. */
  17953. static readonly FILTER_NONE: number;
  17954. /**
  17955. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17956. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17957. */
  17958. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17959. /**
  17960. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17961. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17962. */
  17963. static readonly FILTER_POISSONSAMPLING: number;
  17964. /**
  17965. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17966. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17967. */
  17968. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17969. /**
  17970. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17971. * edge artifacts on steep falloff.
  17972. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17973. */
  17974. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17975. /**
  17976. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17977. * edge artifacts on steep falloff.
  17978. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17979. */
  17980. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17981. /**
  17982. * Shadow generator mode PCF: Percentage Closer Filtering
  17983. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17984. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17985. */
  17986. static readonly FILTER_PCF: number;
  17987. /**
  17988. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17989. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17990. * Contact Hardening
  17991. */
  17992. static readonly FILTER_PCSS: number;
  17993. /**
  17994. * Reserved for PCF and PCSS
  17995. * Highest Quality.
  17996. *
  17997. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17998. *
  17999. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18000. */
  18001. static readonly QUALITY_HIGH: number;
  18002. /**
  18003. * Reserved for PCF and PCSS
  18004. * Good tradeoff for quality/perf cross devices
  18005. *
  18006. * Execute PCF on a 3*3 kernel.
  18007. *
  18008. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18009. */
  18010. static readonly QUALITY_MEDIUM: number;
  18011. /**
  18012. * Reserved for PCF and PCSS
  18013. * The lowest quality but the fastest.
  18014. *
  18015. * Execute PCF on a 1*1 kernel.
  18016. *
  18017. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18018. */
  18019. static readonly QUALITY_LOW: number;
  18020. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18021. id: string;
  18022. /** Gets or sets the custom shader name to use */
  18023. customShaderOptions: ICustomShaderOptions;
  18024. /**
  18025. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18026. */
  18027. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18028. /**
  18029. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18030. */
  18031. onAfterShadowMapRenderObservable: Observable<Effect>;
  18032. /**
  18033. * Observable triggered before a mesh is rendered in the shadow map.
  18034. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18035. */
  18036. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18037. /**
  18038. * Observable triggered after a mesh is rendered in the shadow map.
  18039. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18040. */
  18041. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18042. protected _bias: number;
  18043. /**
  18044. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18045. */
  18046. get bias(): number;
  18047. /**
  18048. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18049. */
  18050. set bias(bias: number);
  18051. protected _normalBias: number;
  18052. /**
  18053. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18054. */
  18055. get normalBias(): number;
  18056. /**
  18057. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18058. */
  18059. set normalBias(normalBias: number);
  18060. protected _blurBoxOffset: number;
  18061. /**
  18062. * Gets the blur box offset: offset applied during the blur pass.
  18063. * Only useful if useKernelBlur = false
  18064. */
  18065. get blurBoxOffset(): number;
  18066. /**
  18067. * Sets the blur box offset: offset applied during the blur pass.
  18068. * Only useful if useKernelBlur = false
  18069. */
  18070. set blurBoxOffset(value: number);
  18071. protected _blurScale: number;
  18072. /**
  18073. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18074. * 2 means half of the size.
  18075. */
  18076. get blurScale(): number;
  18077. /**
  18078. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18079. * 2 means half of the size.
  18080. */
  18081. set blurScale(value: number);
  18082. protected _blurKernel: number;
  18083. /**
  18084. * Gets the blur kernel: kernel size of the blur pass.
  18085. * Only useful if useKernelBlur = true
  18086. */
  18087. get blurKernel(): number;
  18088. /**
  18089. * Sets the blur kernel: kernel size of the blur pass.
  18090. * Only useful if useKernelBlur = true
  18091. */
  18092. set blurKernel(value: number);
  18093. protected _useKernelBlur: boolean;
  18094. /**
  18095. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18096. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18097. */
  18098. get useKernelBlur(): boolean;
  18099. /**
  18100. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18101. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18102. */
  18103. set useKernelBlur(value: boolean);
  18104. protected _depthScale: number;
  18105. /**
  18106. * Gets the depth scale used in ESM mode.
  18107. */
  18108. get depthScale(): number;
  18109. /**
  18110. * Sets the depth scale used in ESM mode.
  18111. * This can override the scale stored on the light.
  18112. */
  18113. set depthScale(value: number);
  18114. protected _validateFilter(filter: number): number;
  18115. protected _filter: number;
  18116. /**
  18117. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18118. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18119. */
  18120. get filter(): number;
  18121. /**
  18122. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18123. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18124. */
  18125. set filter(value: number);
  18126. /**
  18127. * Gets if the current filter is set to Poisson Sampling.
  18128. */
  18129. get usePoissonSampling(): boolean;
  18130. /**
  18131. * Sets the current filter to Poisson Sampling.
  18132. */
  18133. set usePoissonSampling(value: boolean);
  18134. /**
  18135. * Gets if the current filter is set to ESM.
  18136. */
  18137. get useExponentialShadowMap(): boolean;
  18138. /**
  18139. * Sets the current filter is to ESM.
  18140. */
  18141. set useExponentialShadowMap(value: boolean);
  18142. /**
  18143. * Gets if the current filter is set to filtered ESM.
  18144. */
  18145. get useBlurExponentialShadowMap(): boolean;
  18146. /**
  18147. * Gets if the current filter is set to filtered ESM.
  18148. */
  18149. set useBlurExponentialShadowMap(value: boolean);
  18150. /**
  18151. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18152. * exponential to prevent steep falloff artifacts).
  18153. */
  18154. get useCloseExponentialShadowMap(): boolean;
  18155. /**
  18156. * Sets the current filter to "close ESM" (using the inverse of the
  18157. * exponential to prevent steep falloff artifacts).
  18158. */
  18159. set useCloseExponentialShadowMap(value: boolean);
  18160. /**
  18161. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18162. * exponential to prevent steep falloff artifacts).
  18163. */
  18164. get useBlurCloseExponentialShadowMap(): boolean;
  18165. /**
  18166. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18167. * exponential to prevent steep falloff artifacts).
  18168. */
  18169. set useBlurCloseExponentialShadowMap(value: boolean);
  18170. /**
  18171. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18172. */
  18173. get usePercentageCloserFiltering(): boolean;
  18174. /**
  18175. * Sets the current filter to "PCF" (percentage closer filtering).
  18176. */
  18177. set usePercentageCloserFiltering(value: boolean);
  18178. protected _filteringQuality: number;
  18179. /**
  18180. * Gets the PCF or PCSS Quality.
  18181. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18182. */
  18183. get filteringQuality(): number;
  18184. /**
  18185. * Sets the PCF or PCSS Quality.
  18186. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18187. */
  18188. set filteringQuality(filteringQuality: number);
  18189. /**
  18190. * Gets if the current filter is set to "PCSS" (contact hardening).
  18191. */
  18192. get useContactHardeningShadow(): boolean;
  18193. /**
  18194. * Sets the current filter to "PCSS" (contact hardening).
  18195. */
  18196. set useContactHardeningShadow(value: boolean);
  18197. protected _contactHardeningLightSizeUVRatio: number;
  18198. /**
  18199. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18200. * Using a ratio helps keeping shape stability independently of the map size.
  18201. *
  18202. * It does not account for the light projection as it was having too much
  18203. * instability during the light setup or during light position changes.
  18204. *
  18205. * Only valid if useContactHardeningShadow is true.
  18206. */
  18207. get contactHardeningLightSizeUVRatio(): number;
  18208. /**
  18209. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18210. * Using a ratio helps keeping shape stability independently of the map size.
  18211. *
  18212. * It does not account for the light projection as it was having too much
  18213. * instability during the light setup or during light position changes.
  18214. *
  18215. * Only valid if useContactHardeningShadow is true.
  18216. */
  18217. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18218. protected _darkness: number;
  18219. /** Gets or sets the actual darkness of a shadow */
  18220. get darkness(): number;
  18221. set darkness(value: number);
  18222. /**
  18223. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18224. * 0 means strongest and 1 would means no shadow.
  18225. * @returns the darkness.
  18226. */
  18227. getDarkness(): number;
  18228. /**
  18229. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18230. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18231. * @returns the shadow generator allowing fluent coding.
  18232. */
  18233. setDarkness(darkness: number): ShadowGenerator;
  18234. protected _transparencyShadow: boolean;
  18235. /** Gets or sets the ability to have transparent shadow */
  18236. get transparencyShadow(): boolean;
  18237. set transparencyShadow(value: boolean);
  18238. /**
  18239. * Sets the ability to have transparent shadow (boolean).
  18240. * @param transparent True if transparent else False
  18241. * @returns the shadow generator allowing fluent coding
  18242. */
  18243. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18244. /**
  18245. * Enables or disables shadows with varying strength based on the transparency
  18246. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18247. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18248. * mesh.visibility * alphaTexture.a
  18249. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18250. */
  18251. enableSoftTransparentShadow: boolean;
  18252. protected _shadowMap: Nullable<RenderTargetTexture>;
  18253. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18254. /**
  18255. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18256. * @returns The render target texture if present otherwise, null
  18257. */
  18258. getShadowMap(): Nullable<RenderTargetTexture>;
  18259. /**
  18260. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18261. * @returns The render target texture if the shadow map is present otherwise, null
  18262. */
  18263. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18264. /**
  18265. * Gets the class name of that object
  18266. * @returns "ShadowGenerator"
  18267. */
  18268. getClassName(): string;
  18269. /**
  18270. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18271. * @param mesh Mesh to add
  18272. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18273. * @returns the Shadow Generator itself
  18274. */
  18275. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18276. /**
  18277. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18278. * @param mesh Mesh to remove
  18279. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18280. * @returns the Shadow Generator itself
  18281. */
  18282. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18283. /**
  18284. * Controls the extent to which the shadows fade out at the edge of the frustum
  18285. */
  18286. frustumEdgeFalloff: number;
  18287. protected _light: IShadowLight;
  18288. /**
  18289. * Returns the associated light object.
  18290. * @returns the light generating the shadow
  18291. */
  18292. getLight(): IShadowLight;
  18293. /**
  18294. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18295. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18296. * It might on the other hand introduce peter panning.
  18297. */
  18298. forceBackFacesOnly: boolean;
  18299. protected _scene: Scene;
  18300. protected _lightDirection: Vector3;
  18301. protected _effect: Effect;
  18302. protected _viewMatrix: Matrix;
  18303. protected _projectionMatrix: Matrix;
  18304. protected _transformMatrix: Matrix;
  18305. protected _cachedPosition: Vector3;
  18306. protected _cachedDirection: Vector3;
  18307. protected _cachedDefines: string;
  18308. protected _currentRenderID: number;
  18309. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18310. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18311. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18312. protected _blurPostProcesses: PostProcess[];
  18313. protected _mapSize: number;
  18314. protected _currentFaceIndex: number;
  18315. protected _currentFaceIndexCache: number;
  18316. protected _textureType: number;
  18317. protected _defaultTextureMatrix: Matrix;
  18318. protected _storedUniqueId: Nullable<number>;
  18319. /** @hidden */
  18320. static _SceneComponentInitialization: (scene: Scene) => void;
  18321. /**
  18322. * Creates a ShadowGenerator object.
  18323. * A ShadowGenerator is the required tool to use the shadows.
  18324. * Each light casting shadows needs to use its own ShadowGenerator.
  18325. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18326. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18327. * @param light The light object generating the shadows.
  18328. * @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.
  18329. */
  18330. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18331. protected _initializeGenerator(): void;
  18332. protected _createTargetRenderTexture(): void;
  18333. protected _initializeShadowMap(): void;
  18334. protected _initializeBlurRTTAndPostProcesses(): void;
  18335. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18336. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18337. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18338. protected _applyFilterValues(): void;
  18339. /**
  18340. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18341. * @param onCompiled Callback triggered at the and of the effects compilation
  18342. * @param options Sets of optional options forcing the compilation with different modes
  18343. */
  18344. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18345. useInstances: boolean;
  18346. }>): void;
  18347. /**
  18348. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18349. * @param options Sets of optional options forcing the compilation with different modes
  18350. * @returns A promise that resolves when the compilation completes
  18351. */
  18352. forceCompilationAsync(options?: Partial<{
  18353. useInstances: boolean;
  18354. }>): Promise<void>;
  18355. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18356. private _prepareShadowDefines;
  18357. /**
  18358. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18359. * @param subMesh The submesh we want to render in the shadow map
  18360. * @param useInstances Defines wether will draw in the map using instances
  18361. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18362. * @returns true if ready otherwise, false
  18363. */
  18364. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18365. /**
  18366. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18367. * @param defines Defines of the material we want to update
  18368. * @param lightIndex Index of the light in the enabled light list of the material
  18369. */
  18370. prepareDefines(defines: any, lightIndex: number): void;
  18371. /**
  18372. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18373. * defined in the generator but impacting the effect).
  18374. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18375. * @param effect The effect we are binfing the information for
  18376. */
  18377. bindShadowLight(lightIndex: string, effect: Effect): void;
  18378. /**
  18379. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18380. * (eq to shadow prjection matrix * light transform matrix)
  18381. * @returns The transform matrix used to create the shadow map
  18382. */
  18383. getTransformMatrix(): Matrix;
  18384. /**
  18385. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18386. * Cube and 2D textures for instance.
  18387. */
  18388. recreateShadowMap(): void;
  18389. protected _disposeBlurPostProcesses(): void;
  18390. protected _disposeRTTandPostProcesses(): void;
  18391. /**
  18392. * Disposes the ShadowGenerator.
  18393. * Returns nothing.
  18394. */
  18395. dispose(): void;
  18396. /**
  18397. * Serializes the shadow generator setup to a json object.
  18398. * @returns The serialized JSON object
  18399. */
  18400. serialize(): any;
  18401. /**
  18402. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18403. * @param parsedShadowGenerator The JSON object to parse
  18404. * @param scene The scene to create the shadow map for
  18405. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18406. * @returns The parsed shadow generator
  18407. */
  18408. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18409. }
  18410. }
  18411. declare module "babylonjs/Lights/light" {
  18412. import { Nullable } from "babylonjs/types";
  18413. import { Scene } from "babylonjs/scene";
  18414. import { Vector3 } from "babylonjs/Maths/math.vector";
  18415. import { Color3 } from "babylonjs/Maths/math.color";
  18416. import { Node } from "babylonjs/node";
  18417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18418. import { Effect } from "babylonjs/Materials/effect";
  18419. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18420. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18421. /**
  18422. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18423. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18424. * 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.
  18425. */
  18426. export abstract class Light extends Node {
  18427. /**
  18428. * Falloff Default: light is falling off following the material specification:
  18429. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18430. */
  18431. static readonly FALLOFF_DEFAULT: number;
  18432. /**
  18433. * Falloff Physical: light is falling off following the inverse squared distance law.
  18434. */
  18435. static readonly FALLOFF_PHYSICAL: number;
  18436. /**
  18437. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18438. * to enhance interoperability with other engines.
  18439. */
  18440. static readonly FALLOFF_GLTF: number;
  18441. /**
  18442. * Falloff Standard: light is falling off like in the standard material
  18443. * to enhance interoperability with other materials.
  18444. */
  18445. static readonly FALLOFF_STANDARD: number;
  18446. /**
  18447. * If every light affecting the material is in this lightmapMode,
  18448. * material.lightmapTexture adds or multiplies
  18449. * (depends on material.useLightmapAsShadowmap)
  18450. * after every other light calculations.
  18451. */
  18452. static readonly LIGHTMAP_DEFAULT: number;
  18453. /**
  18454. * material.lightmapTexture as only diffuse lighting from this light
  18455. * adds only specular lighting from this light
  18456. * adds dynamic shadows
  18457. */
  18458. static readonly LIGHTMAP_SPECULAR: number;
  18459. /**
  18460. * material.lightmapTexture as only lighting
  18461. * no light calculation from this light
  18462. * only adds dynamic shadows from this light
  18463. */
  18464. static readonly LIGHTMAP_SHADOWSONLY: number;
  18465. /**
  18466. * Each light type uses the default quantity according to its type:
  18467. * point/spot lights use luminous intensity
  18468. * directional lights use illuminance
  18469. */
  18470. static readonly INTENSITYMODE_AUTOMATIC: number;
  18471. /**
  18472. * lumen (lm)
  18473. */
  18474. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18475. /**
  18476. * candela (lm/sr)
  18477. */
  18478. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18479. /**
  18480. * lux (lm/m^2)
  18481. */
  18482. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18483. /**
  18484. * nit (cd/m^2)
  18485. */
  18486. static readonly INTENSITYMODE_LUMINANCE: number;
  18487. /**
  18488. * Light type const id of the point light.
  18489. */
  18490. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18491. /**
  18492. * Light type const id of the directional light.
  18493. */
  18494. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18495. /**
  18496. * Light type const id of the spot light.
  18497. */
  18498. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18499. /**
  18500. * Light type const id of the hemispheric light.
  18501. */
  18502. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18503. /**
  18504. * Diffuse gives the basic color to an object.
  18505. */
  18506. diffuse: Color3;
  18507. /**
  18508. * Specular produces a highlight color on an object.
  18509. * Note: This is note affecting PBR materials.
  18510. */
  18511. specular: Color3;
  18512. /**
  18513. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18514. * falling off base on range or angle.
  18515. * This can be set to any values in Light.FALLOFF_x.
  18516. *
  18517. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18518. * other types of materials.
  18519. */
  18520. falloffType: number;
  18521. /**
  18522. * Strength of the light.
  18523. * Note: By default it is define in the framework own unit.
  18524. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18525. */
  18526. intensity: number;
  18527. private _range;
  18528. protected _inverseSquaredRange: number;
  18529. /**
  18530. * Defines how far from the source the light is impacting in scene units.
  18531. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18532. */
  18533. get range(): number;
  18534. /**
  18535. * Defines how far from the source the light is impacting in scene units.
  18536. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18537. */
  18538. set range(value: number);
  18539. /**
  18540. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18541. * of light.
  18542. */
  18543. private _photometricScale;
  18544. private _intensityMode;
  18545. /**
  18546. * Gets the photometric scale used to interpret the intensity.
  18547. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18548. */
  18549. get intensityMode(): number;
  18550. /**
  18551. * Sets the photometric scale used to interpret the intensity.
  18552. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18553. */
  18554. set intensityMode(value: number);
  18555. private _radius;
  18556. /**
  18557. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18558. */
  18559. get radius(): number;
  18560. /**
  18561. * sets the light radius used by PBR Materials to simulate soft area lights.
  18562. */
  18563. set radius(value: number);
  18564. private _renderPriority;
  18565. /**
  18566. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18567. * exceeding the number allowed of the materials.
  18568. */
  18569. renderPriority: number;
  18570. private _shadowEnabled;
  18571. /**
  18572. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18573. * the current shadow generator.
  18574. */
  18575. get shadowEnabled(): boolean;
  18576. /**
  18577. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18578. * the current shadow generator.
  18579. */
  18580. set shadowEnabled(value: boolean);
  18581. private _includedOnlyMeshes;
  18582. /**
  18583. * Gets the only meshes impacted by this light.
  18584. */
  18585. get includedOnlyMeshes(): AbstractMesh[];
  18586. /**
  18587. * Sets the only meshes impacted by this light.
  18588. */
  18589. set includedOnlyMeshes(value: AbstractMesh[]);
  18590. private _excludedMeshes;
  18591. /**
  18592. * Gets the meshes not impacted by this light.
  18593. */
  18594. get excludedMeshes(): AbstractMesh[];
  18595. /**
  18596. * Sets the meshes not impacted by this light.
  18597. */
  18598. set excludedMeshes(value: AbstractMesh[]);
  18599. private _excludeWithLayerMask;
  18600. /**
  18601. * Gets the layer id use to find what meshes are not impacted by the light.
  18602. * Inactive if 0
  18603. */
  18604. get excludeWithLayerMask(): number;
  18605. /**
  18606. * Sets the layer id use to find what meshes are not impacted by the light.
  18607. * Inactive if 0
  18608. */
  18609. set excludeWithLayerMask(value: number);
  18610. private _includeOnlyWithLayerMask;
  18611. /**
  18612. * Gets the layer id use to find what meshes are impacted by the light.
  18613. * Inactive if 0
  18614. */
  18615. get includeOnlyWithLayerMask(): number;
  18616. /**
  18617. * Sets the layer id use to find what meshes are impacted by the light.
  18618. * Inactive if 0
  18619. */
  18620. set includeOnlyWithLayerMask(value: number);
  18621. private _lightmapMode;
  18622. /**
  18623. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18624. */
  18625. get lightmapMode(): number;
  18626. /**
  18627. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18628. */
  18629. set lightmapMode(value: number);
  18630. /**
  18631. * Shadow generator associted to the light.
  18632. * @hidden Internal use only.
  18633. */
  18634. _shadowGenerator: Nullable<IShadowGenerator>;
  18635. /**
  18636. * @hidden Internal use only.
  18637. */
  18638. _excludedMeshesIds: string[];
  18639. /**
  18640. * @hidden Internal use only.
  18641. */
  18642. _includedOnlyMeshesIds: string[];
  18643. /**
  18644. * The current light unifom buffer.
  18645. * @hidden Internal use only.
  18646. */
  18647. _uniformBuffer: UniformBuffer;
  18648. /** @hidden */
  18649. _renderId: number;
  18650. /**
  18651. * Creates a Light object in the scene.
  18652. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18653. * @param name The firendly name of the light
  18654. * @param scene The scene the light belongs too
  18655. */
  18656. constructor(name: string, scene: Scene);
  18657. protected abstract _buildUniformLayout(): void;
  18658. /**
  18659. * Sets the passed Effect "effect" with the Light information.
  18660. * @param effect The effect to update
  18661. * @param lightIndex The index of the light in the effect to update
  18662. * @returns The light
  18663. */
  18664. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18665. /**
  18666. * Sets the passed Effect "effect" with the Light textures.
  18667. * @param effect The effect to update
  18668. * @param lightIndex The index of the light in the effect to update
  18669. * @returns The light
  18670. */
  18671. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18672. /**
  18673. * Binds the lights information from the scene to the effect for the given mesh.
  18674. * @param lightIndex Light index
  18675. * @param scene The scene where the light belongs to
  18676. * @param effect The effect we are binding the data to
  18677. * @param useSpecular Defines if specular is supported
  18678. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18679. */
  18680. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18681. /**
  18682. * Sets the passed Effect "effect" with the Light information.
  18683. * @param effect The effect to update
  18684. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18685. * @returns The light
  18686. */
  18687. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18688. /**
  18689. * Returns the string "Light".
  18690. * @returns the class name
  18691. */
  18692. getClassName(): string;
  18693. /** @hidden */
  18694. readonly _isLight: boolean;
  18695. /**
  18696. * Converts the light information to a readable string for debug purpose.
  18697. * @param fullDetails Supports for multiple levels of logging within scene loading
  18698. * @returns the human readable light info
  18699. */
  18700. toString(fullDetails?: boolean): string;
  18701. /** @hidden */
  18702. protected _syncParentEnabledState(): void;
  18703. /**
  18704. * Set the enabled state of this node.
  18705. * @param value - the new enabled state
  18706. */
  18707. setEnabled(value: boolean): void;
  18708. /**
  18709. * Returns the Light associated shadow generator if any.
  18710. * @return the associated shadow generator.
  18711. */
  18712. getShadowGenerator(): Nullable<IShadowGenerator>;
  18713. /**
  18714. * Returns a Vector3, the absolute light position in the World.
  18715. * @returns the world space position of the light
  18716. */
  18717. getAbsolutePosition(): Vector3;
  18718. /**
  18719. * Specifies if the light will affect the passed mesh.
  18720. * @param mesh The mesh to test against the light
  18721. * @return true the mesh is affected otherwise, false.
  18722. */
  18723. canAffectMesh(mesh: AbstractMesh): boolean;
  18724. /**
  18725. * Sort function to order lights for rendering.
  18726. * @param a First Light object to compare to second.
  18727. * @param b Second Light object to compare first.
  18728. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18729. */
  18730. static CompareLightsPriority(a: Light, b: Light): number;
  18731. /**
  18732. * Releases resources associated with this node.
  18733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18735. */
  18736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18737. /**
  18738. * Returns the light type ID (integer).
  18739. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18740. */
  18741. getTypeID(): number;
  18742. /**
  18743. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18744. * @returns the scaled intensity in intensity mode unit
  18745. */
  18746. getScaledIntensity(): number;
  18747. /**
  18748. * Returns a new Light object, named "name", from the current one.
  18749. * @param name The name of the cloned light
  18750. * @param newParent The parent of this light, if it has one
  18751. * @returns the new created light
  18752. */
  18753. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18754. /**
  18755. * Serializes the current light into a Serialization object.
  18756. * @returns the serialized object.
  18757. */
  18758. serialize(): any;
  18759. /**
  18760. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18761. * This new light is named "name" and added to the passed scene.
  18762. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18763. * @param name The friendly name of the light
  18764. * @param scene The scene the new light will belong to
  18765. * @returns the constructor function
  18766. */
  18767. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18768. /**
  18769. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18770. * @param parsedLight The JSON representation of the light
  18771. * @param scene The scene to create the parsed light in
  18772. * @returns the created light after parsing
  18773. */
  18774. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18775. private _hookArrayForExcluded;
  18776. private _hookArrayForIncludedOnly;
  18777. private _resyncMeshes;
  18778. /**
  18779. * Forces the meshes to update their light related information in their rendering used effects
  18780. * @hidden Internal Use Only
  18781. */
  18782. _markMeshesAsLightDirty(): void;
  18783. /**
  18784. * Recomputes the cached photometric scale if needed.
  18785. */
  18786. private _computePhotometricScale;
  18787. /**
  18788. * Returns the Photometric Scale according to the light type and intensity mode.
  18789. */
  18790. private _getPhotometricScale;
  18791. /**
  18792. * Reorder the light in the scene according to their defined priority.
  18793. * @hidden Internal Use Only
  18794. */
  18795. _reorderLightsInScene(): void;
  18796. /**
  18797. * Prepares the list of defines specific to the light type.
  18798. * @param defines the list of defines
  18799. * @param lightIndex defines the index of the light for the effect
  18800. */
  18801. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18802. }
  18803. }
  18804. declare module "babylonjs/Cameras/targetCamera" {
  18805. import { Nullable } from "babylonjs/types";
  18806. import { Camera } from "babylonjs/Cameras/camera";
  18807. import { Scene } from "babylonjs/scene";
  18808. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18809. /**
  18810. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18811. * This is the base of the follow, arc rotate cameras and Free camera
  18812. * @see https://doc.babylonjs.com/features/cameras
  18813. */
  18814. export class TargetCamera extends Camera {
  18815. private static _RigCamTransformMatrix;
  18816. private static _TargetTransformMatrix;
  18817. private static _TargetFocalPoint;
  18818. private _tmpUpVector;
  18819. private _tmpTargetVector;
  18820. /**
  18821. * Define the current direction the camera is moving to
  18822. */
  18823. cameraDirection: Vector3;
  18824. /**
  18825. * Define the current rotation the camera is rotating to
  18826. */
  18827. cameraRotation: Vector2;
  18828. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18829. ignoreParentScaling: boolean;
  18830. /**
  18831. * When set, the up vector of the camera will be updated by the rotation of the camera
  18832. */
  18833. updateUpVectorFromRotation: boolean;
  18834. private _tmpQuaternion;
  18835. /**
  18836. * Define the current rotation of the camera
  18837. */
  18838. rotation: Vector3;
  18839. /**
  18840. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18841. */
  18842. rotationQuaternion: Quaternion;
  18843. /**
  18844. * Define the current speed of the camera
  18845. */
  18846. speed: number;
  18847. /**
  18848. * Add constraint to the camera to prevent it to move freely in all directions and
  18849. * around all axis.
  18850. */
  18851. noRotationConstraint: boolean;
  18852. /**
  18853. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18854. * panning
  18855. */
  18856. invertRotation: boolean;
  18857. /**
  18858. * Speed multiplier for inverse camera panning
  18859. */
  18860. inverseRotationSpeed: number;
  18861. /**
  18862. * Define the current target of the camera as an object or a position.
  18863. */
  18864. lockedTarget: any;
  18865. /** @hidden */
  18866. _currentTarget: Vector3;
  18867. /** @hidden */
  18868. _initialFocalDistance: number;
  18869. /** @hidden */
  18870. _viewMatrix: Matrix;
  18871. /** @hidden */
  18872. _camMatrix: Matrix;
  18873. /** @hidden */
  18874. _cameraTransformMatrix: Matrix;
  18875. /** @hidden */
  18876. _cameraRotationMatrix: Matrix;
  18877. /** @hidden */
  18878. _referencePoint: Vector3;
  18879. /** @hidden */
  18880. _transformedReferencePoint: Vector3;
  18881. /** @hidden */
  18882. _reset: () => void;
  18883. private _defaultUp;
  18884. /**
  18885. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18886. * This is the base of the follow, arc rotate cameras and Free camera
  18887. * @see https://doc.babylonjs.com/features/cameras
  18888. * @param name Defines the name of the camera in the scene
  18889. * @param position Defines the start position of the camera in the scene
  18890. * @param scene Defines the scene the camera belongs to
  18891. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18892. */
  18893. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18894. /**
  18895. * Gets the position in front of the camera at a given distance.
  18896. * @param distance The distance from the camera we want the position to be
  18897. * @returns the position
  18898. */
  18899. getFrontPosition(distance: number): Vector3;
  18900. /** @hidden */
  18901. _getLockedTargetPosition(): Nullable<Vector3>;
  18902. private _storedPosition;
  18903. private _storedRotation;
  18904. private _storedRotationQuaternion;
  18905. /**
  18906. * Store current camera state of the camera (fov, position, rotation, etc..)
  18907. * @returns the camera
  18908. */
  18909. storeState(): Camera;
  18910. /**
  18911. * Restored camera state. You must call storeState() first
  18912. * @returns whether it was successful or not
  18913. * @hidden
  18914. */
  18915. _restoreStateValues(): boolean;
  18916. /** @hidden */
  18917. _initCache(): void;
  18918. /** @hidden */
  18919. _updateCache(ignoreParentClass?: boolean): void;
  18920. /** @hidden */
  18921. _isSynchronizedViewMatrix(): boolean;
  18922. /** @hidden */
  18923. _computeLocalCameraSpeed(): number;
  18924. /**
  18925. * Defines the target the camera should look at.
  18926. * @param target Defines the new target as a Vector or a mesh
  18927. */
  18928. setTarget(target: Vector3): void;
  18929. /**
  18930. * Defines the target point of the camera.
  18931. * The camera looks towards it form the radius distance.
  18932. */
  18933. get target(): Vector3;
  18934. set target(value: Vector3);
  18935. /**
  18936. * Return the current target position of the camera. This value is expressed in local space.
  18937. * @returns the target position
  18938. */
  18939. getTarget(): Vector3;
  18940. /** @hidden */
  18941. _decideIfNeedsToMove(): boolean;
  18942. /** @hidden */
  18943. _updatePosition(): void;
  18944. /** @hidden */
  18945. _checkInputs(): void;
  18946. protected _updateCameraRotationMatrix(): void;
  18947. /**
  18948. * 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)
  18949. * @returns the current camera
  18950. */
  18951. private _rotateUpVectorWithCameraRotationMatrix;
  18952. private _cachedRotationZ;
  18953. private _cachedQuaternionRotationZ;
  18954. /** @hidden */
  18955. _getViewMatrix(): Matrix;
  18956. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18957. /**
  18958. * @hidden
  18959. */
  18960. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18961. /**
  18962. * @hidden
  18963. */
  18964. _updateRigCameras(): void;
  18965. private _getRigCamPositionAndTarget;
  18966. /**
  18967. * Gets the current object class name.
  18968. * @return the class name
  18969. */
  18970. getClassName(): string;
  18971. }
  18972. }
  18973. declare module "babylonjs/Events/keyboardEvents" {
  18974. /**
  18975. * Gather the list of keyboard event types as constants.
  18976. */
  18977. export class KeyboardEventTypes {
  18978. /**
  18979. * The keydown event is fired when a key becomes active (pressed).
  18980. */
  18981. static readonly KEYDOWN: number;
  18982. /**
  18983. * The keyup event is fired when a key has been released.
  18984. */
  18985. static readonly KEYUP: number;
  18986. }
  18987. /**
  18988. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18989. */
  18990. export class KeyboardInfo {
  18991. /**
  18992. * Defines the type of event (KeyboardEventTypes)
  18993. */
  18994. type: number;
  18995. /**
  18996. * Defines the related dom event
  18997. */
  18998. event: KeyboardEvent;
  18999. /**
  19000. * Instantiates a new keyboard info.
  19001. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19002. * @param type Defines the type of event (KeyboardEventTypes)
  19003. * @param event Defines the related dom event
  19004. */
  19005. constructor(
  19006. /**
  19007. * Defines the type of event (KeyboardEventTypes)
  19008. */
  19009. type: number,
  19010. /**
  19011. * Defines the related dom event
  19012. */
  19013. event: KeyboardEvent);
  19014. }
  19015. /**
  19016. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19017. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19018. */
  19019. export class KeyboardInfoPre extends KeyboardInfo {
  19020. /**
  19021. * Defines the type of event (KeyboardEventTypes)
  19022. */
  19023. type: number;
  19024. /**
  19025. * Defines the related dom event
  19026. */
  19027. event: KeyboardEvent;
  19028. /**
  19029. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19030. */
  19031. skipOnPointerObservable: boolean;
  19032. /**
  19033. * Instantiates a new keyboard pre info.
  19034. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19035. * @param type Defines the type of event (KeyboardEventTypes)
  19036. * @param event Defines the related dom event
  19037. */
  19038. constructor(
  19039. /**
  19040. * Defines the type of event (KeyboardEventTypes)
  19041. */
  19042. type: number,
  19043. /**
  19044. * Defines the related dom event
  19045. */
  19046. event: KeyboardEvent);
  19047. }
  19048. }
  19049. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19050. import { Nullable } from "babylonjs/types";
  19051. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19052. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19053. /**
  19054. * Manage the keyboard inputs to control the movement of a free camera.
  19055. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19056. */
  19057. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19058. /**
  19059. * Defines the camera the input is attached to.
  19060. */
  19061. camera: FreeCamera;
  19062. /**
  19063. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19064. */
  19065. keysUp: number[];
  19066. /**
  19067. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19068. */
  19069. keysUpward: number[];
  19070. /**
  19071. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19072. */
  19073. keysDown: number[];
  19074. /**
  19075. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19076. */
  19077. keysDownward: number[];
  19078. /**
  19079. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19080. */
  19081. keysLeft: number[];
  19082. /**
  19083. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19084. */
  19085. keysRight: number[];
  19086. private _keys;
  19087. private _onCanvasBlurObserver;
  19088. private _onKeyboardObserver;
  19089. private _engine;
  19090. private _scene;
  19091. /**
  19092. * Attach the input controls to a specific dom element to get the input from.
  19093. * @param element Defines the element the controls should be listened from
  19094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19095. */
  19096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19097. /**
  19098. * Detach the current controls from the specified dom element.
  19099. * @param element Defines the element to stop listening the inputs from
  19100. */
  19101. detachControl(element: Nullable<HTMLElement>): void;
  19102. /**
  19103. * Update the current camera state depending on the inputs that have been used this frame.
  19104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19105. */
  19106. checkInputs(): void;
  19107. /**
  19108. * Gets the class name of the current intput.
  19109. * @returns the class name
  19110. */
  19111. getClassName(): string;
  19112. /** @hidden */
  19113. _onLostFocus(): void;
  19114. /**
  19115. * Get the friendly name associated with the input class.
  19116. * @returns the input friendly name
  19117. */
  19118. getSimpleName(): string;
  19119. }
  19120. }
  19121. declare module "babylonjs/Events/pointerEvents" {
  19122. import { Nullable } from "babylonjs/types";
  19123. import { Vector2 } from "babylonjs/Maths/math.vector";
  19124. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19125. import { Ray } from "babylonjs/Culling/ray";
  19126. /**
  19127. * Gather the list of pointer event types as constants.
  19128. */
  19129. export class PointerEventTypes {
  19130. /**
  19131. * 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.
  19132. */
  19133. static readonly POINTERDOWN: number;
  19134. /**
  19135. * The pointerup event is fired when a pointer is no longer active.
  19136. */
  19137. static readonly POINTERUP: number;
  19138. /**
  19139. * The pointermove event is fired when a pointer changes coordinates.
  19140. */
  19141. static readonly POINTERMOVE: number;
  19142. /**
  19143. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19144. */
  19145. static readonly POINTERWHEEL: number;
  19146. /**
  19147. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19148. */
  19149. static readonly POINTERPICK: number;
  19150. /**
  19151. * The pointertap event is fired when a the object has been touched and released without drag.
  19152. */
  19153. static readonly POINTERTAP: number;
  19154. /**
  19155. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19156. */
  19157. static readonly POINTERDOUBLETAP: number;
  19158. }
  19159. /**
  19160. * Base class of pointer info types.
  19161. */
  19162. export class PointerInfoBase {
  19163. /**
  19164. * Defines the type of event (PointerEventTypes)
  19165. */
  19166. type: number;
  19167. /**
  19168. * Defines the related dom event
  19169. */
  19170. event: PointerEvent | MouseWheelEvent;
  19171. /**
  19172. * Instantiates the base class of pointers info.
  19173. * @param type Defines the type of event (PointerEventTypes)
  19174. * @param event Defines the related dom event
  19175. */
  19176. constructor(
  19177. /**
  19178. * Defines the type of event (PointerEventTypes)
  19179. */
  19180. type: number,
  19181. /**
  19182. * Defines the related dom event
  19183. */
  19184. event: PointerEvent | MouseWheelEvent);
  19185. }
  19186. /**
  19187. * This class is used to store pointer related info for the onPrePointerObservable event.
  19188. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19189. */
  19190. export class PointerInfoPre extends PointerInfoBase {
  19191. /**
  19192. * Ray from a pointer if availible (eg. 6dof controller)
  19193. */
  19194. ray: Nullable<Ray>;
  19195. /**
  19196. * Defines the local position of the pointer on the canvas.
  19197. */
  19198. localPosition: Vector2;
  19199. /**
  19200. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19201. */
  19202. skipOnPointerObservable: boolean;
  19203. /**
  19204. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19205. * @param type Defines the type of event (PointerEventTypes)
  19206. * @param event Defines the related dom event
  19207. * @param localX Defines the local x coordinates of the pointer when the event occured
  19208. * @param localY Defines the local y coordinates of the pointer when the event occured
  19209. */
  19210. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19211. }
  19212. /**
  19213. * This type contains all the data related to a pointer event in Babylon.js.
  19214. * 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.
  19215. */
  19216. export class PointerInfo extends PointerInfoBase {
  19217. /**
  19218. * Defines the picking info associated to the info (if any)\
  19219. */
  19220. pickInfo: Nullable<PickingInfo>;
  19221. /**
  19222. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19223. * @param type Defines the type of event (PointerEventTypes)
  19224. * @param event Defines the related dom event
  19225. * @param pickInfo Defines the picking info associated to the info (if any)\
  19226. */
  19227. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19228. /**
  19229. * Defines the picking info associated to the info (if any)\
  19230. */
  19231. pickInfo: Nullable<PickingInfo>);
  19232. }
  19233. /**
  19234. * Data relating to a touch event on the screen.
  19235. */
  19236. export interface PointerTouch {
  19237. /**
  19238. * X coordinate of touch.
  19239. */
  19240. x: number;
  19241. /**
  19242. * Y coordinate of touch.
  19243. */
  19244. y: number;
  19245. /**
  19246. * Id of touch. Unique for each finger.
  19247. */
  19248. pointerId: number;
  19249. /**
  19250. * Event type passed from DOM.
  19251. */
  19252. type: any;
  19253. }
  19254. }
  19255. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19256. import { Observable } from "babylonjs/Misc/observable";
  19257. import { Nullable } from "babylonjs/types";
  19258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19260. /**
  19261. * Manage the mouse inputs to control the movement of a free camera.
  19262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19263. */
  19264. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19265. /**
  19266. * Define if touch is enabled in the mouse input
  19267. */
  19268. touchEnabled: boolean;
  19269. /**
  19270. * Defines the camera the input is attached to.
  19271. */
  19272. camera: FreeCamera;
  19273. /**
  19274. * Defines the buttons associated with the input to handle camera move.
  19275. */
  19276. buttons: number[];
  19277. /**
  19278. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19279. */
  19280. angularSensibility: number;
  19281. private _pointerInput;
  19282. private _onMouseMove;
  19283. private _observer;
  19284. private previousPosition;
  19285. /**
  19286. * Observable for when a pointer move event occurs containing the move offset
  19287. */
  19288. onPointerMovedObservable: Observable<{
  19289. offsetX: number;
  19290. offsetY: number;
  19291. }>;
  19292. /**
  19293. * @hidden
  19294. * If the camera should be rotated automatically based on pointer movement
  19295. */
  19296. _allowCameraRotation: boolean;
  19297. /**
  19298. * Manage the mouse inputs to control the movement of a free camera.
  19299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19300. * @param touchEnabled Defines if touch is enabled or not
  19301. */
  19302. constructor(
  19303. /**
  19304. * Define if touch is enabled in the mouse input
  19305. */
  19306. touchEnabled?: boolean);
  19307. /**
  19308. * Attach the input controls to a specific dom element to get the input from.
  19309. * @param element Defines the element the controls should be listened from
  19310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19311. */
  19312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19313. /**
  19314. * Called on JS contextmenu event.
  19315. * Override this method to provide functionality.
  19316. */
  19317. protected onContextMenu(evt: PointerEvent): void;
  19318. /**
  19319. * Detach the current controls from the specified dom element.
  19320. * @param element Defines the element to stop listening the inputs from
  19321. */
  19322. detachControl(element: Nullable<HTMLElement>): void;
  19323. /**
  19324. * Gets the class name of the current intput.
  19325. * @returns the class name
  19326. */
  19327. getClassName(): string;
  19328. /**
  19329. * Get the friendly name associated with the input class.
  19330. * @returns the input friendly name
  19331. */
  19332. getSimpleName(): string;
  19333. }
  19334. }
  19335. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19336. import { Nullable } from "babylonjs/types";
  19337. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19338. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19339. /**
  19340. * Manage the touch inputs to control the movement of a free camera.
  19341. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19342. */
  19343. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19344. /**
  19345. * Defines the camera the input is attached to.
  19346. */
  19347. camera: FreeCamera;
  19348. /**
  19349. * Defines the touch sensibility for rotation.
  19350. * The higher the faster.
  19351. */
  19352. touchAngularSensibility: number;
  19353. /**
  19354. * Defines the touch sensibility for move.
  19355. * The higher the faster.
  19356. */
  19357. touchMoveSensibility: number;
  19358. private _offsetX;
  19359. private _offsetY;
  19360. private _pointerPressed;
  19361. private _pointerInput;
  19362. private _observer;
  19363. private _onLostFocus;
  19364. /**
  19365. * Attach the input controls to a specific dom element to get the input from.
  19366. * @param element Defines the element the controls should be listened from
  19367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19368. */
  19369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19370. /**
  19371. * Detach the current controls from the specified dom element.
  19372. * @param element Defines the element to stop listening the inputs from
  19373. */
  19374. detachControl(element: Nullable<HTMLElement>): void;
  19375. /**
  19376. * Update the current camera state depending on the inputs that have been used this frame.
  19377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19378. */
  19379. checkInputs(): void;
  19380. /**
  19381. * Gets the class name of the current intput.
  19382. * @returns the class name
  19383. */
  19384. getClassName(): string;
  19385. /**
  19386. * Get the friendly name associated with the input class.
  19387. * @returns the input friendly name
  19388. */
  19389. getSimpleName(): string;
  19390. }
  19391. }
  19392. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19393. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19394. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19395. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19396. import { Nullable } from "babylonjs/types";
  19397. /**
  19398. * Default Inputs manager for the FreeCamera.
  19399. * It groups all the default supported inputs for ease of use.
  19400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19401. */
  19402. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19403. /**
  19404. * @hidden
  19405. */
  19406. _mouseInput: Nullable<FreeCameraMouseInput>;
  19407. /**
  19408. * Instantiates a new FreeCameraInputsManager.
  19409. * @param camera Defines the camera the inputs belong to
  19410. */
  19411. constructor(camera: FreeCamera);
  19412. /**
  19413. * Add keyboard input support to the input manager.
  19414. * @returns the current input manager
  19415. */
  19416. addKeyboard(): FreeCameraInputsManager;
  19417. /**
  19418. * Add mouse input support to the input manager.
  19419. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19420. * @returns the current input manager
  19421. */
  19422. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19423. /**
  19424. * Removes the mouse input support from the manager
  19425. * @returns the current input manager
  19426. */
  19427. removeMouse(): FreeCameraInputsManager;
  19428. /**
  19429. * Add touch input support to the input manager.
  19430. * @returns the current input manager
  19431. */
  19432. addTouch(): FreeCameraInputsManager;
  19433. /**
  19434. * Remove all attached input methods from a camera
  19435. */
  19436. clear(): void;
  19437. }
  19438. }
  19439. declare module "babylonjs/Cameras/freeCamera" {
  19440. import { Vector3 } from "babylonjs/Maths/math.vector";
  19441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19442. import { Scene } from "babylonjs/scene";
  19443. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19444. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19445. /**
  19446. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19447. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19448. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19449. */
  19450. export class FreeCamera extends TargetCamera {
  19451. /**
  19452. * Define the collision ellipsoid of the camera.
  19453. * This is helpful to simulate a camera body like the player body around the camera
  19454. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19455. */
  19456. ellipsoid: Vector3;
  19457. /**
  19458. * Define an offset for the position of the ellipsoid around the camera.
  19459. * This can be helpful to determine the center of the body near the gravity center of the body
  19460. * instead of its head.
  19461. */
  19462. ellipsoidOffset: Vector3;
  19463. /**
  19464. * Enable or disable collisions of the camera with the rest of the scene objects.
  19465. */
  19466. checkCollisions: boolean;
  19467. /**
  19468. * Enable or disable gravity on the camera.
  19469. */
  19470. applyGravity: boolean;
  19471. /**
  19472. * Define the input manager associated to the camera.
  19473. */
  19474. inputs: FreeCameraInputsManager;
  19475. /**
  19476. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19477. * Higher values reduce sensitivity.
  19478. */
  19479. get angularSensibility(): number;
  19480. /**
  19481. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19482. * Higher values reduce sensitivity.
  19483. */
  19484. set angularSensibility(value: number);
  19485. /**
  19486. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19487. */
  19488. get keysUp(): number[];
  19489. set keysUp(value: number[]);
  19490. /**
  19491. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19492. */
  19493. get keysUpward(): number[];
  19494. set keysUpward(value: number[]);
  19495. /**
  19496. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19497. */
  19498. get keysDown(): number[];
  19499. set keysDown(value: number[]);
  19500. /**
  19501. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19502. */
  19503. get keysDownward(): number[];
  19504. set keysDownward(value: number[]);
  19505. /**
  19506. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19507. */
  19508. get keysLeft(): number[];
  19509. set keysLeft(value: number[]);
  19510. /**
  19511. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19512. */
  19513. get keysRight(): number[];
  19514. set keysRight(value: number[]);
  19515. /**
  19516. * Event raised when the camera collide with a mesh in the scene.
  19517. */
  19518. onCollide: (collidedMesh: AbstractMesh) => void;
  19519. private _collider;
  19520. private _needMoveForGravity;
  19521. private _oldPosition;
  19522. private _diffPosition;
  19523. private _newPosition;
  19524. /** @hidden */
  19525. _localDirection: Vector3;
  19526. /** @hidden */
  19527. _transformedDirection: Vector3;
  19528. /**
  19529. * Instantiates a Free Camera.
  19530. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19531. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19532. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19533. * @param name Define the name of the camera in the scene
  19534. * @param position Define the start position of the camera in the scene
  19535. * @param scene Define the scene the camera belongs to
  19536. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19537. */
  19538. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19539. /**
  19540. * Attached controls to the current camera.
  19541. * @param element Defines the element the controls should be listened from
  19542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19543. */
  19544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19545. /**
  19546. * Detach the current controls from the camera.
  19547. * The camera will stop reacting to inputs.
  19548. * @param element Defines the element to stop listening the inputs from
  19549. */
  19550. detachControl(element: HTMLElement): void;
  19551. private _collisionMask;
  19552. /**
  19553. * Define a collision mask to limit the list of object the camera can collide with
  19554. */
  19555. get collisionMask(): number;
  19556. set collisionMask(mask: number);
  19557. /** @hidden */
  19558. _collideWithWorld(displacement: Vector3): void;
  19559. private _onCollisionPositionChange;
  19560. /** @hidden */
  19561. _checkInputs(): void;
  19562. /** @hidden */
  19563. _decideIfNeedsToMove(): boolean;
  19564. /** @hidden */
  19565. _updatePosition(): void;
  19566. /**
  19567. * Destroy the camera and release the current resources hold by it.
  19568. */
  19569. dispose(): void;
  19570. /**
  19571. * Gets the current object class name.
  19572. * @return the class name
  19573. */
  19574. getClassName(): string;
  19575. }
  19576. }
  19577. declare module "babylonjs/Gamepads/gamepad" {
  19578. import { Observable } from "babylonjs/Misc/observable";
  19579. /**
  19580. * Represents a gamepad control stick position
  19581. */
  19582. export class StickValues {
  19583. /**
  19584. * The x component of the control stick
  19585. */
  19586. x: number;
  19587. /**
  19588. * The y component of the control stick
  19589. */
  19590. y: number;
  19591. /**
  19592. * Initializes the gamepad x and y control stick values
  19593. * @param x The x component of the gamepad control stick value
  19594. * @param y The y component of the gamepad control stick value
  19595. */
  19596. constructor(
  19597. /**
  19598. * The x component of the control stick
  19599. */
  19600. x: number,
  19601. /**
  19602. * The y component of the control stick
  19603. */
  19604. y: number);
  19605. }
  19606. /**
  19607. * An interface which manages callbacks for gamepad button changes
  19608. */
  19609. export interface GamepadButtonChanges {
  19610. /**
  19611. * Called when a gamepad has been changed
  19612. */
  19613. changed: boolean;
  19614. /**
  19615. * Called when a gamepad press event has been triggered
  19616. */
  19617. pressChanged: boolean;
  19618. /**
  19619. * Called when a touch event has been triggered
  19620. */
  19621. touchChanged: boolean;
  19622. /**
  19623. * Called when a value has changed
  19624. */
  19625. valueChanged: boolean;
  19626. }
  19627. /**
  19628. * Represents a gamepad
  19629. */
  19630. export class Gamepad {
  19631. /**
  19632. * The id of the gamepad
  19633. */
  19634. id: string;
  19635. /**
  19636. * The index of the gamepad
  19637. */
  19638. index: number;
  19639. /**
  19640. * The browser gamepad
  19641. */
  19642. browserGamepad: any;
  19643. /**
  19644. * Specifies what type of gamepad this represents
  19645. */
  19646. type: number;
  19647. private _leftStick;
  19648. private _rightStick;
  19649. /** @hidden */
  19650. _isConnected: boolean;
  19651. private _leftStickAxisX;
  19652. private _leftStickAxisY;
  19653. private _rightStickAxisX;
  19654. private _rightStickAxisY;
  19655. /**
  19656. * Triggered when the left control stick has been changed
  19657. */
  19658. private _onleftstickchanged;
  19659. /**
  19660. * Triggered when the right control stick has been changed
  19661. */
  19662. private _onrightstickchanged;
  19663. /**
  19664. * Represents a gamepad controller
  19665. */
  19666. static GAMEPAD: number;
  19667. /**
  19668. * Represents a generic controller
  19669. */
  19670. static GENERIC: number;
  19671. /**
  19672. * Represents an XBox controller
  19673. */
  19674. static XBOX: number;
  19675. /**
  19676. * Represents a pose-enabled controller
  19677. */
  19678. static POSE_ENABLED: number;
  19679. /**
  19680. * Represents an Dual Shock controller
  19681. */
  19682. static DUALSHOCK: number;
  19683. /**
  19684. * Specifies whether the left control stick should be Y-inverted
  19685. */
  19686. protected _invertLeftStickY: boolean;
  19687. /**
  19688. * Specifies if the gamepad has been connected
  19689. */
  19690. get isConnected(): boolean;
  19691. /**
  19692. * Initializes the gamepad
  19693. * @param id The id of the gamepad
  19694. * @param index The index of the gamepad
  19695. * @param browserGamepad The browser gamepad
  19696. * @param leftStickX The x component of the left joystick
  19697. * @param leftStickY The y component of the left joystick
  19698. * @param rightStickX The x component of the right joystick
  19699. * @param rightStickY The y component of the right joystick
  19700. */
  19701. constructor(
  19702. /**
  19703. * The id of the gamepad
  19704. */
  19705. id: string,
  19706. /**
  19707. * The index of the gamepad
  19708. */
  19709. index: number,
  19710. /**
  19711. * The browser gamepad
  19712. */
  19713. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19714. /**
  19715. * Callback triggered when the left joystick has changed
  19716. * @param callback
  19717. */
  19718. onleftstickchanged(callback: (values: StickValues) => void): void;
  19719. /**
  19720. * Callback triggered when the right joystick has changed
  19721. * @param callback
  19722. */
  19723. onrightstickchanged(callback: (values: StickValues) => void): void;
  19724. /**
  19725. * Gets the left joystick
  19726. */
  19727. get leftStick(): StickValues;
  19728. /**
  19729. * Sets the left joystick values
  19730. */
  19731. set leftStick(newValues: StickValues);
  19732. /**
  19733. * Gets the right joystick
  19734. */
  19735. get rightStick(): StickValues;
  19736. /**
  19737. * Sets the right joystick value
  19738. */
  19739. set rightStick(newValues: StickValues);
  19740. /**
  19741. * Updates the gamepad joystick positions
  19742. */
  19743. update(): void;
  19744. /**
  19745. * Disposes the gamepad
  19746. */
  19747. dispose(): void;
  19748. }
  19749. /**
  19750. * Represents a generic gamepad
  19751. */
  19752. export class GenericPad extends Gamepad {
  19753. private _buttons;
  19754. private _onbuttondown;
  19755. private _onbuttonup;
  19756. /**
  19757. * Observable triggered when a button has been pressed
  19758. */
  19759. onButtonDownObservable: Observable<number>;
  19760. /**
  19761. * Observable triggered when a button has been released
  19762. */
  19763. onButtonUpObservable: Observable<number>;
  19764. /**
  19765. * Callback triggered when a button has been pressed
  19766. * @param callback Called when a button has been pressed
  19767. */
  19768. onbuttondown(callback: (buttonPressed: number) => void): void;
  19769. /**
  19770. * Callback triggered when a button has been released
  19771. * @param callback Called when a button has been released
  19772. */
  19773. onbuttonup(callback: (buttonReleased: number) => void): void;
  19774. /**
  19775. * Initializes the generic gamepad
  19776. * @param id The id of the generic gamepad
  19777. * @param index The index of the generic gamepad
  19778. * @param browserGamepad The browser gamepad
  19779. */
  19780. constructor(id: string, index: number, browserGamepad: any);
  19781. private _setButtonValue;
  19782. /**
  19783. * Updates the generic gamepad
  19784. */
  19785. update(): void;
  19786. /**
  19787. * Disposes the generic gamepad
  19788. */
  19789. dispose(): void;
  19790. }
  19791. }
  19792. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19793. import { Observable } from "babylonjs/Misc/observable";
  19794. import { Nullable } from "babylonjs/types";
  19795. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19796. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19798. import { Ray } from "babylonjs/Culling/ray";
  19799. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19800. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19801. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19802. /**
  19803. * Defines the types of pose enabled controllers that are supported
  19804. */
  19805. export enum PoseEnabledControllerType {
  19806. /**
  19807. * HTC Vive
  19808. */
  19809. VIVE = 0,
  19810. /**
  19811. * Oculus Rift
  19812. */
  19813. OCULUS = 1,
  19814. /**
  19815. * Windows mixed reality
  19816. */
  19817. WINDOWS = 2,
  19818. /**
  19819. * Samsung gear VR
  19820. */
  19821. GEAR_VR = 3,
  19822. /**
  19823. * Google Daydream
  19824. */
  19825. DAYDREAM = 4,
  19826. /**
  19827. * Generic
  19828. */
  19829. GENERIC = 5
  19830. }
  19831. /**
  19832. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19833. */
  19834. export interface MutableGamepadButton {
  19835. /**
  19836. * Value of the button/trigger
  19837. */
  19838. value: number;
  19839. /**
  19840. * If the button/trigger is currently touched
  19841. */
  19842. touched: boolean;
  19843. /**
  19844. * If the button/trigger is currently pressed
  19845. */
  19846. pressed: boolean;
  19847. }
  19848. /**
  19849. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19850. * @hidden
  19851. */
  19852. export interface ExtendedGamepadButton extends GamepadButton {
  19853. /**
  19854. * If the button/trigger is currently pressed
  19855. */
  19856. readonly pressed: boolean;
  19857. /**
  19858. * If the button/trigger is currently touched
  19859. */
  19860. readonly touched: boolean;
  19861. /**
  19862. * Value of the button/trigger
  19863. */
  19864. readonly value: number;
  19865. }
  19866. /** @hidden */
  19867. export interface _GamePadFactory {
  19868. /**
  19869. * Returns whether or not the current gamepad can be created for this type of controller.
  19870. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19871. * @returns true if it can be created, otherwise false
  19872. */
  19873. canCreate(gamepadInfo: any): boolean;
  19874. /**
  19875. * Creates a new instance of the Gamepad.
  19876. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19877. * @returns the new gamepad instance
  19878. */
  19879. create(gamepadInfo: any): Gamepad;
  19880. }
  19881. /**
  19882. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19883. */
  19884. export class PoseEnabledControllerHelper {
  19885. /** @hidden */
  19886. static _ControllerFactories: _GamePadFactory[];
  19887. /** @hidden */
  19888. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19889. /**
  19890. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19891. * @param vrGamepad the gamepad to initialized
  19892. * @returns a vr controller of the type the gamepad identified as
  19893. */
  19894. static InitiateController(vrGamepad: any): Gamepad;
  19895. }
  19896. /**
  19897. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19898. */
  19899. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19900. /**
  19901. * If the controller is used in a webXR session
  19902. */
  19903. isXR: boolean;
  19904. private _deviceRoomPosition;
  19905. private _deviceRoomRotationQuaternion;
  19906. /**
  19907. * The device position in babylon space
  19908. */
  19909. devicePosition: Vector3;
  19910. /**
  19911. * The device rotation in babylon space
  19912. */
  19913. deviceRotationQuaternion: Quaternion;
  19914. /**
  19915. * The scale factor of the device in babylon space
  19916. */
  19917. deviceScaleFactor: number;
  19918. /**
  19919. * (Likely devicePosition should be used instead) The device position in its room space
  19920. */
  19921. position: Vector3;
  19922. /**
  19923. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19924. */
  19925. rotationQuaternion: Quaternion;
  19926. /**
  19927. * The type of controller (Eg. Windows mixed reality)
  19928. */
  19929. controllerType: PoseEnabledControllerType;
  19930. protected _calculatedPosition: Vector3;
  19931. private _calculatedRotation;
  19932. /**
  19933. * The raw pose from the device
  19934. */
  19935. rawPose: DevicePose;
  19936. private _trackPosition;
  19937. private _maxRotationDistFromHeadset;
  19938. private _draggedRoomRotation;
  19939. /**
  19940. * @hidden
  19941. */
  19942. _disableTrackPosition(fixedPosition: Vector3): void;
  19943. /**
  19944. * Internal, the mesh attached to the controller
  19945. * @hidden
  19946. */
  19947. _mesh: Nullable<AbstractMesh>;
  19948. private _poseControlledCamera;
  19949. private _leftHandSystemQuaternion;
  19950. /**
  19951. * Internal, matrix used to convert room space to babylon space
  19952. * @hidden
  19953. */
  19954. _deviceToWorld: Matrix;
  19955. /**
  19956. * Node to be used when casting a ray from the controller
  19957. * @hidden
  19958. */
  19959. _pointingPoseNode: Nullable<TransformNode>;
  19960. /**
  19961. * Name of the child mesh that can be used to cast a ray from the controller
  19962. */
  19963. static readonly POINTING_POSE: string;
  19964. /**
  19965. * Creates a new PoseEnabledController from a gamepad
  19966. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19967. */
  19968. constructor(browserGamepad: any);
  19969. private _workingMatrix;
  19970. /**
  19971. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19972. */
  19973. update(): void;
  19974. /**
  19975. * Updates only the pose device and mesh without doing any button event checking
  19976. */
  19977. protected _updatePoseAndMesh(): void;
  19978. /**
  19979. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19980. * @param poseData raw pose fromthe device
  19981. */
  19982. updateFromDevice(poseData: DevicePose): void;
  19983. /**
  19984. * @hidden
  19985. */
  19986. _meshAttachedObservable: Observable<AbstractMesh>;
  19987. /**
  19988. * Attaches a mesh to the controller
  19989. * @param mesh the mesh to be attached
  19990. */
  19991. attachToMesh(mesh: AbstractMesh): void;
  19992. /**
  19993. * Attaches the controllers mesh to a camera
  19994. * @param camera the camera the mesh should be attached to
  19995. */
  19996. attachToPoseControlledCamera(camera: TargetCamera): void;
  19997. /**
  19998. * Disposes of the controller
  19999. */
  20000. dispose(): void;
  20001. /**
  20002. * The mesh that is attached to the controller
  20003. */
  20004. get mesh(): Nullable<AbstractMesh>;
  20005. /**
  20006. * Gets the ray of the controller in the direction the controller is pointing
  20007. * @param length the length the resulting ray should be
  20008. * @returns a ray in the direction the controller is pointing
  20009. */
  20010. getForwardRay(length?: number): Ray;
  20011. }
  20012. }
  20013. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20014. import { Observable } from "babylonjs/Misc/observable";
  20015. import { Scene } from "babylonjs/scene";
  20016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20017. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20018. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20019. import { Nullable } from "babylonjs/types";
  20020. /**
  20021. * Defines the WebVRController object that represents controllers tracked in 3D space
  20022. */
  20023. export abstract class WebVRController extends PoseEnabledController {
  20024. /**
  20025. * Internal, the default controller model for the controller
  20026. */
  20027. protected _defaultModel: Nullable<AbstractMesh>;
  20028. /**
  20029. * Fired when the trigger state has changed
  20030. */
  20031. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20032. /**
  20033. * Fired when the main button state has changed
  20034. */
  20035. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20036. /**
  20037. * Fired when the secondary button state has changed
  20038. */
  20039. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20040. /**
  20041. * Fired when the pad state has changed
  20042. */
  20043. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20044. /**
  20045. * Fired when controllers stick values have changed
  20046. */
  20047. onPadValuesChangedObservable: Observable<StickValues>;
  20048. /**
  20049. * Array of button availible on the controller
  20050. */
  20051. protected _buttons: Array<MutableGamepadButton>;
  20052. private _onButtonStateChange;
  20053. /**
  20054. * Fired when a controller button's state has changed
  20055. * @param callback the callback containing the button that was modified
  20056. */
  20057. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20058. /**
  20059. * X and Y axis corresponding to the controllers joystick
  20060. */
  20061. pad: StickValues;
  20062. /**
  20063. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20064. */
  20065. hand: string;
  20066. /**
  20067. * The default controller model for the controller
  20068. */
  20069. get defaultModel(): Nullable<AbstractMesh>;
  20070. /**
  20071. * Creates a new WebVRController from a gamepad
  20072. * @param vrGamepad the gamepad that the WebVRController should be created from
  20073. */
  20074. constructor(vrGamepad: any);
  20075. /**
  20076. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20077. */
  20078. update(): void;
  20079. /**
  20080. * Function to be called when a button is modified
  20081. */
  20082. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20083. /**
  20084. * Loads a mesh and attaches it to the controller
  20085. * @param scene the scene the mesh should be added to
  20086. * @param meshLoaded callback for when the mesh has been loaded
  20087. */
  20088. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20089. private _setButtonValue;
  20090. private _changes;
  20091. private _checkChanges;
  20092. /**
  20093. * Disposes of th webVRCOntroller
  20094. */
  20095. dispose(): void;
  20096. }
  20097. }
  20098. declare module "babylonjs/Lights/hemisphericLight" {
  20099. import { Nullable } from "babylonjs/types";
  20100. import { Scene } from "babylonjs/scene";
  20101. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20102. import { Color3 } from "babylonjs/Maths/math.color";
  20103. import { Effect } from "babylonjs/Materials/effect";
  20104. import { Light } from "babylonjs/Lights/light";
  20105. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20106. /**
  20107. * The HemisphericLight simulates the ambient environment light,
  20108. * so the passed direction is the light reflection direction, not the incoming direction.
  20109. */
  20110. export class HemisphericLight extends Light {
  20111. /**
  20112. * The groundColor is the light in the opposite direction to the one specified during creation.
  20113. * 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.
  20114. */
  20115. groundColor: Color3;
  20116. /**
  20117. * The light reflection direction, not the incoming direction.
  20118. */
  20119. direction: Vector3;
  20120. /**
  20121. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20122. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20123. * The HemisphericLight can't cast shadows.
  20124. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20125. * @param name The friendly name of the light
  20126. * @param direction The direction of the light reflection
  20127. * @param scene The scene the light belongs to
  20128. */
  20129. constructor(name: string, direction: Vector3, scene: Scene);
  20130. protected _buildUniformLayout(): void;
  20131. /**
  20132. * Returns the string "HemisphericLight".
  20133. * @return The class name
  20134. */
  20135. getClassName(): string;
  20136. /**
  20137. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20138. * Returns the updated direction.
  20139. * @param target The target the direction should point to
  20140. * @return The computed direction
  20141. */
  20142. setDirectionToTarget(target: Vector3): Vector3;
  20143. /**
  20144. * Returns the shadow generator associated to the light.
  20145. * @returns Always null for hemispheric lights because it does not support shadows.
  20146. */
  20147. getShadowGenerator(): Nullable<IShadowGenerator>;
  20148. /**
  20149. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20150. * @param effect The effect to update
  20151. * @param lightIndex The index of the light in the effect to update
  20152. * @returns The hemispheric light
  20153. */
  20154. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20155. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20156. /**
  20157. * Computes the world matrix of the node
  20158. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20159. * @param useWasUpdatedFlag defines a reserved property
  20160. * @returns the world matrix
  20161. */
  20162. computeWorldMatrix(): Matrix;
  20163. /**
  20164. * Returns the integer 3.
  20165. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20166. */
  20167. getTypeID(): number;
  20168. /**
  20169. * Prepares the list of defines specific to the light type.
  20170. * @param defines the list of defines
  20171. * @param lightIndex defines the index of the light for the effect
  20172. */
  20173. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20174. }
  20175. }
  20176. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20177. /** @hidden */
  20178. export var vrMultiviewToSingleviewPixelShader: {
  20179. name: string;
  20180. shader: string;
  20181. };
  20182. }
  20183. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20184. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20185. import { Scene } from "babylonjs/scene";
  20186. /**
  20187. * Renders to multiple views with a single draw call
  20188. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20189. */
  20190. export class MultiviewRenderTarget extends RenderTargetTexture {
  20191. /**
  20192. * Creates a multiview render target
  20193. * @param scene scene used with the render target
  20194. * @param size the size of the render target (used for each view)
  20195. */
  20196. constructor(scene: Scene, size?: number | {
  20197. width: number;
  20198. height: number;
  20199. } | {
  20200. ratio: number;
  20201. });
  20202. /**
  20203. * @hidden
  20204. * @param faceIndex the face index, if its a cube texture
  20205. */
  20206. _bindFrameBuffer(faceIndex?: number): void;
  20207. /**
  20208. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20209. * @returns the view count
  20210. */
  20211. getViewCount(): number;
  20212. }
  20213. }
  20214. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20215. import { Camera } from "babylonjs/Cameras/camera";
  20216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20217. import { Nullable } from "babylonjs/types";
  20218. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20219. import { Matrix } from "babylonjs/Maths/math.vector";
  20220. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20221. module "babylonjs/Engines/engine" {
  20222. interface Engine {
  20223. /**
  20224. * Creates a new multiview render target
  20225. * @param width defines the width of the texture
  20226. * @param height defines the height of the texture
  20227. * @returns the created multiview texture
  20228. */
  20229. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20230. /**
  20231. * Binds a multiview framebuffer to be drawn to
  20232. * @param multiviewTexture texture to bind
  20233. */
  20234. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20235. }
  20236. }
  20237. module "babylonjs/Cameras/camera" {
  20238. interface Camera {
  20239. /**
  20240. * @hidden
  20241. * 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)
  20242. */
  20243. _useMultiviewToSingleView: boolean;
  20244. /**
  20245. * @hidden
  20246. * 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)
  20247. */
  20248. _multiviewTexture: Nullable<RenderTargetTexture>;
  20249. /**
  20250. * @hidden
  20251. * ensures the multiview texture of the camera exists and has the specified width/height
  20252. * @param width height to set on the multiview texture
  20253. * @param height width to set on the multiview texture
  20254. */
  20255. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20256. }
  20257. }
  20258. module "babylonjs/scene" {
  20259. interface Scene {
  20260. /** @hidden */
  20261. _transformMatrixR: Matrix;
  20262. /** @hidden */
  20263. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20264. /** @hidden */
  20265. _createMultiviewUbo(): void;
  20266. /** @hidden */
  20267. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20268. /** @hidden */
  20269. _renderMultiviewToSingleView(camera: Camera): void;
  20270. }
  20271. }
  20272. }
  20273. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20274. import { Camera } from "babylonjs/Cameras/camera";
  20275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20276. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20277. import "babylonjs/Engines/Extensions/engine.multiview";
  20278. /**
  20279. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20280. * This will not be used for webXR as it supports displaying texture arrays directly
  20281. */
  20282. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20283. /**
  20284. * Initializes a VRMultiviewToSingleview
  20285. * @param name name of the post process
  20286. * @param camera camera to be applied to
  20287. * @param scaleFactor scaling factor to the size of the output texture
  20288. */
  20289. constructor(name: string, camera: Camera, scaleFactor: number);
  20290. }
  20291. }
  20292. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20293. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20294. import { Nullable } from "babylonjs/types";
  20295. import { Size } from "babylonjs/Maths/math.size";
  20296. import { Observable } from "babylonjs/Misc/observable";
  20297. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20298. /**
  20299. * Interface used to define additional presentation attributes
  20300. */
  20301. export interface IVRPresentationAttributes {
  20302. /**
  20303. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20304. */
  20305. highRefreshRate: boolean;
  20306. /**
  20307. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20308. */
  20309. foveationLevel: number;
  20310. }
  20311. module "babylonjs/Engines/engine" {
  20312. interface Engine {
  20313. /** @hidden */
  20314. _vrDisplay: any;
  20315. /** @hidden */
  20316. _vrSupported: boolean;
  20317. /** @hidden */
  20318. _oldSize: Size;
  20319. /** @hidden */
  20320. _oldHardwareScaleFactor: number;
  20321. /** @hidden */
  20322. _vrExclusivePointerMode: boolean;
  20323. /** @hidden */
  20324. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20325. /** @hidden */
  20326. _onVRDisplayPointerRestricted: () => void;
  20327. /** @hidden */
  20328. _onVRDisplayPointerUnrestricted: () => void;
  20329. /** @hidden */
  20330. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20331. /** @hidden */
  20332. _onVrDisplayDisconnect: Nullable<() => void>;
  20333. /** @hidden */
  20334. _onVrDisplayPresentChange: Nullable<() => void>;
  20335. /**
  20336. * Observable signaled when VR display mode changes
  20337. */
  20338. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20339. /**
  20340. * Observable signaled when VR request present is complete
  20341. */
  20342. onVRRequestPresentComplete: Observable<boolean>;
  20343. /**
  20344. * Observable signaled when VR request present starts
  20345. */
  20346. onVRRequestPresentStart: Observable<Engine>;
  20347. /**
  20348. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20349. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20350. */
  20351. isInVRExclusivePointerMode: boolean;
  20352. /**
  20353. * Gets a boolean indicating if a webVR device was detected
  20354. * @returns true if a webVR device was detected
  20355. */
  20356. isVRDevicePresent(): boolean;
  20357. /**
  20358. * Gets the current webVR device
  20359. * @returns the current webVR device (or null)
  20360. */
  20361. getVRDevice(): any;
  20362. /**
  20363. * Initializes a webVR display and starts listening to display change events
  20364. * The onVRDisplayChangedObservable will be notified upon these changes
  20365. * @returns A promise containing a VRDisplay and if vr is supported
  20366. */
  20367. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20368. /** @hidden */
  20369. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20370. /**
  20371. * Gets or sets the presentation attributes used to configure VR rendering
  20372. */
  20373. vrPresentationAttributes?: IVRPresentationAttributes;
  20374. /**
  20375. * Call this function to switch to webVR mode
  20376. * Will do nothing if webVR is not supported or if there is no webVR device
  20377. * @param options the webvr options provided to the camera. mainly used for multiview
  20378. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20379. */
  20380. enableVR(options: WebVROptions): void;
  20381. /** @hidden */
  20382. _onVRFullScreenTriggered(): void;
  20383. }
  20384. }
  20385. }
  20386. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20387. import { Nullable } from "babylonjs/types";
  20388. import { Observable } from "babylonjs/Misc/observable";
  20389. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20390. import { Scene } from "babylonjs/scene";
  20391. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20392. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20393. import { Node } from "babylonjs/node";
  20394. import { Ray } from "babylonjs/Culling/ray";
  20395. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20396. import "babylonjs/Engines/Extensions/engine.webVR";
  20397. /**
  20398. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20399. * IMPORTANT!! The data is right-hand data.
  20400. * @export
  20401. * @interface DevicePose
  20402. */
  20403. export interface DevicePose {
  20404. /**
  20405. * The position of the device, values in array are [x,y,z].
  20406. */
  20407. readonly position: Nullable<Float32Array>;
  20408. /**
  20409. * The linearVelocity of the device, values in array are [x,y,z].
  20410. */
  20411. readonly linearVelocity: Nullable<Float32Array>;
  20412. /**
  20413. * The linearAcceleration of the device, values in array are [x,y,z].
  20414. */
  20415. readonly linearAcceleration: Nullable<Float32Array>;
  20416. /**
  20417. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20418. */
  20419. readonly orientation: Nullable<Float32Array>;
  20420. /**
  20421. * The angularVelocity of the device, values in array are [x,y,z].
  20422. */
  20423. readonly angularVelocity: Nullable<Float32Array>;
  20424. /**
  20425. * The angularAcceleration of the device, values in array are [x,y,z].
  20426. */
  20427. readonly angularAcceleration: Nullable<Float32Array>;
  20428. }
  20429. /**
  20430. * Interface representing a pose controlled object in Babylon.
  20431. * A pose controlled object has both regular pose values as well as pose values
  20432. * from an external device such as a VR head mounted display
  20433. */
  20434. export interface PoseControlled {
  20435. /**
  20436. * The position of the object in babylon space.
  20437. */
  20438. position: Vector3;
  20439. /**
  20440. * The rotation quaternion of the object in babylon space.
  20441. */
  20442. rotationQuaternion: Quaternion;
  20443. /**
  20444. * The position of the device in babylon space.
  20445. */
  20446. devicePosition?: Vector3;
  20447. /**
  20448. * The rotation quaternion of the device in babylon space.
  20449. */
  20450. deviceRotationQuaternion: Quaternion;
  20451. /**
  20452. * The raw pose coming from the device.
  20453. */
  20454. rawPose: Nullable<DevicePose>;
  20455. /**
  20456. * The scale of the device to be used when translating from device space to babylon space.
  20457. */
  20458. deviceScaleFactor: number;
  20459. /**
  20460. * Updates the poseControlled values based on the input device pose.
  20461. * @param poseData the pose data to update the object with
  20462. */
  20463. updateFromDevice(poseData: DevicePose): void;
  20464. }
  20465. /**
  20466. * Set of options to customize the webVRCamera
  20467. */
  20468. export interface WebVROptions {
  20469. /**
  20470. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20471. */
  20472. trackPosition?: boolean;
  20473. /**
  20474. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20475. */
  20476. positionScale?: number;
  20477. /**
  20478. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20479. */
  20480. displayName?: string;
  20481. /**
  20482. * Should the native controller meshes be initialized. (default: true)
  20483. */
  20484. controllerMeshes?: boolean;
  20485. /**
  20486. * Creating a default HemiLight only on controllers. (default: true)
  20487. */
  20488. defaultLightingOnControllers?: boolean;
  20489. /**
  20490. * If you don't want to use the default VR button of the helper. (default: false)
  20491. */
  20492. useCustomVRButton?: boolean;
  20493. /**
  20494. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20495. */
  20496. customVRButton?: HTMLButtonElement;
  20497. /**
  20498. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20499. */
  20500. rayLength?: number;
  20501. /**
  20502. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20503. */
  20504. defaultHeight?: number;
  20505. /**
  20506. * If multiview should be used if availible (default: false)
  20507. */
  20508. useMultiview?: boolean;
  20509. }
  20510. /**
  20511. * This represents a WebVR camera.
  20512. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20513. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20514. */
  20515. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20516. private webVROptions;
  20517. /**
  20518. * @hidden
  20519. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20520. */
  20521. _vrDevice: any;
  20522. /**
  20523. * The rawPose of the vrDevice.
  20524. */
  20525. rawPose: Nullable<DevicePose>;
  20526. private _onVREnabled;
  20527. private _specsVersion;
  20528. private _attached;
  20529. private _frameData;
  20530. protected _descendants: Array<Node>;
  20531. private _deviceRoomPosition;
  20532. /** @hidden */
  20533. _deviceRoomRotationQuaternion: Quaternion;
  20534. private _standingMatrix;
  20535. /**
  20536. * Represents device position in babylon space.
  20537. */
  20538. devicePosition: Vector3;
  20539. /**
  20540. * Represents device rotation in babylon space.
  20541. */
  20542. deviceRotationQuaternion: Quaternion;
  20543. /**
  20544. * The scale of the device to be used when translating from device space to babylon space.
  20545. */
  20546. deviceScaleFactor: number;
  20547. private _deviceToWorld;
  20548. private _worldToDevice;
  20549. /**
  20550. * References to the webVR controllers for the vrDevice.
  20551. */
  20552. controllers: Array<WebVRController>;
  20553. /**
  20554. * Emits an event when a controller is attached.
  20555. */
  20556. onControllersAttachedObservable: Observable<WebVRController[]>;
  20557. /**
  20558. * Emits an event when a controller's mesh has been loaded;
  20559. */
  20560. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20561. /**
  20562. * Emits an event when the HMD's pose has been updated.
  20563. */
  20564. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20565. private _poseSet;
  20566. /**
  20567. * If the rig cameras be used as parent instead of this camera.
  20568. */
  20569. rigParenting: boolean;
  20570. private _lightOnControllers;
  20571. private _defaultHeight?;
  20572. /**
  20573. * Instantiates a WebVRFreeCamera.
  20574. * @param name The name of the WebVRFreeCamera
  20575. * @param position The starting anchor position for the camera
  20576. * @param scene The scene the camera belongs to
  20577. * @param webVROptions a set of customizable options for the webVRCamera
  20578. */
  20579. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20580. /**
  20581. * Gets the device distance from the ground in meters.
  20582. * @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.
  20583. */
  20584. deviceDistanceToRoomGround(): number;
  20585. /**
  20586. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20587. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20588. */
  20589. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20590. /**
  20591. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20592. * @returns A promise with a boolean set to if the standing matrix is supported.
  20593. */
  20594. useStandingMatrixAsync(): Promise<boolean>;
  20595. /**
  20596. * Disposes the camera
  20597. */
  20598. dispose(): void;
  20599. /**
  20600. * Gets a vrController by name.
  20601. * @param name The name of the controller to retreive
  20602. * @returns the controller matching the name specified or null if not found
  20603. */
  20604. getControllerByName(name: string): Nullable<WebVRController>;
  20605. private _leftController;
  20606. /**
  20607. * The controller corresponding to the users left hand.
  20608. */
  20609. get leftController(): Nullable<WebVRController>;
  20610. private _rightController;
  20611. /**
  20612. * The controller corresponding to the users right hand.
  20613. */
  20614. get rightController(): Nullable<WebVRController>;
  20615. /**
  20616. * Casts a ray forward from the vrCamera's gaze.
  20617. * @param length Length of the ray (default: 100)
  20618. * @returns the ray corresponding to the gaze
  20619. */
  20620. getForwardRay(length?: number): Ray;
  20621. /**
  20622. * @hidden
  20623. * Updates the camera based on device's frame data
  20624. */
  20625. _checkInputs(): void;
  20626. /**
  20627. * Updates the poseControlled values based on the input device pose.
  20628. * @param poseData Pose coming from the device
  20629. */
  20630. updateFromDevice(poseData: DevicePose): void;
  20631. private _htmlElementAttached;
  20632. private _detachIfAttached;
  20633. /**
  20634. * WebVR's attach control will start broadcasting frames to the device.
  20635. * Note that in certain browsers (chrome for example) this function must be called
  20636. * within a user-interaction callback. Example:
  20637. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20638. *
  20639. * @param element html element to attach the vrDevice to
  20640. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20641. */
  20642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20643. /**
  20644. * Detaches the camera from the html element and disables VR
  20645. *
  20646. * @param element html element to detach from
  20647. */
  20648. detachControl(element: HTMLElement): void;
  20649. /**
  20650. * @returns the name of this class
  20651. */
  20652. getClassName(): string;
  20653. /**
  20654. * Calls resetPose on the vrDisplay
  20655. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20656. */
  20657. resetToCurrentRotation(): void;
  20658. /**
  20659. * @hidden
  20660. * Updates the rig cameras (left and right eye)
  20661. */
  20662. _updateRigCameras(): void;
  20663. private _workingVector;
  20664. private _oneVector;
  20665. private _workingMatrix;
  20666. private updateCacheCalled;
  20667. private _correctPositionIfNotTrackPosition;
  20668. /**
  20669. * @hidden
  20670. * Updates the cached values of the camera
  20671. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20672. */
  20673. _updateCache(ignoreParentClass?: boolean): void;
  20674. /**
  20675. * @hidden
  20676. * Get current device position in babylon world
  20677. */
  20678. _computeDevicePosition(): void;
  20679. /**
  20680. * Updates the current device position and rotation in the babylon world
  20681. */
  20682. update(): void;
  20683. /**
  20684. * @hidden
  20685. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20686. * @returns an identity matrix
  20687. */
  20688. _getViewMatrix(): Matrix;
  20689. private _tmpMatrix;
  20690. /**
  20691. * This function is called by the two RIG cameras.
  20692. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20693. * @hidden
  20694. */
  20695. _getWebVRViewMatrix(): Matrix;
  20696. /** @hidden */
  20697. _getWebVRProjectionMatrix(): Matrix;
  20698. private _onGamepadConnectedObserver;
  20699. private _onGamepadDisconnectedObserver;
  20700. private _updateCacheWhenTrackingDisabledObserver;
  20701. /**
  20702. * Initializes the controllers and their meshes
  20703. */
  20704. initControllers(): void;
  20705. }
  20706. }
  20707. declare module "babylonjs/Materials/materialHelper" {
  20708. import { Nullable } from "babylonjs/types";
  20709. import { Scene } from "babylonjs/scene";
  20710. import { Engine } from "babylonjs/Engines/engine";
  20711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20712. import { Light } from "babylonjs/Lights/light";
  20713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20714. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20716. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20717. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20718. /**
  20719. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20720. *
  20721. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20722. *
  20723. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20724. */
  20725. export class MaterialHelper {
  20726. /**
  20727. * Bind the current view position to an effect.
  20728. * @param effect The effect to be bound
  20729. * @param scene The scene the eyes position is used from
  20730. * @param variableName name of the shader variable that will hold the eye position
  20731. */
  20732. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20733. /**
  20734. * Helps preparing the defines values about the UVs in used in the effect.
  20735. * UVs are shared as much as we can accross channels in the shaders.
  20736. * @param texture The texture we are preparing the UVs for
  20737. * @param defines The defines to update
  20738. * @param key The channel key "diffuse", "specular"... used in the shader
  20739. */
  20740. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20741. /**
  20742. * Binds a texture matrix value to its corrsponding uniform
  20743. * @param texture The texture to bind the matrix for
  20744. * @param uniformBuffer The uniform buffer receivin the data
  20745. * @param key The channel key "diffuse", "specular"... used in the shader
  20746. */
  20747. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20748. /**
  20749. * Gets the current status of the fog (should it be enabled?)
  20750. * @param mesh defines the mesh to evaluate for fog support
  20751. * @param scene defines the hosting scene
  20752. * @returns true if fog must be enabled
  20753. */
  20754. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20755. /**
  20756. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20757. * @param mesh defines the current mesh
  20758. * @param scene defines the current scene
  20759. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20760. * @param pointsCloud defines if point cloud rendering has to be turned on
  20761. * @param fogEnabled defines if fog has to be turned on
  20762. * @param alphaTest defines if alpha testing has to be turned on
  20763. * @param defines defines the current list of defines
  20764. */
  20765. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20766. /**
  20767. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20768. * @param scene defines the current scene
  20769. * @param engine defines the current engine
  20770. * @param defines specifies the list of active defines
  20771. * @param useInstances defines if instances have to be turned on
  20772. * @param useClipPlane defines if clip plane have to be turned on
  20773. * @param useInstances defines if instances have to be turned on
  20774. * @param useThinInstances defines if thin instances have to be turned on
  20775. */
  20776. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20777. /**
  20778. * Prepares the defines for bones
  20779. * @param mesh The mesh containing the geometry data we will draw
  20780. * @param defines The defines to update
  20781. */
  20782. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20783. /**
  20784. * Prepares the defines for morph targets
  20785. * @param mesh The mesh containing the geometry data we will draw
  20786. * @param defines The defines to update
  20787. */
  20788. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20789. /**
  20790. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20791. * @param mesh The mesh containing the geometry data we will draw
  20792. * @param defines The defines to update
  20793. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20794. * @param useBones Precise whether bones should be used or not (override mesh info)
  20795. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20796. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20797. * @returns false if defines are considered not dirty and have not been checked
  20798. */
  20799. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20800. /**
  20801. * Prepares the defines related to multiview
  20802. * @param scene The scene we are intending to draw
  20803. * @param defines The defines to update
  20804. */
  20805. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20806. /**
  20807. * Prepares the defines related to the prepass
  20808. * @param scene The scene we are intending to draw
  20809. * @param defines The defines to update
  20810. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20811. */
  20812. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20813. /**
  20814. * Prepares the defines related to the light information passed in parameter
  20815. * @param scene The scene we are intending to draw
  20816. * @param mesh The mesh the effect is compiling for
  20817. * @param light The light the effect is compiling for
  20818. * @param lightIndex The index of the light
  20819. * @param defines The defines to update
  20820. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20821. * @param state Defines the current state regarding what is needed (normals, etc...)
  20822. */
  20823. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20824. needNormals: boolean;
  20825. needRebuild: boolean;
  20826. shadowEnabled: boolean;
  20827. specularEnabled: boolean;
  20828. lightmapMode: boolean;
  20829. }): void;
  20830. /**
  20831. * Prepares the defines related to the light information passed in parameter
  20832. * @param scene The scene we are intending to draw
  20833. * @param mesh The mesh the effect is compiling for
  20834. * @param defines The defines to update
  20835. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20836. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20837. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20838. * @returns true if normals will be required for the rest of the effect
  20839. */
  20840. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20841. /**
  20842. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20843. * @param lightIndex defines the light index
  20844. * @param uniformsList The uniform list
  20845. * @param samplersList The sampler list
  20846. * @param projectedLightTexture defines if projected texture must be used
  20847. * @param uniformBuffersList defines an optional list of uniform buffers
  20848. */
  20849. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20850. /**
  20851. * Prepares the uniforms and samplers list to be used in the effect
  20852. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20853. * @param samplersList The sampler list
  20854. * @param defines The defines helping in the list generation
  20855. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20856. */
  20857. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20858. /**
  20859. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20860. * @param defines The defines to update while falling back
  20861. * @param fallbacks The authorized effect fallbacks
  20862. * @param maxSimultaneousLights The maximum number of lights allowed
  20863. * @param rank the current rank of the Effect
  20864. * @returns The newly affected rank
  20865. */
  20866. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20867. private static _TmpMorphInfluencers;
  20868. /**
  20869. * Prepares the list of attributes required for morph targets according to the effect defines.
  20870. * @param attribs The current list of supported attribs
  20871. * @param mesh The mesh to prepare the morph targets attributes for
  20872. * @param influencers The number of influencers
  20873. */
  20874. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20875. /**
  20876. * Prepares the list of attributes required for morph targets according to the effect defines.
  20877. * @param attribs The current list of supported attribs
  20878. * @param mesh The mesh to prepare the morph targets attributes for
  20879. * @param defines The current Defines of the effect
  20880. */
  20881. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20882. /**
  20883. * Prepares the list of attributes required for bones according to the effect defines.
  20884. * @param attribs The current list of supported attribs
  20885. * @param mesh The mesh to prepare the bones attributes for
  20886. * @param defines The current Defines of the effect
  20887. * @param fallbacks The current efffect fallback strategy
  20888. */
  20889. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20890. /**
  20891. * Check and prepare the list of attributes required for instances according to the effect defines.
  20892. * @param attribs The current list of supported attribs
  20893. * @param defines The current MaterialDefines of the effect
  20894. */
  20895. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20896. /**
  20897. * Add the list of attributes required for instances to the attribs array.
  20898. * @param attribs The current list of supported attribs
  20899. */
  20900. static PushAttributesForInstances(attribs: string[]): void;
  20901. /**
  20902. * Binds the light information to the effect.
  20903. * @param light The light containing the generator
  20904. * @param effect The effect we are binding the data to
  20905. * @param lightIndex The light index in the effect used to render
  20906. */
  20907. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20908. /**
  20909. * Binds the lights information from the scene to the effect for the given mesh.
  20910. * @param light Light to bind
  20911. * @param lightIndex Light index
  20912. * @param scene The scene where the light belongs to
  20913. * @param effect The effect we are binding the data to
  20914. * @param useSpecular Defines if specular is supported
  20915. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20916. */
  20917. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20918. /**
  20919. * Binds the lights information from the scene to the effect for the given mesh.
  20920. * @param scene The scene the lights belongs to
  20921. * @param mesh The mesh we are binding the information to render
  20922. * @param effect The effect we are binding the data to
  20923. * @param defines The generated defines for the effect
  20924. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20925. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20926. */
  20927. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20928. private static _tempFogColor;
  20929. /**
  20930. * Binds the fog information from the scene to the effect for the given mesh.
  20931. * @param scene The scene the lights belongs to
  20932. * @param mesh The mesh we are binding the information to render
  20933. * @param effect The effect we are binding the data to
  20934. * @param linearSpace Defines if the fog effect is applied in linear space
  20935. */
  20936. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20937. /**
  20938. * Binds the bones information from the mesh to the effect.
  20939. * @param mesh The mesh we are binding the information to render
  20940. * @param effect The effect we are binding the data to
  20941. */
  20942. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20943. /**
  20944. * Binds the morph targets information from the mesh to the effect.
  20945. * @param abstractMesh The mesh we are binding the information to render
  20946. * @param effect The effect we are binding the data to
  20947. */
  20948. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20949. /**
  20950. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20951. * @param defines The generated defines used in the effect
  20952. * @param effect The effect we are binding the data to
  20953. * @param scene The scene we are willing to render with logarithmic scale for
  20954. */
  20955. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20956. /**
  20957. * Binds the clip plane information from the scene to the effect.
  20958. * @param scene The scene the clip plane information are extracted from
  20959. * @param effect The effect we are binding the data to
  20960. */
  20961. static BindClipPlane(effect: Effect, scene: Scene): void;
  20962. }
  20963. }
  20964. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20966. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20967. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20968. import { Nullable } from "babylonjs/types";
  20969. import { Effect } from "babylonjs/Materials/effect";
  20970. import { Matrix } from "babylonjs/Maths/math.vector";
  20971. import { Scene } from "babylonjs/scene";
  20972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20974. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20975. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20976. import { Observable } from "babylonjs/Misc/observable";
  20977. /**
  20978. * Block used to expose an input value
  20979. */
  20980. export class InputBlock extends NodeMaterialBlock {
  20981. private _mode;
  20982. private _associatedVariableName;
  20983. private _storedValue;
  20984. private _valueCallback;
  20985. private _type;
  20986. private _animationType;
  20987. /** Gets or set a value used to limit the range of float values */
  20988. min: number;
  20989. /** Gets or set a value used to limit the range of float values */
  20990. max: number;
  20991. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20992. isBoolean: boolean;
  20993. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20994. matrixMode: number;
  20995. /** @hidden */
  20996. _systemValue: Nullable<NodeMaterialSystemValues>;
  20997. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20998. visibleInInspector: boolean;
  20999. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21000. isConstant: boolean;
  21001. /** Gets or sets the group to use to display this block in the Inspector */
  21002. groupInInspector: string;
  21003. /** Gets an observable raised when the value is changed */
  21004. onValueChangedObservable: Observable<InputBlock>;
  21005. /**
  21006. * Gets or sets the connection point type (default is float)
  21007. */
  21008. get type(): NodeMaterialBlockConnectionPointTypes;
  21009. /**
  21010. * Creates a new InputBlock
  21011. * @param name defines the block name
  21012. * @param target defines the target of that block (Vertex by default)
  21013. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21014. */
  21015. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21016. /**
  21017. * Validates if a name is a reserve word.
  21018. * @param newName the new name to be given to the node.
  21019. * @returns false if the name is a reserve word, else true.
  21020. */
  21021. validateBlockName(newName: string): boolean;
  21022. /**
  21023. * Gets the output component
  21024. */
  21025. get output(): NodeMaterialConnectionPoint;
  21026. /**
  21027. * Set the source of this connection point to a vertex attribute
  21028. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21029. * @returns the current connection point
  21030. */
  21031. setAsAttribute(attributeName?: string): InputBlock;
  21032. /**
  21033. * Set the source of this connection point to a system value
  21034. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21035. * @returns the current connection point
  21036. */
  21037. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21038. /**
  21039. * Gets or sets the value of that point.
  21040. * Please note that this value will be ignored if valueCallback is defined
  21041. */
  21042. get value(): any;
  21043. set value(value: any);
  21044. /**
  21045. * Gets or sets a callback used to get the value of that point.
  21046. * Please note that setting this value will force the connection point to ignore the value property
  21047. */
  21048. get valueCallback(): () => any;
  21049. set valueCallback(value: () => any);
  21050. /**
  21051. * Gets or sets the associated variable name in the shader
  21052. */
  21053. get associatedVariableName(): string;
  21054. set associatedVariableName(value: string);
  21055. /** Gets or sets the type of animation applied to the input */
  21056. get animationType(): AnimatedInputBlockTypes;
  21057. set animationType(value: AnimatedInputBlockTypes);
  21058. /**
  21059. * Gets a boolean indicating that this connection point not defined yet
  21060. */
  21061. get isUndefined(): boolean;
  21062. /**
  21063. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21064. * In this case the connection point name must be the name of the uniform to use.
  21065. * Can only be set on inputs
  21066. */
  21067. get isUniform(): boolean;
  21068. set isUniform(value: boolean);
  21069. /**
  21070. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21071. * In this case the connection point name must be the name of the attribute to use
  21072. * Can only be set on inputs
  21073. */
  21074. get isAttribute(): boolean;
  21075. set isAttribute(value: boolean);
  21076. /**
  21077. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21078. * Can only be set on exit points
  21079. */
  21080. get isVarying(): boolean;
  21081. set isVarying(value: boolean);
  21082. /**
  21083. * Gets a boolean indicating that the current connection point is a system value
  21084. */
  21085. get isSystemValue(): boolean;
  21086. /**
  21087. * Gets or sets the current well known value or null if not defined as a system value
  21088. */
  21089. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21090. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21091. /**
  21092. * Gets the current class name
  21093. * @returns the class name
  21094. */
  21095. getClassName(): string;
  21096. /**
  21097. * Animate the input if animationType !== None
  21098. * @param scene defines the rendering scene
  21099. */
  21100. animate(scene: Scene): void;
  21101. private _emitDefine;
  21102. initialize(state: NodeMaterialBuildState): void;
  21103. /**
  21104. * Set the input block to its default value (based on its type)
  21105. */
  21106. setDefaultValue(): void;
  21107. private _emitConstant;
  21108. /** @hidden */
  21109. get _noContextSwitch(): boolean;
  21110. private _emit;
  21111. /** @hidden */
  21112. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21113. /** @hidden */
  21114. _transmit(effect: Effect, scene: Scene): void;
  21115. protected _buildBlock(state: NodeMaterialBuildState): void;
  21116. protected _dumpPropertiesCode(): string;
  21117. dispose(): void;
  21118. serialize(): any;
  21119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21120. }
  21121. }
  21122. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21123. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21124. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21125. import { Nullable } from "babylonjs/types";
  21126. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21127. import { Observable } from "babylonjs/Misc/observable";
  21128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21129. /**
  21130. * Enum used to define the compatibility state between two connection points
  21131. */
  21132. export enum NodeMaterialConnectionPointCompatibilityStates {
  21133. /** Points are compatibles */
  21134. Compatible = 0,
  21135. /** Points are incompatible because of their types */
  21136. TypeIncompatible = 1,
  21137. /** Points are incompatible because of their targets (vertex vs fragment) */
  21138. TargetIncompatible = 2
  21139. }
  21140. /**
  21141. * Defines the direction of a connection point
  21142. */
  21143. export enum NodeMaterialConnectionPointDirection {
  21144. /** Input */
  21145. Input = 0,
  21146. /** Output */
  21147. Output = 1
  21148. }
  21149. /**
  21150. * Defines a connection point for a block
  21151. */
  21152. export class NodeMaterialConnectionPoint {
  21153. /** @hidden */
  21154. _ownerBlock: NodeMaterialBlock;
  21155. /** @hidden */
  21156. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21157. private _endpoints;
  21158. private _associatedVariableName;
  21159. private _direction;
  21160. /** @hidden */
  21161. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21162. /** @hidden */
  21163. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21164. private _type;
  21165. /** @hidden */
  21166. _enforceAssociatedVariableName: boolean;
  21167. /** Gets the direction of the point */
  21168. get direction(): NodeMaterialConnectionPointDirection;
  21169. /** Indicates that this connection point needs dual validation before being connected to another point */
  21170. needDualDirectionValidation: boolean;
  21171. /**
  21172. * Gets or sets the additional types supported by this connection point
  21173. */
  21174. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21175. /**
  21176. * Gets or sets the additional types excluded by this connection point
  21177. */
  21178. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21179. /**
  21180. * Observable triggered when this point is connected
  21181. */
  21182. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21183. /**
  21184. * Gets or sets the associated variable name in the shader
  21185. */
  21186. get associatedVariableName(): string;
  21187. set associatedVariableName(value: string);
  21188. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21189. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21190. /**
  21191. * Gets or sets the connection point type (default is float)
  21192. */
  21193. get type(): NodeMaterialBlockConnectionPointTypes;
  21194. set type(value: NodeMaterialBlockConnectionPointTypes);
  21195. /**
  21196. * Gets or sets the connection point name
  21197. */
  21198. name: string;
  21199. /**
  21200. * Gets or sets the connection point name
  21201. */
  21202. displayName: string;
  21203. /**
  21204. * Gets or sets a boolean indicating that this connection point can be omitted
  21205. */
  21206. isOptional: boolean;
  21207. /**
  21208. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21209. */
  21210. isExposedOnFrame: boolean;
  21211. /**
  21212. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21213. */
  21214. define: string;
  21215. /** @hidden */
  21216. _prioritizeVertex: boolean;
  21217. private _target;
  21218. /** Gets or sets the target of that connection point */
  21219. get target(): NodeMaterialBlockTargets;
  21220. set target(value: NodeMaterialBlockTargets);
  21221. /**
  21222. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21223. */
  21224. get isConnected(): boolean;
  21225. /**
  21226. * Gets a boolean indicating that the current point is connected to an input block
  21227. */
  21228. get isConnectedToInputBlock(): boolean;
  21229. /**
  21230. * Gets a the connected input block (if any)
  21231. */
  21232. get connectInputBlock(): Nullable<InputBlock>;
  21233. /** Get the other side of the connection (if any) */
  21234. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21235. /** Get the block that owns this connection point */
  21236. get ownerBlock(): NodeMaterialBlock;
  21237. /** Get the block connected on the other side of this connection (if any) */
  21238. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21239. /** Get the block connected on the endpoints of this connection (if any) */
  21240. get connectedBlocks(): Array<NodeMaterialBlock>;
  21241. /** Gets the list of connected endpoints */
  21242. get endpoints(): NodeMaterialConnectionPoint[];
  21243. /** Gets a boolean indicating if that output point is connected to at least one input */
  21244. get hasEndpoints(): boolean;
  21245. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21246. get isConnectedInVertexShader(): boolean;
  21247. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21248. get isConnectedInFragmentShader(): boolean;
  21249. /**
  21250. * Creates a block suitable to be used as an input for this input point.
  21251. * If null is returned, a block based on the point type will be created.
  21252. * @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
  21253. */
  21254. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21255. /**
  21256. * Creates a new connection point
  21257. * @param name defines the connection point name
  21258. * @param ownerBlock defines the block hosting this connection point
  21259. * @param direction defines the direction of the connection point
  21260. */
  21261. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21262. /**
  21263. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21264. * @returns the class name
  21265. */
  21266. getClassName(): string;
  21267. /**
  21268. * Gets a boolean indicating if the current point can be connected to another point
  21269. * @param connectionPoint defines the other connection point
  21270. * @returns a boolean
  21271. */
  21272. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21273. /**
  21274. * Gets a number indicating if the current point can be connected to another point
  21275. * @param connectionPoint defines the other connection point
  21276. * @returns a number defining the compatibility state
  21277. */
  21278. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21279. /**
  21280. * Connect this point to another connection point
  21281. * @param connectionPoint defines the other connection point
  21282. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21283. * @returns the current connection point
  21284. */
  21285. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Disconnect this point from one of his endpoint
  21288. * @param endpoint defines the other connection point
  21289. * @returns the current connection point
  21290. */
  21291. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21292. /**
  21293. * Serializes this point in a JSON representation
  21294. * @param isInput defines if the connection point is an input (default is true)
  21295. * @returns the serialized point object
  21296. */
  21297. serialize(isInput?: boolean): any;
  21298. /**
  21299. * Release resources
  21300. */
  21301. dispose(): void;
  21302. }
  21303. }
  21304. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21305. /**
  21306. * Enum used to define the material modes
  21307. */
  21308. export enum NodeMaterialModes {
  21309. /** Regular material */
  21310. Material = 0,
  21311. /** For post process */
  21312. PostProcess = 1,
  21313. /** For particle system */
  21314. Particle = 2
  21315. }
  21316. }
  21317. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21320. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21323. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21324. import { Effect } from "babylonjs/Materials/effect";
  21325. import { Mesh } from "babylonjs/Meshes/mesh";
  21326. import { Nullable } from "babylonjs/types";
  21327. import { Texture } from "babylonjs/Materials/Textures/texture";
  21328. import { Scene } from "babylonjs/scene";
  21329. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21330. /**
  21331. * Block used to read a texture from a sampler
  21332. */
  21333. export class TextureBlock extends NodeMaterialBlock {
  21334. private _defineName;
  21335. private _linearDefineName;
  21336. private _gammaDefineName;
  21337. private _tempTextureRead;
  21338. private _samplerName;
  21339. private _transformedUVName;
  21340. private _textureTransformName;
  21341. private _textureInfoName;
  21342. private _mainUVName;
  21343. private _mainUVDefineName;
  21344. private _fragmentOnly;
  21345. /**
  21346. * Gets or sets the texture associated with the node
  21347. */
  21348. texture: Nullable<Texture>;
  21349. /**
  21350. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21351. */
  21352. convertToGammaSpace: boolean;
  21353. /**
  21354. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21355. */
  21356. convertToLinearSpace: boolean;
  21357. /**
  21358. * Create a new TextureBlock
  21359. * @param name defines the block name
  21360. */
  21361. constructor(name: string, fragmentOnly?: boolean);
  21362. /**
  21363. * Gets the current class name
  21364. * @returns the class name
  21365. */
  21366. getClassName(): string;
  21367. /**
  21368. * Gets the uv input component
  21369. */
  21370. get uv(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Gets the rgba output component
  21373. */
  21374. get rgba(): NodeMaterialConnectionPoint;
  21375. /**
  21376. * Gets the rgb output component
  21377. */
  21378. get rgb(): NodeMaterialConnectionPoint;
  21379. /**
  21380. * Gets the r output component
  21381. */
  21382. get r(): NodeMaterialConnectionPoint;
  21383. /**
  21384. * Gets the g output component
  21385. */
  21386. get g(): NodeMaterialConnectionPoint;
  21387. /**
  21388. * Gets the b output component
  21389. */
  21390. get b(): NodeMaterialConnectionPoint;
  21391. /**
  21392. * Gets the a output component
  21393. */
  21394. get a(): NodeMaterialConnectionPoint;
  21395. get target(): NodeMaterialBlockTargets;
  21396. autoConfigure(material: NodeMaterial): void;
  21397. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21399. isReady(): boolean;
  21400. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21401. private get _isMixed();
  21402. private _injectVertexCode;
  21403. private _writeTextureRead;
  21404. private _writeOutput;
  21405. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21406. protected _dumpPropertiesCode(): string;
  21407. serialize(): any;
  21408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21409. }
  21410. }
  21411. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21412. /** @hidden */
  21413. export var reflectionFunction: {
  21414. name: string;
  21415. shader: string;
  21416. };
  21417. }
  21418. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21424. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21425. import { Effect } from "babylonjs/Materials/effect";
  21426. import { Mesh } from "babylonjs/Meshes/mesh";
  21427. import { Nullable } from "babylonjs/types";
  21428. import { Scene } from "babylonjs/scene";
  21429. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21430. /**
  21431. * Base block used to read a reflection texture from a sampler
  21432. */
  21433. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21434. /** @hidden */
  21435. _define3DName: string;
  21436. /** @hidden */
  21437. _defineCubicName: string;
  21438. /** @hidden */
  21439. _defineExplicitName: string;
  21440. /** @hidden */
  21441. _defineProjectionName: string;
  21442. /** @hidden */
  21443. _defineLocalCubicName: string;
  21444. /** @hidden */
  21445. _defineSphericalName: string;
  21446. /** @hidden */
  21447. _definePlanarName: string;
  21448. /** @hidden */
  21449. _defineEquirectangularName: string;
  21450. /** @hidden */
  21451. _defineMirroredEquirectangularFixedName: string;
  21452. /** @hidden */
  21453. _defineEquirectangularFixedName: string;
  21454. /** @hidden */
  21455. _defineSkyboxName: string;
  21456. /** @hidden */
  21457. _defineOppositeZ: string;
  21458. /** @hidden */
  21459. _cubeSamplerName: string;
  21460. /** @hidden */
  21461. _2DSamplerName: string;
  21462. protected _positionUVWName: string;
  21463. protected _directionWName: string;
  21464. protected _reflectionVectorName: string;
  21465. /** @hidden */
  21466. _reflectionCoordsName: string;
  21467. /** @hidden */
  21468. _reflectionMatrixName: string;
  21469. protected _reflectionColorName: string;
  21470. /**
  21471. * Gets or sets the texture associated with the node
  21472. */
  21473. texture: Nullable<BaseTexture>;
  21474. /**
  21475. * Create a new ReflectionTextureBaseBlock
  21476. * @param name defines the block name
  21477. */
  21478. constructor(name: string);
  21479. /**
  21480. * Gets the current class name
  21481. * @returns the class name
  21482. */
  21483. getClassName(): string;
  21484. /**
  21485. * Gets the world position input component
  21486. */
  21487. abstract get position(): NodeMaterialConnectionPoint;
  21488. /**
  21489. * Gets the world position input component
  21490. */
  21491. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21492. /**
  21493. * Gets the world normal input component
  21494. */
  21495. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21496. /**
  21497. * Gets the world input component
  21498. */
  21499. abstract get world(): NodeMaterialConnectionPoint;
  21500. /**
  21501. * Gets the camera (or eye) position component
  21502. */
  21503. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21504. /**
  21505. * Gets the view input component
  21506. */
  21507. abstract get view(): NodeMaterialConnectionPoint;
  21508. protected _getTexture(): Nullable<BaseTexture>;
  21509. autoConfigure(material: NodeMaterial): void;
  21510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21511. isReady(): boolean;
  21512. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21513. /**
  21514. * Gets the code to inject in the vertex shader
  21515. * @param state current state of the node material building
  21516. * @returns the shader code
  21517. */
  21518. handleVertexSide(state: NodeMaterialBuildState): string;
  21519. /**
  21520. * Handles the inits for the fragment code path
  21521. * @param state node material build state
  21522. */
  21523. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21524. /**
  21525. * Generates the reflection coords code for the fragment code path
  21526. * @param worldNormalVarName name of the world normal variable
  21527. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21528. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21529. * @returns the shader code
  21530. */
  21531. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21532. /**
  21533. * Generates the reflection color code for the fragment code path
  21534. * @param lodVarName name of the lod variable
  21535. * @param swizzleLookupTexture swizzle to use for the final color variable
  21536. * @returns the shader code
  21537. */
  21538. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21539. /**
  21540. * Generates the code corresponding to the connected output points
  21541. * @param state node material build state
  21542. * @param varName name of the variable to output
  21543. * @returns the shader code
  21544. */
  21545. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21546. protected _buildBlock(state: NodeMaterialBuildState): this;
  21547. protected _dumpPropertiesCode(): string;
  21548. serialize(): any;
  21549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21550. }
  21551. }
  21552. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21554. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21555. import { Nullable } from "babylonjs/types";
  21556. /**
  21557. * Defines a connection point to be used for points with a custom object type
  21558. */
  21559. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21560. private _blockType;
  21561. private _blockName;
  21562. private _nameForCheking?;
  21563. /**
  21564. * Creates a new connection point
  21565. * @param name defines the connection point name
  21566. * @param ownerBlock defines the block hosting this connection point
  21567. * @param direction defines the direction of the connection point
  21568. */
  21569. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21570. /**
  21571. * Gets a number indicating if the current point can be connected to another point
  21572. * @param connectionPoint defines the other connection point
  21573. * @returns a number defining the compatibility state
  21574. */
  21575. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21576. /**
  21577. * Creates a block suitable to be used as an input for this input point.
  21578. * If null is returned, a block based on the point type will be created.
  21579. * @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
  21580. */
  21581. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21582. }
  21583. }
  21584. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21585. /**
  21586. * Enum defining the type of properties that can be edited in the property pages in the NME
  21587. */
  21588. export enum PropertyTypeForEdition {
  21589. /** property is a boolean */
  21590. Boolean = 0,
  21591. /** property is a float */
  21592. Float = 1,
  21593. /** property is a Vector2 */
  21594. Vector2 = 2,
  21595. /** property is a list of values */
  21596. List = 3
  21597. }
  21598. /**
  21599. * Interface that defines an option in a variable of type list
  21600. */
  21601. export interface IEditablePropertyListOption {
  21602. /** label of the option */
  21603. "label": string;
  21604. /** value of the option */
  21605. "value": number;
  21606. }
  21607. /**
  21608. * Interface that defines the options available for an editable property
  21609. */
  21610. export interface IEditablePropertyOption {
  21611. /** min value */
  21612. "min"?: number;
  21613. /** max value */
  21614. "max"?: number;
  21615. /** notifiers: indicates which actions to take when the property is changed */
  21616. "notifiers"?: {
  21617. /** the material should be rebuilt */
  21618. "rebuild"?: boolean;
  21619. /** the preview should be updated */
  21620. "update"?: boolean;
  21621. };
  21622. /** list of the options for a variable of type list */
  21623. "options"?: IEditablePropertyListOption[];
  21624. }
  21625. /**
  21626. * Interface that describes an editable property
  21627. */
  21628. export interface IPropertyDescriptionForEdition {
  21629. /** name of the property */
  21630. "propertyName": string;
  21631. /** display name of the property */
  21632. "displayName": string;
  21633. /** type of the property */
  21634. "type": PropertyTypeForEdition;
  21635. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21636. "groupName": string;
  21637. /** options for the property */
  21638. "options": IEditablePropertyOption;
  21639. }
  21640. /**
  21641. * Decorator that flags a property in a node material block as being editable
  21642. */
  21643. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21644. }
  21645. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21648. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21650. import { Nullable } from "babylonjs/types";
  21651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21652. import { Mesh } from "babylonjs/Meshes/mesh";
  21653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21654. import { Effect } from "babylonjs/Materials/effect";
  21655. import { Scene } from "babylonjs/scene";
  21656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21657. /**
  21658. * Block used to implement the refraction part of the sub surface module of the PBR material
  21659. */
  21660. export class RefractionBlock extends NodeMaterialBlock {
  21661. /** @hidden */
  21662. _define3DName: string;
  21663. /** @hidden */
  21664. _refractionMatrixName: string;
  21665. /** @hidden */
  21666. _defineLODRefractionAlpha: string;
  21667. /** @hidden */
  21668. _defineLinearSpecularRefraction: string;
  21669. /** @hidden */
  21670. _defineOppositeZ: string;
  21671. /** @hidden */
  21672. _cubeSamplerName: string;
  21673. /** @hidden */
  21674. _2DSamplerName: string;
  21675. /** @hidden */
  21676. _vRefractionMicrosurfaceInfosName: string;
  21677. /** @hidden */
  21678. _vRefractionInfosName: string;
  21679. private _scene;
  21680. /**
  21681. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21682. * Materials half opaque for instance using refraction could benefit from this control.
  21683. */
  21684. linkRefractionWithTransparency: boolean;
  21685. /**
  21686. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21687. */
  21688. invertRefractionY: boolean;
  21689. /**
  21690. * Gets or sets the texture associated with the node
  21691. */
  21692. texture: Nullable<BaseTexture>;
  21693. /**
  21694. * Create a new RefractionBlock
  21695. * @param name defines the block name
  21696. */
  21697. constructor(name: string);
  21698. /**
  21699. * Gets the current class name
  21700. * @returns the class name
  21701. */
  21702. getClassName(): string;
  21703. /**
  21704. * Gets the intensity input component
  21705. */
  21706. get intensity(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the index of refraction input component
  21709. */
  21710. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the tint at distance input component
  21713. */
  21714. get tintAtDistance(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the view input component
  21717. */
  21718. get view(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the refraction object output component
  21721. */
  21722. get refraction(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Returns true if the block has a texture
  21725. */
  21726. get hasTexture(): boolean;
  21727. protected _getTexture(): Nullable<BaseTexture>;
  21728. autoConfigure(material: NodeMaterial): void;
  21729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21730. isReady(): boolean;
  21731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21732. /**
  21733. * Gets the main code of the block (fragment side)
  21734. * @param state current state of the node material building
  21735. * @returns the shader code
  21736. */
  21737. getCode(state: NodeMaterialBuildState): string;
  21738. protected _buildBlock(state: NodeMaterialBuildState): this;
  21739. protected _dumpPropertiesCode(): string;
  21740. serialize(): any;
  21741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21742. }
  21743. }
  21744. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21747. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21750. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21752. import { Nullable } from "babylonjs/types";
  21753. import { Scene } from "babylonjs/scene";
  21754. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21755. /**
  21756. * Base block used as input for post process
  21757. */
  21758. export class CurrentScreenBlock extends NodeMaterialBlock {
  21759. private _samplerName;
  21760. private _linearDefineName;
  21761. private _gammaDefineName;
  21762. private _mainUVName;
  21763. private _tempTextureRead;
  21764. /**
  21765. * Gets or sets the texture associated with the node
  21766. */
  21767. texture: Nullable<BaseTexture>;
  21768. /**
  21769. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21770. */
  21771. convertToGammaSpace: boolean;
  21772. /**
  21773. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21774. */
  21775. convertToLinearSpace: boolean;
  21776. /**
  21777. * Create a new CurrentScreenBlock
  21778. * @param name defines the block name
  21779. */
  21780. constructor(name: string);
  21781. /**
  21782. * Gets the current class name
  21783. * @returns the class name
  21784. */
  21785. getClassName(): string;
  21786. /**
  21787. * Gets the uv input component
  21788. */
  21789. get uv(): NodeMaterialConnectionPoint;
  21790. /**
  21791. * Gets the rgba output component
  21792. */
  21793. get rgba(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the rgb output component
  21796. */
  21797. get rgb(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the r output component
  21800. */
  21801. get r(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the g output component
  21804. */
  21805. get g(): NodeMaterialConnectionPoint;
  21806. /**
  21807. * Gets the b output component
  21808. */
  21809. get b(): NodeMaterialConnectionPoint;
  21810. /**
  21811. * Gets the a output component
  21812. */
  21813. get a(): NodeMaterialConnectionPoint;
  21814. /**
  21815. * Initialize the block and prepare the context for build
  21816. * @param state defines the state that will be used for the build
  21817. */
  21818. initialize(state: NodeMaterialBuildState): void;
  21819. get target(): NodeMaterialBlockTargets;
  21820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21821. isReady(): boolean;
  21822. private _injectVertexCode;
  21823. private _writeTextureRead;
  21824. private _writeOutput;
  21825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21826. serialize(): any;
  21827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21828. }
  21829. }
  21830. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21835. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21837. import { Nullable } from "babylonjs/types";
  21838. import { Scene } from "babylonjs/scene";
  21839. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21840. /**
  21841. * Base block used for the particle texture
  21842. */
  21843. export class ParticleTextureBlock extends NodeMaterialBlock {
  21844. private _samplerName;
  21845. private _linearDefineName;
  21846. private _gammaDefineName;
  21847. private _tempTextureRead;
  21848. /**
  21849. * Gets or sets the texture associated with the node
  21850. */
  21851. texture: Nullable<BaseTexture>;
  21852. /**
  21853. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21854. */
  21855. convertToGammaSpace: boolean;
  21856. /**
  21857. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21858. */
  21859. convertToLinearSpace: boolean;
  21860. /**
  21861. * Create a new ParticleTextureBlock
  21862. * @param name defines the block name
  21863. */
  21864. constructor(name: string);
  21865. /**
  21866. * Gets the current class name
  21867. * @returns the class name
  21868. */
  21869. getClassName(): string;
  21870. /**
  21871. * Gets the uv input component
  21872. */
  21873. get uv(): NodeMaterialConnectionPoint;
  21874. /**
  21875. * Gets the rgba output component
  21876. */
  21877. get rgba(): NodeMaterialConnectionPoint;
  21878. /**
  21879. * Gets the rgb output component
  21880. */
  21881. get rgb(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the r output component
  21884. */
  21885. get r(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the g output component
  21888. */
  21889. get g(): NodeMaterialConnectionPoint;
  21890. /**
  21891. * Gets the b output component
  21892. */
  21893. get b(): NodeMaterialConnectionPoint;
  21894. /**
  21895. * Gets the a output component
  21896. */
  21897. get a(): NodeMaterialConnectionPoint;
  21898. /**
  21899. * Initialize the block and prepare the context for build
  21900. * @param state defines the state that will be used for the build
  21901. */
  21902. initialize(state: NodeMaterialBuildState): void;
  21903. autoConfigure(material: NodeMaterial): void;
  21904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21905. isReady(): boolean;
  21906. private _writeOutput;
  21907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21908. serialize(): any;
  21909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21910. }
  21911. }
  21912. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21915. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21916. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21917. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21918. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21919. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21920. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21921. import { Scene } from "babylonjs/scene";
  21922. /**
  21923. * Class used to store shared data between 2 NodeMaterialBuildState
  21924. */
  21925. export class NodeMaterialBuildStateSharedData {
  21926. /**
  21927. * Gets the list of emitted varyings
  21928. */
  21929. temps: string[];
  21930. /**
  21931. * Gets the list of emitted varyings
  21932. */
  21933. varyings: string[];
  21934. /**
  21935. * Gets the varying declaration string
  21936. */
  21937. varyingDeclaration: string;
  21938. /**
  21939. * Input blocks
  21940. */
  21941. inputBlocks: InputBlock[];
  21942. /**
  21943. * Input blocks
  21944. */
  21945. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21946. /**
  21947. * Bindable blocks (Blocks that need to set data to the effect)
  21948. */
  21949. bindableBlocks: NodeMaterialBlock[];
  21950. /**
  21951. * List of blocks that can provide a compilation fallback
  21952. */
  21953. blocksWithFallbacks: NodeMaterialBlock[];
  21954. /**
  21955. * List of blocks that can provide a define update
  21956. */
  21957. blocksWithDefines: NodeMaterialBlock[];
  21958. /**
  21959. * List of blocks that can provide a repeatable content
  21960. */
  21961. repeatableContentBlocks: NodeMaterialBlock[];
  21962. /**
  21963. * List of blocks that can provide a dynamic list of uniforms
  21964. */
  21965. dynamicUniformBlocks: NodeMaterialBlock[];
  21966. /**
  21967. * List of blocks that can block the isReady function for the material
  21968. */
  21969. blockingBlocks: NodeMaterialBlock[];
  21970. /**
  21971. * Gets the list of animated inputs
  21972. */
  21973. animatedInputs: InputBlock[];
  21974. /**
  21975. * Build Id used to avoid multiple recompilations
  21976. */
  21977. buildId: number;
  21978. /** List of emitted variables */
  21979. variableNames: {
  21980. [key: string]: number;
  21981. };
  21982. /** List of emitted defines */
  21983. defineNames: {
  21984. [key: string]: number;
  21985. };
  21986. /** Should emit comments? */
  21987. emitComments: boolean;
  21988. /** Emit build activity */
  21989. verbose: boolean;
  21990. /** Gets or sets the hosting scene */
  21991. scene: Scene;
  21992. /**
  21993. * Gets the compilation hints emitted at compilation time
  21994. */
  21995. hints: {
  21996. needWorldViewMatrix: boolean;
  21997. needWorldViewProjectionMatrix: boolean;
  21998. needAlphaBlending: boolean;
  21999. needAlphaTesting: boolean;
  22000. };
  22001. /**
  22002. * List of compilation checks
  22003. */
  22004. checks: {
  22005. emitVertex: boolean;
  22006. emitFragment: boolean;
  22007. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22008. };
  22009. /**
  22010. * Is vertex program allowed to be empty?
  22011. */
  22012. allowEmptyVertexProgram: boolean;
  22013. /** Creates a new shared data */
  22014. constructor();
  22015. /**
  22016. * Emits console errors and exceptions if there is a failing check
  22017. */
  22018. emitErrors(): void;
  22019. }
  22020. }
  22021. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22022. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22023. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22024. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22025. /**
  22026. * Class used to store node based material build state
  22027. */
  22028. export class NodeMaterialBuildState {
  22029. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22030. supportUniformBuffers: boolean;
  22031. /**
  22032. * Gets the list of emitted attributes
  22033. */
  22034. attributes: string[];
  22035. /**
  22036. * Gets the list of emitted uniforms
  22037. */
  22038. uniforms: string[];
  22039. /**
  22040. * Gets the list of emitted constants
  22041. */
  22042. constants: string[];
  22043. /**
  22044. * Gets the list of emitted samplers
  22045. */
  22046. samplers: string[];
  22047. /**
  22048. * Gets the list of emitted functions
  22049. */
  22050. functions: {
  22051. [key: string]: string;
  22052. };
  22053. /**
  22054. * Gets the list of emitted extensions
  22055. */
  22056. extensions: {
  22057. [key: string]: string;
  22058. };
  22059. /**
  22060. * Gets the target of the compilation state
  22061. */
  22062. target: NodeMaterialBlockTargets;
  22063. /**
  22064. * Gets the list of emitted counters
  22065. */
  22066. counters: {
  22067. [key: string]: number;
  22068. };
  22069. /**
  22070. * Shared data between multiple NodeMaterialBuildState instances
  22071. */
  22072. sharedData: NodeMaterialBuildStateSharedData;
  22073. /** @hidden */
  22074. _vertexState: NodeMaterialBuildState;
  22075. /** @hidden */
  22076. _attributeDeclaration: string;
  22077. /** @hidden */
  22078. _uniformDeclaration: string;
  22079. /** @hidden */
  22080. _constantDeclaration: string;
  22081. /** @hidden */
  22082. _samplerDeclaration: string;
  22083. /** @hidden */
  22084. _varyingTransfer: string;
  22085. /** @hidden */
  22086. _injectAtEnd: string;
  22087. private _repeatableContentAnchorIndex;
  22088. /** @hidden */
  22089. _builtCompilationString: string;
  22090. /**
  22091. * Gets the emitted compilation strings
  22092. */
  22093. compilationString: string;
  22094. /**
  22095. * Finalize the compilation strings
  22096. * @param state defines the current compilation state
  22097. */
  22098. finalize(state: NodeMaterialBuildState): void;
  22099. /** @hidden */
  22100. get _repeatableContentAnchor(): string;
  22101. /** @hidden */
  22102. _getFreeVariableName(prefix: string): string;
  22103. /** @hidden */
  22104. _getFreeDefineName(prefix: string): string;
  22105. /** @hidden */
  22106. _excludeVariableName(name: string): void;
  22107. /** @hidden */
  22108. _emit2DSampler(name: string): void;
  22109. /** @hidden */
  22110. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22111. /** @hidden */
  22112. _emitExtension(name: string, extension: string, define?: string): void;
  22113. /** @hidden */
  22114. _emitFunction(name: string, code: string, comments: string): void;
  22115. /** @hidden */
  22116. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22117. replaceStrings?: {
  22118. search: RegExp;
  22119. replace: string;
  22120. }[];
  22121. repeatKey?: string;
  22122. }): string;
  22123. /** @hidden */
  22124. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22125. repeatKey?: string;
  22126. removeAttributes?: boolean;
  22127. removeUniforms?: boolean;
  22128. removeVaryings?: boolean;
  22129. removeIfDef?: boolean;
  22130. replaceStrings?: {
  22131. search: RegExp;
  22132. replace: string;
  22133. }[];
  22134. }, storeKey?: string): void;
  22135. /** @hidden */
  22136. _registerTempVariable(name: string): boolean;
  22137. /** @hidden */
  22138. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22139. /** @hidden */
  22140. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22141. /** @hidden */
  22142. _emitFloat(value: number): string;
  22143. }
  22144. }
  22145. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22146. /**
  22147. * Helper class used to generate session unique ID
  22148. */
  22149. export class UniqueIdGenerator {
  22150. private static _UniqueIdCounter;
  22151. /**
  22152. * Gets an unique (relatively to the current scene) Id
  22153. */
  22154. static get UniqueId(): number;
  22155. }
  22156. }
  22157. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22158. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22160. import { Nullable } from "babylonjs/types";
  22161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22162. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22163. import { Effect } from "babylonjs/Materials/effect";
  22164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22165. import { Mesh } from "babylonjs/Meshes/mesh";
  22166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22167. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22168. import { Scene } from "babylonjs/scene";
  22169. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22170. /**
  22171. * Defines a block that can be used inside a node based material
  22172. */
  22173. export class NodeMaterialBlock {
  22174. private _buildId;
  22175. private _buildTarget;
  22176. private _target;
  22177. private _isFinalMerger;
  22178. private _isInput;
  22179. private _name;
  22180. protected _isUnique: boolean;
  22181. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22182. inputsAreExclusive: boolean;
  22183. /** @hidden */
  22184. _codeVariableName: string;
  22185. /** @hidden */
  22186. _inputs: NodeMaterialConnectionPoint[];
  22187. /** @hidden */
  22188. _outputs: NodeMaterialConnectionPoint[];
  22189. /** @hidden */
  22190. _preparationId: number;
  22191. /**
  22192. * Gets the name of the block
  22193. */
  22194. get name(): string;
  22195. /**
  22196. * Sets the name of the block. Will check if the name is valid.
  22197. */
  22198. set name(newName: string);
  22199. /**
  22200. * Gets or sets the unique id of the node
  22201. */
  22202. uniqueId: number;
  22203. /**
  22204. * Gets or sets the comments associated with this block
  22205. */
  22206. comments: string;
  22207. /**
  22208. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22209. */
  22210. get isUnique(): boolean;
  22211. /**
  22212. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22213. */
  22214. get isFinalMerger(): boolean;
  22215. /**
  22216. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22217. */
  22218. get isInput(): boolean;
  22219. /**
  22220. * Gets or sets the build Id
  22221. */
  22222. get buildId(): number;
  22223. set buildId(value: number);
  22224. /**
  22225. * Gets or sets the target of the block
  22226. */
  22227. get target(): NodeMaterialBlockTargets;
  22228. set target(value: NodeMaterialBlockTargets);
  22229. /**
  22230. * Gets the list of input points
  22231. */
  22232. get inputs(): NodeMaterialConnectionPoint[];
  22233. /** Gets the list of output points */
  22234. get outputs(): NodeMaterialConnectionPoint[];
  22235. /**
  22236. * Find an input by its name
  22237. * @param name defines the name of the input to look for
  22238. * @returns the input or null if not found
  22239. */
  22240. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22241. /**
  22242. * Find an output by its name
  22243. * @param name defines the name of the outputto look for
  22244. * @returns the output or null if not found
  22245. */
  22246. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22247. /**
  22248. * Creates a new NodeMaterialBlock
  22249. * @param name defines the block name
  22250. * @param target defines the target of that block (Vertex by default)
  22251. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22252. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22253. */
  22254. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22255. /**
  22256. * Initialize the block and prepare the context for build
  22257. * @param state defines the state that will be used for the build
  22258. */
  22259. initialize(state: NodeMaterialBuildState): void;
  22260. /**
  22261. * Bind data to effect. Will only be called for blocks with isBindable === true
  22262. * @param effect defines the effect to bind data to
  22263. * @param nodeMaterial defines the hosting NodeMaterial
  22264. * @param mesh defines the mesh that will be rendered
  22265. * @param subMesh defines the submesh that will be rendered
  22266. */
  22267. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22268. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22269. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22270. protected _writeFloat(value: number): string;
  22271. /**
  22272. * Gets the current class name e.g. "NodeMaterialBlock"
  22273. * @returns the class name
  22274. */
  22275. getClassName(): string;
  22276. /**
  22277. * Register a new input. Must be called inside a block constructor
  22278. * @param name defines the connection point name
  22279. * @param type defines the connection point type
  22280. * @param isOptional defines a boolean indicating that this input can be omitted
  22281. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22282. * @param point an already created connection point. If not provided, create a new one
  22283. * @returns the current block
  22284. */
  22285. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22286. /**
  22287. * Register a new output. Must be called inside a block constructor
  22288. * @param name defines the connection point name
  22289. * @param type defines the connection point type
  22290. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22291. * @param point an already created connection point. If not provided, create a new one
  22292. * @returns the current block
  22293. */
  22294. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22295. /**
  22296. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22297. * @param forOutput defines an optional connection point to check compatibility with
  22298. * @returns the first available input or null
  22299. */
  22300. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22301. /**
  22302. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22303. * @param forBlock defines an optional block to check compatibility with
  22304. * @returns the first available input or null
  22305. */
  22306. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22307. /**
  22308. * Gets the sibling of the given output
  22309. * @param current defines the current output
  22310. * @returns the next output in the list or null
  22311. */
  22312. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22313. /**
  22314. * Connect current block with another block
  22315. * @param other defines the block to connect with
  22316. * @param options define the various options to help pick the right connections
  22317. * @returns the current block
  22318. */
  22319. connectTo(other: NodeMaterialBlock, options?: {
  22320. input?: string;
  22321. output?: string;
  22322. outputSwizzle?: string;
  22323. }): this | undefined;
  22324. protected _buildBlock(state: NodeMaterialBuildState): void;
  22325. /**
  22326. * Add uniforms, samplers and uniform buffers at compilation time
  22327. * @param state defines the state to update
  22328. * @param nodeMaterial defines the node material requesting the update
  22329. * @param defines defines the material defines to update
  22330. * @param uniformBuffers defines the list of uniform buffer names
  22331. */
  22332. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22333. /**
  22334. * Add potential fallbacks if shader compilation fails
  22335. * @param mesh defines the mesh to be rendered
  22336. * @param fallbacks defines the current prioritized list of fallbacks
  22337. */
  22338. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22339. /**
  22340. * Initialize defines for shader compilation
  22341. * @param mesh defines the mesh to be rendered
  22342. * @param nodeMaterial defines the node material requesting the update
  22343. * @param defines defines the material defines to update
  22344. * @param useInstances specifies that instances should be used
  22345. */
  22346. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22347. /**
  22348. * Update defines for shader compilation
  22349. * @param mesh defines the mesh to be rendered
  22350. * @param nodeMaterial defines the node material requesting the update
  22351. * @param defines defines the material defines to update
  22352. * @param useInstances specifies that instances should be used
  22353. * @param subMesh defines which submesh to render
  22354. */
  22355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22356. /**
  22357. * Lets the block try to connect some inputs automatically
  22358. * @param material defines the hosting NodeMaterial
  22359. */
  22360. autoConfigure(material: NodeMaterial): void;
  22361. /**
  22362. * Function called when a block is declared as repeatable content generator
  22363. * @param vertexShaderState defines the current compilation state for the vertex shader
  22364. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22365. * @param mesh defines the mesh to be rendered
  22366. * @param defines defines the material defines to update
  22367. */
  22368. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22369. /**
  22370. * Checks if the block is ready
  22371. * @param mesh defines the mesh to be rendered
  22372. * @param nodeMaterial defines the node material requesting the update
  22373. * @param defines defines the material defines to update
  22374. * @param useInstances specifies that instances should be used
  22375. * @returns true if the block is ready
  22376. */
  22377. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22378. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22379. private _processBuild;
  22380. /**
  22381. * Validates the new name for the block node.
  22382. * @param newName the new name to be given to the node.
  22383. * @returns false if the name is a reserve word, else true.
  22384. */
  22385. validateBlockName(newName: string): boolean;
  22386. /**
  22387. * Compile the current node and generate the shader code
  22388. * @param state defines the current compilation state (uniforms, samplers, current string)
  22389. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22390. * @returns true if already built
  22391. */
  22392. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22393. protected _inputRename(name: string): string;
  22394. protected _outputRename(name: string): string;
  22395. protected _dumpPropertiesCode(): string;
  22396. /** @hidden */
  22397. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22398. /** @hidden */
  22399. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22400. /**
  22401. * Clone the current block to a new identical block
  22402. * @param scene defines the hosting scene
  22403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22404. * @returns a copy of the current block
  22405. */
  22406. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22407. /**
  22408. * Serializes this block in a JSON representation
  22409. * @returns the serialized block object
  22410. */
  22411. serialize(): any;
  22412. /** @hidden */
  22413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22414. private _deserializePortDisplayNamesAndExposedOnFrame;
  22415. /**
  22416. * Release resources
  22417. */
  22418. dispose(): void;
  22419. }
  22420. }
  22421. declare module "babylonjs/Materials/pushMaterial" {
  22422. import { Nullable } from "babylonjs/types";
  22423. import { Scene } from "babylonjs/scene";
  22424. import { Matrix } from "babylonjs/Maths/math.vector";
  22425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22426. import { Mesh } from "babylonjs/Meshes/mesh";
  22427. import { Material } from "babylonjs/Materials/material";
  22428. import { Effect } from "babylonjs/Materials/effect";
  22429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22430. /**
  22431. * Base class of materials working in push mode in babylon JS
  22432. * @hidden
  22433. */
  22434. export class PushMaterial extends Material {
  22435. protected _activeEffect: Effect;
  22436. protected _normalMatrix: Matrix;
  22437. constructor(name: string, scene: Scene);
  22438. getEffect(): Effect;
  22439. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22440. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22441. /**
  22442. * Binds the given world matrix to the active effect
  22443. *
  22444. * @param world the matrix to bind
  22445. */
  22446. bindOnlyWorldMatrix(world: Matrix): void;
  22447. /**
  22448. * Binds the given normal matrix to the active effect
  22449. *
  22450. * @param normalMatrix the matrix to bind
  22451. */
  22452. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22453. bind(world: Matrix, mesh?: Mesh): void;
  22454. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22455. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22456. }
  22457. }
  22458. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22460. /**
  22461. * Root class for all node material optimizers
  22462. */
  22463. export class NodeMaterialOptimizer {
  22464. /**
  22465. * Function used to optimize a NodeMaterial graph
  22466. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22467. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22468. */
  22469. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22470. }
  22471. }
  22472. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22476. import { Scene } from "babylonjs/scene";
  22477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22478. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22480. /**
  22481. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22482. */
  22483. export class TransformBlock extends NodeMaterialBlock {
  22484. /**
  22485. * Defines the value to use to complement W value to transform it to a Vector4
  22486. */
  22487. complementW: number;
  22488. /**
  22489. * Defines the value to use to complement z value to transform it to a Vector4
  22490. */
  22491. complementZ: number;
  22492. /**
  22493. * Creates a new TransformBlock
  22494. * @param name defines the block name
  22495. */
  22496. constructor(name: string);
  22497. /**
  22498. * Gets the current class name
  22499. * @returns the class name
  22500. */
  22501. getClassName(): string;
  22502. /**
  22503. * Gets the vector input
  22504. */
  22505. get vector(): NodeMaterialConnectionPoint;
  22506. /**
  22507. * Gets the output component
  22508. */
  22509. get output(): NodeMaterialConnectionPoint;
  22510. /**
  22511. * Gets the xyz output component
  22512. */
  22513. get xyz(): NodeMaterialConnectionPoint;
  22514. /**
  22515. * Gets the matrix transform input
  22516. */
  22517. get transform(): NodeMaterialConnectionPoint;
  22518. protected _buildBlock(state: NodeMaterialBuildState): this;
  22519. /**
  22520. * Update defines for shader compilation
  22521. * @param mesh defines the mesh to be rendered
  22522. * @param nodeMaterial defines the node material requesting the update
  22523. * @param defines defines the material defines to update
  22524. * @param useInstances specifies that instances should be used
  22525. * @param subMesh defines which submesh to render
  22526. */
  22527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22528. serialize(): any;
  22529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22530. protected _dumpPropertiesCode(): string;
  22531. }
  22532. }
  22533. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22537. /**
  22538. * Block used to output the vertex position
  22539. */
  22540. export class VertexOutputBlock extends NodeMaterialBlock {
  22541. /**
  22542. * Creates a new VertexOutputBlock
  22543. * @param name defines the block name
  22544. */
  22545. constructor(name: string);
  22546. /**
  22547. * Gets the current class name
  22548. * @returns the class name
  22549. */
  22550. getClassName(): string;
  22551. /**
  22552. * Gets the vector input component
  22553. */
  22554. get vector(): NodeMaterialConnectionPoint;
  22555. protected _buildBlock(state: NodeMaterialBuildState): this;
  22556. }
  22557. }
  22558. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22560. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22561. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22562. /**
  22563. * Block used to output the final color
  22564. */
  22565. export class FragmentOutputBlock extends NodeMaterialBlock {
  22566. /**
  22567. * Create a new FragmentOutputBlock
  22568. * @param name defines the block name
  22569. */
  22570. constructor(name: string);
  22571. /**
  22572. * Gets the current class name
  22573. * @returns the class name
  22574. */
  22575. getClassName(): string;
  22576. /**
  22577. * Gets the rgba input component
  22578. */
  22579. get rgba(): NodeMaterialConnectionPoint;
  22580. /**
  22581. * Gets the rgb input component
  22582. */
  22583. get rgb(): NodeMaterialConnectionPoint;
  22584. /**
  22585. * Gets the a input component
  22586. */
  22587. get a(): NodeMaterialConnectionPoint;
  22588. protected _buildBlock(state: NodeMaterialBuildState): this;
  22589. }
  22590. }
  22591. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22595. /**
  22596. * Block used for the particle ramp gradient section
  22597. */
  22598. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22599. /**
  22600. * Create a new ParticleRampGradientBlock
  22601. * @param name defines the block name
  22602. */
  22603. constructor(name: string);
  22604. /**
  22605. * Gets the current class name
  22606. * @returns the class name
  22607. */
  22608. getClassName(): string;
  22609. /**
  22610. * Gets the color input component
  22611. */
  22612. get color(): NodeMaterialConnectionPoint;
  22613. /**
  22614. * Gets the rampColor output component
  22615. */
  22616. get rampColor(): NodeMaterialConnectionPoint;
  22617. /**
  22618. * Initialize the block and prepare the context for build
  22619. * @param state defines the state that will be used for the build
  22620. */
  22621. initialize(state: NodeMaterialBuildState): void;
  22622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22623. }
  22624. }
  22625. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22629. /**
  22630. * Block used for the particle blend multiply section
  22631. */
  22632. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22633. /**
  22634. * Create a new ParticleBlendMultiplyBlock
  22635. * @param name defines the block name
  22636. */
  22637. constructor(name: string);
  22638. /**
  22639. * Gets the current class name
  22640. * @returns the class name
  22641. */
  22642. getClassName(): string;
  22643. /**
  22644. * Gets the color input component
  22645. */
  22646. get color(): NodeMaterialConnectionPoint;
  22647. /**
  22648. * Gets the alphaTexture input component
  22649. */
  22650. get alphaTexture(): NodeMaterialConnectionPoint;
  22651. /**
  22652. * Gets the alphaColor input component
  22653. */
  22654. get alphaColor(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the blendColor output component
  22657. */
  22658. get blendColor(): NodeMaterialConnectionPoint;
  22659. /**
  22660. * Initialize the block and prepare the context for build
  22661. * @param state defines the state that will be used for the build
  22662. */
  22663. initialize(state: NodeMaterialBuildState): void;
  22664. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22665. }
  22666. }
  22667. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22671. /**
  22672. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22673. */
  22674. export class VectorMergerBlock extends NodeMaterialBlock {
  22675. /**
  22676. * Create a new VectorMergerBlock
  22677. * @param name defines the block name
  22678. */
  22679. constructor(name: string);
  22680. /**
  22681. * Gets the current class name
  22682. * @returns the class name
  22683. */
  22684. getClassName(): string;
  22685. /**
  22686. * Gets the xyz component (input)
  22687. */
  22688. get xyzIn(): NodeMaterialConnectionPoint;
  22689. /**
  22690. * Gets the xy component (input)
  22691. */
  22692. get xyIn(): NodeMaterialConnectionPoint;
  22693. /**
  22694. * Gets the x component (input)
  22695. */
  22696. get x(): NodeMaterialConnectionPoint;
  22697. /**
  22698. * Gets the y component (input)
  22699. */
  22700. get y(): NodeMaterialConnectionPoint;
  22701. /**
  22702. * Gets the z component (input)
  22703. */
  22704. get z(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Gets the w component (input)
  22707. */
  22708. get w(): NodeMaterialConnectionPoint;
  22709. /**
  22710. * Gets the xyzw component (output)
  22711. */
  22712. get xyzw(): NodeMaterialConnectionPoint;
  22713. /**
  22714. * Gets the xyz component (output)
  22715. */
  22716. get xyzOut(): NodeMaterialConnectionPoint;
  22717. /**
  22718. * Gets the xy component (output)
  22719. */
  22720. get xyOut(): NodeMaterialConnectionPoint;
  22721. /**
  22722. * Gets the xy component (output)
  22723. * @deprecated Please use xyOut instead.
  22724. */
  22725. get xy(): NodeMaterialConnectionPoint;
  22726. /**
  22727. * Gets the xyz component (output)
  22728. * @deprecated Please use xyzOut instead.
  22729. */
  22730. get xyz(): NodeMaterialConnectionPoint;
  22731. protected _buildBlock(state: NodeMaterialBuildState): this;
  22732. }
  22733. }
  22734. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22738. import { Vector2 } from "babylonjs/Maths/math.vector";
  22739. import { Scene } from "babylonjs/scene";
  22740. /**
  22741. * Block used to remap a float from a range to a new one
  22742. */
  22743. export class RemapBlock extends NodeMaterialBlock {
  22744. /**
  22745. * Gets or sets the source range
  22746. */
  22747. sourceRange: Vector2;
  22748. /**
  22749. * Gets or sets the target range
  22750. */
  22751. targetRange: Vector2;
  22752. /**
  22753. * Creates a new RemapBlock
  22754. * @param name defines the block name
  22755. */
  22756. constructor(name: string);
  22757. /**
  22758. * Gets the current class name
  22759. * @returns the class name
  22760. */
  22761. getClassName(): string;
  22762. /**
  22763. * Gets the input component
  22764. */
  22765. get input(): NodeMaterialConnectionPoint;
  22766. /**
  22767. * Gets the source min input component
  22768. */
  22769. get sourceMin(): NodeMaterialConnectionPoint;
  22770. /**
  22771. * Gets the source max input component
  22772. */
  22773. get sourceMax(): NodeMaterialConnectionPoint;
  22774. /**
  22775. * Gets the target min input component
  22776. */
  22777. get targetMin(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the target max input component
  22780. */
  22781. get targetMax(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Gets the output component
  22784. */
  22785. get output(): NodeMaterialConnectionPoint;
  22786. protected _buildBlock(state: NodeMaterialBuildState): this;
  22787. protected _dumpPropertiesCode(): string;
  22788. serialize(): any;
  22789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22790. }
  22791. }
  22792. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22796. /**
  22797. * Block used to multiply 2 values
  22798. */
  22799. export class MultiplyBlock extends NodeMaterialBlock {
  22800. /**
  22801. * Creates a new MultiplyBlock
  22802. * @param name defines the block name
  22803. */
  22804. constructor(name: string);
  22805. /**
  22806. * Gets the current class name
  22807. * @returns the class name
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Gets the left operand input component
  22812. */
  22813. get left(): NodeMaterialConnectionPoint;
  22814. /**
  22815. * Gets the right operand input component
  22816. */
  22817. get right(): NodeMaterialConnectionPoint;
  22818. /**
  22819. * Gets the output component
  22820. */
  22821. get output(): NodeMaterialConnectionPoint;
  22822. protected _buildBlock(state: NodeMaterialBuildState): this;
  22823. }
  22824. }
  22825. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22829. /**
  22830. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22831. */
  22832. export class ColorSplitterBlock extends NodeMaterialBlock {
  22833. /**
  22834. * Create a new ColorSplitterBlock
  22835. * @param name defines the block name
  22836. */
  22837. constructor(name: string);
  22838. /**
  22839. * Gets the current class name
  22840. * @returns the class name
  22841. */
  22842. getClassName(): string;
  22843. /**
  22844. * Gets the rgba component (input)
  22845. */
  22846. get rgba(): NodeMaterialConnectionPoint;
  22847. /**
  22848. * Gets the rgb component (input)
  22849. */
  22850. get rgbIn(): NodeMaterialConnectionPoint;
  22851. /**
  22852. * Gets the rgb component (output)
  22853. */
  22854. get rgbOut(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the r component (output)
  22857. */
  22858. get r(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the g component (output)
  22861. */
  22862. get g(): NodeMaterialConnectionPoint;
  22863. /**
  22864. * Gets the b component (output)
  22865. */
  22866. get b(): NodeMaterialConnectionPoint;
  22867. /**
  22868. * Gets the a component (output)
  22869. */
  22870. get a(): NodeMaterialConnectionPoint;
  22871. protected _inputRename(name: string): string;
  22872. protected _outputRename(name: string): string;
  22873. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22874. }
  22875. }
  22876. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22878. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22879. import { Scene } from "babylonjs/scene";
  22880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22881. import { Matrix } from "babylonjs/Maths/math.vector";
  22882. import { Mesh } from "babylonjs/Meshes/mesh";
  22883. import { Engine } from "babylonjs/Engines/engine";
  22884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22885. import { Observable } from "babylonjs/Misc/observable";
  22886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22887. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22888. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22889. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22890. import { Nullable } from "babylonjs/types";
  22891. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22892. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22893. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22894. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22895. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22896. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22897. import { Effect } from "babylonjs/Materials/effect";
  22898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22899. import { Camera } from "babylonjs/Cameras/camera";
  22900. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22901. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22902. /**
  22903. * Interface used to configure the node material editor
  22904. */
  22905. export interface INodeMaterialEditorOptions {
  22906. /** Define the URl to load node editor script */
  22907. editorURL?: string;
  22908. }
  22909. /** @hidden */
  22910. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22911. NORMAL: boolean;
  22912. TANGENT: boolean;
  22913. UV1: boolean;
  22914. /** BONES */
  22915. NUM_BONE_INFLUENCERS: number;
  22916. BonesPerMesh: number;
  22917. BONETEXTURE: boolean;
  22918. /** MORPH TARGETS */
  22919. MORPHTARGETS: boolean;
  22920. MORPHTARGETS_NORMAL: boolean;
  22921. MORPHTARGETS_TANGENT: boolean;
  22922. MORPHTARGETS_UV: boolean;
  22923. NUM_MORPH_INFLUENCERS: number;
  22924. /** IMAGE PROCESSING */
  22925. IMAGEPROCESSING: boolean;
  22926. VIGNETTE: boolean;
  22927. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22928. VIGNETTEBLENDMODEOPAQUE: boolean;
  22929. TONEMAPPING: boolean;
  22930. TONEMAPPING_ACES: boolean;
  22931. CONTRAST: boolean;
  22932. EXPOSURE: boolean;
  22933. COLORCURVES: boolean;
  22934. COLORGRADING: boolean;
  22935. COLORGRADING3D: boolean;
  22936. SAMPLER3DGREENDEPTH: boolean;
  22937. SAMPLER3DBGRMAP: boolean;
  22938. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22939. /** MISC. */
  22940. BUMPDIRECTUV: number;
  22941. constructor();
  22942. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22943. }
  22944. /**
  22945. * Class used to configure NodeMaterial
  22946. */
  22947. export interface INodeMaterialOptions {
  22948. /**
  22949. * Defines if blocks should emit comments
  22950. */
  22951. emitComments: boolean;
  22952. }
  22953. /**
  22954. * Class used to create a node based material built by assembling shader blocks
  22955. */
  22956. export class NodeMaterial extends PushMaterial {
  22957. private static _BuildIdGenerator;
  22958. private _options;
  22959. private _vertexCompilationState;
  22960. private _fragmentCompilationState;
  22961. private _sharedData;
  22962. private _buildId;
  22963. private _buildWasSuccessful;
  22964. private _cachedWorldViewMatrix;
  22965. private _cachedWorldViewProjectionMatrix;
  22966. private _optimizers;
  22967. private _animationFrame;
  22968. /** Define the Url to load node editor script */
  22969. static EditorURL: string;
  22970. /** Define the Url to load snippets */
  22971. static SnippetUrl: string;
  22972. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22973. static IgnoreTexturesAtLoadTime: boolean;
  22974. private BJSNODEMATERIALEDITOR;
  22975. /** Get the inspector from bundle or global */
  22976. private _getGlobalNodeMaterialEditor;
  22977. /**
  22978. * Snippet ID if the material was created from the snippet server
  22979. */
  22980. snippetId: string;
  22981. /**
  22982. * Gets or sets data used by visual editor
  22983. * @see https://nme.babylonjs.com
  22984. */
  22985. editorData: any;
  22986. /**
  22987. * 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)
  22988. */
  22989. ignoreAlpha: boolean;
  22990. /**
  22991. * Defines the maximum number of lights that can be used in the material
  22992. */
  22993. maxSimultaneousLights: number;
  22994. /**
  22995. * Observable raised when the material is built
  22996. */
  22997. onBuildObservable: Observable<NodeMaterial>;
  22998. /**
  22999. * Gets or sets the root nodes of the material vertex shader
  23000. */
  23001. _vertexOutputNodes: NodeMaterialBlock[];
  23002. /**
  23003. * Gets or sets the root nodes of the material fragment (pixel) shader
  23004. */
  23005. _fragmentOutputNodes: NodeMaterialBlock[];
  23006. /** Gets or sets options to control the node material overall behavior */
  23007. get options(): INodeMaterialOptions;
  23008. set options(options: INodeMaterialOptions);
  23009. /**
  23010. * Default configuration related to image processing available in the standard Material.
  23011. */
  23012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23013. /**
  23014. * Gets the image processing configuration used either in this material.
  23015. */
  23016. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23017. /**
  23018. * Sets the Default image processing configuration used either in the this material.
  23019. *
  23020. * If sets to null, the scene one is in use.
  23021. */
  23022. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23023. /**
  23024. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23025. */
  23026. attachedBlocks: NodeMaterialBlock[];
  23027. /**
  23028. * Specifies the mode of the node material
  23029. * @hidden
  23030. */
  23031. _mode: NodeMaterialModes;
  23032. /**
  23033. * Gets the mode property
  23034. */
  23035. get mode(): NodeMaterialModes;
  23036. /**
  23037. * Create a new node based material
  23038. * @param name defines the material name
  23039. * @param scene defines the hosting scene
  23040. * @param options defines creation option
  23041. */
  23042. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23043. /**
  23044. * Gets the current class name of the material e.g. "NodeMaterial"
  23045. * @returns the class name
  23046. */
  23047. getClassName(): string;
  23048. /**
  23049. * Keep track of the image processing observer to allow dispose and replace.
  23050. */
  23051. private _imageProcessingObserver;
  23052. /**
  23053. * Attaches a new image processing configuration to the Standard Material.
  23054. * @param configuration
  23055. */
  23056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23057. /**
  23058. * Get a block by its name
  23059. * @param name defines the name of the block to retrieve
  23060. * @returns the required block or null if not found
  23061. */
  23062. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23063. /**
  23064. * Get a block by its name
  23065. * @param predicate defines the predicate used to find the good candidate
  23066. * @returns the required block or null if not found
  23067. */
  23068. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23069. /**
  23070. * Get an input block by its name
  23071. * @param predicate defines the predicate used to find the good candidate
  23072. * @returns the required input block or null if not found
  23073. */
  23074. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23075. /**
  23076. * Gets the list of input blocks attached to this material
  23077. * @returns an array of InputBlocks
  23078. */
  23079. getInputBlocks(): InputBlock[];
  23080. /**
  23081. * Adds a new optimizer to the list of optimizers
  23082. * @param optimizer defines the optimizers to add
  23083. * @returns the current material
  23084. */
  23085. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23086. /**
  23087. * Remove an optimizer from the list of optimizers
  23088. * @param optimizer defines the optimizers to remove
  23089. * @returns the current material
  23090. */
  23091. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23092. /**
  23093. * Add a new block to the list of output nodes
  23094. * @param node defines the node to add
  23095. * @returns the current material
  23096. */
  23097. addOutputNode(node: NodeMaterialBlock): this;
  23098. /**
  23099. * Remove a block from the list of root nodes
  23100. * @param node defines the node to remove
  23101. * @returns the current material
  23102. */
  23103. removeOutputNode(node: NodeMaterialBlock): this;
  23104. private _addVertexOutputNode;
  23105. private _removeVertexOutputNode;
  23106. private _addFragmentOutputNode;
  23107. private _removeFragmentOutputNode;
  23108. /**
  23109. * Specifies if the material will require alpha blending
  23110. * @returns a boolean specifying if alpha blending is needed
  23111. */
  23112. needAlphaBlending(): boolean;
  23113. /**
  23114. * Specifies if this material should be rendered in alpha test mode
  23115. * @returns a boolean specifying if an alpha test is needed.
  23116. */
  23117. needAlphaTesting(): boolean;
  23118. private _initializeBlock;
  23119. private _resetDualBlocks;
  23120. /**
  23121. * Remove a block from the current node material
  23122. * @param block defines the block to remove
  23123. */
  23124. removeBlock(block: NodeMaterialBlock): void;
  23125. /**
  23126. * Build the material and generates the inner effect
  23127. * @param verbose defines if the build should log activity
  23128. */
  23129. build(verbose?: boolean): void;
  23130. /**
  23131. * Runs an otpimization phase to try to improve the shader code
  23132. */
  23133. optimize(): void;
  23134. private _prepareDefinesForAttributes;
  23135. /**
  23136. * Create a post process from the material
  23137. * @param camera The camera to apply the render pass to.
  23138. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23140. * @param engine The engine which the post process will be applied. (default: current engine)
  23141. * @param reusable If the post process can be reused on the same frame. (default: false)
  23142. * @param textureType Type of textures used when performing the post process. (default: 0)
  23143. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23144. * @returns the post process created
  23145. */
  23146. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23147. /**
  23148. * Create the post process effect from the material
  23149. * @param postProcess The post process to create the effect for
  23150. */
  23151. createEffectForPostProcess(postProcess: PostProcess): void;
  23152. private _createEffectOrPostProcess;
  23153. private _createEffectForParticles;
  23154. /**
  23155. * Create the effect to be used as the custom effect for a particle system
  23156. * @param particleSystem Particle system to create the effect for
  23157. * @param onCompiled defines a function to call when the effect creation is successful
  23158. * @param onError defines a function to call when the effect creation has failed
  23159. */
  23160. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23161. private _processDefines;
  23162. /**
  23163. * Get if the submesh is ready to be used and all its information available.
  23164. * Child classes can use it to update shaders
  23165. * @param mesh defines the mesh to check
  23166. * @param subMesh defines which submesh to check
  23167. * @param useInstances specifies that instances should be used
  23168. * @returns a boolean indicating that the submesh is ready or not
  23169. */
  23170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23171. /**
  23172. * Get a string representing the shaders built by the current node graph
  23173. */
  23174. get compiledShaders(): string;
  23175. /**
  23176. * Binds the world matrix to the material
  23177. * @param world defines the world transformation matrix
  23178. */
  23179. bindOnlyWorldMatrix(world: Matrix): void;
  23180. /**
  23181. * Binds the submesh to this material by preparing the effect and shader to draw
  23182. * @param world defines the world transformation matrix
  23183. * @param mesh defines the mesh containing the submesh
  23184. * @param subMesh defines the submesh to bind the material to
  23185. */
  23186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23187. /**
  23188. * Gets the active textures from the material
  23189. * @returns an array of textures
  23190. */
  23191. getActiveTextures(): BaseTexture[];
  23192. /**
  23193. * Gets the list of texture blocks
  23194. * @returns an array of texture blocks
  23195. */
  23196. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23197. /**
  23198. * Specifies if the material uses a texture
  23199. * @param texture defines the texture to check against the material
  23200. * @returns a boolean specifying if the material uses the texture
  23201. */
  23202. hasTexture(texture: BaseTexture): boolean;
  23203. /**
  23204. * Disposes the material
  23205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23206. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23207. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23208. */
  23209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23210. /** Creates the node editor window. */
  23211. private _createNodeEditor;
  23212. /**
  23213. * Launch the node material editor
  23214. * @param config Define the configuration of the editor
  23215. * @return a promise fulfilled when the node editor is visible
  23216. */
  23217. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23218. /**
  23219. * Clear the current material
  23220. */
  23221. clear(): void;
  23222. /**
  23223. * Clear the current material and set it to a default state
  23224. */
  23225. setToDefault(): void;
  23226. /**
  23227. * Clear the current material and set it to a default state for post process
  23228. */
  23229. setToDefaultPostProcess(): void;
  23230. /**
  23231. * Clear the current material and set it to a default state for particle
  23232. */
  23233. setToDefaultParticle(): void;
  23234. /**
  23235. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23236. * @param url defines the url to load from
  23237. * @returns a promise that will fullfil when the material is fully loaded
  23238. */
  23239. loadAsync(url: string): Promise<void>;
  23240. private _gatherBlocks;
  23241. /**
  23242. * Generate a string containing the code declaration required to create an equivalent of this material
  23243. * @returns a string
  23244. */
  23245. generateCode(): string;
  23246. /**
  23247. * Serializes this material in a JSON representation
  23248. * @returns the serialized material object
  23249. */
  23250. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23251. private _restoreConnections;
  23252. /**
  23253. * Clear the current graph and load a new one from a serialization object
  23254. * @param source defines the JSON representation of the material
  23255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23256. * @param merge defines whether or not the source must be merged or replace the current content
  23257. */
  23258. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23259. /**
  23260. * Makes a duplicate of the current material.
  23261. * @param name - name to use for the new material.
  23262. */
  23263. clone(name: string): NodeMaterial;
  23264. /**
  23265. * Creates a node material from parsed material data
  23266. * @param source defines the JSON representation of the material
  23267. * @param scene defines the hosting scene
  23268. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23269. * @returns a new node material
  23270. */
  23271. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23272. /**
  23273. * Creates a node material from a snippet saved in a remote file
  23274. * @param name defines the name of the material to create
  23275. * @param url defines the url to load from
  23276. * @param scene defines the hosting scene
  23277. * @returns a promise that will resolve to the new node material
  23278. */
  23279. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23280. /**
  23281. * Creates a node material from a snippet saved by the node material editor
  23282. * @param snippetId defines the snippet to load
  23283. * @param scene defines the hosting scene
  23284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23285. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23286. * @returns a promise that will resolve to the new node material
  23287. */
  23288. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23289. /**
  23290. * Creates a new node material set to default basic configuration
  23291. * @param name defines the name of the material
  23292. * @param scene defines the hosting scene
  23293. * @returns a new NodeMaterial
  23294. */
  23295. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23296. }
  23297. }
  23298. declare module "babylonjs/PostProcesses/postProcess" {
  23299. import { Nullable } from "babylonjs/types";
  23300. import { SmartArray } from "babylonjs/Misc/smartArray";
  23301. import { Observable } from "babylonjs/Misc/observable";
  23302. import { Vector2 } from "babylonjs/Maths/math.vector";
  23303. import { Camera } from "babylonjs/Cameras/camera";
  23304. import { Effect } from "babylonjs/Materials/effect";
  23305. import "babylonjs/Shaders/postprocess.vertex";
  23306. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23307. import { Engine } from "babylonjs/Engines/engine";
  23308. import { Color4 } from "babylonjs/Maths/math.color";
  23309. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23310. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23311. import { Scene } from "babylonjs/scene";
  23312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23313. /**
  23314. * Size options for a post process
  23315. */
  23316. export type PostProcessOptions = {
  23317. width: number;
  23318. height: number;
  23319. };
  23320. /**
  23321. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23322. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23323. */
  23324. export class PostProcess {
  23325. /** Name of the PostProcess. */
  23326. name: string;
  23327. /**
  23328. * Gets or sets the unique id of the post process
  23329. */
  23330. uniqueId: number;
  23331. /**
  23332. * Width of the texture to apply the post process on
  23333. */
  23334. width: number;
  23335. /**
  23336. * Height of the texture to apply the post process on
  23337. */
  23338. height: number;
  23339. /**
  23340. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23341. */
  23342. nodeMaterialSource: Nullable<NodeMaterial>;
  23343. /**
  23344. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23345. * @hidden
  23346. */
  23347. _outputTexture: Nullable<InternalTexture>;
  23348. /**
  23349. * Sampling mode used by the shader
  23350. * See https://doc.babylonjs.com/classes/3.1/texture
  23351. */
  23352. renderTargetSamplingMode: number;
  23353. /**
  23354. * Clear color to use when screen clearing
  23355. */
  23356. clearColor: Color4;
  23357. /**
  23358. * If the buffer needs to be cleared before applying the post process. (default: true)
  23359. * Should be set to false if shader will overwrite all previous pixels.
  23360. */
  23361. autoClear: boolean;
  23362. /**
  23363. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23364. */
  23365. alphaMode: number;
  23366. /**
  23367. * Sets the setAlphaBlendConstants of the babylon engine
  23368. */
  23369. alphaConstants: Color4;
  23370. /**
  23371. * Animations to be used for the post processing
  23372. */
  23373. animations: import("babylonjs/Animations/animation").Animation[];
  23374. /**
  23375. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23376. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23377. */
  23378. enablePixelPerfectMode: boolean;
  23379. /**
  23380. * Force the postprocess to be applied without taking in account viewport
  23381. */
  23382. forceFullscreenViewport: boolean;
  23383. /**
  23384. * List of inspectable custom properties (used by the Inspector)
  23385. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23386. */
  23387. inspectableCustomProperties: IInspectable[];
  23388. /**
  23389. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23390. *
  23391. * | Value | Type | Description |
  23392. * | ----- | ----------------------------------- | ----------- |
  23393. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23394. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23395. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23396. *
  23397. */
  23398. scaleMode: number;
  23399. /**
  23400. * Force textures to be a power of two (default: false)
  23401. */
  23402. alwaysForcePOT: boolean;
  23403. private _samples;
  23404. /**
  23405. * Number of sample textures (default: 1)
  23406. */
  23407. get samples(): number;
  23408. set samples(n: number);
  23409. /**
  23410. * Modify the scale of the post process to be the same as the viewport (default: false)
  23411. */
  23412. adaptScaleToCurrentViewport: boolean;
  23413. private _camera;
  23414. protected _scene: Scene;
  23415. private _engine;
  23416. private _options;
  23417. private _reusable;
  23418. private _textureType;
  23419. private _textureFormat;
  23420. /**
  23421. * Smart array of input and output textures for the post process.
  23422. * @hidden
  23423. */
  23424. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23425. /**
  23426. * The index in _textures that corresponds to the output texture.
  23427. * @hidden
  23428. */
  23429. _currentRenderTextureInd: number;
  23430. private _effect;
  23431. private _samplers;
  23432. private _fragmentUrl;
  23433. private _vertexUrl;
  23434. private _parameters;
  23435. private _scaleRatio;
  23436. protected _indexParameters: any;
  23437. private _shareOutputWithPostProcess;
  23438. private _texelSize;
  23439. private _forcedOutputTexture;
  23440. /**
  23441. * Returns the fragment url or shader name used in the post process.
  23442. * @returns the fragment url or name in the shader store.
  23443. */
  23444. getEffectName(): string;
  23445. /**
  23446. * An event triggered when the postprocess is activated.
  23447. */
  23448. onActivateObservable: Observable<Camera>;
  23449. private _onActivateObserver;
  23450. /**
  23451. * A function that is added to the onActivateObservable
  23452. */
  23453. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23454. /**
  23455. * An event triggered when the postprocess changes its size.
  23456. */
  23457. onSizeChangedObservable: Observable<PostProcess>;
  23458. private _onSizeChangedObserver;
  23459. /**
  23460. * A function that is added to the onSizeChangedObservable
  23461. */
  23462. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23463. /**
  23464. * An event triggered when the postprocess applies its effect.
  23465. */
  23466. onApplyObservable: Observable<Effect>;
  23467. private _onApplyObserver;
  23468. /**
  23469. * A function that is added to the onApplyObservable
  23470. */
  23471. set onApply(callback: (effect: Effect) => void);
  23472. /**
  23473. * An event triggered before rendering the postprocess
  23474. */
  23475. onBeforeRenderObservable: Observable<Effect>;
  23476. private _onBeforeRenderObserver;
  23477. /**
  23478. * A function that is added to the onBeforeRenderObservable
  23479. */
  23480. set onBeforeRender(callback: (effect: Effect) => void);
  23481. /**
  23482. * An event triggered after rendering the postprocess
  23483. */
  23484. onAfterRenderObservable: Observable<Effect>;
  23485. private _onAfterRenderObserver;
  23486. /**
  23487. * A function that is added to the onAfterRenderObservable
  23488. */
  23489. set onAfterRender(callback: (efect: Effect) => void);
  23490. /**
  23491. * 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
  23492. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23493. */
  23494. get inputTexture(): InternalTexture;
  23495. set inputTexture(value: InternalTexture);
  23496. /**
  23497. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23498. * the only way to unset it is to use this function to restore its internal state
  23499. */
  23500. restoreDefaultInputTexture(): void;
  23501. /**
  23502. * Gets the camera which post process is applied to.
  23503. * @returns The camera the post process is applied to.
  23504. */
  23505. getCamera(): Camera;
  23506. /**
  23507. * Gets the texel size of the postprocess.
  23508. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23509. */
  23510. get texelSize(): Vector2;
  23511. /**
  23512. * Creates a new instance PostProcess
  23513. * @param name The name of the PostProcess.
  23514. * @param fragmentUrl The url of the fragment shader to be used.
  23515. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23516. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23517. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23518. * @param camera The camera to apply the render pass to.
  23519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23520. * @param engine The engine which the post process will be applied. (default: current engine)
  23521. * @param reusable If the post process can be reused on the same frame. (default: false)
  23522. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23523. * @param textureType Type of textures used when performing the post process. (default: 0)
  23524. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23525. * @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
  23526. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23527. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23528. */
  23529. constructor(
  23530. /** Name of the PostProcess. */
  23531. 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);
  23532. /**
  23533. * Gets a string idenfifying the name of the class
  23534. * @returns "PostProcess" string
  23535. */
  23536. getClassName(): string;
  23537. /**
  23538. * Gets the engine which this post process belongs to.
  23539. * @returns The engine the post process was enabled with.
  23540. */
  23541. getEngine(): Engine;
  23542. /**
  23543. * The effect that is created when initializing the post process.
  23544. * @returns The created effect corresponding the the postprocess.
  23545. */
  23546. getEffect(): Effect;
  23547. /**
  23548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23549. * @param postProcess The post process to share the output with.
  23550. * @returns This post process.
  23551. */
  23552. shareOutputWith(postProcess: PostProcess): PostProcess;
  23553. /**
  23554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23556. */
  23557. useOwnOutput(): void;
  23558. /**
  23559. * Updates the effect with the current post process compile time values and recompiles the shader.
  23560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23563. * @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
  23564. * @param onCompiled Called when the shader has been compiled.
  23565. * @param onError Called if there is an error when compiling a shader.
  23566. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23567. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23568. */
  23569. 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;
  23570. /**
  23571. * The post process is reusable if it can be used multiple times within one frame.
  23572. * @returns If the post process is reusable
  23573. */
  23574. isReusable(): boolean;
  23575. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23576. markTextureDirty(): void;
  23577. /**
  23578. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23579. * 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.
  23580. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23581. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23582. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23583. * @returns The target texture that was bound to be written to.
  23584. */
  23585. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23586. /**
  23587. * If the post process is supported.
  23588. */
  23589. get isSupported(): boolean;
  23590. /**
  23591. * The aspect ratio of the output texture.
  23592. */
  23593. get aspectRatio(): number;
  23594. /**
  23595. * Get a value indicating if the post-process is ready to be used
  23596. * @returns true if the post-process is ready (shader is compiled)
  23597. */
  23598. isReady(): boolean;
  23599. /**
  23600. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23601. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23602. */
  23603. apply(): Nullable<Effect>;
  23604. private _disposeTextures;
  23605. /**
  23606. * Disposes the post process.
  23607. * @param camera The camera to dispose the post process on.
  23608. */
  23609. dispose(camera?: Camera): void;
  23610. }
  23611. }
  23612. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23613. /** @hidden */
  23614. export var kernelBlurVaryingDeclaration: {
  23615. name: string;
  23616. shader: string;
  23617. };
  23618. }
  23619. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23620. /** @hidden */
  23621. export var kernelBlurFragment: {
  23622. name: string;
  23623. shader: string;
  23624. };
  23625. }
  23626. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23627. /** @hidden */
  23628. export var kernelBlurFragment2: {
  23629. name: string;
  23630. shader: string;
  23631. };
  23632. }
  23633. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23634. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23635. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23636. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23637. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23638. /** @hidden */
  23639. export var kernelBlurPixelShader: {
  23640. name: string;
  23641. shader: string;
  23642. };
  23643. }
  23644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23645. /** @hidden */
  23646. export var kernelBlurVertex: {
  23647. name: string;
  23648. shader: string;
  23649. };
  23650. }
  23651. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23652. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23653. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23654. /** @hidden */
  23655. export var kernelBlurVertexShader: {
  23656. name: string;
  23657. shader: string;
  23658. };
  23659. }
  23660. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23661. import { Vector2 } from "babylonjs/Maths/math.vector";
  23662. import { Nullable } from "babylonjs/types";
  23663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23664. import { Camera } from "babylonjs/Cameras/camera";
  23665. import { Effect } from "babylonjs/Materials/effect";
  23666. import { Engine } from "babylonjs/Engines/engine";
  23667. import "babylonjs/Shaders/kernelBlur.fragment";
  23668. import "babylonjs/Shaders/kernelBlur.vertex";
  23669. /**
  23670. * The Blur Post Process which blurs an image based on a kernel and direction.
  23671. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23672. */
  23673. export class BlurPostProcess extends PostProcess {
  23674. /** The direction in which to blur the image. */
  23675. direction: Vector2;
  23676. private blockCompilation;
  23677. protected _kernel: number;
  23678. protected _idealKernel: number;
  23679. protected _packedFloat: boolean;
  23680. private _staticDefines;
  23681. /**
  23682. * Sets the length in pixels of the blur sample region
  23683. */
  23684. set kernel(v: number);
  23685. /**
  23686. * Gets the length in pixels of the blur sample region
  23687. */
  23688. get kernel(): number;
  23689. /**
  23690. * Sets wether or not the blur needs to unpack/repack floats
  23691. */
  23692. set packedFloat(v: boolean);
  23693. /**
  23694. * Gets wether or not the blur is unpacking/repacking floats
  23695. */
  23696. get packedFloat(): boolean;
  23697. /**
  23698. * Creates a new instance BlurPostProcess
  23699. * @param name The name of the effect.
  23700. * @param direction The direction in which to blur the image.
  23701. * @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.
  23702. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23703. * @param camera The camera to apply the render pass to.
  23704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23705. * @param engine The engine which the post process will be applied. (default: current engine)
  23706. * @param reusable If the post process can be reused on the same frame. (default: false)
  23707. * @param textureType Type of textures used when performing the post process. (default: 0)
  23708. * @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)
  23709. */
  23710. constructor(name: string,
  23711. /** The direction in which to blur the image. */
  23712. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23713. /**
  23714. * Updates the effect with the current post process compile time values and recompiles the shader.
  23715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23718. * @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
  23719. * @param onCompiled Called when the shader has been compiled.
  23720. * @param onError Called if there is an error when compiling a shader.
  23721. */
  23722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23723. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23724. /**
  23725. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23726. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23727. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23728. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23729. * The gaps between physical kernels are compensated for in the weighting of the samples
  23730. * @param idealKernel Ideal blur kernel.
  23731. * @return Nearest best kernel.
  23732. */
  23733. protected _nearestBestKernel(idealKernel: number): number;
  23734. /**
  23735. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23736. * @param x The point on the Gaussian distribution to sample.
  23737. * @return the value of the Gaussian function at x.
  23738. */
  23739. protected _gaussianWeight(x: number): number;
  23740. /**
  23741. * Generates a string that can be used as a floating point number in GLSL.
  23742. * @param x Value to print.
  23743. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23744. * @return GLSL float string.
  23745. */
  23746. protected _glslFloat(x: number, decimalFigures?: number): string;
  23747. }
  23748. }
  23749. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23750. import { Scene } from "babylonjs/scene";
  23751. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23752. import { Plane } from "babylonjs/Maths/math.plane";
  23753. /**
  23754. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23755. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23756. * You can then easily use it as a reflectionTexture on a flat surface.
  23757. * In case the surface is not a plane, please consider relying on reflection probes.
  23758. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23759. */
  23760. export class MirrorTexture extends RenderTargetTexture {
  23761. private scene;
  23762. /**
  23763. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23764. * 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.
  23765. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23766. */
  23767. mirrorPlane: Plane;
  23768. /**
  23769. * Define the blur ratio used to blur the reflection if needed.
  23770. */
  23771. set blurRatio(value: number);
  23772. get blurRatio(): number;
  23773. /**
  23774. * Define the adaptive blur kernel used to blur the reflection if needed.
  23775. * This will autocompute the closest best match for the `blurKernel`
  23776. */
  23777. set adaptiveBlurKernel(value: number);
  23778. /**
  23779. * Define the blur kernel used to blur the reflection if needed.
  23780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23781. */
  23782. set blurKernel(value: number);
  23783. /**
  23784. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23786. */
  23787. set blurKernelX(value: number);
  23788. get blurKernelX(): number;
  23789. /**
  23790. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23791. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23792. */
  23793. set blurKernelY(value: number);
  23794. get blurKernelY(): number;
  23795. private _autoComputeBlurKernel;
  23796. protected _onRatioRescale(): void;
  23797. private _updateGammaSpace;
  23798. private _imageProcessingConfigChangeObserver;
  23799. private _transformMatrix;
  23800. private _mirrorMatrix;
  23801. private _savedViewMatrix;
  23802. private _blurX;
  23803. private _blurY;
  23804. private _adaptiveBlurKernel;
  23805. private _blurKernelX;
  23806. private _blurKernelY;
  23807. private _blurRatio;
  23808. /**
  23809. * Instantiates a Mirror Texture.
  23810. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23811. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23812. * You can then easily use it as a reflectionTexture on a flat surface.
  23813. * In case the surface is not a plane, please consider relying on reflection probes.
  23814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23815. * @param name
  23816. * @param size
  23817. * @param scene
  23818. * @param generateMipMaps
  23819. * @param type
  23820. * @param samplingMode
  23821. * @param generateDepthBuffer
  23822. */
  23823. constructor(name: string, size: number | {
  23824. width: number;
  23825. height: number;
  23826. } | {
  23827. ratio: number;
  23828. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23829. private _preparePostProcesses;
  23830. /**
  23831. * Clone the mirror texture.
  23832. * @returns the cloned texture
  23833. */
  23834. clone(): MirrorTexture;
  23835. /**
  23836. * Serialize the texture to a JSON representation you could use in Parse later on
  23837. * @returns the serialized JSON representation
  23838. */
  23839. serialize(): any;
  23840. /**
  23841. * Dispose the texture and release its associated resources.
  23842. */
  23843. dispose(): void;
  23844. }
  23845. }
  23846. declare module "babylonjs/Materials/Textures/texture" {
  23847. import { Observable } from "babylonjs/Misc/observable";
  23848. import { Nullable } from "babylonjs/types";
  23849. import { Matrix } from "babylonjs/Maths/math.vector";
  23850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23851. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23852. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23853. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23854. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23856. import { Scene } from "babylonjs/scene";
  23857. /**
  23858. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23859. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23860. */
  23861. export class Texture extends BaseTexture {
  23862. /**
  23863. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23864. */
  23865. static SerializeBuffers: boolean;
  23866. /** @hidden */
  23867. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23868. /** @hidden */
  23869. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23870. /** @hidden */
  23871. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23872. /** nearest is mag = nearest and min = nearest and mip = linear */
  23873. static readonly NEAREST_SAMPLINGMODE: number;
  23874. /** nearest is mag = nearest and min = nearest and mip = linear */
  23875. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23877. static readonly BILINEAR_SAMPLINGMODE: number;
  23878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23879. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23880. /** Trilinear is mag = linear and min = linear and mip = linear */
  23881. static readonly TRILINEAR_SAMPLINGMODE: number;
  23882. /** Trilinear is mag = linear and min = linear and mip = linear */
  23883. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23884. /** mag = nearest and min = nearest and mip = nearest */
  23885. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23886. /** mag = nearest and min = linear and mip = nearest */
  23887. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23888. /** mag = nearest and min = linear and mip = linear */
  23889. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23890. /** mag = nearest and min = linear and mip = none */
  23891. static readonly NEAREST_LINEAR: number;
  23892. /** mag = nearest and min = nearest and mip = none */
  23893. static readonly NEAREST_NEAREST: number;
  23894. /** mag = linear and min = nearest and mip = nearest */
  23895. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23896. /** mag = linear and min = nearest and mip = linear */
  23897. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23898. /** mag = linear and min = linear and mip = none */
  23899. static readonly LINEAR_LINEAR: number;
  23900. /** mag = linear and min = nearest and mip = none */
  23901. static readonly LINEAR_NEAREST: number;
  23902. /** Explicit coordinates mode */
  23903. static readonly EXPLICIT_MODE: number;
  23904. /** Spherical coordinates mode */
  23905. static readonly SPHERICAL_MODE: number;
  23906. /** Planar coordinates mode */
  23907. static readonly PLANAR_MODE: number;
  23908. /** Cubic coordinates mode */
  23909. static readonly CUBIC_MODE: number;
  23910. /** Projection coordinates mode */
  23911. static readonly PROJECTION_MODE: number;
  23912. /** Inverse Cubic coordinates mode */
  23913. static readonly SKYBOX_MODE: number;
  23914. /** Inverse Cubic coordinates mode */
  23915. static readonly INVCUBIC_MODE: number;
  23916. /** Equirectangular coordinates mode */
  23917. static readonly EQUIRECTANGULAR_MODE: number;
  23918. /** Equirectangular Fixed coordinates mode */
  23919. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23920. /** Equirectangular Fixed Mirrored coordinates mode */
  23921. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23922. /** Texture is not repeating outside of 0..1 UVs */
  23923. static readonly CLAMP_ADDRESSMODE: number;
  23924. /** Texture is repeating outside of 0..1 UVs */
  23925. static readonly WRAP_ADDRESSMODE: number;
  23926. /** Texture is repeating and mirrored */
  23927. static readonly MIRROR_ADDRESSMODE: number;
  23928. /**
  23929. * 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
  23930. */
  23931. static UseSerializedUrlIfAny: boolean;
  23932. /**
  23933. * Define the url of the texture.
  23934. */
  23935. url: Nullable<string>;
  23936. /**
  23937. * Define an offset on the texture to offset the u coordinates of the UVs
  23938. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23939. */
  23940. uOffset: number;
  23941. /**
  23942. * Define an offset on the texture to offset the v coordinates of the UVs
  23943. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23944. */
  23945. vOffset: number;
  23946. /**
  23947. * Define an offset on the texture to scale the u coordinates of the UVs
  23948. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23949. */
  23950. uScale: number;
  23951. /**
  23952. * Define an offset on the texture to scale the v coordinates of the UVs
  23953. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23954. */
  23955. vScale: number;
  23956. /**
  23957. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23958. * @see https://doc.babylonjs.com/how_to/more_materials
  23959. */
  23960. uAng: number;
  23961. /**
  23962. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23963. * @see https://doc.babylonjs.com/how_to/more_materials
  23964. */
  23965. vAng: number;
  23966. /**
  23967. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23968. * @see https://doc.babylonjs.com/how_to/more_materials
  23969. */
  23970. wAng: number;
  23971. /**
  23972. * Defines the center of rotation (U)
  23973. */
  23974. uRotationCenter: number;
  23975. /**
  23976. * Defines the center of rotation (V)
  23977. */
  23978. vRotationCenter: number;
  23979. /**
  23980. * Defines the center of rotation (W)
  23981. */
  23982. wRotationCenter: number;
  23983. /**
  23984. * Are mip maps generated for this texture or not.
  23985. */
  23986. get noMipmap(): boolean;
  23987. /**
  23988. * List of inspectable custom properties (used by the Inspector)
  23989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23990. */
  23991. inspectableCustomProperties: Nullable<IInspectable[]>;
  23992. private _noMipmap;
  23993. /** @hidden */
  23994. _invertY: boolean;
  23995. private _rowGenerationMatrix;
  23996. private _cachedTextureMatrix;
  23997. private _projectionModeMatrix;
  23998. private _t0;
  23999. private _t1;
  24000. private _t2;
  24001. private _cachedUOffset;
  24002. private _cachedVOffset;
  24003. private _cachedUScale;
  24004. private _cachedVScale;
  24005. private _cachedUAng;
  24006. private _cachedVAng;
  24007. private _cachedWAng;
  24008. private _cachedProjectionMatrixId;
  24009. private _cachedCoordinatesMode;
  24010. /** @hidden */
  24011. protected _initialSamplingMode: number;
  24012. /** @hidden */
  24013. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24014. private _deleteBuffer;
  24015. protected _format: Nullable<number>;
  24016. private _delayedOnLoad;
  24017. private _delayedOnError;
  24018. private _mimeType?;
  24019. /**
  24020. * Observable triggered once the texture has been loaded.
  24021. */
  24022. onLoadObservable: Observable<Texture>;
  24023. protected _isBlocking: boolean;
  24024. /**
  24025. * Is the texture preventing material to render while loading.
  24026. * If false, a default texture will be used instead of the loading one during the preparation step.
  24027. */
  24028. set isBlocking(value: boolean);
  24029. get isBlocking(): boolean;
  24030. /**
  24031. * Get the current sampling mode associated with the texture.
  24032. */
  24033. get samplingMode(): number;
  24034. /**
  24035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24036. */
  24037. get invertY(): boolean;
  24038. /**
  24039. * Instantiates a new texture.
  24040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24041. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24042. * @param url defines the url of the picture to load as a texture
  24043. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24044. * @param noMipmap defines if the texture will require mip maps or not
  24045. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24046. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24047. * @param onLoad defines a callback triggered when the texture has been loaded
  24048. * @param onError defines a callback triggered when an error occurred during the loading session
  24049. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24050. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24051. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24052. * @param mimeType defines an optional mime type information
  24053. */
  24054. 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);
  24055. /**
  24056. * Update the url (and optional buffer) of this texture if url was null during construction.
  24057. * @param url the url of the texture
  24058. * @param buffer the buffer of the texture (defaults to null)
  24059. * @param onLoad callback called when the texture is loaded (defaults to null)
  24060. */
  24061. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24062. /**
  24063. * Finish the loading sequence of a texture flagged as delayed load.
  24064. * @hidden
  24065. */
  24066. delayLoad(): void;
  24067. private _prepareRowForTextureGeneration;
  24068. /**
  24069. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24070. * @returns the transform matrix of the texture.
  24071. */
  24072. getTextureMatrix(uBase?: number): Matrix;
  24073. /**
  24074. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24075. * @returns The reflection texture transform
  24076. */
  24077. getReflectionTextureMatrix(): Matrix;
  24078. /**
  24079. * Clones the texture.
  24080. * @returns the cloned texture
  24081. */
  24082. clone(): Texture;
  24083. /**
  24084. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24085. * @returns The JSON representation of the texture
  24086. */
  24087. serialize(): any;
  24088. /**
  24089. * Get the current class name of the texture useful for serialization or dynamic coding.
  24090. * @returns "Texture"
  24091. */
  24092. getClassName(): string;
  24093. /**
  24094. * Dispose the texture and release its associated resources.
  24095. */
  24096. dispose(): void;
  24097. /**
  24098. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24099. * @param parsedTexture Define the JSON representation of the texture
  24100. * @param scene Define the scene the parsed texture should be instantiated in
  24101. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24102. * @returns The parsed texture if successful
  24103. */
  24104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24105. /**
  24106. * Creates a texture from its base 64 representation.
  24107. * @param data Define the base64 payload without the data: prefix
  24108. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24109. * @param scene Define the scene the texture should belong to
  24110. * @param noMipmap Forces the texture to not create mip map information if true
  24111. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24112. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24113. * @param onLoad define a callback triggered when the texture has been loaded
  24114. * @param onError define a callback triggered when an error occurred during the loading session
  24115. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24116. * @returns the created texture
  24117. */
  24118. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24119. /**
  24120. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24121. * @param data Define the base64 payload without the data: prefix
  24122. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24123. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24124. * @param scene Define the scene the texture should belong to
  24125. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24126. * @param noMipmap Forces the texture to not create mip map information if true
  24127. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24128. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24129. * @param onLoad define a callback triggered when the texture has been loaded
  24130. * @param onError define a callback triggered when an error occurred during the loading session
  24131. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24132. * @returns the created texture
  24133. */
  24134. 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;
  24135. }
  24136. }
  24137. declare module "babylonjs/PostProcesses/postProcessManager" {
  24138. import { Nullable } from "babylonjs/types";
  24139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24141. import { Scene } from "babylonjs/scene";
  24142. /**
  24143. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24144. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24145. */
  24146. export class PostProcessManager {
  24147. private _scene;
  24148. private _indexBuffer;
  24149. private _vertexBuffers;
  24150. /**
  24151. * Creates a new instance PostProcess
  24152. * @param scene The scene that the post process is associated with.
  24153. */
  24154. constructor(scene: Scene);
  24155. private _prepareBuffers;
  24156. private _buildIndexBuffer;
  24157. /**
  24158. * Rebuilds the vertex buffers of the manager.
  24159. * @hidden
  24160. */
  24161. _rebuild(): void;
  24162. /**
  24163. * Prepares a frame to be run through a post process.
  24164. * @param sourceTexture The input texture to the post procesess. (default: null)
  24165. * @param postProcesses An array of post processes to be run. (default: null)
  24166. * @returns True if the post processes were able to be run.
  24167. * @hidden
  24168. */
  24169. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24170. /**
  24171. * Manually render a set of post processes to a texture.
  24172. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24173. * @param postProcesses An array of post processes to be run.
  24174. * @param targetTexture The target texture to render to.
  24175. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24176. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24177. * @param lodLevel defines which lod of the texture to render to
  24178. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24179. */
  24180. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24181. /**
  24182. * Finalize the result of the output of the postprocesses.
  24183. * @param doNotPresent If true the result will not be displayed to the screen.
  24184. * @param targetTexture The target texture to render to.
  24185. * @param faceIndex The index of the face to bind the target texture to.
  24186. * @param postProcesses The array of post processes to render.
  24187. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24188. * @hidden
  24189. */
  24190. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24191. /**
  24192. * Disposes of the post process manager.
  24193. */
  24194. dispose(): void;
  24195. }
  24196. }
  24197. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24198. import { Observable } from "babylonjs/Misc/observable";
  24199. import { SmartArray } from "babylonjs/Misc/smartArray";
  24200. import { Nullable, Immutable } from "babylonjs/types";
  24201. import { Camera } from "babylonjs/Cameras/camera";
  24202. import { Scene } from "babylonjs/scene";
  24203. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24204. import { Color4 } from "babylonjs/Maths/math.color";
  24205. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24207. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24208. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24209. import { Texture } from "babylonjs/Materials/Textures/texture";
  24210. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24211. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24212. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24213. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24214. import { Engine } from "babylonjs/Engines/engine";
  24215. /**
  24216. * This Helps creating a texture that will be created from a camera in your scene.
  24217. * It is basically a dynamic texture that could be used to create special effects for instance.
  24218. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24219. */
  24220. export class RenderTargetTexture extends Texture {
  24221. isCube: boolean;
  24222. /**
  24223. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24224. */
  24225. static readonly REFRESHRATE_RENDER_ONCE: number;
  24226. /**
  24227. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24228. */
  24229. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24230. /**
  24231. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24232. * the central point of your effect and can save a lot of performances.
  24233. */
  24234. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24235. /**
  24236. * Use this predicate to dynamically define the list of mesh you want to render.
  24237. * If set, the renderList property will be overwritten.
  24238. */
  24239. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24240. private _renderList;
  24241. /**
  24242. * Use this list to define the list of mesh you want to render.
  24243. */
  24244. get renderList(): Nullable<Array<AbstractMesh>>;
  24245. set renderList(value: Nullable<Array<AbstractMesh>>);
  24246. /**
  24247. * Use this function to overload the renderList array at rendering time.
  24248. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24249. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24250. * the cube (if the RTT is a cube, else layerOrFace=0).
  24251. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24252. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24253. * hold dummy elements!
  24254. */
  24255. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24256. private _hookArray;
  24257. /**
  24258. * Define if particles should be rendered in your texture.
  24259. */
  24260. renderParticles: boolean;
  24261. /**
  24262. * Define if sprites should be rendered in your texture.
  24263. */
  24264. renderSprites: boolean;
  24265. /**
  24266. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24267. */
  24268. coordinatesMode: number;
  24269. /**
  24270. * Define the camera used to render the texture.
  24271. */
  24272. activeCamera: Nullable<Camera>;
  24273. /**
  24274. * Override the mesh isReady function with your own one.
  24275. */
  24276. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24277. /**
  24278. * Override the render function of the texture with your own one.
  24279. */
  24280. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24281. /**
  24282. * Define if camera post processes should be use while rendering the texture.
  24283. */
  24284. useCameraPostProcesses: boolean;
  24285. /**
  24286. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24287. */
  24288. ignoreCameraViewport: boolean;
  24289. private _postProcessManager;
  24290. private _postProcesses;
  24291. private _resizeObserver;
  24292. /**
  24293. * An event triggered when the texture is unbind.
  24294. */
  24295. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24296. /**
  24297. * An event triggered when the texture is unbind.
  24298. */
  24299. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24300. private _onAfterUnbindObserver;
  24301. /**
  24302. * Set a after unbind callback in the texture.
  24303. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24304. */
  24305. set onAfterUnbind(callback: () => void);
  24306. /**
  24307. * An event triggered before rendering the texture
  24308. */
  24309. onBeforeRenderObservable: Observable<number>;
  24310. private _onBeforeRenderObserver;
  24311. /**
  24312. * Set a before render callback in the texture.
  24313. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24314. */
  24315. set onBeforeRender(callback: (faceIndex: number) => void);
  24316. /**
  24317. * An event triggered after rendering the texture
  24318. */
  24319. onAfterRenderObservable: Observable<number>;
  24320. private _onAfterRenderObserver;
  24321. /**
  24322. * Set a after render callback in the texture.
  24323. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24324. */
  24325. set onAfterRender(callback: (faceIndex: number) => void);
  24326. /**
  24327. * An event triggered after the texture clear
  24328. */
  24329. onClearObservable: Observable<Engine>;
  24330. private _onClearObserver;
  24331. /**
  24332. * Set a clear callback in the texture.
  24333. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24334. */
  24335. set onClear(callback: (Engine: Engine) => void);
  24336. /**
  24337. * An event triggered when the texture is resized.
  24338. */
  24339. onResizeObservable: Observable<RenderTargetTexture>;
  24340. /**
  24341. * Define the clear color of the Render Target if it should be different from the scene.
  24342. */
  24343. clearColor: Color4;
  24344. protected _size: number | {
  24345. width: number;
  24346. height: number;
  24347. layers?: number;
  24348. };
  24349. protected _initialSizeParameter: number | {
  24350. width: number;
  24351. height: number;
  24352. } | {
  24353. ratio: number;
  24354. };
  24355. protected _sizeRatio: Nullable<number>;
  24356. /** @hidden */
  24357. _generateMipMaps: boolean;
  24358. protected _renderingManager: RenderingManager;
  24359. /** @hidden */
  24360. _waitingRenderList: string[];
  24361. protected _doNotChangeAspectRatio: boolean;
  24362. protected _currentRefreshId: number;
  24363. protected _refreshRate: number;
  24364. protected _textureMatrix: Matrix;
  24365. protected _samples: number;
  24366. protected _renderTargetOptions: RenderTargetCreationOptions;
  24367. /**
  24368. * Gets render target creation options that were used.
  24369. */
  24370. get renderTargetOptions(): RenderTargetCreationOptions;
  24371. protected _onRatioRescale(): void;
  24372. /**
  24373. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24374. * It must define where the camera used to render the texture is set
  24375. */
  24376. boundingBoxPosition: Vector3;
  24377. private _boundingBoxSize;
  24378. /**
  24379. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24380. * When defined, the cubemap will switch to local mode
  24381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24382. * @example https://www.babylonjs-playground.com/#RNASML
  24383. */
  24384. set boundingBoxSize(value: Vector3);
  24385. get boundingBoxSize(): Vector3;
  24386. /**
  24387. * In case the RTT has been created with a depth texture, get the associated
  24388. * depth texture.
  24389. * Otherwise, return null.
  24390. */
  24391. get depthStencilTexture(): Nullable<InternalTexture>;
  24392. /**
  24393. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24394. * or used a shadow, depth texture...
  24395. * @param name The friendly name of the texture
  24396. * @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)
  24397. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24398. * @param generateMipMaps True if mip maps need to be generated after render.
  24399. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24400. * @param type The type of the buffer in the RTT (int, half float, float...)
  24401. * @param isCube True if a cube texture needs to be created
  24402. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24403. * @param generateDepthBuffer True to generate a depth buffer
  24404. * @param generateStencilBuffer True to generate a stencil buffer
  24405. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24406. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24407. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24408. */
  24409. constructor(name: string, size: number | {
  24410. width: number;
  24411. height: number;
  24412. layers?: number;
  24413. } | {
  24414. ratio: number;
  24415. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24416. /**
  24417. * Creates a depth stencil texture.
  24418. * This is only available in WebGL 2 or with the depth texture extension available.
  24419. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24420. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24421. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24422. */
  24423. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24424. private _processSizeParameter;
  24425. /**
  24426. * Define the number of samples to use in case of MSAA.
  24427. * It defaults to one meaning no MSAA has been enabled.
  24428. */
  24429. get samples(): number;
  24430. set samples(value: number);
  24431. /**
  24432. * Resets the refresh counter of the texture and start bak from scratch.
  24433. * Could be useful to regenerate the texture if it is setup to render only once.
  24434. */
  24435. resetRefreshCounter(): void;
  24436. /**
  24437. * Define the refresh rate of the texture or the rendering frequency.
  24438. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24439. */
  24440. get refreshRate(): number;
  24441. set refreshRate(value: number);
  24442. /**
  24443. * Adds a post process to the render target rendering passes.
  24444. * @param postProcess define the post process to add
  24445. */
  24446. addPostProcess(postProcess: PostProcess): void;
  24447. /**
  24448. * Clear all the post processes attached to the render target
  24449. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24450. */
  24451. clearPostProcesses(dispose?: boolean): void;
  24452. /**
  24453. * Remove one of the post process from the list of attached post processes to the texture
  24454. * @param postProcess define the post process to remove from the list
  24455. */
  24456. removePostProcess(postProcess: PostProcess): void;
  24457. /** @hidden */
  24458. _shouldRender(): boolean;
  24459. /**
  24460. * Gets the actual render size of the texture.
  24461. * @returns the width of the render size
  24462. */
  24463. getRenderSize(): number;
  24464. /**
  24465. * Gets the actual render width of the texture.
  24466. * @returns the width of the render size
  24467. */
  24468. getRenderWidth(): number;
  24469. /**
  24470. * Gets the actual render height of the texture.
  24471. * @returns the height of the render size
  24472. */
  24473. getRenderHeight(): number;
  24474. /**
  24475. * Gets the actual number of layers of the texture.
  24476. * @returns the number of layers
  24477. */
  24478. getRenderLayers(): number;
  24479. /**
  24480. * Get if the texture can be rescaled or not.
  24481. */
  24482. get canRescale(): boolean;
  24483. /**
  24484. * Resize the texture using a ratio.
  24485. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24486. */
  24487. scale(ratio: number): void;
  24488. /**
  24489. * Get the texture reflection matrix used to rotate/transform the reflection.
  24490. * @returns the reflection matrix
  24491. */
  24492. getReflectionTextureMatrix(): Matrix;
  24493. /**
  24494. * Resize the texture to a new desired size.
  24495. * Be carrefull as it will recreate all the data in the new texture.
  24496. * @param size Define the new size. It can be:
  24497. * - a number for squared texture,
  24498. * - an object containing { width: number, height: number }
  24499. * - or an object containing a ratio { ratio: number }
  24500. */
  24501. resize(size: number | {
  24502. width: number;
  24503. height: number;
  24504. } | {
  24505. ratio: number;
  24506. }): void;
  24507. private _defaultRenderListPrepared;
  24508. /**
  24509. * Renders all the objects from the render list into the texture.
  24510. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24511. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24512. */
  24513. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24514. private _bestReflectionRenderTargetDimension;
  24515. private _prepareRenderingManager;
  24516. /**
  24517. * @hidden
  24518. * @param faceIndex face index to bind to if this is a cubetexture
  24519. * @param layer defines the index of the texture to bind in the array
  24520. */
  24521. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24522. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24523. private renderToTarget;
  24524. /**
  24525. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24526. * This allowed control for front to back rendering or reversly depending of the special needs.
  24527. *
  24528. * @param renderingGroupId The rendering group id corresponding to its index
  24529. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24530. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24531. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24532. */
  24533. 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;
  24534. /**
  24535. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24536. *
  24537. * @param renderingGroupId The rendering group id corresponding to its index
  24538. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24539. */
  24540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24541. /**
  24542. * Clones the texture.
  24543. * @returns the cloned texture
  24544. */
  24545. clone(): RenderTargetTexture;
  24546. /**
  24547. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24548. * @returns The JSON representation of the texture
  24549. */
  24550. serialize(): any;
  24551. /**
  24552. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24553. */
  24554. disposeFramebufferObjects(): void;
  24555. /**
  24556. * Dispose the texture and release its associated resources.
  24557. */
  24558. dispose(): void;
  24559. /** @hidden */
  24560. _rebuild(): void;
  24561. /**
  24562. * Clear the info related to rendering groups preventing retention point in material dispose.
  24563. */
  24564. freeRenderingGroups(): void;
  24565. /**
  24566. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24567. * @returns the view count
  24568. */
  24569. getViewCount(): number;
  24570. }
  24571. }
  24572. declare module "babylonjs/Misc/guid" {
  24573. /**
  24574. * Class used to manipulate GUIDs
  24575. */
  24576. export class GUID {
  24577. /**
  24578. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24579. * Be aware Math.random() could cause collisions, but:
  24580. * "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"
  24581. * @returns a pseudo random id
  24582. */
  24583. static RandomId(): string;
  24584. }
  24585. }
  24586. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24587. import { Nullable } from "babylonjs/types";
  24588. import { Scene } from "babylonjs/scene";
  24589. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24590. import { Material } from "babylonjs/Materials/material";
  24591. import { Effect } from "babylonjs/Materials/effect";
  24592. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24593. /**
  24594. * Options to be used when creating a shadow depth material
  24595. */
  24596. export interface IIOptionShadowDepthMaterial {
  24597. /** Variables in the vertex shader code that need to have their names remapped.
  24598. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24599. * "var_name" should be either: worldPos or vNormalW
  24600. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24601. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24602. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24603. */
  24604. remappedVariables?: string[];
  24605. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24606. standalone?: boolean;
  24607. }
  24608. /**
  24609. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24610. */
  24611. export class ShadowDepthWrapper {
  24612. private _scene;
  24613. private _options?;
  24614. private _baseMaterial;
  24615. private _onEffectCreatedObserver;
  24616. private _subMeshToEffect;
  24617. private _subMeshToDepthEffect;
  24618. private _meshes;
  24619. /** @hidden */
  24620. _matriceNames: any;
  24621. /** Gets the standalone status of the wrapper */
  24622. get standalone(): boolean;
  24623. /** Gets the base material the wrapper is built upon */
  24624. get baseMaterial(): Material;
  24625. /**
  24626. * Instantiate a new shadow depth wrapper.
  24627. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24628. * generate the shadow depth map. For more information, please refer to the documentation:
  24629. * https://doc.babylonjs.com/babylon101/shadows
  24630. * @param baseMaterial Material to wrap
  24631. * @param scene Define the scene the material belongs to
  24632. * @param options Options used to create the wrapper
  24633. */
  24634. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24635. /**
  24636. * Gets the effect to use to generate the depth map
  24637. * @param subMesh subMesh to get the effect for
  24638. * @param shadowGenerator shadow generator to get the effect for
  24639. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24640. */
  24641. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24642. /**
  24643. * Specifies that the submesh is ready to be used for depth rendering
  24644. * @param subMesh submesh to check
  24645. * @param defines the list of defines to take into account when checking the effect
  24646. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24647. * @param useInstances specifies that instances should be used
  24648. * @returns a boolean indicating that the submesh is ready or not
  24649. */
  24650. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24651. /**
  24652. * Disposes the resources
  24653. */
  24654. dispose(): void;
  24655. private _makeEffect;
  24656. }
  24657. }
  24658. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24659. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24660. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24661. import { Nullable } from "babylonjs/types";
  24662. module "babylonjs/Engines/thinEngine" {
  24663. interface ThinEngine {
  24664. /**
  24665. * Unbind a list of render target textures from the webGL context
  24666. * This is used only when drawBuffer extension or webGL2 are active
  24667. * @param textures defines the render target textures to unbind
  24668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24670. */
  24671. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24672. /**
  24673. * Create a multi render target texture
  24674. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24675. * @param size defines the size of the texture
  24676. * @param options defines the creation options
  24677. * @returns the cube texture as an InternalTexture
  24678. */
  24679. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24680. /**
  24681. * Update the sample count for a given multiple render target texture
  24682. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24683. * @param textures defines the textures to update
  24684. * @param samples defines the sample count to set
  24685. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24686. */
  24687. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24688. /**
  24689. * Select a subsets of attachments to draw to.
  24690. * @param attachments gl attachments
  24691. */
  24692. bindAttachments(attachments: number[]): void;
  24693. }
  24694. }
  24695. }
  24696. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24697. import { Scene } from "babylonjs/scene";
  24698. import { Engine } from "babylonjs/Engines/engine";
  24699. import { Texture } from "babylonjs/Materials/Textures/texture";
  24700. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24701. import "babylonjs/Engines/Extensions/engine.multiRender";
  24702. /**
  24703. * Creation options of the multi render target texture.
  24704. */
  24705. export interface IMultiRenderTargetOptions {
  24706. /**
  24707. * Define if the texture needs to create mip maps after render.
  24708. */
  24709. generateMipMaps?: boolean;
  24710. /**
  24711. * Define the types of all the draw buffers we want to create
  24712. */
  24713. types?: number[];
  24714. /**
  24715. * Define the sampling modes of all the draw buffers we want to create
  24716. */
  24717. samplingModes?: number[];
  24718. /**
  24719. * Define if a depth buffer is required
  24720. */
  24721. generateDepthBuffer?: boolean;
  24722. /**
  24723. * Define if a stencil buffer is required
  24724. */
  24725. generateStencilBuffer?: boolean;
  24726. /**
  24727. * Define if a depth texture is required instead of a depth buffer
  24728. */
  24729. generateDepthTexture?: boolean;
  24730. /**
  24731. * Define the number of desired draw buffers
  24732. */
  24733. textureCount?: number;
  24734. /**
  24735. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24736. */
  24737. doNotChangeAspectRatio?: boolean;
  24738. /**
  24739. * Define the default type of the buffers we are creating
  24740. */
  24741. defaultType?: number;
  24742. }
  24743. /**
  24744. * A multi render target, like a render target provides the ability to render to a texture.
  24745. * Unlike the render target, it can render to several draw buffers in one draw.
  24746. * This is specially interesting in deferred rendering or for any effects requiring more than
  24747. * just one color from a single pass.
  24748. */
  24749. export class MultiRenderTarget extends RenderTargetTexture {
  24750. private _internalTextures;
  24751. private _textures;
  24752. private _multiRenderTargetOptions;
  24753. private _count;
  24754. /**
  24755. * Get if draw buffers are currently supported by the used hardware and browser.
  24756. */
  24757. get isSupported(): boolean;
  24758. /**
  24759. * Get the list of textures generated by the multi render target.
  24760. */
  24761. get textures(): Texture[];
  24762. /**
  24763. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24764. */
  24765. get count(): number;
  24766. /**
  24767. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24768. */
  24769. get depthTexture(): Texture;
  24770. /**
  24771. * Set the wrapping mode on U of all the textures we are rendering to.
  24772. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24773. */
  24774. set wrapU(wrap: number);
  24775. /**
  24776. * Set the wrapping mode on V of all the textures we are rendering to.
  24777. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24778. */
  24779. set wrapV(wrap: number);
  24780. /**
  24781. * Instantiate a new multi render target texture.
  24782. * A multi render target, like a render target provides the ability to render to a texture.
  24783. * Unlike the render target, it can render to several draw buffers in one draw.
  24784. * This is specially interesting in deferred rendering or for any effects requiring more than
  24785. * just one color from a single pass.
  24786. * @param name Define the name of the texture
  24787. * @param size Define the size of the buffers to render to
  24788. * @param count Define the number of target we are rendering into
  24789. * @param scene Define the scene the texture belongs to
  24790. * @param options Define the options used to create the multi render target
  24791. */
  24792. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24793. /** @hidden */
  24794. _rebuild(): void;
  24795. private _createInternalTextures;
  24796. private _createTextures;
  24797. /**
  24798. * Define the number of samples used if MSAA is enabled.
  24799. */
  24800. get samples(): number;
  24801. set samples(value: number);
  24802. /**
  24803. * Resize all the textures in the multi render target.
  24804. * Be carrefull as it will recreate all the data in the new texture.
  24805. * @param size Define the new size
  24806. */
  24807. resize(size: any): void;
  24808. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24809. /**
  24810. * Dispose the render targets and their associated resources
  24811. */
  24812. dispose(): void;
  24813. /**
  24814. * Release all the underlying texture used as draw buffers.
  24815. */
  24816. releaseInternalTextures(): void;
  24817. }
  24818. }
  24819. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24820. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24821. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24823. /** @hidden */
  24824. export var imageProcessingPixelShader: {
  24825. name: string;
  24826. shader: string;
  24827. };
  24828. }
  24829. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24830. import { Nullable } from "babylonjs/types";
  24831. import { Color4 } from "babylonjs/Maths/math.color";
  24832. import { Camera } from "babylonjs/Cameras/camera";
  24833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24834. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24835. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24837. import { Engine } from "babylonjs/Engines/engine";
  24838. import "babylonjs/Shaders/imageProcessing.fragment";
  24839. import "babylonjs/Shaders/postprocess.vertex";
  24840. /**
  24841. * ImageProcessingPostProcess
  24842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24843. */
  24844. export class ImageProcessingPostProcess extends PostProcess {
  24845. /**
  24846. * Default configuration related to image processing available in the PBR Material.
  24847. */
  24848. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24849. /**
  24850. * Gets the image processing configuration used either in this material.
  24851. */
  24852. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24853. /**
  24854. * Sets the Default image processing configuration used either in the this material.
  24855. *
  24856. * If sets to null, the scene one is in use.
  24857. */
  24858. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24859. /**
  24860. * Keep track of the image processing observer to allow dispose and replace.
  24861. */
  24862. private _imageProcessingObserver;
  24863. /**
  24864. * Attaches a new image processing configuration to the PBR Material.
  24865. * @param configuration
  24866. */
  24867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24868. /**
  24869. * If the post process is supported.
  24870. */
  24871. get isSupported(): boolean;
  24872. /**
  24873. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24874. */
  24875. get colorCurves(): Nullable<ColorCurves>;
  24876. /**
  24877. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24878. */
  24879. set colorCurves(value: Nullable<ColorCurves>);
  24880. /**
  24881. * Gets wether the color curves effect is enabled.
  24882. */
  24883. get colorCurvesEnabled(): boolean;
  24884. /**
  24885. * Sets wether the color curves effect is enabled.
  24886. */
  24887. set colorCurvesEnabled(value: boolean);
  24888. /**
  24889. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24890. */
  24891. get colorGradingTexture(): Nullable<BaseTexture>;
  24892. /**
  24893. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24894. */
  24895. set colorGradingTexture(value: Nullable<BaseTexture>);
  24896. /**
  24897. * Gets wether the color grading effect is enabled.
  24898. */
  24899. get colorGradingEnabled(): boolean;
  24900. /**
  24901. * Gets wether the color grading effect is enabled.
  24902. */
  24903. set colorGradingEnabled(value: boolean);
  24904. /**
  24905. * Gets exposure used in the effect.
  24906. */
  24907. get exposure(): number;
  24908. /**
  24909. * Sets exposure used in the effect.
  24910. */
  24911. set exposure(value: number);
  24912. /**
  24913. * Gets wether tonemapping is enabled or not.
  24914. */
  24915. get toneMappingEnabled(): boolean;
  24916. /**
  24917. * Sets wether tonemapping is enabled or not
  24918. */
  24919. set toneMappingEnabled(value: boolean);
  24920. /**
  24921. * Gets the type of tone mapping effect.
  24922. */
  24923. get toneMappingType(): number;
  24924. /**
  24925. * Sets the type of tone mapping effect.
  24926. */
  24927. set toneMappingType(value: number);
  24928. /**
  24929. * Gets contrast used in the effect.
  24930. */
  24931. get contrast(): number;
  24932. /**
  24933. * Sets contrast used in the effect.
  24934. */
  24935. set contrast(value: number);
  24936. /**
  24937. * Gets Vignette stretch size.
  24938. */
  24939. get vignetteStretch(): number;
  24940. /**
  24941. * Sets Vignette stretch size.
  24942. */
  24943. set vignetteStretch(value: number);
  24944. /**
  24945. * Gets Vignette centre X Offset.
  24946. */
  24947. get vignetteCentreX(): number;
  24948. /**
  24949. * Sets Vignette centre X Offset.
  24950. */
  24951. set vignetteCentreX(value: number);
  24952. /**
  24953. * Gets Vignette centre Y Offset.
  24954. */
  24955. get vignetteCentreY(): number;
  24956. /**
  24957. * Sets Vignette centre Y Offset.
  24958. */
  24959. set vignetteCentreY(value: number);
  24960. /**
  24961. * Gets Vignette weight or intensity of the vignette effect.
  24962. */
  24963. get vignetteWeight(): number;
  24964. /**
  24965. * Sets Vignette weight or intensity of the vignette effect.
  24966. */
  24967. set vignetteWeight(value: number);
  24968. /**
  24969. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24970. * if vignetteEnabled is set to true.
  24971. */
  24972. get vignetteColor(): Color4;
  24973. /**
  24974. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24975. * if vignetteEnabled is set to true.
  24976. */
  24977. set vignetteColor(value: Color4);
  24978. /**
  24979. * Gets Camera field of view used by the Vignette effect.
  24980. */
  24981. get vignetteCameraFov(): number;
  24982. /**
  24983. * Sets Camera field of view used by the Vignette effect.
  24984. */
  24985. set vignetteCameraFov(value: number);
  24986. /**
  24987. * Gets the vignette blend mode allowing different kind of effect.
  24988. */
  24989. get vignetteBlendMode(): number;
  24990. /**
  24991. * Sets the vignette blend mode allowing different kind of effect.
  24992. */
  24993. set vignetteBlendMode(value: number);
  24994. /**
  24995. * Gets wether the vignette effect is enabled.
  24996. */
  24997. get vignetteEnabled(): boolean;
  24998. /**
  24999. * Sets wether the vignette effect is enabled.
  25000. */
  25001. set vignetteEnabled(value: boolean);
  25002. private _fromLinearSpace;
  25003. /**
  25004. * Gets wether the input of the processing is in Gamma or Linear Space.
  25005. */
  25006. get fromLinearSpace(): boolean;
  25007. /**
  25008. * Sets wether the input of the processing is in Gamma or Linear Space.
  25009. */
  25010. set fromLinearSpace(value: boolean);
  25011. /**
  25012. * Defines cache preventing GC.
  25013. */
  25014. private _defines;
  25015. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25016. /**
  25017. * "ImageProcessingPostProcess"
  25018. * @returns "ImageProcessingPostProcess"
  25019. */
  25020. getClassName(): string;
  25021. /**
  25022. * @hidden
  25023. */
  25024. _updateParameters(): void;
  25025. dispose(camera?: Camera): void;
  25026. }
  25027. }
  25028. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25029. /** @hidden */
  25030. export var fibonacci: {
  25031. name: string;
  25032. shader: string;
  25033. };
  25034. }
  25035. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25036. /** @hidden */
  25037. export var subSurfaceScatteringFunctions: {
  25038. name: string;
  25039. shader: string;
  25040. };
  25041. }
  25042. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25043. /** @hidden */
  25044. export var diffusionProfile: {
  25045. name: string;
  25046. shader: string;
  25047. };
  25048. }
  25049. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25050. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25051. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25052. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25053. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25054. /** @hidden */
  25055. export var subSurfaceScatteringPixelShader: {
  25056. name: string;
  25057. shader: string;
  25058. };
  25059. }
  25060. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25061. import { Nullable } from "babylonjs/types";
  25062. import { Camera } from "babylonjs/Cameras/camera";
  25063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25064. import { Engine } from "babylonjs/Engines/engine";
  25065. import { Scene } from "babylonjs/scene";
  25066. import "babylonjs/Shaders/imageProcessing.fragment";
  25067. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25068. import "babylonjs/Shaders/postprocess.vertex";
  25069. /**
  25070. * Sub surface scattering post process
  25071. */
  25072. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25073. /** @hidden */
  25074. texelWidth: number;
  25075. /** @hidden */
  25076. texelHeight: number;
  25077. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25078. }
  25079. }
  25080. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25082. /**
  25083. * Interface for defining prepass effects in the prepass post-process pipeline
  25084. */
  25085. export interface PrePassEffectConfiguration {
  25086. /**
  25087. * Post process to attach for this effect
  25088. */
  25089. postProcess: PostProcess;
  25090. /**
  25091. * Is the effect enabled
  25092. */
  25093. enabled: boolean;
  25094. /**
  25095. * Disposes the effect configuration
  25096. */
  25097. dispose(): void;
  25098. /**
  25099. * Disposes the effect configuration
  25100. */
  25101. createPostProcess: () => PostProcess;
  25102. }
  25103. }
  25104. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25105. import { Scene } from "babylonjs/scene";
  25106. import { Color3 } from "babylonjs/Maths/math.color";
  25107. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25108. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25109. /**
  25110. * Contains all parameters needed for the prepass to perform
  25111. * screen space subsurface scattering
  25112. */
  25113. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25114. private _ssDiffusionS;
  25115. private _ssFilterRadii;
  25116. private _ssDiffusionD;
  25117. /**
  25118. * Post process to attach for screen space subsurface scattering
  25119. */
  25120. postProcess: SubSurfaceScatteringPostProcess;
  25121. /**
  25122. * Diffusion profile color for subsurface scattering
  25123. */
  25124. get ssDiffusionS(): number[];
  25125. /**
  25126. * Diffusion profile max color channel value for subsurface scattering
  25127. */
  25128. get ssDiffusionD(): number[];
  25129. /**
  25130. * Diffusion profile filter radius for subsurface scattering
  25131. */
  25132. get ssFilterRadii(): number[];
  25133. /**
  25134. * Is subsurface enabled
  25135. */
  25136. enabled: boolean;
  25137. /**
  25138. * Diffusion profile colors for subsurface scattering
  25139. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25140. * See ...
  25141. * Note that you can only store up to 5 of them
  25142. */
  25143. ssDiffusionProfileColors: Color3[];
  25144. /**
  25145. * Defines the ratio real world => scene units.
  25146. * Used for subsurface scattering
  25147. */
  25148. metersPerUnit: number;
  25149. private _scene;
  25150. /**
  25151. * Builds a subsurface configuration object
  25152. * @param scene The scene
  25153. */
  25154. constructor(scene: Scene);
  25155. /**
  25156. * Adds a new diffusion profile.
  25157. * Useful for more realistic subsurface scattering on diverse materials.
  25158. * @param color The color of the diffusion profile. Should be the average color of the material.
  25159. * @return The index of the diffusion profile for the material subsurface configuration
  25160. */
  25161. addDiffusionProfile(color: Color3): number;
  25162. /**
  25163. * Creates the sss post process
  25164. * @return The created post process
  25165. */
  25166. createPostProcess(): SubSurfaceScatteringPostProcess;
  25167. /**
  25168. * Deletes all diffusion profiles.
  25169. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25170. */
  25171. clearAllDiffusionProfiles(): void;
  25172. /**
  25173. * Disposes this object
  25174. */
  25175. dispose(): void;
  25176. /**
  25177. * @hidden
  25178. * https://zero-radiance.github.io/post/sampling-diffusion/
  25179. *
  25180. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25181. * ------------------------------------------------------------------------------------
  25182. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25183. * PDF[r, phi, s] = r * R[r, phi, s]
  25184. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25185. * ------------------------------------------------------------------------------------
  25186. * We importance sample the color channel with the widest scattering distance.
  25187. */
  25188. getDiffusionProfileParameters(color: Color3): number;
  25189. /**
  25190. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25191. * 'u' is the random number (the value of the CDF): [0, 1).
  25192. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25193. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25194. */
  25195. private _sampleBurleyDiffusionProfile;
  25196. }
  25197. }
  25198. declare module "babylonjs/Rendering/prePassRenderer" {
  25199. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25200. import { Scene } from "babylonjs/scene";
  25201. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25202. import { Effect } from "babylonjs/Materials/effect";
  25203. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25204. /**
  25205. * Renders a pre pass of the scene
  25206. * This means every mesh in the scene will be rendered to a render target texture
  25207. * And then this texture will be composited to the rendering canvas with post processes
  25208. * It is necessary for effects like subsurface scattering or deferred shading
  25209. */
  25210. export class PrePassRenderer {
  25211. /** @hidden */
  25212. static _SceneComponentInitialization: (scene: Scene) => void;
  25213. private _scene;
  25214. private _engine;
  25215. private _isDirty;
  25216. /**
  25217. * Number of textures in the multi render target texture where the scene is directly rendered
  25218. */
  25219. readonly mrtCount: number;
  25220. /**
  25221. * The render target where the scene is directly rendered
  25222. */
  25223. prePassRT: MultiRenderTarget;
  25224. private _mrtTypes;
  25225. private _multiRenderAttachments;
  25226. private _defaultAttachments;
  25227. private _clearAttachments;
  25228. private _postProcesses;
  25229. private readonly _clearColor;
  25230. /**
  25231. * Image processing post process for composition
  25232. */
  25233. imageProcessingPostProcess: ImageProcessingPostProcess;
  25234. /**
  25235. * Configuration for sub surface scattering post process
  25236. */
  25237. subSurfaceConfiguration: SubSurfaceConfiguration;
  25238. /**
  25239. * Should materials render their geometry on the MRT
  25240. */
  25241. materialsShouldRenderGeometry: boolean;
  25242. /**
  25243. * Should materials render the irradiance information on the MRT
  25244. */
  25245. materialsShouldRenderIrradiance: boolean;
  25246. private _enabled;
  25247. /**
  25248. * Indicates if the prepass is enabled
  25249. */
  25250. get enabled(): boolean;
  25251. /**
  25252. * How many samples are used for MSAA of the scene render target
  25253. */
  25254. get samples(): number;
  25255. set samples(n: number);
  25256. /**
  25257. * Instanciates a prepass renderer
  25258. * @param scene The scene
  25259. */
  25260. constructor(scene: Scene);
  25261. private _initializeAttachments;
  25262. private _createCompositionEffect;
  25263. /**
  25264. * Indicates if rendering a prepass is supported
  25265. */
  25266. get isSupported(): boolean;
  25267. /**
  25268. * Sets the proper output textures to draw in the engine.
  25269. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25270. */
  25271. bindAttachmentsForEffect(effect: Effect): void;
  25272. /**
  25273. * @hidden
  25274. */
  25275. _beforeCameraDraw(): void;
  25276. /**
  25277. * @hidden
  25278. */
  25279. _afterCameraDraw(): void;
  25280. private _checkRTSize;
  25281. private _bindFrameBuffer;
  25282. /**
  25283. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25284. */
  25285. clear(): void;
  25286. private _setState;
  25287. private _enable;
  25288. private _disable;
  25289. private _resetPostProcessChain;
  25290. private _bindPostProcessChain;
  25291. /**
  25292. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25293. */
  25294. markAsDirty(): void;
  25295. private _update;
  25296. /**
  25297. * Disposes the prepass renderer.
  25298. */
  25299. dispose(): void;
  25300. }
  25301. }
  25302. declare module "babylonjs/Materials/material" {
  25303. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25304. import { SmartArray } from "babylonjs/Misc/smartArray";
  25305. import { Observable } from "babylonjs/Misc/observable";
  25306. import { Nullable } from "babylonjs/types";
  25307. import { Scene } from "babylonjs/scene";
  25308. import { Matrix } from "babylonjs/Maths/math.vector";
  25309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25311. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25312. import { Effect } from "babylonjs/Materials/effect";
  25313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25314. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25315. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25316. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25317. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25318. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25319. import { Mesh } from "babylonjs/Meshes/mesh";
  25320. import { Animation } from "babylonjs/Animations/animation";
  25321. /**
  25322. * Options for compiling materials.
  25323. */
  25324. export interface IMaterialCompilationOptions {
  25325. /**
  25326. * Defines whether clip planes are enabled.
  25327. */
  25328. clipPlane: boolean;
  25329. /**
  25330. * Defines whether instances are enabled.
  25331. */
  25332. useInstances: boolean;
  25333. }
  25334. /**
  25335. * Options passed when calling customShaderNameResolve
  25336. */
  25337. export interface ICustomShaderNameResolveOptions {
  25338. /**
  25339. * 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
  25340. */
  25341. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25342. }
  25343. /**
  25344. * Base class for the main features of a material in Babylon.js
  25345. */
  25346. export class Material implements IAnimatable {
  25347. /**
  25348. * Returns the triangle fill mode
  25349. */
  25350. static readonly TriangleFillMode: number;
  25351. /**
  25352. * Returns the wireframe mode
  25353. */
  25354. static readonly WireFrameFillMode: number;
  25355. /**
  25356. * Returns the point fill mode
  25357. */
  25358. static readonly PointFillMode: number;
  25359. /**
  25360. * Returns the point list draw mode
  25361. */
  25362. static readonly PointListDrawMode: number;
  25363. /**
  25364. * Returns the line list draw mode
  25365. */
  25366. static readonly LineListDrawMode: number;
  25367. /**
  25368. * Returns the line loop draw mode
  25369. */
  25370. static readonly LineLoopDrawMode: number;
  25371. /**
  25372. * Returns the line strip draw mode
  25373. */
  25374. static readonly LineStripDrawMode: number;
  25375. /**
  25376. * Returns the triangle strip draw mode
  25377. */
  25378. static readonly TriangleStripDrawMode: number;
  25379. /**
  25380. * Returns the triangle fan draw mode
  25381. */
  25382. static readonly TriangleFanDrawMode: number;
  25383. /**
  25384. * Stores the clock-wise side orientation
  25385. */
  25386. static readonly ClockWiseSideOrientation: number;
  25387. /**
  25388. * Stores the counter clock-wise side orientation
  25389. */
  25390. static readonly CounterClockWiseSideOrientation: number;
  25391. /**
  25392. * The dirty texture flag value
  25393. */
  25394. static readonly TextureDirtyFlag: number;
  25395. /**
  25396. * The dirty light flag value
  25397. */
  25398. static readonly LightDirtyFlag: number;
  25399. /**
  25400. * The dirty fresnel flag value
  25401. */
  25402. static readonly FresnelDirtyFlag: number;
  25403. /**
  25404. * The dirty attribute flag value
  25405. */
  25406. static readonly AttributesDirtyFlag: number;
  25407. /**
  25408. * The dirty misc flag value
  25409. */
  25410. static readonly MiscDirtyFlag: number;
  25411. /**
  25412. * The all dirty flag value
  25413. */
  25414. static readonly AllDirtyFlag: number;
  25415. /**
  25416. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25417. */
  25418. static readonly MATERIAL_OPAQUE: number;
  25419. /**
  25420. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25421. */
  25422. static readonly MATERIAL_ALPHATEST: number;
  25423. /**
  25424. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25425. */
  25426. static readonly MATERIAL_ALPHABLEND: number;
  25427. /**
  25428. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25429. * They are also discarded below the alpha cutoff threshold to improve performances.
  25430. */
  25431. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25432. /**
  25433. * The Whiteout method is used to blend normals.
  25434. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25435. */
  25436. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25437. /**
  25438. * The Reoriented Normal Mapping method is used to blend normals.
  25439. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25440. */
  25441. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25442. /**
  25443. * Custom callback helping to override the default shader used in the material.
  25444. */
  25445. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25446. /**
  25447. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25448. */
  25449. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25450. /**
  25451. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25452. * This means that the material can keep using a previous shader while a new one is being compiled.
  25453. * This is mostly used when shader parallel compilation is supported (true by default)
  25454. */
  25455. allowShaderHotSwapping: boolean;
  25456. /**
  25457. * The ID of the material
  25458. */
  25459. id: string;
  25460. /**
  25461. * Gets or sets the unique id of the material
  25462. */
  25463. uniqueId: number;
  25464. /**
  25465. * The name of the material
  25466. */
  25467. name: string;
  25468. /**
  25469. * Gets or sets user defined metadata
  25470. */
  25471. metadata: any;
  25472. /**
  25473. * For internal use only. Please do not use.
  25474. */
  25475. reservedDataStore: any;
  25476. /**
  25477. * Specifies if the ready state should be checked on each call
  25478. */
  25479. checkReadyOnEveryCall: boolean;
  25480. /**
  25481. * Specifies if the ready state should be checked once
  25482. */
  25483. checkReadyOnlyOnce: boolean;
  25484. /**
  25485. * The state of the material
  25486. */
  25487. state: string;
  25488. /**
  25489. * If the material can be rendered to several textures with MRT extension
  25490. */
  25491. get canRenderToMRT(): boolean;
  25492. /**
  25493. * The alpha value of the material
  25494. */
  25495. protected _alpha: number;
  25496. /**
  25497. * List of inspectable custom properties (used by the Inspector)
  25498. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25499. */
  25500. inspectableCustomProperties: IInspectable[];
  25501. /**
  25502. * Sets the alpha value of the material
  25503. */
  25504. set alpha(value: number);
  25505. /**
  25506. * Gets the alpha value of the material
  25507. */
  25508. get alpha(): number;
  25509. /**
  25510. * Specifies if back face culling is enabled
  25511. */
  25512. protected _backFaceCulling: boolean;
  25513. /**
  25514. * Sets the back-face culling state
  25515. */
  25516. set backFaceCulling(value: boolean);
  25517. /**
  25518. * Gets the back-face culling state
  25519. */
  25520. get backFaceCulling(): boolean;
  25521. /**
  25522. * Stores the value for side orientation
  25523. */
  25524. sideOrientation: number;
  25525. /**
  25526. * Callback triggered when the material is compiled
  25527. */
  25528. onCompiled: Nullable<(effect: Effect) => void>;
  25529. /**
  25530. * Callback triggered when an error occurs
  25531. */
  25532. onError: Nullable<(effect: Effect, errors: string) => void>;
  25533. /**
  25534. * Callback triggered to get the render target textures
  25535. */
  25536. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25537. /**
  25538. * Gets a boolean indicating that current material needs to register RTT
  25539. */
  25540. get hasRenderTargetTextures(): boolean;
  25541. /**
  25542. * Specifies if the material should be serialized
  25543. */
  25544. doNotSerialize: boolean;
  25545. /**
  25546. * @hidden
  25547. */
  25548. _storeEffectOnSubMeshes: boolean;
  25549. /**
  25550. * Stores the animations for the material
  25551. */
  25552. animations: Nullable<Array<Animation>>;
  25553. /**
  25554. * An event triggered when the material is disposed
  25555. */
  25556. onDisposeObservable: Observable<Material>;
  25557. /**
  25558. * An observer which watches for dispose events
  25559. */
  25560. private _onDisposeObserver;
  25561. private _onUnBindObservable;
  25562. /**
  25563. * Called during a dispose event
  25564. */
  25565. set onDispose(callback: () => void);
  25566. private _onBindObservable;
  25567. /**
  25568. * An event triggered when the material is bound
  25569. */
  25570. get onBindObservable(): Observable<AbstractMesh>;
  25571. /**
  25572. * An observer which watches for bind events
  25573. */
  25574. private _onBindObserver;
  25575. /**
  25576. * Called during a bind event
  25577. */
  25578. set onBind(callback: (Mesh: AbstractMesh) => void);
  25579. /**
  25580. * An event triggered when the material is unbound
  25581. */
  25582. get onUnBindObservable(): Observable<Material>;
  25583. protected _onEffectCreatedObservable: Nullable<Observable<{
  25584. effect: Effect;
  25585. subMesh: Nullable<SubMesh>;
  25586. }>>;
  25587. /**
  25588. * An event triggered when the effect is (re)created
  25589. */
  25590. get onEffectCreatedObservable(): Observable<{
  25591. effect: Effect;
  25592. subMesh: Nullable<SubMesh>;
  25593. }>;
  25594. /**
  25595. * Stores the value of the alpha mode
  25596. */
  25597. private _alphaMode;
  25598. /**
  25599. * Sets the value of the alpha mode.
  25600. *
  25601. * | Value | Type | Description |
  25602. * | --- | --- | --- |
  25603. * | 0 | ALPHA_DISABLE | |
  25604. * | 1 | ALPHA_ADD | |
  25605. * | 2 | ALPHA_COMBINE | |
  25606. * | 3 | ALPHA_SUBTRACT | |
  25607. * | 4 | ALPHA_MULTIPLY | |
  25608. * | 5 | ALPHA_MAXIMIZED | |
  25609. * | 6 | ALPHA_ONEONE | |
  25610. * | 7 | ALPHA_PREMULTIPLIED | |
  25611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25612. * | 9 | ALPHA_INTERPOLATE | |
  25613. * | 10 | ALPHA_SCREENMODE | |
  25614. *
  25615. */
  25616. set alphaMode(value: number);
  25617. /**
  25618. * Gets the value of the alpha mode
  25619. */
  25620. get alphaMode(): number;
  25621. /**
  25622. * Stores the state of the need depth pre-pass value
  25623. */
  25624. private _needDepthPrePass;
  25625. /**
  25626. * Sets the need depth pre-pass value
  25627. */
  25628. set needDepthPrePass(value: boolean);
  25629. /**
  25630. * Gets the depth pre-pass value
  25631. */
  25632. get needDepthPrePass(): boolean;
  25633. /**
  25634. * Specifies if depth writing should be disabled
  25635. */
  25636. disableDepthWrite: boolean;
  25637. /**
  25638. * Specifies if color writing should be disabled
  25639. */
  25640. disableColorWrite: boolean;
  25641. /**
  25642. * Specifies if depth writing should be forced
  25643. */
  25644. forceDepthWrite: boolean;
  25645. /**
  25646. * Specifies the depth function that should be used. 0 means the default engine function
  25647. */
  25648. depthFunction: number;
  25649. /**
  25650. * Specifies if there should be a separate pass for culling
  25651. */
  25652. separateCullingPass: boolean;
  25653. /**
  25654. * Stores the state specifing if fog should be enabled
  25655. */
  25656. private _fogEnabled;
  25657. /**
  25658. * Sets the state for enabling fog
  25659. */
  25660. set fogEnabled(value: boolean);
  25661. /**
  25662. * Gets the value of the fog enabled state
  25663. */
  25664. get fogEnabled(): boolean;
  25665. /**
  25666. * Stores the size of points
  25667. */
  25668. pointSize: number;
  25669. /**
  25670. * Stores the z offset value
  25671. */
  25672. zOffset: number;
  25673. get wireframe(): boolean;
  25674. /**
  25675. * Sets the state of wireframe mode
  25676. */
  25677. set wireframe(value: boolean);
  25678. /**
  25679. * Gets the value specifying if point clouds are enabled
  25680. */
  25681. get pointsCloud(): boolean;
  25682. /**
  25683. * Sets the state of point cloud mode
  25684. */
  25685. set pointsCloud(value: boolean);
  25686. /**
  25687. * Gets the material fill mode
  25688. */
  25689. get fillMode(): number;
  25690. /**
  25691. * Sets the material fill mode
  25692. */
  25693. set fillMode(value: number);
  25694. /**
  25695. * @hidden
  25696. * Stores the effects for the material
  25697. */
  25698. _effect: Nullable<Effect>;
  25699. /**
  25700. * Specifies if uniform buffers should be used
  25701. */
  25702. private _useUBO;
  25703. /**
  25704. * Stores a reference to the scene
  25705. */
  25706. private _scene;
  25707. /**
  25708. * Stores the fill mode state
  25709. */
  25710. private _fillMode;
  25711. /**
  25712. * Specifies if the depth write state should be cached
  25713. */
  25714. private _cachedDepthWriteState;
  25715. /**
  25716. * Specifies if the color write state should be cached
  25717. */
  25718. private _cachedColorWriteState;
  25719. /**
  25720. * Specifies if the depth function state should be cached
  25721. */
  25722. private _cachedDepthFunctionState;
  25723. /**
  25724. * Stores the uniform buffer
  25725. */
  25726. protected _uniformBuffer: UniformBuffer;
  25727. /** @hidden */
  25728. _indexInSceneMaterialArray: number;
  25729. /** @hidden */
  25730. meshMap: Nullable<{
  25731. [id: string]: AbstractMesh | undefined;
  25732. }>;
  25733. /**
  25734. * Creates a material instance
  25735. * @param name defines the name of the material
  25736. * @param scene defines the scene to reference
  25737. * @param doNotAdd specifies if the material should be added to the scene
  25738. */
  25739. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25740. /**
  25741. * Returns a string representation of the current material
  25742. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25743. * @returns a string with material information
  25744. */
  25745. toString(fullDetails?: boolean): string;
  25746. /**
  25747. * Gets the class name of the material
  25748. * @returns a string with the class name of the material
  25749. */
  25750. getClassName(): string;
  25751. /**
  25752. * Specifies if updates for the material been locked
  25753. */
  25754. get isFrozen(): boolean;
  25755. /**
  25756. * Locks updates for the material
  25757. */
  25758. freeze(): void;
  25759. /**
  25760. * Unlocks updates for the material
  25761. */
  25762. unfreeze(): void;
  25763. /**
  25764. * Specifies if the material is ready to be used
  25765. * @param mesh defines the mesh to check
  25766. * @param useInstances specifies if instances should be used
  25767. * @returns a boolean indicating if the material is ready to be used
  25768. */
  25769. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25770. /**
  25771. * Specifies that the submesh is ready to be used
  25772. * @param mesh defines the mesh to check
  25773. * @param subMesh defines which submesh to check
  25774. * @param useInstances specifies that instances should be used
  25775. * @returns a boolean indicating that the submesh is ready or not
  25776. */
  25777. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25778. /**
  25779. * Returns the material effect
  25780. * @returns the effect associated with the material
  25781. */
  25782. getEffect(): Nullable<Effect>;
  25783. /**
  25784. * Returns the current scene
  25785. * @returns a Scene
  25786. */
  25787. getScene(): Scene;
  25788. /**
  25789. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25790. */
  25791. protected _forceAlphaTest: boolean;
  25792. /**
  25793. * The transparency mode of the material.
  25794. */
  25795. protected _transparencyMode: Nullable<number>;
  25796. /**
  25797. * Gets the current transparency mode.
  25798. */
  25799. get transparencyMode(): Nullable<number>;
  25800. /**
  25801. * Sets the transparency mode of the material.
  25802. *
  25803. * | Value | Type | Description |
  25804. * | ----- | ----------------------------------- | ----------- |
  25805. * | 0 | OPAQUE | |
  25806. * | 1 | ALPHATEST | |
  25807. * | 2 | ALPHABLEND | |
  25808. * | 3 | ALPHATESTANDBLEND | |
  25809. *
  25810. */
  25811. set transparencyMode(value: Nullable<number>);
  25812. /**
  25813. * Returns true if alpha blending should be disabled.
  25814. */
  25815. protected get _disableAlphaBlending(): boolean;
  25816. /**
  25817. * Specifies whether or not this material should be rendered in alpha blend mode.
  25818. * @returns a boolean specifying if alpha blending is needed
  25819. */
  25820. needAlphaBlending(): boolean;
  25821. /**
  25822. * Specifies if the mesh will require alpha blending
  25823. * @param mesh defines the mesh to check
  25824. * @returns a boolean specifying if alpha blending is needed for the mesh
  25825. */
  25826. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25827. /**
  25828. * Specifies whether or not this material should be rendered in alpha test mode.
  25829. * @returns a boolean specifying if an alpha test is needed.
  25830. */
  25831. needAlphaTesting(): boolean;
  25832. /**
  25833. * Specifies if material alpha testing should be turned on for the mesh
  25834. * @param mesh defines the mesh to check
  25835. */
  25836. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25837. /**
  25838. * Gets the texture used for the alpha test
  25839. * @returns the texture to use for alpha testing
  25840. */
  25841. getAlphaTestTexture(): Nullable<BaseTexture>;
  25842. /**
  25843. * Marks the material to indicate that it needs to be re-calculated
  25844. */
  25845. markDirty(): void;
  25846. /** @hidden */
  25847. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25848. /**
  25849. * Binds the material to the mesh
  25850. * @param world defines the world transformation matrix
  25851. * @param mesh defines the mesh to bind the material to
  25852. */
  25853. bind(world: Matrix, mesh?: Mesh): void;
  25854. /**
  25855. * Binds the submesh to the material
  25856. * @param world defines the world transformation matrix
  25857. * @param mesh defines the mesh containing the submesh
  25858. * @param subMesh defines the submesh to bind the material to
  25859. */
  25860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25861. /**
  25862. * Binds the world matrix to the material
  25863. * @param world defines the world transformation matrix
  25864. */
  25865. bindOnlyWorldMatrix(world: Matrix): void;
  25866. /**
  25867. * Binds the scene's uniform buffer to the effect.
  25868. * @param effect defines the effect to bind to the scene uniform buffer
  25869. * @param sceneUbo defines the uniform buffer storing scene data
  25870. */
  25871. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25872. /**
  25873. * Binds the view matrix to the effect
  25874. * @param effect defines the effect to bind the view matrix to
  25875. */
  25876. bindView(effect: Effect): void;
  25877. /**
  25878. * Binds the view projection matrix to the effect
  25879. * @param effect defines the effect to bind the view projection matrix to
  25880. */
  25881. bindViewProjection(effect: Effect): void;
  25882. /**
  25883. * Processes to execute after binding the material to a mesh
  25884. * @param mesh defines the rendered mesh
  25885. */
  25886. protected _afterBind(mesh?: Mesh): void;
  25887. /**
  25888. * Unbinds the material from the mesh
  25889. */
  25890. unbind(): void;
  25891. /**
  25892. * Gets the active textures from the material
  25893. * @returns an array of textures
  25894. */
  25895. getActiveTextures(): BaseTexture[];
  25896. /**
  25897. * Specifies if the material uses a texture
  25898. * @param texture defines the texture to check against the material
  25899. * @returns a boolean specifying if the material uses the texture
  25900. */
  25901. hasTexture(texture: BaseTexture): boolean;
  25902. /**
  25903. * Makes a duplicate of the material, and gives it a new name
  25904. * @param name defines the new name for the duplicated material
  25905. * @returns the cloned material
  25906. */
  25907. clone(name: string): Nullable<Material>;
  25908. /**
  25909. * Gets the meshes bound to the material
  25910. * @returns an array of meshes bound to the material
  25911. */
  25912. getBindedMeshes(): AbstractMesh[];
  25913. /**
  25914. * Force shader compilation
  25915. * @param mesh defines the mesh associated with this material
  25916. * @param onCompiled defines a function to execute once the material is compiled
  25917. * @param options defines the options to configure the compilation
  25918. * @param onError defines a function to execute if the material fails compiling
  25919. */
  25920. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25921. /**
  25922. * Force shader compilation
  25923. * @param mesh defines the mesh that will use this material
  25924. * @param options defines additional options for compiling the shaders
  25925. * @returns a promise that resolves when the compilation completes
  25926. */
  25927. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25928. private static readonly _AllDirtyCallBack;
  25929. private static readonly _ImageProcessingDirtyCallBack;
  25930. private static readonly _TextureDirtyCallBack;
  25931. private static readonly _FresnelDirtyCallBack;
  25932. private static readonly _MiscDirtyCallBack;
  25933. private static readonly _LightsDirtyCallBack;
  25934. private static readonly _AttributeDirtyCallBack;
  25935. private static _FresnelAndMiscDirtyCallBack;
  25936. private static _TextureAndMiscDirtyCallBack;
  25937. private static readonly _DirtyCallbackArray;
  25938. private static readonly _RunDirtyCallBacks;
  25939. /**
  25940. * Marks a define in the material to indicate that it needs to be re-computed
  25941. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25942. */
  25943. markAsDirty(flag: number): void;
  25944. /**
  25945. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25946. * @param func defines a function which checks material defines against the submeshes
  25947. */
  25948. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25949. /**
  25950. * Indicates that the scene should check if the rendering now needs a prepass
  25951. */
  25952. protected _markScenePrePassDirty(): void;
  25953. /**
  25954. * Indicates that we need to re-calculated for all submeshes
  25955. */
  25956. protected _markAllSubMeshesAsAllDirty(): void;
  25957. /**
  25958. * Indicates that image processing needs to be re-calculated for all submeshes
  25959. */
  25960. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25961. /**
  25962. * Indicates that textures need to be re-calculated for all submeshes
  25963. */
  25964. protected _markAllSubMeshesAsTexturesDirty(): void;
  25965. /**
  25966. * Indicates that fresnel needs to be re-calculated for all submeshes
  25967. */
  25968. protected _markAllSubMeshesAsFresnelDirty(): void;
  25969. /**
  25970. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25971. */
  25972. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25973. /**
  25974. * Indicates that lights need to be re-calculated for all submeshes
  25975. */
  25976. protected _markAllSubMeshesAsLightsDirty(): void;
  25977. /**
  25978. * Indicates that attributes need to be re-calculated for all submeshes
  25979. */
  25980. protected _markAllSubMeshesAsAttributesDirty(): void;
  25981. /**
  25982. * Indicates that misc needs to be re-calculated for all submeshes
  25983. */
  25984. protected _markAllSubMeshesAsMiscDirty(): void;
  25985. /**
  25986. * Indicates that textures and misc need to be re-calculated for all submeshes
  25987. */
  25988. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25989. /**
  25990. * Sets the required values to the prepass renderer.
  25991. * @param prePassRenderer defines the prepass renderer to setup.
  25992. * @returns true if the pre pass is needed.
  25993. */
  25994. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25995. /**
  25996. * Disposes the material
  25997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25998. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25999. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26000. */
  26001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26002. /** @hidden */
  26003. private releaseVertexArrayObject;
  26004. /**
  26005. * Serializes this material
  26006. * @returns the serialized material object
  26007. */
  26008. serialize(): any;
  26009. /**
  26010. * Creates a material from parsed material data
  26011. * @param parsedMaterial defines parsed material data
  26012. * @param scene defines the hosting scene
  26013. * @param rootUrl defines the root URL to use to load textures
  26014. * @returns a new material
  26015. */
  26016. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26017. }
  26018. }
  26019. declare module "babylonjs/Materials/multiMaterial" {
  26020. import { Nullable } from "babylonjs/types";
  26021. import { Scene } from "babylonjs/scene";
  26022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26023. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26025. import { Material } from "babylonjs/Materials/material";
  26026. /**
  26027. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26028. * separate meshes. This can be use to improve performances.
  26029. * @see https://doc.babylonjs.com/how_to/multi_materials
  26030. */
  26031. export class MultiMaterial extends Material {
  26032. private _subMaterials;
  26033. /**
  26034. * Gets or Sets the list of Materials used within the multi material.
  26035. * They need to be ordered according to the submeshes order in the associated mesh
  26036. */
  26037. get subMaterials(): Nullable<Material>[];
  26038. set subMaterials(value: Nullable<Material>[]);
  26039. /**
  26040. * Function used to align with Node.getChildren()
  26041. * @returns the list of Materials used within the multi material
  26042. */
  26043. getChildren(): Nullable<Material>[];
  26044. /**
  26045. * Instantiates a new Multi Material
  26046. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26047. * separate meshes. This can be use to improve performances.
  26048. * @see https://doc.babylonjs.com/how_to/multi_materials
  26049. * @param name Define the name in the scene
  26050. * @param scene Define the scene the material belongs to
  26051. */
  26052. constructor(name: string, scene: Scene);
  26053. private _hookArray;
  26054. /**
  26055. * Get one of the submaterial by its index in the submaterials array
  26056. * @param index The index to look the sub material at
  26057. * @returns The Material if the index has been defined
  26058. */
  26059. getSubMaterial(index: number): Nullable<Material>;
  26060. /**
  26061. * Get the list of active textures for the whole sub materials list.
  26062. * @returns All the textures that will be used during the rendering
  26063. */
  26064. getActiveTextures(): BaseTexture[];
  26065. /**
  26066. * Gets the current class name of the material e.g. "MultiMaterial"
  26067. * Mainly use in serialization.
  26068. * @returns the class name
  26069. */
  26070. getClassName(): string;
  26071. /**
  26072. * Checks if the material is ready to render the requested sub mesh
  26073. * @param mesh Define the mesh the submesh belongs to
  26074. * @param subMesh Define the sub mesh to look readyness for
  26075. * @param useInstances Define whether or not the material is used with instances
  26076. * @returns true if ready, otherwise false
  26077. */
  26078. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26079. /**
  26080. * Clones the current material and its related sub materials
  26081. * @param name Define the name of the newly cloned material
  26082. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26083. * @returns the cloned material
  26084. */
  26085. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26086. /**
  26087. * Serializes the materials into a JSON representation.
  26088. * @returns the JSON representation
  26089. */
  26090. serialize(): any;
  26091. /**
  26092. * Dispose the material and release its associated resources
  26093. * @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)
  26094. * @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)
  26095. * @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)
  26096. */
  26097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26098. /**
  26099. * Creates a MultiMaterial from parsed MultiMaterial data.
  26100. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26101. * @param scene defines the hosting scene
  26102. * @returns a new MultiMaterial
  26103. */
  26104. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26105. }
  26106. }
  26107. declare module "babylonjs/Meshes/subMesh" {
  26108. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26109. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26110. import { Engine } from "babylonjs/Engines/engine";
  26111. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26112. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26113. import { Effect } from "babylonjs/Materials/effect";
  26114. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26115. import { Plane } from "babylonjs/Maths/math.plane";
  26116. import { Collider } from "babylonjs/Collisions/collider";
  26117. import { Material } from "babylonjs/Materials/material";
  26118. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26120. import { Mesh } from "babylonjs/Meshes/mesh";
  26121. import { Ray } from "babylonjs/Culling/ray";
  26122. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26123. /**
  26124. * Defines a subdivision inside a mesh
  26125. */
  26126. export class SubMesh implements ICullable {
  26127. /** the material index to use */
  26128. materialIndex: number;
  26129. /** vertex index start */
  26130. verticesStart: number;
  26131. /** vertices count */
  26132. verticesCount: number;
  26133. /** index start */
  26134. indexStart: number;
  26135. /** indices count */
  26136. indexCount: number;
  26137. /** @hidden */
  26138. _materialDefines: Nullable<MaterialDefines>;
  26139. /** @hidden */
  26140. _materialEffect: Nullable<Effect>;
  26141. /** @hidden */
  26142. _effectOverride: Nullable<Effect>;
  26143. /**
  26144. * Gets material defines used by the effect associated to the sub mesh
  26145. */
  26146. get materialDefines(): Nullable<MaterialDefines>;
  26147. /**
  26148. * Sets material defines used by the effect associated to the sub mesh
  26149. */
  26150. set materialDefines(defines: Nullable<MaterialDefines>);
  26151. /**
  26152. * Gets associated effect
  26153. */
  26154. get effect(): Nullable<Effect>;
  26155. /**
  26156. * Sets associated effect (effect used to render this submesh)
  26157. * @param effect defines the effect to associate with
  26158. * @param defines defines the set of defines used to compile this effect
  26159. */
  26160. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26161. /** @hidden */
  26162. _linesIndexCount: number;
  26163. private _mesh;
  26164. private _renderingMesh;
  26165. private _boundingInfo;
  26166. private _linesIndexBuffer;
  26167. /** @hidden */
  26168. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26169. /** @hidden */
  26170. _trianglePlanes: Plane[];
  26171. /** @hidden */
  26172. _lastColliderTransformMatrix: Nullable<Matrix>;
  26173. /** @hidden */
  26174. _renderId: number;
  26175. /** @hidden */
  26176. _alphaIndex: number;
  26177. /** @hidden */
  26178. _distanceToCamera: number;
  26179. /** @hidden */
  26180. _id: number;
  26181. private _currentMaterial;
  26182. /**
  26183. * Add a new submesh to a mesh
  26184. * @param materialIndex defines the material index to use
  26185. * @param verticesStart defines vertex index start
  26186. * @param verticesCount defines vertices count
  26187. * @param indexStart defines index start
  26188. * @param indexCount defines indices count
  26189. * @param mesh defines the parent mesh
  26190. * @param renderingMesh defines an optional rendering mesh
  26191. * @param createBoundingBox defines if bounding box should be created for this submesh
  26192. * @returns the new submesh
  26193. */
  26194. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26195. /**
  26196. * Creates a new submesh
  26197. * @param materialIndex defines the material index to use
  26198. * @param verticesStart defines vertex index start
  26199. * @param verticesCount defines vertices count
  26200. * @param indexStart defines index start
  26201. * @param indexCount defines indices count
  26202. * @param mesh defines the parent mesh
  26203. * @param renderingMesh defines an optional rendering mesh
  26204. * @param createBoundingBox defines if bounding box should be created for this submesh
  26205. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26206. */
  26207. constructor(
  26208. /** the material index to use */
  26209. materialIndex: number,
  26210. /** vertex index start */
  26211. verticesStart: number,
  26212. /** vertices count */
  26213. verticesCount: number,
  26214. /** index start */
  26215. indexStart: number,
  26216. /** indices count */
  26217. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26218. /**
  26219. * Returns true if this submesh covers the entire parent mesh
  26220. * @ignorenaming
  26221. */
  26222. get IsGlobal(): boolean;
  26223. /**
  26224. * Returns the submesh BoudingInfo object
  26225. * @returns current bounding info (or mesh's one if the submesh is global)
  26226. */
  26227. getBoundingInfo(): BoundingInfo;
  26228. /**
  26229. * Sets the submesh BoundingInfo
  26230. * @param boundingInfo defines the new bounding info to use
  26231. * @returns the SubMesh
  26232. */
  26233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26234. /**
  26235. * Returns the mesh of the current submesh
  26236. * @return the parent mesh
  26237. */
  26238. getMesh(): AbstractMesh;
  26239. /**
  26240. * Returns the rendering mesh of the submesh
  26241. * @returns the rendering mesh (could be different from parent mesh)
  26242. */
  26243. getRenderingMesh(): Mesh;
  26244. /**
  26245. * Returns the replacement mesh of the submesh
  26246. * @returns the replacement mesh (could be different from parent mesh)
  26247. */
  26248. getReplacementMesh(): Nullable<AbstractMesh>;
  26249. /**
  26250. * Returns the effective mesh of the submesh
  26251. * @returns the effective mesh (could be different from parent mesh)
  26252. */
  26253. getEffectiveMesh(): AbstractMesh;
  26254. /**
  26255. * Returns the submesh material
  26256. * @returns null or the current material
  26257. */
  26258. getMaterial(): Nullable<Material>;
  26259. private _IsMultiMaterial;
  26260. /**
  26261. * Sets a new updated BoundingInfo object to the submesh
  26262. * @param data defines an optional position array to use to determine the bounding info
  26263. * @returns the SubMesh
  26264. */
  26265. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26266. /** @hidden */
  26267. _checkCollision(collider: Collider): boolean;
  26268. /**
  26269. * Updates the submesh BoundingInfo
  26270. * @param world defines the world matrix to use to update the bounding info
  26271. * @returns the submesh
  26272. */
  26273. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26274. /**
  26275. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26276. * @param frustumPlanes defines the frustum planes
  26277. * @returns true if the submesh is intersecting with the frustum
  26278. */
  26279. isInFrustum(frustumPlanes: Plane[]): boolean;
  26280. /**
  26281. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26282. * @param frustumPlanes defines the frustum planes
  26283. * @returns true if the submesh is inside the frustum
  26284. */
  26285. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26286. /**
  26287. * Renders the submesh
  26288. * @param enableAlphaMode defines if alpha needs to be used
  26289. * @returns the submesh
  26290. */
  26291. render(enableAlphaMode: boolean): SubMesh;
  26292. /**
  26293. * @hidden
  26294. */
  26295. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26296. /**
  26297. * Checks if the submesh intersects with a ray
  26298. * @param ray defines the ray to test
  26299. * @returns true is the passed ray intersects the submesh bounding box
  26300. */
  26301. canIntersects(ray: Ray): boolean;
  26302. /**
  26303. * Intersects current submesh with a ray
  26304. * @param ray defines the ray to test
  26305. * @param positions defines mesh's positions array
  26306. * @param indices defines mesh's indices array
  26307. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26308. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26309. * @returns intersection info or null if no intersection
  26310. */
  26311. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26312. /** @hidden */
  26313. private _intersectLines;
  26314. /** @hidden */
  26315. private _intersectUnIndexedLines;
  26316. /** @hidden */
  26317. private _intersectTriangles;
  26318. /** @hidden */
  26319. private _intersectUnIndexedTriangles;
  26320. /** @hidden */
  26321. _rebuild(): void;
  26322. /**
  26323. * Creates a new submesh from the passed mesh
  26324. * @param newMesh defines the new hosting mesh
  26325. * @param newRenderingMesh defines an optional rendering mesh
  26326. * @returns the new submesh
  26327. */
  26328. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26329. /**
  26330. * Release associated resources
  26331. */
  26332. dispose(): void;
  26333. /**
  26334. * Gets the class name
  26335. * @returns the string "SubMesh".
  26336. */
  26337. getClassName(): string;
  26338. /**
  26339. * Creates a new submesh from indices data
  26340. * @param materialIndex the index of the main mesh material
  26341. * @param startIndex the index where to start the copy in the mesh indices array
  26342. * @param indexCount the number of indices to copy then from the startIndex
  26343. * @param mesh the main mesh to create the submesh from
  26344. * @param renderingMesh the optional rendering mesh
  26345. * @returns a new submesh
  26346. */
  26347. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26348. }
  26349. }
  26350. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26351. /**
  26352. * Class used to represent data loading progression
  26353. */
  26354. export class SceneLoaderFlags {
  26355. private static _ForceFullSceneLoadingForIncremental;
  26356. private static _ShowLoadingScreen;
  26357. private static _CleanBoneMatrixWeights;
  26358. private static _loggingLevel;
  26359. /**
  26360. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26361. */
  26362. static get ForceFullSceneLoadingForIncremental(): boolean;
  26363. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26364. /**
  26365. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26366. */
  26367. static get ShowLoadingScreen(): boolean;
  26368. static set ShowLoadingScreen(value: boolean);
  26369. /**
  26370. * Defines the current logging level (while loading the scene)
  26371. * @ignorenaming
  26372. */
  26373. static get loggingLevel(): number;
  26374. static set loggingLevel(value: number);
  26375. /**
  26376. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26377. */
  26378. static get CleanBoneMatrixWeights(): boolean;
  26379. static set CleanBoneMatrixWeights(value: boolean);
  26380. }
  26381. }
  26382. declare module "babylonjs/Meshes/geometry" {
  26383. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26384. import { Scene } from "babylonjs/scene";
  26385. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26386. import { Engine } from "babylonjs/Engines/engine";
  26387. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26389. import { Effect } from "babylonjs/Materials/effect";
  26390. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26391. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26392. import { Mesh } from "babylonjs/Meshes/mesh";
  26393. /**
  26394. * Class used to store geometry data (vertex buffers + index buffer)
  26395. */
  26396. export class Geometry implements IGetSetVerticesData {
  26397. /**
  26398. * Gets or sets the ID of the geometry
  26399. */
  26400. id: string;
  26401. /**
  26402. * Gets or sets the unique ID of the geometry
  26403. */
  26404. uniqueId: number;
  26405. /**
  26406. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26407. */
  26408. delayLoadState: number;
  26409. /**
  26410. * Gets the file containing the data to load when running in delay load state
  26411. */
  26412. delayLoadingFile: Nullable<string>;
  26413. /**
  26414. * Callback called when the geometry is updated
  26415. */
  26416. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26417. private _scene;
  26418. private _engine;
  26419. private _meshes;
  26420. private _totalVertices;
  26421. /** @hidden */
  26422. _indices: IndicesArray;
  26423. /** @hidden */
  26424. _vertexBuffers: {
  26425. [key: string]: VertexBuffer;
  26426. };
  26427. private _isDisposed;
  26428. private _extend;
  26429. private _boundingBias;
  26430. /** @hidden */
  26431. _delayInfo: Array<string>;
  26432. private _indexBuffer;
  26433. private _indexBufferIsUpdatable;
  26434. /** @hidden */
  26435. _boundingInfo: Nullable<BoundingInfo>;
  26436. /** @hidden */
  26437. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26438. /** @hidden */
  26439. _softwareSkinningFrameId: number;
  26440. private _vertexArrayObjects;
  26441. private _updatable;
  26442. /** @hidden */
  26443. _positions: Nullable<Vector3[]>;
  26444. /**
  26445. * 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
  26446. */
  26447. get boundingBias(): Vector2;
  26448. /**
  26449. * 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
  26450. */
  26451. set boundingBias(value: Vector2);
  26452. /**
  26453. * Static function used to attach a new empty geometry to a mesh
  26454. * @param mesh defines the mesh to attach the geometry to
  26455. * @returns the new Geometry
  26456. */
  26457. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26458. /** Get the list of meshes using this geometry */
  26459. get meshes(): Mesh[];
  26460. /**
  26461. * 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
  26462. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26463. */
  26464. useBoundingInfoFromGeometry: boolean;
  26465. /**
  26466. * Creates a new geometry
  26467. * @param id defines the unique ID
  26468. * @param scene defines the hosting scene
  26469. * @param vertexData defines the VertexData used to get geometry data
  26470. * @param updatable defines if geometry must be updatable (false by default)
  26471. * @param mesh defines the mesh that will be associated with the geometry
  26472. */
  26473. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26474. /**
  26475. * Gets the current extend of the geometry
  26476. */
  26477. get extend(): {
  26478. minimum: Vector3;
  26479. maximum: Vector3;
  26480. };
  26481. /**
  26482. * Gets the hosting scene
  26483. * @returns the hosting Scene
  26484. */
  26485. getScene(): Scene;
  26486. /**
  26487. * Gets the hosting engine
  26488. * @returns the hosting Engine
  26489. */
  26490. getEngine(): Engine;
  26491. /**
  26492. * Defines if the geometry is ready to use
  26493. * @returns true if the geometry is ready to be used
  26494. */
  26495. isReady(): boolean;
  26496. /**
  26497. * Gets a value indicating that the geometry should not be serialized
  26498. */
  26499. get doNotSerialize(): boolean;
  26500. /** @hidden */
  26501. _rebuild(): void;
  26502. /**
  26503. * Affects all geometry data in one call
  26504. * @param vertexData defines the geometry data
  26505. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26506. */
  26507. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26508. /**
  26509. * Set specific vertex data
  26510. * @param kind defines the data kind (Position, normal, etc...)
  26511. * @param data defines the vertex data to use
  26512. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26513. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26514. */
  26515. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26516. /**
  26517. * Removes a specific vertex data
  26518. * @param kind defines the data kind (Position, normal, etc...)
  26519. */
  26520. removeVerticesData(kind: string): void;
  26521. /**
  26522. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26523. * @param buffer defines the vertex buffer to use
  26524. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26525. */
  26526. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26527. /**
  26528. * Update a specific vertex buffer
  26529. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26530. * It will do nothing if the buffer is not updatable
  26531. * @param kind defines the data kind (Position, normal, etc...)
  26532. * @param data defines the data to use
  26533. * @param offset defines the offset in the target buffer where to store the data
  26534. * @param useBytes set to true if the offset is in bytes
  26535. */
  26536. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26537. /**
  26538. * Update a specific vertex buffer
  26539. * This function will create a new buffer if the current one is not updatable
  26540. * @param kind defines the data kind (Position, normal, etc...)
  26541. * @param data defines the data to use
  26542. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26543. */
  26544. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26545. private _updateBoundingInfo;
  26546. /** @hidden */
  26547. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26548. /**
  26549. * Gets total number of vertices
  26550. * @returns the total number of vertices
  26551. */
  26552. getTotalVertices(): number;
  26553. /**
  26554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26555. * @param kind defines the data kind (Position, normal, etc...)
  26556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26558. * @returns a float array containing vertex data
  26559. */
  26560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26561. /**
  26562. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26563. * @param kind defines the data kind (Position, normal, etc...)
  26564. * @returns true if the vertex buffer with the specified kind is updatable
  26565. */
  26566. isVertexBufferUpdatable(kind: string): boolean;
  26567. /**
  26568. * Gets a specific vertex buffer
  26569. * @param kind defines the data kind (Position, normal, etc...)
  26570. * @returns a VertexBuffer
  26571. */
  26572. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26573. /**
  26574. * Returns all vertex buffers
  26575. * @return an object holding all vertex buffers indexed by kind
  26576. */
  26577. getVertexBuffers(): Nullable<{
  26578. [key: string]: VertexBuffer;
  26579. }>;
  26580. /**
  26581. * Gets a boolean indicating if specific vertex buffer is present
  26582. * @param kind defines the data kind (Position, normal, etc...)
  26583. * @returns true if data is present
  26584. */
  26585. isVerticesDataPresent(kind: string): boolean;
  26586. /**
  26587. * Gets a list of all attached data kinds (Position, normal, etc...)
  26588. * @returns a list of string containing all kinds
  26589. */
  26590. getVerticesDataKinds(): string[];
  26591. /**
  26592. * Update index buffer
  26593. * @param indices defines the indices to store in the index buffer
  26594. * @param offset defines the offset in the target buffer where to store the data
  26595. * @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)
  26596. */
  26597. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26598. /**
  26599. * Creates a new index buffer
  26600. * @param indices defines the indices to store in the index buffer
  26601. * @param totalVertices defines the total number of vertices (could be null)
  26602. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26603. */
  26604. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26605. /**
  26606. * Return the total number of indices
  26607. * @returns the total number of indices
  26608. */
  26609. getTotalIndices(): number;
  26610. /**
  26611. * Gets the index buffer array
  26612. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26613. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26614. * @returns the index buffer array
  26615. */
  26616. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26617. /**
  26618. * Gets the index buffer
  26619. * @return the index buffer
  26620. */
  26621. getIndexBuffer(): Nullable<DataBuffer>;
  26622. /** @hidden */
  26623. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26624. /**
  26625. * Release the associated resources for a specific mesh
  26626. * @param mesh defines the source mesh
  26627. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26628. */
  26629. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26630. /**
  26631. * Apply current geometry to a given mesh
  26632. * @param mesh defines the mesh to apply geometry to
  26633. */
  26634. applyToMesh(mesh: Mesh): void;
  26635. private _updateExtend;
  26636. private _applyToMesh;
  26637. private notifyUpdate;
  26638. /**
  26639. * Load the geometry if it was flagged as delay loaded
  26640. * @param scene defines the hosting scene
  26641. * @param onLoaded defines a callback called when the geometry is loaded
  26642. */
  26643. load(scene: Scene, onLoaded?: () => void): void;
  26644. private _queueLoad;
  26645. /**
  26646. * Invert the geometry to move from a right handed system to a left handed one.
  26647. */
  26648. toLeftHanded(): void;
  26649. /** @hidden */
  26650. _resetPointsArrayCache(): void;
  26651. /** @hidden */
  26652. _generatePointsArray(): boolean;
  26653. /**
  26654. * Gets a value indicating if the geometry is disposed
  26655. * @returns true if the geometry was disposed
  26656. */
  26657. isDisposed(): boolean;
  26658. private _disposeVertexArrayObjects;
  26659. /**
  26660. * Free all associated resources
  26661. */
  26662. dispose(): void;
  26663. /**
  26664. * Clone the current geometry into a new geometry
  26665. * @param id defines the unique ID of the new geometry
  26666. * @returns a new geometry object
  26667. */
  26668. copy(id: string): Geometry;
  26669. /**
  26670. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26671. * @return a JSON representation of the current geometry data (without the vertices data)
  26672. */
  26673. serialize(): any;
  26674. private toNumberArray;
  26675. /**
  26676. * Serialize all vertices data into a JSON oject
  26677. * @returns a JSON representation of the current geometry data
  26678. */
  26679. serializeVerticeData(): any;
  26680. /**
  26681. * Extracts a clone of a mesh geometry
  26682. * @param mesh defines the source mesh
  26683. * @param id defines the unique ID of the new geometry object
  26684. * @returns the new geometry object
  26685. */
  26686. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26687. /**
  26688. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26689. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26690. * Be aware Math.random() could cause collisions, but:
  26691. * "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"
  26692. * @returns a string containing a new GUID
  26693. */
  26694. static RandomId(): string;
  26695. /** @hidden */
  26696. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26697. private static _CleanMatricesWeights;
  26698. /**
  26699. * Create a new geometry from persisted data (Using .babylon file format)
  26700. * @param parsedVertexData defines the persisted data
  26701. * @param scene defines the hosting scene
  26702. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26703. * @returns the new geometry object
  26704. */
  26705. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26706. }
  26707. }
  26708. declare module "babylonjs/Meshes/mesh.vertexData" {
  26709. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26710. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26711. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26712. import { Geometry } from "babylonjs/Meshes/geometry";
  26713. import { Mesh } from "babylonjs/Meshes/mesh";
  26714. /**
  26715. * Define an interface for all classes that will get and set the data on vertices
  26716. */
  26717. export interface IGetSetVerticesData {
  26718. /**
  26719. * Gets a boolean indicating if specific vertex data is present
  26720. * @param kind defines the vertex data kind to use
  26721. * @returns true is data kind is present
  26722. */
  26723. isVerticesDataPresent(kind: string): boolean;
  26724. /**
  26725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26726. * @param kind defines the data kind (Position, normal, etc...)
  26727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26729. * @returns a float array containing vertex data
  26730. */
  26731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26732. /**
  26733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26734. * @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.
  26735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26736. * @returns the indices array or an empty array if the mesh has no geometry
  26737. */
  26738. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26739. /**
  26740. * Set specific vertex data
  26741. * @param kind defines the data kind (Position, normal, etc...)
  26742. * @param data defines the vertex data to use
  26743. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26744. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26745. */
  26746. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26747. /**
  26748. * Update a specific associated vertex buffer
  26749. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26750. * - VertexBuffer.PositionKind
  26751. * - VertexBuffer.UVKind
  26752. * - VertexBuffer.UV2Kind
  26753. * - VertexBuffer.UV3Kind
  26754. * - VertexBuffer.UV4Kind
  26755. * - VertexBuffer.UV5Kind
  26756. * - VertexBuffer.UV6Kind
  26757. * - VertexBuffer.ColorKind
  26758. * - VertexBuffer.MatricesIndicesKind
  26759. * - VertexBuffer.MatricesIndicesExtraKind
  26760. * - VertexBuffer.MatricesWeightsKind
  26761. * - VertexBuffer.MatricesWeightsExtraKind
  26762. * @param data defines the data source
  26763. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26764. * @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)
  26765. */
  26766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26767. /**
  26768. * Creates a new index buffer
  26769. * @param indices defines the indices to store in the index buffer
  26770. * @param totalVertices defines the total number of vertices (could be null)
  26771. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26772. */
  26773. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26774. }
  26775. /**
  26776. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26777. */
  26778. export class VertexData {
  26779. /**
  26780. * Mesh side orientation : usually the external or front surface
  26781. */
  26782. static readonly FRONTSIDE: number;
  26783. /**
  26784. * Mesh side orientation : usually the internal or back surface
  26785. */
  26786. static readonly BACKSIDE: number;
  26787. /**
  26788. * Mesh side orientation : both internal and external or front and back surfaces
  26789. */
  26790. static readonly DOUBLESIDE: number;
  26791. /**
  26792. * Mesh side orientation : by default, `FRONTSIDE`
  26793. */
  26794. static readonly DEFAULTSIDE: number;
  26795. /**
  26796. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26797. */
  26798. positions: Nullable<FloatArray>;
  26799. /**
  26800. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26801. */
  26802. normals: Nullable<FloatArray>;
  26803. /**
  26804. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26805. */
  26806. tangents: Nullable<FloatArray>;
  26807. /**
  26808. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26809. */
  26810. uvs: Nullable<FloatArray>;
  26811. /**
  26812. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26813. */
  26814. uvs2: Nullable<FloatArray>;
  26815. /**
  26816. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26817. */
  26818. uvs3: Nullable<FloatArray>;
  26819. /**
  26820. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26821. */
  26822. uvs4: Nullable<FloatArray>;
  26823. /**
  26824. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26825. */
  26826. uvs5: Nullable<FloatArray>;
  26827. /**
  26828. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26829. */
  26830. uvs6: Nullable<FloatArray>;
  26831. /**
  26832. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26833. */
  26834. colors: Nullable<FloatArray>;
  26835. /**
  26836. * 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).
  26837. */
  26838. matricesIndices: Nullable<FloatArray>;
  26839. /**
  26840. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26841. */
  26842. matricesWeights: Nullable<FloatArray>;
  26843. /**
  26844. * An array extending the number of possible indices
  26845. */
  26846. matricesIndicesExtra: Nullable<FloatArray>;
  26847. /**
  26848. * An array extending the number of possible weights when the number of indices is extended
  26849. */
  26850. matricesWeightsExtra: Nullable<FloatArray>;
  26851. /**
  26852. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26853. */
  26854. indices: Nullable<IndicesArray>;
  26855. /**
  26856. * Uses the passed data array to set the set the values for the specified kind of data
  26857. * @param data a linear array of floating numbers
  26858. * @param kind the type of data that is being set, eg positions, colors etc
  26859. */
  26860. set(data: FloatArray, kind: string): void;
  26861. /**
  26862. * Associates the vertexData to the passed Mesh.
  26863. * Sets it as updatable or not (default `false`)
  26864. * @param mesh the mesh the vertexData is applied to
  26865. * @param updatable when used and having the value true allows new data to update the vertexData
  26866. * @returns the VertexData
  26867. */
  26868. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26869. /**
  26870. * Associates the vertexData to the passed Geometry.
  26871. * Sets it as updatable or not (default `false`)
  26872. * @param geometry the geometry the vertexData is applied to
  26873. * @param updatable when used and having the value true allows new data to update the vertexData
  26874. * @returns VertexData
  26875. */
  26876. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26877. /**
  26878. * Updates the associated mesh
  26879. * @param mesh the mesh to be updated
  26880. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26881. * @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
  26882. * @returns VertexData
  26883. */
  26884. updateMesh(mesh: Mesh): VertexData;
  26885. /**
  26886. * Updates the associated geometry
  26887. * @param geometry the geometry to be updated
  26888. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26889. * @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
  26890. * @returns VertexData.
  26891. */
  26892. updateGeometry(geometry: Geometry): VertexData;
  26893. private _applyTo;
  26894. private _update;
  26895. /**
  26896. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26897. * @param matrix the transforming matrix
  26898. * @returns the VertexData
  26899. */
  26900. transform(matrix: Matrix): VertexData;
  26901. /**
  26902. * Merges the passed VertexData into the current one
  26903. * @param other the VertexData to be merged into the current one
  26904. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26905. * @returns the modified VertexData
  26906. */
  26907. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26908. private _mergeElement;
  26909. private _validate;
  26910. /**
  26911. * Serializes the VertexData
  26912. * @returns a serialized object
  26913. */
  26914. serialize(): any;
  26915. /**
  26916. * Extracts the vertexData from a mesh
  26917. * @param mesh the mesh from which to extract the VertexData
  26918. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26919. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26920. * @returns the object VertexData associated to the passed mesh
  26921. */
  26922. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26923. /**
  26924. * Extracts the vertexData from the geometry
  26925. * @param geometry the geometry from which to extract the VertexData
  26926. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26927. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26928. * @returns the object VertexData associated to the passed mesh
  26929. */
  26930. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26931. private static _ExtractFrom;
  26932. /**
  26933. * Creates the VertexData for a Ribbon
  26934. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26935. * * pathArray array of paths, each of which an array of successive Vector3
  26936. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26937. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26938. * * 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
  26939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26940. * * 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)
  26941. * * 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)
  26942. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26943. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26944. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26945. * @returns the VertexData of the ribbon
  26946. */
  26947. static CreateRibbon(options: {
  26948. pathArray: Vector3[][];
  26949. closeArray?: boolean;
  26950. closePath?: boolean;
  26951. offset?: number;
  26952. sideOrientation?: number;
  26953. frontUVs?: Vector4;
  26954. backUVs?: Vector4;
  26955. invertUV?: boolean;
  26956. uvs?: Vector2[];
  26957. colors?: Color4[];
  26958. }): VertexData;
  26959. /**
  26960. * Creates the VertexData for a box
  26961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26962. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26963. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26964. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26965. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26966. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26967. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26969. * * 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)
  26970. * * 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)
  26971. * @returns the VertexData of the box
  26972. */
  26973. static CreateBox(options: {
  26974. size?: number;
  26975. width?: number;
  26976. height?: number;
  26977. depth?: number;
  26978. faceUV?: Vector4[];
  26979. faceColors?: Color4[];
  26980. sideOrientation?: number;
  26981. frontUVs?: Vector4;
  26982. backUVs?: Vector4;
  26983. }): VertexData;
  26984. /**
  26985. * Creates the VertexData for a tiled box
  26986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26987. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26988. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26989. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26991. * @returns the VertexData of the box
  26992. */
  26993. static CreateTiledBox(options: {
  26994. pattern?: number;
  26995. width?: number;
  26996. height?: number;
  26997. depth?: number;
  26998. tileSize?: number;
  26999. tileWidth?: number;
  27000. tileHeight?: number;
  27001. alignHorizontal?: number;
  27002. alignVertical?: number;
  27003. faceUV?: Vector4[];
  27004. faceColors?: Color4[];
  27005. sideOrientation?: number;
  27006. }): VertexData;
  27007. /**
  27008. * Creates the VertexData for a tiled plane
  27009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27010. * * pattern a limited pattern arrangement depending on the number
  27011. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27012. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27013. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27015. * * 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)
  27016. * * 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)
  27017. * @returns the VertexData of the tiled plane
  27018. */
  27019. static CreateTiledPlane(options: {
  27020. pattern?: number;
  27021. tileSize?: number;
  27022. tileWidth?: number;
  27023. tileHeight?: number;
  27024. size?: number;
  27025. width?: number;
  27026. height?: number;
  27027. alignHorizontal?: number;
  27028. alignVertical?: number;
  27029. sideOrientation?: number;
  27030. frontUVs?: Vector4;
  27031. backUVs?: Vector4;
  27032. }): VertexData;
  27033. /**
  27034. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27036. * * segments sets the number of horizontal strips optional, default 32
  27037. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27038. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27039. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27040. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27041. * * 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
  27042. * * 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
  27043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27044. * * 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)
  27045. * * 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)
  27046. * @returns the VertexData of the ellipsoid
  27047. */
  27048. static CreateSphere(options: {
  27049. segments?: number;
  27050. diameter?: number;
  27051. diameterX?: number;
  27052. diameterY?: number;
  27053. diameterZ?: number;
  27054. arc?: number;
  27055. slice?: number;
  27056. sideOrientation?: number;
  27057. frontUVs?: Vector4;
  27058. backUVs?: Vector4;
  27059. }): VertexData;
  27060. /**
  27061. * Creates the VertexData for a cylinder, cone or prism
  27062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27063. * * height sets the height (y direction) of the cylinder, optional, default 2
  27064. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27065. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27066. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27067. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27068. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27069. * * 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
  27070. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27071. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27072. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27073. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27075. * * 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)
  27076. * * 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)
  27077. * @returns the VertexData of the cylinder, cone or prism
  27078. */
  27079. static CreateCylinder(options: {
  27080. height?: number;
  27081. diameterTop?: number;
  27082. diameterBottom?: number;
  27083. diameter?: number;
  27084. tessellation?: number;
  27085. subdivisions?: number;
  27086. arc?: number;
  27087. faceColors?: Color4[];
  27088. faceUV?: Vector4[];
  27089. hasRings?: boolean;
  27090. enclose?: boolean;
  27091. sideOrientation?: number;
  27092. frontUVs?: Vector4;
  27093. backUVs?: Vector4;
  27094. }): VertexData;
  27095. /**
  27096. * Creates the VertexData for a torus
  27097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27098. * * diameter the diameter of the torus, optional default 1
  27099. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27100. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27102. * * 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)
  27103. * * 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)
  27104. * @returns the VertexData of the torus
  27105. */
  27106. static CreateTorus(options: {
  27107. diameter?: number;
  27108. thickness?: number;
  27109. tessellation?: number;
  27110. sideOrientation?: number;
  27111. frontUVs?: Vector4;
  27112. backUVs?: Vector4;
  27113. }): VertexData;
  27114. /**
  27115. * Creates the VertexData of the LineSystem
  27116. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27117. * - lines an array of lines, each line being an array of successive Vector3
  27118. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27119. * @returns the VertexData of the LineSystem
  27120. */
  27121. static CreateLineSystem(options: {
  27122. lines: Vector3[][];
  27123. colors?: Nullable<Color4[][]>;
  27124. }): VertexData;
  27125. /**
  27126. * Create the VertexData for a DashedLines
  27127. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27128. * - points an array successive Vector3
  27129. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27130. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27131. * - dashNb the intended total number of dashes, optional, default 200
  27132. * @returns the VertexData for the DashedLines
  27133. */
  27134. static CreateDashedLines(options: {
  27135. points: Vector3[];
  27136. dashSize?: number;
  27137. gapSize?: number;
  27138. dashNb?: number;
  27139. }): VertexData;
  27140. /**
  27141. * Creates the VertexData for a Ground
  27142. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27143. * - width the width (x direction) of the ground, optional, default 1
  27144. * - height the height (z direction) of the ground, optional, default 1
  27145. * - subdivisions the number of subdivisions per side, optional, default 1
  27146. * @returns the VertexData of the Ground
  27147. */
  27148. static CreateGround(options: {
  27149. width?: number;
  27150. height?: number;
  27151. subdivisions?: number;
  27152. subdivisionsX?: number;
  27153. subdivisionsY?: number;
  27154. }): VertexData;
  27155. /**
  27156. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27157. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27158. * * xmin the ground minimum X coordinate, optional, default -1
  27159. * * zmin the ground minimum Z coordinate, optional, default -1
  27160. * * xmax the ground maximum X coordinate, optional, default 1
  27161. * * zmax the ground maximum Z coordinate, optional, default 1
  27162. * * 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}
  27163. * * 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}
  27164. * @returns the VertexData of the TiledGround
  27165. */
  27166. static CreateTiledGround(options: {
  27167. xmin: number;
  27168. zmin: number;
  27169. xmax: number;
  27170. zmax: number;
  27171. subdivisions?: {
  27172. w: number;
  27173. h: number;
  27174. };
  27175. precision?: {
  27176. w: number;
  27177. h: number;
  27178. };
  27179. }): VertexData;
  27180. /**
  27181. * Creates the VertexData of the Ground designed from a heightmap
  27182. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27183. * * width the width (x direction) of the ground
  27184. * * height the height (z direction) of the ground
  27185. * * subdivisions the number of subdivisions per side
  27186. * * minHeight the minimum altitude on the ground, optional, default 0
  27187. * * maxHeight the maximum altitude on the ground, optional default 1
  27188. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27189. * * buffer the array holding the image color data
  27190. * * bufferWidth the width of image
  27191. * * bufferHeight the height of image
  27192. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27193. * @returns the VertexData of the Ground designed from a heightmap
  27194. */
  27195. static CreateGroundFromHeightMap(options: {
  27196. width: number;
  27197. height: number;
  27198. subdivisions: number;
  27199. minHeight: number;
  27200. maxHeight: number;
  27201. colorFilter: Color3;
  27202. buffer: Uint8Array;
  27203. bufferWidth: number;
  27204. bufferHeight: number;
  27205. alphaFilter: number;
  27206. }): VertexData;
  27207. /**
  27208. * Creates the VertexData for a Plane
  27209. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27210. * * size sets the width and height of the plane to the value of size, optional default 1
  27211. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27212. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27214. * * 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)
  27215. * * 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)
  27216. * @returns the VertexData of the box
  27217. */
  27218. static CreatePlane(options: {
  27219. size?: number;
  27220. width?: number;
  27221. height?: number;
  27222. sideOrientation?: number;
  27223. frontUVs?: Vector4;
  27224. backUVs?: Vector4;
  27225. }): VertexData;
  27226. /**
  27227. * Creates the VertexData of the Disc or regular Polygon
  27228. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27229. * * radius the radius of the disc, optional default 0.5
  27230. * * tessellation the number of polygon sides, optional, default 64
  27231. * * 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
  27232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27233. * * 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)
  27234. * * 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)
  27235. * @returns the VertexData of the box
  27236. */
  27237. static CreateDisc(options: {
  27238. radius?: number;
  27239. tessellation?: number;
  27240. arc?: number;
  27241. sideOrientation?: number;
  27242. frontUVs?: Vector4;
  27243. backUVs?: Vector4;
  27244. }): VertexData;
  27245. /**
  27246. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27247. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27248. * @param polygon a mesh built from polygonTriangulation.build()
  27249. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27250. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27251. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27252. * @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)
  27253. * @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)
  27254. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27255. * @returns the VertexData of the Polygon
  27256. */
  27257. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27258. /**
  27259. * Creates the VertexData of the IcoSphere
  27260. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27261. * * radius the radius of the IcoSphere, optional default 1
  27262. * * radiusX allows stretching in the x direction, optional, default radius
  27263. * * radiusY allows stretching in the y direction, optional, default radius
  27264. * * radiusZ allows stretching in the z direction, optional, default radius
  27265. * * flat when true creates a flat shaded mesh, optional, default true
  27266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27268. * * 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)
  27269. * * 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)
  27270. * @returns the VertexData of the IcoSphere
  27271. */
  27272. static CreateIcoSphere(options: {
  27273. radius?: number;
  27274. radiusX?: number;
  27275. radiusY?: number;
  27276. radiusZ?: number;
  27277. flat?: boolean;
  27278. subdivisions?: number;
  27279. sideOrientation?: number;
  27280. frontUVs?: Vector4;
  27281. backUVs?: Vector4;
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData for a Polyhedron
  27285. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27286. * * type provided types are:
  27287. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27288. * * 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)
  27289. * * size the size of the IcoSphere, optional default 1
  27290. * * sizeX allows stretching in the x direction, optional, default size
  27291. * * sizeY allows stretching in the y direction, optional, default size
  27292. * * sizeZ allows stretching in the z direction, optional, default size
  27293. * * 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
  27294. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27295. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27296. * * flat when true creates a flat shaded mesh, optional, default true
  27297. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27298. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27299. * * 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)
  27300. * * 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)
  27301. * @returns the VertexData of the Polyhedron
  27302. */
  27303. static CreatePolyhedron(options: {
  27304. type?: number;
  27305. size?: number;
  27306. sizeX?: number;
  27307. sizeY?: number;
  27308. sizeZ?: number;
  27309. custom?: any;
  27310. faceUV?: Vector4[];
  27311. faceColors?: Color4[];
  27312. flat?: boolean;
  27313. sideOrientation?: number;
  27314. frontUVs?: Vector4;
  27315. backUVs?: Vector4;
  27316. }): VertexData;
  27317. /**
  27318. * Creates the VertexData for a TorusKnot
  27319. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27320. * * radius the radius of the torus knot, optional, default 2
  27321. * * tube the thickness of the tube, optional, default 0.5
  27322. * * radialSegments the number of sides on each tube segments, optional, default 32
  27323. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27324. * * p the number of windings around the z axis, optional, default 2
  27325. * * q the number of windings around the x axis, optional, default 3
  27326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27327. * * 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)
  27328. * * 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)
  27329. * @returns the VertexData of the Torus Knot
  27330. */
  27331. static CreateTorusKnot(options: {
  27332. radius?: number;
  27333. tube?: number;
  27334. radialSegments?: number;
  27335. tubularSegments?: number;
  27336. p?: number;
  27337. q?: number;
  27338. sideOrientation?: number;
  27339. frontUVs?: Vector4;
  27340. backUVs?: Vector4;
  27341. }): VertexData;
  27342. /**
  27343. * Compute normals for given positions and indices
  27344. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27345. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27346. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27347. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27348. * * facetNormals : optional array of facet normals (vector3)
  27349. * * facetPositions : optional array of facet positions (vector3)
  27350. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27351. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27352. * * bInfo : optional bounding info, required for facetPartitioning computation
  27353. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27354. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27355. * * useRightHandedSystem: optional boolean to for right handed system computation
  27356. * * depthSort : optional boolean to enable the facet depth sort computation
  27357. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27358. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27359. */
  27360. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27361. facetNormals?: any;
  27362. facetPositions?: any;
  27363. facetPartitioning?: any;
  27364. ratio?: number;
  27365. bInfo?: any;
  27366. bbSize?: Vector3;
  27367. subDiv?: any;
  27368. useRightHandedSystem?: boolean;
  27369. depthSort?: boolean;
  27370. distanceTo?: Vector3;
  27371. depthSortedFacets?: any;
  27372. }): void;
  27373. /** @hidden */
  27374. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27375. /**
  27376. * Applies VertexData created from the imported parameters to the geometry
  27377. * @param parsedVertexData the parsed data from an imported file
  27378. * @param geometry the geometry to apply the VertexData to
  27379. */
  27380. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27381. }
  27382. }
  27383. declare module "babylonjs/Morph/morphTarget" {
  27384. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27385. import { Observable } from "babylonjs/Misc/observable";
  27386. import { Nullable, FloatArray } from "babylonjs/types";
  27387. import { Scene } from "babylonjs/scene";
  27388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27389. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27390. /**
  27391. * Defines a target to use with MorphTargetManager
  27392. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27393. */
  27394. export class MorphTarget implements IAnimatable {
  27395. /** defines the name of the target */
  27396. name: string;
  27397. /**
  27398. * Gets or sets the list of animations
  27399. */
  27400. animations: import("babylonjs/Animations/animation").Animation[];
  27401. private _scene;
  27402. private _positions;
  27403. private _normals;
  27404. private _tangents;
  27405. private _uvs;
  27406. private _influence;
  27407. private _uniqueId;
  27408. /**
  27409. * Observable raised when the influence changes
  27410. */
  27411. onInfluenceChanged: Observable<boolean>;
  27412. /** @hidden */
  27413. _onDataLayoutChanged: Observable<void>;
  27414. /**
  27415. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27416. */
  27417. get influence(): number;
  27418. set influence(influence: number);
  27419. /**
  27420. * Gets or sets the id of the morph Target
  27421. */
  27422. id: string;
  27423. private _animationPropertiesOverride;
  27424. /**
  27425. * Gets or sets the animation properties override
  27426. */
  27427. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27428. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27429. /**
  27430. * Creates a new MorphTarget
  27431. * @param name defines the name of the target
  27432. * @param influence defines the influence to use
  27433. * @param scene defines the scene the morphtarget belongs to
  27434. */
  27435. constructor(
  27436. /** defines the name of the target */
  27437. name: string, influence?: number, scene?: Nullable<Scene>);
  27438. /**
  27439. * Gets the unique ID of this manager
  27440. */
  27441. get uniqueId(): number;
  27442. /**
  27443. * Gets a boolean defining if the target contains position data
  27444. */
  27445. get hasPositions(): boolean;
  27446. /**
  27447. * Gets a boolean defining if the target contains normal data
  27448. */
  27449. get hasNormals(): boolean;
  27450. /**
  27451. * Gets a boolean defining if the target contains tangent data
  27452. */
  27453. get hasTangents(): boolean;
  27454. /**
  27455. * Gets a boolean defining if the target contains texture coordinates data
  27456. */
  27457. get hasUVs(): boolean;
  27458. /**
  27459. * Affects position data to this target
  27460. * @param data defines the position data to use
  27461. */
  27462. setPositions(data: Nullable<FloatArray>): void;
  27463. /**
  27464. * Gets the position data stored in this target
  27465. * @returns a FloatArray containing the position data (or null if not present)
  27466. */
  27467. getPositions(): Nullable<FloatArray>;
  27468. /**
  27469. * Affects normal data to this target
  27470. * @param data defines the normal data to use
  27471. */
  27472. setNormals(data: Nullable<FloatArray>): void;
  27473. /**
  27474. * Gets the normal data stored in this target
  27475. * @returns a FloatArray containing the normal data (or null if not present)
  27476. */
  27477. getNormals(): Nullable<FloatArray>;
  27478. /**
  27479. * Affects tangent data to this target
  27480. * @param data defines the tangent data to use
  27481. */
  27482. setTangents(data: Nullable<FloatArray>): void;
  27483. /**
  27484. * Gets the tangent data stored in this target
  27485. * @returns a FloatArray containing the tangent data (or null if not present)
  27486. */
  27487. getTangents(): Nullable<FloatArray>;
  27488. /**
  27489. * Affects texture coordinates data to this target
  27490. * @param data defines the texture coordinates data to use
  27491. */
  27492. setUVs(data: Nullable<FloatArray>): void;
  27493. /**
  27494. * Gets the texture coordinates data stored in this target
  27495. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27496. */
  27497. getUVs(): Nullable<FloatArray>;
  27498. /**
  27499. * Clone the current target
  27500. * @returns a new MorphTarget
  27501. */
  27502. clone(): MorphTarget;
  27503. /**
  27504. * Serializes the current target into a Serialization object
  27505. * @returns the serialized object
  27506. */
  27507. serialize(): any;
  27508. /**
  27509. * Returns the string "MorphTarget"
  27510. * @returns "MorphTarget"
  27511. */
  27512. getClassName(): string;
  27513. /**
  27514. * Creates a new target from serialized data
  27515. * @param serializationObject defines the serialized data to use
  27516. * @returns a new MorphTarget
  27517. */
  27518. static Parse(serializationObject: any): MorphTarget;
  27519. /**
  27520. * Creates a MorphTarget from mesh data
  27521. * @param mesh defines the source mesh
  27522. * @param name defines the name to use for the new target
  27523. * @param influence defines the influence to attach to the target
  27524. * @returns a new MorphTarget
  27525. */
  27526. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27527. }
  27528. }
  27529. declare module "babylonjs/Morph/morphTargetManager" {
  27530. import { Nullable } from "babylonjs/types";
  27531. import { Scene } from "babylonjs/scene";
  27532. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27533. /**
  27534. * This class is used to deform meshes using morphing between different targets
  27535. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27536. */
  27537. export class MorphTargetManager {
  27538. private _targets;
  27539. private _targetInfluenceChangedObservers;
  27540. private _targetDataLayoutChangedObservers;
  27541. private _activeTargets;
  27542. private _scene;
  27543. private _influences;
  27544. private _supportsNormals;
  27545. private _supportsTangents;
  27546. private _supportsUVs;
  27547. private _vertexCount;
  27548. private _uniqueId;
  27549. private _tempInfluences;
  27550. /**
  27551. * Gets or sets a boolean indicating if normals must be morphed
  27552. */
  27553. enableNormalMorphing: boolean;
  27554. /**
  27555. * Gets or sets a boolean indicating if tangents must be morphed
  27556. */
  27557. enableTangentMorphing: boolean;
  27558. /**
  27559. * Gets or sets a boolean indicating if UV must be morphed
  27560. */
  27561. enableUVMorphing: boolean;
  27562. /**
  27563. * Creates a new MorphTargetManager
  27564. * @param scene defines the current scene
  27565. */
  27566. constructor(scene?: Nullable<Scene>);
  27567. /**
  27568. * Gets the unique ID of this manager
  27569. */
  27570. get uniqueId(): number;
  27571. /**
  27572. * Gets the number of vertices handled by this manager
  27573. */
  27574. get vertexCount(): number;
  27575. /**
  27576. * Gets a boolean indicating if this manager supports morphing of normals
  27577. */
  27578. get supportsNormals(): boolean;
  27579. /**
  27580. * Gets a boolean indicating if this manager supports morphing of tangents
  27581. */
  27582. get supportsTangents(): boolean;
  27583. /**
  27584. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27585. */
  27586. get supportsUVs(): boolean;
  27587. /**
  27588. * Gets the number of targets stored in this manager
  27589. */
  27590. get numTargets(): number;
  27591. /**
  27592. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27593. */
  27594. get numInfluencers(): number;
  27595. /**
  27596. * Gets the list of influences (one per target)
  27597. */
  27598. get influences(): Float32Array;
  27599. /**
  27600. * Gets the active target at specified index. An active target is a target with an influence > 0
  27601. * @param index defines the index to check
  27602. * @returns the requested target
  27603. */
  27604. getActiveTarget(index: number): MorphTarget;
  27605. /**
  27606. * Gets the target at specified index
  27607. * @param index defines the index to check
  27608. * @returns the requested target
  27609. */
  27610. getTarget(index: number): MorphTarget;
  27611. /**
  27612. * Add a new target to this manager
  27613. * @param target defines the target to add
  27614. */
  27615. addTarget(target: MorphTarget): void;
  27616. /**
  27617. * Removes a target from the manager
  27618. * @param target defines the target to remove
  27619. */
  27620. removeTarget(target: MorphTarget): void;
  27621. /**
  27622. * Clone the current manager
  27623. * @returns a new MorphTargetManager
  27624. */
  27625. clone(): MorphTargetManager;
  27626. /**
  27627. * Serializes the current manager into a Serialization object
  27628. * @returns the serialized object
  27629. */
  27630. serialize(): any;
  27631. private _syncActiveTargets;
  27632. /**
  27633. * Syncrhonize the targets with all the meshes using this morph target manager
  27634. */
  27635. synchronize(): void;
  27636. /**
  27637. * Creates a new MorphTargetManager from serialized data
  27638. * @param serializationObject defines the serialized data
  27639. * @param scene defines the hosting scene
  27640. * @returns the new MorphTargetManager
  27641. */
  27642. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27643. }
  27644. }
  27645. declare module "babylonjs/Meshes/meshLODLevel" {
  27646. import { Mesh } from "babylonjs/Meshes/mesh";
  27647. import { Nullable } from "babylonjs/types";
  27648. /**
  27649. * Class used to represent a specific level of detail of a mesh
  27650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27651. */
  27652. export class MeshLODLevel {
  27653. /** Defines the distance where this level should start being displayed */
  27654. distance: number;
  27655. /** Defines the mesh to use to render this level */
  27656. mesh: Nullable<Mesh>;
  27657. /**
  27658. * Creates a new LOD level
  27659. * @param distance defines the distance where this level should star being displayed
  27660. * @param mesh defines the mesh to use to render this level
  27661. */
  27662. constructor(
  27663. /** Defines the distance where this level should start being displayed */
  27664. distance: number,
  27665. /** Defines the mesh to use to render this level */
  27666. mesh: Nullable<Mesh>);
  27667. }
  27668. }
  27669. declare module "babylonjs/Misc/canvasGenerator" {
  27670. /**
  27671. * Helper class used to generate a canvas to manipulate images
  27672. */
  27673. export class CanvasGenerator {
  27674. /**
  27675. * Create a new canvas (or offscreen canvas depending on the context)
  27676. * @param width defines the expected width
  27677. * @param height defines the expected height
  27678. * @return a new canvas or offscreen canvas
  27679. */
  27680. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27681. }
  27682. }
  27683. declare module "babylonjs/Meshes/groundMesh" {
  27684. import { Scene } from "babylonjs/scene";
  27685. import { Vector3 } from "babylonjs/Maths/math.vector";
  27686. import { Mesh } from "babylonjs/Meshes/mesh";
  27687. /**
  27688. * Mesh representing the gorund
  27689. */
  27690. export class GroundMesh extends Mesh {
  27691. /** If octree should be generated */
  27692. generateOctree: boolean;
  27693. private _heightQuads;
  27694. /** @hidden */
  27695. _subdivisionsX: number;
  27696. /** @hidden */
  27697. _subdivisionsY: number;
  27698. /** @hidden */
  27699. _width: number;
  27700. /** @hidden */
  27701. _height: number;
  27702. /** @hidden */
  27703. _minX: number;
  27704. /** @hidden */
  27705. _maxX: number;
  27706. /** @hidden */
  27707. _minZ: number;
  27708. /** @hidden */
  27709. _maxZ: number;
  27710. constructor(name: string, scene: Scene);
  27711. /**
  27712. * "GroundMesh"
  27713. * @returns "GroundMesh"
  27714. */
  27715. getClassName(): string;
  27716. /**
  27717. * The minimum of x and y subdivisions
  27718. */
  27719. get subdivisions(): number;
  27720. /**
  27721. * X subdivisions
  27722. */
  27723. get subdivisionsX(): number;
  27724. /**
  27725. * Y subdivisions
  27726. */
  27727. get subdivisionsY(): number;
  27728. /**
  27729. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27730. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27731. * @param chunksCount the number of subdivisions for x and y
  27732. * @param octreeBlocksSize (Default: 32)
  27733. */
  27734. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27735. /**
  27736. * Returns a height (y) value in the Worl system :
  27737. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27738. * @param x x coordinate
  27739. * @param z z coordinate
  27740. * @returns the ground y position if (x, z) are outside the ground surface.
  27741. */
  27742. getHeightAtCoordinates(x: number, z: number): number;
  27743. /**
  27744. * Returns a normalized vector (Vector3) orthogonal to the ground
  27745. * at the ground coordinates (x, z) expressed in the World system.
  27746. * @param x x coordinate
  27747. * @param z z coordinate
  27748. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27749. */
  27750. getNormalAtCoordinates(x: number, z: number): Vector3;
  27751. /**
  27752. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27753. * at the ground coordinates (x, z) expressed in the World system.
  27754. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27755. * @param x x coordinate
  27756. * @param z z coordinate
  27757. * @param ref vector to store the result
  27758. * @returns the GroundMesh.
  27759. */
  27760. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27761. /**
  27762. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27763. * if the ground has been updated.
  27764. * This can be used in the render loop.
  27765. * @returns the GroundMesh.
  27766. */
  27767. updateCoordinateHeights(): GroundMesh;
  27768. private _getFacetAt;
  27769. private _initHeightQuads;
  27770. private _computeHeightQuads;
  27771. /**
  27772. * Serializes this ground mesh
  27773. * @param serializationObject object to write serialization to
  27774. */
  27775. serialize(serializationObject: any): void;
  27776. /**
  27777. * Parses a serialized ground mesh
  27778. * @param parsedMesh the serialized mesh
  27779. * @param scene the scene to create the ground mesh in
  27780. * @returns the created ground mesh
  27781. */
  27782. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27783. }
  27784. }
  27785. declare module "babylonjs/Physics/physicsJoint" {
  27786. import { Vector3 } from "babylonjs/Maths/math.vector";
  27787. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27788. /**
  27789. * Interface for Physics-Joint data
  27790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27791. */
  27792. export interface PhysicsJointData {
  27793. /**
  27794. * The main pivot of the joint
  27795. */
  27796. mainPivot?: Vector3;
  27797. /**
  27798. * The connected pivot of the joint
  27799. */
  27800. connectedPivot?: Vector3;
  27801. /**
  27802. * The main axis of the joint
  27803. */
  27804. mainAxis?: Vector3;
  27805. /**
  27806. * The connected axis of the joint
  27807. */
  27808. connectedAxis?: Vector3;
  27809. /**
  27810. * The collision of the joint
  27811. */
  27812. collision?: boolean;
  27813. /**
  27814. * Native Oimo/Cannon/Energy data
  27815. */
  27816. nativeParams?: any;
  27817. }
  27818. /**
  27819. * This is a holder class for the physics joint created by the physics plugin
  27820. * It holds a set of functions to control the underlying joint
  27821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27822. */
  27823. export class PhysicsJoint {
  27824. /**
  27825. * The type of the physics joint
  27826. */
  27827. type: number;
  27828. /**
  27829. * The data for the physics joint
  27830. */
  27831. jointData: PhysicsJointData;
  27832. private _physicsJoint;
  27833. protected _physicsPlugin: IPhysicsEnginePlugin;
  27834. /**
  27835. * Initializes the physics joint
  27836. * @param type The type of the physics joint
  27837. * @param jointData The data for the physics joint
  27838. */
  27839. constructor(
  27840. /**
  27841. * The type of the physics joint
  27842. */
  27843. type: number,
  27844. /**
  27845. * The data for the physics joint
  27846. */
  27847. jointData: PhysicsJointData);
  27848. /**
  27849. * Gets the physics joint
  27850. */
  27851. get physicsJoint(): any;
  27852. /**
  27853. * Sets the physics joint
  27854. */
  27855. set physicsJoint(newJoint: any);
  27856. /**
  27857. * Sets the physics plugin
  27858. */
  27859. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27860. /**
  27861. * Execute a function that is physics-plugin specific.
  27862. * @param {Function} func the function that will be executed.
  27863. * It accepts two parameters: the physics world and the physics joint
  27864. */
  27865. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27866. /**
  27867. * Distance-Joint type
  27868. */
  27869. static DistanceJoint: number;
  27870. /**
  27871. * Hinge-Joint type
  27872. */
  27873. static HingeJoint: number;
  27874. /**
  27875. * Ball-and-Socket joint type
  27876. */
  27877. static BallAndSocketJoint: number;
  27878. /**
  27879. * Wheel-Joint type
  27880. */
  27881. static WheelJoint: number;
  27882. /**
  27883. * Slider-Joint type
  27884. */
  27885. static SliderJoint: number;
  27886. /**
  27887. * Prismatic-Joint type
  27888. */
  27889. static PrismaticJoint: number;
  27890. /**
  27891. * Universal-Joint type
  27892. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27893. */
  27894. static UniversalJoint: number;
  27895. /**
  27896. * Hinge-Joint 2 type
  27897. */
  27898. static Hinge2Joint: number;
  27899. /**
  27900. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27901. */
  27902. static PointToPointJoint: number;
  27903. /**
  27904. * Spring-Joint type
  27905. */
  27906. static SpringJoint: number;
  27907. /**
  27908. * Lock-Joint type
  27909. */
  27910. static LockJoint: number;
  27911. }
  27912. /**
  27913. * A class representing a physics distance joint
  27914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27915. */
  27916. export class DistanceJoint extends PhysicsJoint {
  27917. /**
  27918. *
  27919. * @param jointData The data for the Distance-Joint
  27920. */
  27921. constructor(jointData: DistanceJointData);
  27922. /**
  27923. * Update the predefined distance.
  27924. * @param maxDistance The maximum preferred distance
  27925. * @param minDistance The minimum preferred distance
  27926. */
  27927. updateDistance(maxDistance: number, minDistance?: number): void;
  27928. }
  27929. /**
  27930. * Represents a Motor-Enabled Joint
  27931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27932. */
  27933. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27934. /**
  27935. * Initializes the Motor-Enabled Joint
  27936. * @param type The type of the joint
  27937. * @param jointData The physica joint data for the joint
  27938. */
  27939. constructor(type: number, jointData: PhysicsJointData);
  27940. /**
  27941. * Set the motor values.
  27942. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27943. * @param force the force to apply
  27944. * @param maxForce max force for this motor.
  27945. */
  27946. setMotor(force?: number, maxForce?: number): void;
  27947. /**
  27948. * Set the motor's limits.
  27949. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27950. * @param upperLimit The upper limit of the motor
  27951. * @param lowerLimit The lower limit of the motor
  27952. */
  27953. setLimit(upperLimit: number, lowerLimit?: number): void;
  27954. }
  27955. /**
  27956. * This class represents a single physics Hinge-Joint
  27957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27958. */
  27959. export class HingeJoint extends MotorEnabledJoint {
  27960. /**
  27961. * Initializes the Hinge-Joint
  27962. * @param jointData The joint data for the Hinge-Joint
  27963. */
  27964. constructor(jointData: PhysicsJointData);
  27965. /**
  27966. * Set the motor values.
  27967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27968. * @param {number} force the force to apply
  27969. * @param {number} maxForce max force for this motor.
  27970. */
  27971. setMotor(force?: number, maxForce?: number): void;
  27972. /**
  27973. * Set the motor's limits.
  27974. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27975. * @param upperLimit The upper limit of the motor
  27976. * @param lowerLimit The lower limit of the motor
  27977. */
  27978. setLimit(upperLimit: number, lowerLimit?: number): void;
  27979. }
  27980. /**
  27981. * This class represents a dual hinge physics joint (same as wheel joint)
  27982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27983. */
  27984. export class Hinge2Joint extends MotorEnabledJoint {
  27985. /**
  27986. * Initializes the Hinge2-Joint
  27987. * @param jointData The joint data for the Hinge2-Joint
  27988. */
  27989. constructor(jointData: PhysicsJointData);
  27990. /**
  27991. * Set the motor values.
  27992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27993. * @param {number} targetSpeed the speed the motor is to reach
  27994. * @param {number} maxForce max force for this motor.
  27995. * @param {motorIndex} the motor's index, 0 or 1.
  27996. */
  27997. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27998. /**
  27999. * Set the motor limits.
  28000. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28001. * @param {number} upperLimit the upper limit
  28002. * @param {number} lowerLimit lower limit
  28003. * @param {motorIndex} the motor's index, 0 or 1.
  28004. */
  28005. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28006. }
  28007. /**
  28008. * Interface for a motor enabled joint
  28009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28010. */
  28011. export interface IMotorEnabledJoint {
  28012. /**
  28013. * Physics joint
  28014. */
  28015. physicsJoint: any;
  28016. /**
  28017. * Sets the motor of the motor-enabled joint
  28018. * @param force The force of the motor
  28019. * @param maxForce The maximum force of the motor
  28020. * @param motorIndex The index of the motor
  28021. */
  28022. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28023. /**
  28024. * Sets the limit of the motor
  28025. * @param upperLimit The upper limit of the motor
  28026. * @param lowerLimit The lower limit of the motor
  28027. * @param motorIndex The index of the motor
  28028. */
  28029. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28030. }
  28031. /**
  28032. * Joint data for a Distance-Joint
  28033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28034. */
  28035. export interface DistanceJointData extends PhysicsJointData {
  28036. /**
  28037. * Max distance the 2 joint objects can be apart
  28038. */
  28039. maxDistance: number;
  28040. }
  28041. /**
  28042. * Joint data from a spring joint
  28043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28044. */
  28045. export interface SpringJointData extends PhysicsJointData {
  28046. /**
  28047. * Length of the spring
  28048. */
  28049. length: number;
  28050. /**
  28051. * Stiffness of the spring
  28052. */
  28053. stiffness: number;
  28054. /**
  28055. * Damping of the spring
  28056. */
  28057. damping: number;
  28058. /** this callback will be called when applying the force to the impostors. */
  28059. forceApplicationCallback: () => void;
  28060. }
  28061. }
  28062. declare module "babylonjs/Physics/physicsRaycastResult" {
  28063. import { Vector3 } from "babylonjs/Maths/math.vector";
  28064. /**
  28065. * Holds the data for the raycast result
  28066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28067. */
  28068. export class PhysicsRaycastResult {
  28069. private _hasHit;
  28070. private _hitDistance;
  28071. private _hitNormalWorld;
  28072. private _hitPointWorld;
  28073. private _rayFromWorld;
  28074. private _rayToWorld;
  28075. /**
  28076. * Gets if there was a hit
  28077. */
  28078. get hasHit(): boolean;
  28079. /**
  28080. * Gets the distance from the hit
  28081. */
  28082. get hitDistance(): number;
  28083. /**
  28084. * Gets the hit normal/direction in the world
  28085. */
  28086. get hitNormalWorld(): Vector3;
  28087. /**
  28088. * Gets the hit point in the world
  28089. */
  28090. get hitPointWorld(): Vector3;
  28091. /**
  28092. * Gets the ray "start point" of the ray in the world
  28093. */
  28094. get rayFromWorld(): Vector3;
  28095. /**
  28096. * Gets the ray "end point" of the ray in the world
  28097. */
  28098. get rayToWorld(): Vector3;
  28099. /**
  28100. * Sets the hit data (normal & point in world space)
  28101. * @param hitNormalWorld defines the normal in world space
  28102. * @param hitPointWorld defines the point in world space
  28103. */
  28104. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28105. /**
  28106. * Sets the distance from the start point to the hit point
  28107. * @param distance
  28108. */
  28109. setHitDistance(distance: number): void;
  28110. /**
  28111. * Calculates the distance manually
  28112. */
  28113. calculateHitDistance(): void;
  28114. /**
  28115. * Resets all the values to default
  28116. * @param from The from point on world space
  28117. * @param to The to point on world space
  28118. */
  28119. reset(from?: Vector3, to?: Vector3): void;
  28120. }
  28121. /**
  28122. * Interface for the size containing width and height
  28123. */
  28124. interface IXYZ {
  28125. /**
  28126. * X
  28127. */
  28128. x: number;
  28129. /**
  28130. * Y
  28131. */
  28132. y: number;
  28133. /**
  28134. * Z
  28135. */
  28136. z: number;
  28137. }
  28138. }
  28139. declare module "babylonjs/Physics/IPhysicsEngine" {
  28140. import { Nullable } from "babylonjs/types";
  28141. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28143. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28144. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28145. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28146. /**
  28147. * Interface used to describe a physics joint
  28148. */
  28149. export interface PhysicsImpostorJoint {
  28150. /** Defines the main impostor to which the joint is linked */
  28151. mainImpostor: PhysicsImpostor;
  28152. /** Defines the impostor that is connected to the main impostor using this joint */
  28153. connectedImpostor: PhysicsImpostor;
  28154. /** Defines the joint itself */
  28155. joint: PhysicsJoint;
  28156. }
  28157. /** @hidden */
  28158. export interface IPhysicsEnginePlugin {
  28159. world: any;
  28160. name: string;
  28161. setGravity(gravity: Vector3): void;
  28162. setTimeStep(timeStep: number): void;
  28163. getTimeStep(): number;
  28164. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28165. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28166. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28167. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28168. removePhysicsBody(impostor: PhysicsImpostor): void;
  28169. generateJoint(joint: PhysicsImpostorJoint): void;
  28170. removeJoint(joint: PhysicsImpostorJoint): void;
  28171. isSupported(): boolean;
  28172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28179. getBodyMass(impostor: PhysicsImpostor): number;
  28180. getBodyFriction(impostor: PhysicsImpostor): number;
  28181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28182. getBodyRestitution(impostor: PhysicsImpostor): number;
  28183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28184. getBodyPressure?(impostor: PhysicsImpostor): number;
  28185. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28186. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28187. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28188. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28189. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28190. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28191. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28192. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28193. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28194. sleepBody(impostor: PhysicsImpostor): void;
  28195. wakeUpBody(impostor: PhysicsImpostor): void;
  28196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28197. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28198. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28199. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28200. getRadius(impostor: PhysicsImpostor): number;
  28201. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28203. dispose(): void;
  28204. }
  28205. /**
  28206. * Interface used to define a physics engine
  28207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28208. */
  28209. export interface IPhysicsEngine {
  28210. /**
  28211. * Gets the gravity vector used by the simulation
  28212. */
  28213. gravity: Vector3;
  28214. /**
  28215. * Sets the gravity vector used by the simulation
  28216. * @param gravity defines the gravity vector to use
  28217. */
  28218. setGravity(gravity: Vector3): void;
  28219. /**
  28220. * Set the time step of the physics engine.
  28221. * Default is 1/60.
  28222. * To slow it down, enter 1/600 for example.
  28223. * To speed it up, 1/30
  28224. * @param newTimeStep the new timestep to apply to this world.
  28225. */
  28226. setTimeStep(newTimeStep: number): void;
  28227. /**
  28228. * Get the time step of the physics engine.
  28229. * @returns the current time step
  28230. */
  28231. getTimeStep(): number;
  28232. /**
  28233. * Set the sub time step of the physics engine.
  28234. * Default is 0 meaning there is no sub steps
  28235. * To increase physics resolution precision, set a small value (like 1 ms)
  28236. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28237. */
  28238. setSubTimeStep(subTimeStep: number): void;
  28239. /**
  28240. * Get the sub time step of the physics engine.
  28241. * @returns the current sub time step
  28242. */
  28243. getSubTimeStep(): number;
  28244. /**
  28245. * Release all resources
  28246. */
  28247. dispose(): void;
  28248. /**
  28249. * Gets the name of the current physics plugin
  28250. * @returns the name of the plugin
  28251. */
  28252. getPhysicsPluginName(): string;
  28253. /**
  28254. * Adding a new impostor for the impostor tracking.
  28255. * This will be done by the impostor itself.
  28256. * @param impostor the impostor to add
  28257. */
  28258. addImpostor(impostor: PhysicsImpostor): void;
  28259. /**
  28260. * Remove an impostor from the engine.
  28261. * This impostor and its mesh will not longer be updated by the physics engine.
  28262. * @param impostor the impostor to remove
  28263. */
  28264. removeImpostor(impostor: PhysicsImpostor): void;
  28265. /**
  28266. * Add a joint to the physics engine
  28267. * @param mainImpostor defines the main impostor to which the joint is added.
  28268. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28269. * @param joint defines the joint that will connect both impostors.
  28270. */
  28271. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28272. /**
  28273. * Removes a joint from the simulation
  28274. * @param mainImpostor defines the impostor used with the joint
  28275. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28276. * @param joint defines the joint to remove
  28277. */
  28278. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28279. /**
  28280. * Gets the current plugin used to run the simulation
  28281. * @returns current plugin
  28282. */
  28283. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28284. /**
  28285. * Gets the list of physic impostors
  28286. * @returns an array of PhysicsImpostor
  28287. */
  28288. getImpostors(): Array<PhysicsImpostor>;
  28289. /**
  28290. * Gets the impostor for a physics enabled object
  28291. * @param object defines the object impersonated by the impostor
  28292. * @returns the PhysicsImpostor or null if not found
  28293. */
  28294. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28295. /**
  28296. * Gets the impostor for a physics body object
  28297. * @param body defines physics body used by the impostor
  28298. * @returns the PhysicsImpostor or null if not found
  28299. */
  28300. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28301. /**
  28302. * Does a raycast in the physics world
  28303. * @param from when should the ray start?
  28304. * @param to when should the ray end?
  28305. * @returns PhysicsRaycastResult
  28306. */
  28307. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28308. /**
  28309. * Called by the scene. No need to call it.
  28310. * @param delta defines the timespam between frames
  28311. */
  28312. _step(delta: number): void;
  28313. }
  28314. }
  28315. declare module "babylonjs/Physics/physicsImpostor" {
  28316. import { Nullable, IndicesArray } from "babylonjs/types";
  28317. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28320. import { Scene } from "babylonjs/scene";
  28321. import { Bone } from "babylonjs/Bones/bone";
  28322. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28323. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28324. import { Space } from "babylonjs/Maths/math.axis";
  28325. /**
  28326. * The interface for the physics imposter parameters
  28327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28328. */
  28329. export interface PhysicsImpostorParameters {
  28330. /**
  28331. * The mass of the physics imposter
  28332. */
  28333. mass: number;
  28334. /**
  28335. * The friction of the physics imposter
  28336. */
  28337. friction?: number;
  28338. /**
  28339. * The coefficient of restitution of the physics imposter
  28340. */
  28341. restitution?: number;
  28342. /**
  28343. * The native options of the physics imposter
  28344. */
  28345. nativeOptions?: any;
  28346. /**
  28347. * Specifies if the parent should be ignored
  28348. */
  28349. ignoreParent?: boolean;
  28350. /**
  28351. * Specifies if bi-directional transformations should be disabled
  28352. */
  28353. disableBidirectionalTransformation?: boolean;
  28354. /**
  28355. * The pressure inside the physics imposter, soft object only
  28356. */
  28357. pressure?: number;
  28358. /**
  28359. * The stiffness the physics imposter, soft object only
  28360. */
  28361. stiffness?: number;
  28362. /**
  28363. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28364. */
  28365. velocityIterations?: number;
  28366. /**
  28367. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28368. */
  28369. positionIterations?: number;
  28370. /**
  28371. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28372. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28373. * Add to fix multiple points
  28374. */
  28375. fixedPoints?: number;
  28376. /**
  28377. * The collision margin around a soft object
  28378. */
  28379. margin?: number;
  28380. /**
  28381. * The collision margin around a soft object
  28382. */
  28383. damping?: number;
  28384. /**
  28385. * The path for a rope based on an extrusion
  28386. */
  28387. path?: any;
  28388. /**
  28389. * The shape of an extrusion used for a rope based on an extrusion
  28390. */
  28391. shape?: any;
  28392. }
  28393. /**
  28394. * Interface for a physics-enabled object
  28395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28396. */
  28397. export interface IPhysicsEnabledObject {
  28398. /**
  28399. * The position of the physics-enabled object
  28400. */
  28401. position: Vector3;
  28402. /**
  28403. * The rotation of the physics-enabled object
  28404. */
  28405. rotationQuaternion: Nullable<Quaternion>;
  28406. /**
  28407. * The scale of the physics-enabled object
  28408. */
  28409. scaling: Vector3;
  28410. /**
  28411. * The rotation of the physics-enabled object
  28412. */
  28413. rotation?: Vector3;
  28414. /**
  28415. * The parent of the physics-enabled object
  28416. */
  28417. parent?: any;
  28418. /**
  28419. * The bounding info of the physics-enabled object
  28420. * @returns The bounding info of the physics-enabled object
  28421. */
  28422. getBoundingInfo(): BoundingInfo;
  28423. /**
  28424. * Computes the world matrix
  28425. * @param force Specifies if the world matrix should be computed by force
  28426. * @returns A world matrix
  28427. */
  28428. computeWorldMatrix(force: boolean): Matrix;
  28429. /**
  28430. * Gets the world matrix
  28431. * @returns A world matrix
  28432. */
  28433. getWorldMatrix?(): Matrix;
  28434. /**
  28435. * Gets the child meshes
  28436. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28437. * @returns An array of abstract meshes
  28438. */
  28439. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28440. /**
  28441. * Gets the vertex data
  28442. * @param kind The type of vertex data
  28443. * @returns A nullable array of numbers, or a float32 array
  28444. */
  28445. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28446. /**
  28447. * Gets the indices from the mesh
  28448. * @returns A nullable array of index arrays
  28449. */
  28450. getIndices?(): Nullable<IndicesArray>;
  28451. /**
  28452. * Gets the scene from the mesh
  28453. * @returns the indices array or null
  28454. */
  28455. getScene?(): Scene;
  28456. /**
  28457. * Gets the absolute position from the mesh
  28458. * @returns the absolute position
  28459. */
  28460. getAbsolutePosition(): Vector3;
  28461. /**
  28462. * Gets the absolute pivot point from the mesh
  28463. * @returns the absolute pivot point
  28464. */
  28465. getAbsolutePivotPoint(): Vector3;
  28466. /**
  28467. * Rotates the mesh
  28468. * @param axis The axis of rotation
  28469. * @param amount The amount of rotation
  28470. * @param space The space of the rotation
  28471. * @returns The rotation transform node
  28472. */
  28473. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28474. /**
  28475. * Translates the mesh
  28476. * @param axis The axis of translation
  28477. * @param distance The distance of translation
  28478. * @param space The space of the translation
  28479. * @returns The transform node
  28480. */
  28481. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28482. /**
  28483. * Sets the absolute position of the mesh
  28484. * @param absolutePosition The absolute position of the mesh
  28485. * @returns The transform node
  28486. */
  28487. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28488. /**
  28489. * Gets the class name of the mesh
  28490. * @returns The class name
  28491. */
  28492. getClassName(): string;
  28493. }
  28494. /**
  28495. * Represents a physics imposter
  28496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28497. */
  28498. export class PhysicsImpostor {
  28499. /**
  28500. * The physics-enabled object used as the physics imposter
  28501. */
  28502. object: IPhysicsEnabledObject;
  28503. /**
  28504. * The type of the physics imposter
  28505. */
  28506. type: number;
  28507. private _options;
  28508. private _scene?;
  28509. /**
  28510. * The default object size of the imposter
  28511. */
  28512. static DEFAULT_OBJECT_SIZE: Vector3;
  28513. /**
  28514. * The identity quaternion of the imposter
  28515. */
  28516. static IDENTITY_QUATERNION: Quaternion;
  28517. /** @hidden */
  28518. _pluginData: any;
  28519. private _physicsEngine;
  28520. private _physicsBody;
  28521. private _bodyUpdateRequired;
  28522. private _onBeforePhysicsStepCallbacks;
  28523. private _onAfterPhysicsStepCallbacks;
  28524. /** @hidden */
  28525. _onPhysicsCollideCallbacks: Array<{
  28526. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28527. otherImpostors: Array<PhysicsImpostor>;
  28528. }>;
  28529. private _deltaPosition;
  28530. private _deltaRotation;
  28531. private _deltaRotationConjugated;
  28532. /** @hidden */
  28533. _isFromLine: boolean;
  28534. private _parent;
  28535. private _isDisposed;
  28536. private static _tmpVecs;
  28537. private static _tmpQuat;
  28538. /**
  28539. * Specifies if the physics imposter is disposed
  28540. */
  28541. get isDisposed(): boolean;
  28542. /**
  28543. * Gets the mass of the physics imposter
  28544. */
  28545. get mass(): number;
  28546. set mass(value: number);
  28547. /**
  28548. * Gets the coefficient of friction
  28549. */
  28550. get friction(): number;
  28551. /**
  28552. * Sets the coefficient of friction
  28553. */
  28554. set friction(value: number);
  28555. /**
  28556. * Gets the coefficient of restitution
  28557. */
  28558. get restitution(): number;
  28559. /**
  28560. * Sets the coefficient of restitution
  28561. */
  28562. set restitution(value: number);
  28563. /**
  28564. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28565. */
  28566. get pressure(): number;
  28567. /**
  28568. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28569. */
  28570. set pressure(value: number);
  28571. /**
  28572. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28573. */
  28574. get stiffness(): number;
  28575. /**
  28576. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28577. */
  28578. set stiffness(value: number);
  28579. /**
  28580. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28581. */
  28582. get velocityIterations(): number;
  28583. /**
  28584. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28585. */
  28586. set velocityIterations(value: number);
  28587. /**
  28588. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28589. */
  28590. get positionIterations(): number;
  28591. /**
  28592. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28593. */
  28594. set positionIterations(value: number);
  28595. /**
  28596. * The unique id of the physics imposter
  28597. * set by the physics engine when adding this impostor to the array
  28598. */
  28599. uniqueId: number;
  28600. /**
  28601. * @hidden
  28602. */
  28603. soft: boolean;
  28604. /**
  28605. * @hidden
  28606. */
  28607. segments: number;
  28608. private _joints;
  28609. /**
  28610. * Initializes the physics imposter
  28611. * @param object The physics-enabled object used as the physics imposter
  28612. * @param type The type of the physics imposter
  28613. * @param _options The options for the physics imposter
  28614. * @param _scene The Babylon scene
  28615. */
  28616. constructor(
  28617. /**
  28618. * The physics-enabled object used as the physics imposter
  28619. */
  28620. object: IPhysicsEnabledObject,
  28621. /**
  28622. * The type of the physics imposter
  28623. */
  28624. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28625. /**
  28626. * This function will completly initialize this impostor.
  28627. * It will create a new body - but only if this mesh has no parent.
  28628. * If it has, this impostor will not be used other than to define the impostor
  28629. * of the child mesh.
  28630. * @hidden
  28631. */
  28632. _init(): void;
  28633. private _getPhysicsParent;
  28634. /**
  28635. * Should a new body be generated.
  28636. * @returns boolean specifying if body initialization is required
  28637. */
  28638. isBodyInitRequired(): boolean;
  28639. /**
  28640. * Sets the updated scaling
  28641. * @param updated Specifies if the scaling is updated
  28642. */
  28643. setScalingUpdated(): void;
  28644. /**
  28645. * Force a regeneration of this or the parent's impostor's body.
  28646. * Use under cautious - This will remove all joints already implemented.
  28647. */
  28648. forceUpdate(): void;
  28649. /**
  28650. * Gets the body that holds this impostor. Either its own, or its parent.
  28651. */
  28652. get physicsBody(): any;
  28653. /**
  28654. * Get the parent of the physics imposter
  28655. * @returns Physics imposter or null
  28656. */
  28657. get parent(): Nullable<PhysicsImpostor>;
  28658. /**
  28659. * Sets the parent of the physics imposter
  28660. */
  28661. set parent(value: Nullable<PhysicsImpostor>);
  28662. /**
  28663. * Set the physics body. Used mainly by the physics engine/plugin
  28664. */
  28665. set physicsBody(physicsBody: any);
  28666. /**
  28667. * Resets the update flags
  28668. */
  28669. resetUpdateFlags(): void;
  28670. /**
  28671. * Gets the object extend size
  28672. * @returns the object extend size
  28673. */
  28674. getObjectExtendSize(): Vector3;
  28675. /**
  28676. * Gets the object center
  28677. * @returns The object center
  28678. */
  28679. getObjectCenter(): Vector3;
  28680. /**
  28681. * Get a specific parameter from the options parameters
  28682. * @param paramName The object parameter name
  28683. * @returns The object parameter
  28684. */
  28685. getParam(paramName: string): any;
  28686. /**
  28687. * Sets a specific parameter in the options given to the physics plugin
  28688. * @param paramName The parameter name
  28689. * @param value The value of the parameter
  28690. */
  28691. setParam(paramName: string, value: number): void;
  28692. /**
  28693. * Specifically change the body's mass option. Won't recreate the physics body object
  28694. * @param mass The mass of the physics imposter
  28695. */
  28696. setMass(mass: number): void;
  28697. /**
  28698. * Gets the linear velocity
  28699. * @returns linear velocity or null
  28700. */
  28701. getLinearVelocity(): Nullable<Vector3>;
  28702. /**
  28703. * Sets the linear velocity
  28704. * @param velocity linear velocity or null
  28705. */
  28706. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28707. /**
  28708. * Gets the angular velocity
  28709. * @returns angular velocity or null
  28710. */
  28711. getAngularVelocity(): Nullable<Vector3>;
  28712. /**
  28713. * Sets the angular velocity
  28714. * @param velocity The velocity or null
  28715. */
  28716. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28717. /**
  28718. * Execute a function with the physics plugin native code
  28719. * Provide a function the will have two variables - the world object and the physics body object
  28720. * @param func The function to execute with the physics plugin native code
  28721. */
  28722. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28723. /**
  28724. * Register a function that will be executed before the physics world is stepping forward
  28725. * @param func The function to execute before the physics world is stepped forward
  28726. */
  28727. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28728. /**
  28729. * Unregister a function that will be executed before the physics world is stepping forward
  28730. * @param func The function to execute before the physics world is stepped forward
  28731. */
  28732. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28733. /**
  28734. * Register a function that will be executed after the physics step
  28735. * @param func The function to execute after physics step
  28736. */
  28737. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28738. /**
  28739. * Unregisters a function that will be executed after the physics step
  28740. * @param func The function to execute after physics step
  28741. */
  28742. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28743. /**
  28744. * register a function that will be executed when this impostor collides against a different body
  28745. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28746. * @param func Callback that is executed on collision
  28747. */
  28748. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28749. /**
  28750. * Unregisters the physics imposter on contact
  28751. * @param collideAgainst The physics object to collide against
  28752. * @param func Callback to execute on collision
  28753. */
  28754. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28755. private _tmpQuat;
  28756. private _tmpQuat2;
  28757. /**
  28758. * Get the parent rotation
  28759. * @returns The parent rotation
  28760. */
  28761. getParentsRotation(): Quaternion;
  28762. /**
  28763. * this function is executed by the physics engine.
  28764. */
  28765. beforeStep: () => void;
  28766. /**
  28767. * this function is executed by the physics engine
  28768. */
  28769. afterStep: () => void;
  28770. /**
  28771. * Legacy collision detection event support
  28772. */
  28773. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28774. /**
  28775. * event and body object due to cannon's event-based architecture.
  28776. */
  28777. onCollide: (e: {
  28778. body: any;
  28779. }) => void;
  28780. /**
  28781. * Apply a force
  28782. * @param force The force to apply
  28783. * @param contactPoint The contact point for the force
  28784. * @returns The physics imposter
  28785. */
  28786. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28787. /**
  28788. * Apply an impulse
  28789. * @param force The impulse force
  28790. * @param contactPoint The contact point for the impulse force
  28791. * @returns The physics imposter
  28792. */
  28793. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28794. /**
  28795. * A help function to create a joint
  28796. * @param otherImpostor A physics imposter used to create a joint
  28797. * @param jointType The type of joint
  28798. * @param jointData The data for the joint
  28799. * @returns The physics imposter
  28800. */
  28801. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28802. /**
  28803. * Add a joint to this impostor with a different impostor
  28804. * @param otherImpostor A physics imposter used to add a joint
  28805. * @param joint The joint to add
  28806. * @returns The physics imposter
  28807. */
  28808. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28809. /**
  28810. * Add an anchor to a cloth impostor
  28811. * @param otherImpostor rigid impostor to anchor to
  28812. * @param width ratio across width from 0 to 1
  28813. * @param height ratio up height from 0 to 1
  28814. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28815. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28816. * @returns impostor the soft imposter
  28817. */
  28818. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28819. /**
  28820. * Add a hook to a rope impostor
  28821. * @param otherImpostor rigid impostor to anchor to
  28822. * @param length ratio across rope from 0 to 1
  28823. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28824. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28825. * @returns impostor the rope imposter
  28826. */
  28827. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28828. /**
  28829. * Will keep this body still, in a sleep mode.
  28830. * @returns the physics imposter
  28831. */
  28832. sleep(): PhysicsImpostor;
  28833. /**
  28834. * Wake the body up.
  28835. * @returns The physics imposter
  28836. */
  28837. wakeUp(): PhysicsImpostor;
  28838. /**
  28839. * Clones the physics imposter
  28840. * @param newObject The physics imposter clones to this physics-enabled object
  28841. * @returns A nullable physics imposter
  28842. */
  28843. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28844. /**
  28845. * Disposes the physics imposter
  28846. */
  28847. dispose(): void;
  28848. /**
  28849. * Sets the delta position
  28850. * @param position The delta position amount
  28851. */
  28852. setDeltaPosition(position: Vector3): void;
  28853. /**
  28854. * Sets the delta rotation
  28855. * @param rotation The delta rotation amount
  28856. */
  28857. setDeltaRotation(rotation: Quaternion): void;
  28858. /**
  28859. * Gets the box size of the physics imposter and stores the result in the input parameter
  28860. * @param result Stores the box size
  28861. * @returns The physics imposter
  28862. */
  28863. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28864. /**
  28865. * Gets the radius of the physics imposter
  28866. * @returns Radius of the physics imposter
  28867. */
  28868. getRadius(): number;
  28869. /**
  28870. * Sync a bone with this impostor
  28871. * @param bone The bone to sync to the impostor.
  28872. * @param boneMesh The mesh that the bone is influencing.
  28873. * @param jointPivot The pivot of the joint / bone in local space.
  28874. * @param distToJoint Optional distance from the impostor to the joint.
  28875. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28876. */
  28877. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28878. /**
  28879. * Sync impostor to a bone
  28880. * @param bone The bone that the impostor will be synced to.
  28881. * @param boneMesh The mesh that the bone is influencing.
  28882. * @param jointPivot The pivot of the joint / bone in local space.
  28883. * @param distToJoint Optional distance from the impostor to the joint.
  28884. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28885. * @param boneAxis Optional vector3 axis the bone is aligned with
  28886. */
  28887. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28888. /**
  28889. * No-Imposter type
  28890. */
  28891. static NoImpostor: number;
  28892. /**
  28893. * Sphere-Imposter type
  28894. */
  28895. static SphereImpostor: number;
  28896. /**
  28897. * Box-Imposter type
  28898. */
  28899. static BoxImpostor: number;
  28900. /**
  28901. * Plane-Imposter type
  28902. */
  28903. static PlaneImpostor: number;
  28904. /**
  28905. * Mesh-imposter type
  28906. */
  28907. static MeshImpostor: number;
  28908. /**
  28909. * Capsule-Impostor type (Ammo.js plugin only)
  28910. */
  28911. static CapsuleImpostor: number;
  28912. /**
  28913. * Cylinder-Imposter type
  28914. */
  28915. static CylinderImpostor: number;
  28916. /**
  28917. * Particle-Imposter type
  28918. */
  28919. static ParticleImpostor: number;
  28920. /**
  28921. * Heightmap-Imposter type
  28922. */
  28923. static HeightmapImpostor: number;
  28924. /**
  28925. * ConvexHull-Impostor type (Ammo.js plugin only)
  28926. */
  28927. static ConvexHullImpostor: number;
  28928. /**
  28929. * Custom-Imposter type (Ammo.js plugin only)
  28930. */
  28931. static CustomImpostor: number;
  28932. /**
  28933. * Rope-Imposter type
  28934. */
  28935. static RopeImpostor: number;
  28936. /**
  28937. * Cloth-Imposter type
  28938. */
  28939. static ClothImpostor: number;
  28940. /**
  28941. * Softbody-Imposter type
  28942. */
  28943. static SoftbodyImpostor: number;
  28944. }
  28945. }
  28946. declare module "babylonjs/Meshes/mesh" {
  28947. import { Observable } from "babylonjs/Misc/observable";
  28948. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28949. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28950. import { Camera } from "babylonjs/Cameras/camera";
  28951. import { Scene } from "babylonjs/scene";
  28952. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28953. import { Color4 } from "babylonjs/Maths/math.color";
  28954. import { Engine } from "babylonjs/Engines/engine";
  28955. import { Node } from "babylonjs/node";
  28956. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28957. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28958. import { Buffer } from "babylonjs/Meshes/buffer";
  28959. import { Geometry } from "babylonjs/Meshes/geometry";
  28960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28962. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28963. import { Effect } from "babylonjs/Materials/effect";
  28964. import { Material } from "babylonjs/Materials/material";
  28965. import { Skeleton } from "babylonjs/Bones/skeleton";
  28966. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28967. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28968. import { Path3D } from "babylonjs/Maths/math.path";
  28969. import { Plane } from "babylonjs/Maths/math.plane";
  28970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28971. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28972. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28973. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28974. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28975. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28976. /**
  28977. * @hidden
  28978. **/
  28979. export class _CreationDataStorage {
  28980. closePath?: boolean;
  28981. closeArray?: boolean;
  28982. idx: number[];
  28983. dashSize: number;
  28984. gapSize: number;
  28985. path3D: Path3D;
  28986. pathArray: Vector3[][];
  28987. arc: number;
  28988. radius: number;
  28989. cap: number;
  28990. tessellation: number;
  28991. }
  28992. /**
  28993. * @hidden
  28994. **/
  28995. class _InstanceDataStorage {
  28996. visibleInstances: any;
  28997. batchCache: _InstancesBatch;
  28998. instancesBufferSize: number;
  28999. instancesBuffer: Nullable<Buffer>;
  29000. instancesData: Float32Array;
  29001. overridenInstanceCount: number;
  29002. isFrozen: boolean;
  29003. previousBatch: Nullable<_InstancesBatch>;
  29004. hardwareInstancedRendering: boolean;
  29005. sideOrientation: number;
  29006. manualUpdate: boolean;
  29007. }
  29008. /**
  29009. * @hidden
  29010. **/
  29011. export class _InstancesBatch {
  29012. mustReturn: boolean;
  29013. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29014. renderSelf: boolean[];
  29015. hardwareInstancedRendering: boolean[];
  29016. }
  29017. /**
  29018. * @hidden
  29019. **/
  29020. class _ThinInstanceDataStorage {
  29021. instancesCount: number;
  29022. matrixBuffer: Nullable<Buffer>;
  29023. matrixBufferSize: number;
  29024. matrixData: Nullable<Float32Array>;
  29025. boundingVectors: Array<Vector3>;
  29026. worldMatrices: Nullable<Matrix[]>;
  29027. }
  29028. /**
  29029. * Class used to represent renderable models
  29030. */
  29031. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29032. /**
  29033. * Mesh side orientation : usually the external or front surface
  29034. */
  29035. static readonly FRONTSIDE: number;
  29036. /**
  29037. * Mesh side orientation : usually the internal or back surface
  29038. */
  29039. static readonly BACKSIDE: number;
  29040. /**
  29041. * Mesh side orientation : both internal and external or front and back surfaces
  29042. */
  29043. static readonly DOUBLESIDE: number;
  29044. /**
  29045. * Mesh side orientation : by default, `FRONTSIDE`
  29046. */
  29047. static readonly DEFAULTSIDE: number;
  29048. /**
  29049. * Mesh cap setting : no cap
  29050. */
  29051. static readonly NO_CAP: number;
  29052. /**
  29053. * Mesh cap setting : one cap at the beginning of the mesh
  29054. */
  29055. static readonly CAP_START: number;
  29056. /**
  29057. * Mesh cap setting : one cap at the end of the mesh
  29058. */
  29059. static readonly CAP_END: number;
  29060. /**
  29061. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29062. */
  29063. static readonly CAP_ALL: number;
  29064. /**
  29065. * Mesh pattern setting : no flip or rotate
  29066. */
  29067. static readonly NO_FLIP: number;
  29068. /**
  29069. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29070. */
  29071. static readonly FLIP_TILE: number;
  29072. /**
  29073. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29074. */
  29075. static readonly ROTATE_TILE: number;
  29076. /**
  29077. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29078. */
  29079. static readonly FLIP_ROW: number;
  29080. /**
  29081. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29082. */
  29083. static readonly ROTATE_ROW: number;
  29084. /**
  29085. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29086. */
  29087. static readonly FLIP_N_ROTATE_TILE: number;
  29088. /**
  29089. * Mesh pattern setting : rotate pattern and rotate
  29090. */
  29091. static readonly FLIP_N_ROTATE_ROW: number;
  29092. /**
  29093. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29094. */
  29095. static readonly CENTER: number;
  29096. /**
  29097. * Mesh tile positioning : part tiles on left
  29098. */
  29099. static readonly LEFT: number;
  29100. /**
  29101. * Mesh tile positioning : part tiles on right
  29102. */
  29103. static readonly RIGHT: number;
  29104. /**
  29105. * Mesh tile positioning : part tiles on top
  29106. */
  29107. static readonly TOP: number;
  29108. /**
  29109. * Mesh tile positioning : part tiles on bottom
  29110. */
  29111. static readonly BOTTOM: number;
  29112. /**
  29113. * Gets the default side orientation.
  29114. * @param orientation the orientation to value to attempt to get
  29115. * @returns the default orientation
  29116. * @hidden
  29117. */
  29118. static _GetDefaultSideOrientation(orientation?: number): number;
  29119. private _internalMeshDataInfo;
  29120. get computeBonesUsingShaders(): boolean;
  29121. set computeBonesUsingShaders(value: boolean);
  29122. /**
  29123. * An event triggered before rendering the mesh
  29124. */
  29125. get onBeforeRenderObservable(): Observable<Mesh>;
  29126. /**
  29127. * An event triggered before binding the mesh
  29128. */
  29129. get onBeforeBindObservable(): Observable<Mesh>;
  29130. /**
  29131. * An event triggered after rendering the mesh
  29132. */
  29133. get onAfterRenderObservable(): Observable<Mesh>;
  29134. /**
  29135. * An event triggered before drawing the mesh
  29136. */
  29137. get onBeforeDrawObservable(): Observable<Mesh>;
  29138. private _onBeforeDrawObserver;
  29139. /**
  29140. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29141. */
  29142. set onBeforeDraw(callback: () => void);
  29143. get hasInstances(): boolean;
  29144. get hasThinInstances(): boolean;
  29145. /**
  29146. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29147. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29148. */
  29149. delayLoadState: number;
  29150. /**
  29151. * Gets the list of instances created from this mesh
  29152. * it is not supposed to be modified manually.
  29153. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29154. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29155. */
  29156. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29157. /**
  29158. * Gets the file containing delay loading data for this mesh
  29159. */
  29160. delayLoadingFile: string;
  29161. /** @hidden */
  29162. _binaryInfo: any;
  29163. /**
  29164. * User defined function used to change how LOD level selection is done
  29165. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29166. */
  29167. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29168. /**
  29169. * Gets or sets the morph target manager
  29170. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29171. */
  29172. get morphTargetManager(): Nullable<MorphTargetManager>;
  29173. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29174. /** @hidden */
  29175. _creationDataStorage: Nullable<_CreationDataStorage>;
  29176. /** @hidden */
  29177. _geometry: Nullable<Geometry>;
  29178. /** @hidden */
  29179. _delayInfo: Array<string>;
  29180. /** @hidden */
  29181. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29182. /** @hidden */
  29183. _instanceDataStorage: _InstanceDataStorage;
  29184. /** @hidden */
  29185. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29186. private _effectiveMaterial;
  29187. /** @hidden */
  29188. _shouldGenerateFlatShading: boolean;
  29189. /** @hidden */
  29190. _originalBuilderSideOrientation: number;
  29191. /**
  29192. * Use this property to change the original side orientation defined at construction time
  29193. */
  29194. overrideMaterialSideOrientation: Nullable<number>;
  29195. /**
  29196. * Gets the source mesh (the one used to clone this one from)
  29197. */
  29198. get source(): Nullable<Mesh>;
  29199. /**
  29200. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29201. */
  29202. get isUnIndexed(): boolean;
  29203. set isUnIndexed(value: boolean);
  29204. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29205. get worldMatrixInstancedBuffer(): Float32Array;
  29206. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29207. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29208. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29209. /**
  29210. * @constructor
  29211. * @param name The value used by scene.getMeshByName() to do a lookup.
  29212. * @param scene The scene to add this mesh to.
  29213. * @param parent The parent of this mesh, if it has one
  29214. * @param source An optional Mesh from which geometry is shared, cloned.
  29215. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29216. * When false, achieved by calling a clone(), also passing False.
  29217. * This will make creation of children, recursive.
  29218. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29219. */
  29220. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29221. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29222. doNotInstantiate: boolean;
  29223. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29224. /**
  29225. * Gets the class name
  29226. * @returns the string "Mesh".
  29227. */
  29228. getClassName(): string;
  29229. /** @hidden */
  29230. get _isMesh(): boolean;
  29231. /**
  29232. * Returns a description of this mesh
  29233. * @param fullDetails define if full details about this mesh must be used
  29234. * @returns a descriptive string representing this mesh
  29235. */
  29236. toString(fullDetails?: boolean): string;
  29237. /** @hidden */
  29238. _unBindEffect(): void;
  29239. /**
  29240. * Gets a boolean indicating if this mesh has LOD
  29241. */
  29242. get hasLODLevels(): boolean;
  29243. /**
  29244. * Gets the list of MeshLODLevel associated with the current mesh
  29245. * @returns an array of MeshLODLevel
  29246. */
  29247. getLODLevels(): MeshLODLevel[];
  29248. private _sortLODLevels;
  29249. /**
  29250. * Add a mesh as LOD level triggered at the given distance.
  29251. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29252. * @param distance The distance from the center of the object to show this level
  29253. * @param mesh The mesh to be added as LOD level (can be null)
  29254. * @return This mesh (for chaining)
  29255. */
  29256. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29257. /**
  29258. * Returns the LOD level mesh at the passed distance or null if not found.
  29259. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29260. * @param distance The distance from the center of the object to show this level
  29261. * @returns a Mesh or `null`
  29262. */
  29263. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29264. /**
  29265. * Remove a mesh from the LOD array
  29266. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29267. * @param mesh defines the mesh to be removed
  29268. * @return This mesh (for chaining)
  29269. */
  29270. removeLODLevel(mesh: Mesh): Mesh;
  29271. /**
  29272. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29273. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29274. * @param camera defines the camera to use to compute distance
  29275. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29276. * @return This mesh (for chaining)
  29277. */
  29278. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29279. /**
  29280. * Gets the mesh internal Geometry object
  29281. */
  29282. get geometry(): Nullable<Geometry>;
  29283. /**
  29284. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29285. * @returns the total number of vertices
  29286. */
  29287. getTotalVertices(): number;
  29288. /**
  29289. * Returns the content of an associated vertex buffer
  29290. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29291. * - VertexBuffer.PositionKind
  29292. * - VertexBuffer.UVKind
  29293. * - VertexBuffer.UV2Kind
  29294. * - VertexBuffer.UV3Kind
  29295. * - VertexBuffer.UV4Kind
  29296. * - VertexBuffer.UV5Kind
  29297. * - VertexBuffer.UV6Kind
  29298. * - VertexBuffer.ColorKind
  29299. * - VertexBuffer.MatricesIndicesKind
  29300. * - VertexBuffer.MatricesIndicesExtraKind
  29301. * - VertexBuffer.MatricesWeightsKind
  29302. * - VertexBuffer.MatricesWeightsExtraKind
  29303. * @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
  29304. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29305. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29306. */
  29307. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29308. /**
  29309. * Returns the mesh VertexBuffer object from the requested `kind`
  29310. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29311. * - VertexBuffer.PositionKind
  29312. * - VertexBuffer.NormalKind
  29313. * - VertexBuffer.UVKind
  29314. * - VertexBuffer.UV2Kind
  29315. * - VertexBuffer.UV3Kind
  29316. * - VertexBuffer.UV4Kind
  29317. * - VertexBuffer.UV5Kind
  29318. * - VertexBuffer.UV6Kind
  29319. * - VertexBuffer.ColorKind
  29320. * - VertexBuffer.MatricesIndicesKind
  29321. * - VertexBuffer.MatricesIndicesExtraKind
  29322. * - VertexBuffer.MatricesWeightsKind
  29323. * - VertexBuffer.MatricesWeightsExtraKind
  29324. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29325. */
  29326. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29327. /**
  29328. * Tests if a specific vertex buffer is associated with this mesh
  29329. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29330. * - VertexBuffer.PositionKind
  29331. * - VertexBuffer.NormalKind
  29332. * - VertexBuffer.UVKind
  29333. * - VertexBuffer.UV2Kind
  29334. * - VertexBuffer.UV3Kind
  29335. * - VertexBuffer.UV4Kind
  29336. * - VertexBuffer.UV5Kind
  29337. * - VertexBuffer.UV6Kind
  29338. * - VertexBuffer.ColorKind
  29339. * - VertexBuffer.MatricesIndicesKind
  29340. * - VertexBuffer.MatricesIndicesExtraKind
  29341. * - VertexBuffer.MatricesWeightsKind
  29342. * - VertexBuffer.MatricesWeightsExtraKind
  29343. * @returns a boolean
  29344. */
  29345. isVerticesDataPresent(kind: string): boolean;
  29346. /**
  29347. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29348. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29349. * - VertexBuffer.PositionKind
  29350. * - VertexBuffer.UVKind
  29351. * - VertexBuffer.UV2Kind
  29352. * - VertexBuffer.UV3Kind
  29353. * - VertexBuffer.UV4Kind
  29354. * - VertexBuffer.UV5Kind
  29355. * - VertexBuffer.UV6Kind
  29356. * - VertexBuffer.ColorKind
  29357. * - VertexBuffer.MatricesIndicesKind
  29358. * - VertexBuffer.MatricesIndicesExtraKind
  29359. * - VertexBuffer.MatricesWeightsKind
  29360. * - VertexBuffer.MatricesWeightsExtraKind
  29361. * @returns a boolean
  29362. */
  29363. isVertexBufferUpdatable(kind: string): boolean;
  29364. /**
  29365. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29366. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29367. * - VertexBuffer.PositionKind
  29368. * - VertexBuffer.NormalKind
  29369. * - VertexBuffer.UVKind
  29370. * - VertexBuffer.UV2Kind
  29371. * - VertexBuffer.UV3Kind
  29372. * - VertexBuffer.UV4Kind
  29373. * - VertexBuffer.UV5Kind
  29374. * - VertexBuffer.UV6Kind
  29375. * - VertexBuffer.ColorKind
  29376. * - VertexBuffer.MatricesIndicesKind
  29377. * - VertexBuffer.MatricesIndicesExtraKind
  29378. * - VertexBuffer.MatricesWeightsKind
  29379. * - VertexBuffer.MatricesWeightsExtraKind
  29380. * @returns an array of strings
  29381. */
  29382. getVerticesDataKinds(): string[];
  29383. /**
  29384. * Returns a positive integer : the total number of indices in this mesh geometry.
  29385. * @returns the numner of indices or zero if the mesh has no geometry.
  29386. */
  29387. getTotalIndices(): number;
  29388. /**
  29389. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29390. * @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.
  29391. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29392. * @returns the indices array or an empty array if the mesh has no geometry
  29393. */
  29394. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29395. get isBlocked(): boolean;
  29396. /**
  29397. * Determine if the current mesh is ready to be rendered
  29398. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29399. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29400. * @returns true if all associated assets are ready (material, textures, shaders)
  29401. */
  29402. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29403. /**
  29404. * 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.
  29405. */
  29406. get areNormalsFrozen(): boolean;
  29407. /**
  29408. * 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.
  29409. * @returns the current mesh
  29410. */
  29411. freezeNormals(): Mesh;
  29412. /**
  29413. * 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
  29414. * @returns the current mesh
  29415. */
  29416. unfreezeNormals(): Mesh;
  29417. /**
  29418. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29419. */
  29420. set overridenInstanceCount(count: number);
  29421. /** @hidden */
  29422. _preActivate(): Mesh;
  29423. /** @hidden */
  29424. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29425. /** @hidden */
  29426. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29427. protected _afterComputeWorldMatrix(): void;
  29428. /** @hidden */
  29429. _postActivate(): void;
  29430. /**
  29431. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29432. * This means the mesh underlying bounding box and sphere are recomputed.
  29433. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29434. * @returns the current mesh
  29435. */
  29436. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29437. /** @hidden */
  29438. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29439. /**
  29440. * This function will subdivide the mesh into multiple submeshes
  29441. * @param count defines the expected number of submeshes
  29442. */
  29443. subdivide(count: number): void;
  29444. /**
  29445. * Copy a FloatArray into a specific associated vertex buffer
  29446. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29447. * - VertexBuffer.PositionKind
  29448. * - VertexBuffer.UVKind
  29449. * - VertexBuffer.UV2Kind
  29450. * - VertexBuffer.UV3Kind
  29451. * - VertexBuffer.UV4Kind
  29452. * - VertexBuffer.UV5Kind
  29453. * - VertexBuffer.UV6Kind
  29454. * - VertexBuffer.ColorKind
  29455. * - VertexBuffer.MatricesIndicesKind
  29456. * - VertexBuffer.MatricesIndicesExtraKind
  29457. * - VertexBuffer.MatricesWeightsKind
  29458. * - VertexBuffer.MatricesWeightsExtraKind
  29459. * @param data defines the data source
  29460. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29461. * @param stride defines the data stride size (can be null)
  29462. * @returns the current mesh
  29463. */
  29464. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29465. /**
  29466. * Delete a vertex buffer associated with this mesh
  29467. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29468. * - VertexBuffer.PositionKind
  29469. * - VertexBuffer.UVKind
  29470. * - VertexBuffer.UV2Kind
  29471. * - VertexBuffer.UV3Kind
  29472. * - VertexBuffer.UV4Kind
  29473. * - VertexBuffer.UV5Kind
  29474. * - VertexBuffer.UV6Kind
  29475. * - VertexBuffer.ColorKind
  29476. * - VertexBuffer.MatricesIndicesKind
  29477. * - VertexBuffer.MatricesIndicesExtraKind
  29478. * - VertexBuffer.MatricesWeightsKind
  29479. * - VertexBuffer.MatricesWeightsExtraKind
  29480. */
  29481. removeVerticesData(kind: string): void;
  29482. /**
  29483. * Flags an associated vertex buffer as updatable
  29484. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29485. * - VertexBuffer.PositionKind
  29486. * - VertexBuffer.UVKind
  29487. * - VertexBuffer.UV2Kind
  29488. * - VertexBuffer.UV3Kind
  29489. * - VertexBuffer.UV4Kind
  29490. * - VertexBuffer.UV5Kind
  29491. * - VertexBuffer.UV6Kind
  29492. * - VertexBuffer.ColorKind
  29493. * - VertexBuffer.MatricesIndicesKind
  29494. * - VertexBuffer.MatricesIndicesExtraKind
  29495. * - VertexBuffer.MatricesWeightsKind
  29496. * - VertexBuffer.MatricesWeightsExtraKind
  29497. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29498. */
  29499. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29500. /**
  29501. * Sets the mesh global Vertex Buffer
  29502. * @param buffer defines the buffer to use
  29503. * @returns the current mesh
  29504. */
  29505. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29506. /**
  29507. * Update a specific associated vertex buffer
  29508. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29509. * - VertexBuffer.PositionKind
  29510. * - VertexBuffer.UVKind
  29511. * - VertexBuffer.UV2Kind
  29512. * - VertexBuffer.UV3Kind
  29513. * - VertexBuffer.UV4Kind
  29514. * - VertexBuffer.UV5Kind
  29515. * - VertexBuffer.UV6Kind
  29516. * - VertexBuffer.ColorKind
  29517. * - VertexBuffer.MatricesIndicesKind
  29518. * - VertexBuffer.MatricesIndicesExtraKind
  29519. * - VertexBuffer.MatricesWeightsKind
  29520. * - VertexBuffer.MatricesWeightsExtraKind
  29521. * @param data defines the data source
  29522. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29523. * @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)
  29524. * @returns the current mesh
  29525. */
  29526. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29527. /**
  29528. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29529. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29530. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29531. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29532. * @returns the current mesh
  29533. */
  29534. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29535. /**
  29536. * Creates a un-shared specific occurence of the geometry for the mesh.
  29537. * @returns the current mesh
  29538. */
  29539. makeGeometryUnique(): Mesh;
  29540. /**
  29541. * Set the index buffer of this mesh
  29542. * @param indices defines the source data
  29543. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29544. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29545. * @returns the current mesh
  29546. */
  29547. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29548. /**
  29549. * Update the current index buffer
  29550. * @param indices defines the source data
  29551. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29552. * @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)
  29553. * @returns the current mesh
  29554. */
  29555. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29556. /**
  29557. * Invert the geometry to move from a right handed system to a left handed one.
  29558. * @returns the current mesh
  29559. */
  29560. toLeftHanded(): Mesh;
  29561. /** @hidden */
  29562. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29563. /** @hidden */
  29564. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29565. /**
  29566. * Registers for this mesh a javascript function called just before the rendering process
  29567. * @param func defines the function to call before rendering this mesh
  29568. * @returns the current mesh
  29569. */
  29570. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29571. /**
  29572. * Disposes a previously registered javascript function called before the rendering
  29573. * @param func defines the function to remove
  29574. * @returns the current mesh
  29575. */
  29576. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29577. /**
  29578. * Registers for this mesh a javascript function called just after the rendering is complete
  29579. * @param func defines the function to call after rendering this mesh
  29580. * @returns the current mesh
  29581. */
  29582. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29583. /**
  29584. * Disposes a previously registered javascript function called after the rendering.
  29585. * @param func defines the function to remove
  29586. * @returns the current mesh
  29587. */
  29588. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29589. /** @hidden */
  29590. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29591. /** @hidden */
  29592. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29593. /** @hidden */
  29594. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29595. /** @hidden */
  29596. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29597. /** @hidden */
  29598. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29599. /** @hidden */
  29600. _rebuild(): void;
  29601. /** @hidden */
  29602. _freeze(): void;
  29603. /** @hidden */
  29604. _unFreeze(): void;
  29605. /**
  29606. * 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
  29607. * @param subMesh defines the subMesh to render
  29608. * @param enableAlphaMode defines if alpha mode can be changed
  29609. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29610. * @returns the current mesh
  29611. */
  29612. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29613. private _onBeforeDraw;
  29614. /**
  29615. * Renormalize the mesh and patch it up if there are no weights
  29616. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29617. * However in the case of zero weights then we set just a single influence to 1.
  29618. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29619. */
  29620. cleanMatrixWeights(): void;
  29621. private normalizeSkinFourWeights;
  29622. private normalizeSkinWeightsAndExtra;
  29623. /**
  29624. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29625. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29626. * the user know there was an issue with importing the mesh
  29627. * @returns a validation object with skinned, valid and report string
  29628. */
  29629. validateSkinning(): {
  29630. skinned: boolean;
  29631. valid: boolean;
  29632. report: string;
  29633. };
  29634. /** @hidden */
  29635. _checkDelayState(): Mesh;
  29636. private _queueLoad;
  29637. /**
  29638. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29639. * A mesh is in the frustum if its bounding box intersects the frustum
  29640. * @param frustumPlanes defines the frustum to test
  29641. * @returns true if the mesh is in the frustum planes
  29642. */
  29643. isInFrustum(frustumPlanes: Plane[]): boolean;
  29644. /**
  29645. * Sets the mesh material by the material or multiMaterial `id` property
  29646. * @param id is a string identifying the material or the multiMaterial
  29647. * @returns the current mesh
  29648. */
  29649. setMaterialByID(id: string): Mesh;
  29650. /**
  29651. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29652. * @returns an array of IAnimatable
  29653. */
  29654. getAnimatables(): IAnimatable[];
  29655. /**
  29656. * Modifies the mesh geometry according to the passed transformation matrix.
  29657. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29658. * The mesh normals are modified using the same transformation.
  29659. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29660. * @param transform defines the transform matrix to use
  29661. * @see https://doc.babylonjs.com/resources/baking_transformations
  29662. * @returns the current mesh
  29663. */
  29664. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29665. /**
  29666. * Modifies the mesh geometry according to its own current World Matrix.
  29667. * The mesh World Matrix is then reset.
  29668. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29669. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29670. * @see https://doc.babylonjs.com/resources/baking_transformations
  29671. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29672. * @returns the current mesh
  29673. */
  29674. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29675. /** @hidden */
  29676. get _positions(): Nullable<Vector3[]>;
  29677. /** @hidden */
  29678. _resetPointsArrayCache(): Mesh;
  29679. /** @hidden */
  29680. _generatePointsArray(): boolean;
  29681. /**
  29682. * Returns a new Mesh object generated from the current mesh properties.
  29683. * This method must not get confused with createInstance()
  29684. * @param name is a string, the name given to the new mesh
  29685. * @param newParent can be any Node object (default `null`)
  29686. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29687. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29688. * @returns a new mesh
  29689. */
  29690. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29691. /**
  29692. * Releases resources associated with this mesh.
  29693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29695. */
  29696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29697. /** @hidden */
  29698. _disposeInstanceSpecificData(): void;
  29699. /** @hidden */
  29700. _disposeThinInstanceSpecificData(): void;
  29701. /**
  29702. * Modifies the mesh geometry according to a displacement map.
  29703. * 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.
  29704. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29705. * @param url is a string, the URL from the image file is to be downloaded.
  29706. * @param minHeight is the lower limit of the displacement.
  29707. * @param maxHeight is the upper limit of the displacement.
  29708. * @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.
  29709. * @param uvOffset is an optional vector2 used to offset UV.
  29710. * @param uvScale is an optional vector2 used to scale UV.
  29711. * @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.
  29712. * @returns the Mesh.
  29713. */
  29714. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29715. /**
  29716. * Modifies the mesh geometry according to a displacementMap buffer.
  29717. * 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.
  29718. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29719. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29720. * @param heightMapWidth is the width of the buffer image.
  29721. * @param heightMapHeight is the height of the buffer image.
  29722. * @param minHeight is the lower limit of the displacement.
  29723. * @param maxHeight is the upper limit of the displacement.
  29724. * @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.
  29725. * @param uvOffset is an optional vector2 used to offset UV.
  29726. * @param uvScale is an optional vector2 used to scale UV.
  29727. * @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.
  29728. * @returns the Mesh.
  29729. */
  29730. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29731. /**
  29732. * Modify the mesh to get a flat shading rendering.
  29733. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29734. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29735. * @returns current mesh
  29736. */
  29737. convertToFlatShadedMesh(): Mesh;
  29738. /**
  29739. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29740. * In other words, more vertices, no more indices and a single bigger VBO.
  29741. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29742. * @returns current mesh
  29743. */
  29744. convertToUnIndexedMesh(): Mesh;
  29745. /**
  29746. * Inverses facet orientations.
  29747. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29748. * @param flipNormals will also inverts the normals
  29749. * @returns current mesh
  29750. */
  29751. flipFaces(flipNormals?: boolean): Mesh;
  29752. /**
  29753. * Increase the number of facets and hence vertices in a mesh
  29754. * Vertex normals are interpolated from existing vertex normals
  29755. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29756. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29757. */
  29758. increaseVertices(numberPerEdge: number): void;
  29759. /**
  29760. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29761. * This will undo any application of covertToFlatShadedMesh
  29762. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29763. */
  29764. forceSharedVertices(): void;
  29765. /** @hidden */
  29766. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29767. /** @hidden */
  29768. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29769. /**
  29770. * Creates a new InstancedMesh object from the mesh model.
  29771. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29772. * @param name defines the name of the new instance
  29773. * @returns a new InstancedMesh
  29774. */
  29775. createInstance(name: string): InstancedMesh;
  29776. /**
  29777. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29778. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29779. * @returns the current mesh
  29780. */
  29781. synchronizeInstances(): Mesh;
  29782. /**
  29783. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29784. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29785. * This should be used together with the simplification to avoid disappearing triangles.
  29786. * @param successCallback an optional success callback to be called after the optimization finished.
  29787. * @returns the current mesh
  29788. */
  29789. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29790. /**
  29791. * Serialize current mesh
  29792. * @param serializationObject defines the object which will receive the serialization data
  29793. */
  29794. serialize(serializationObject: any): void;
  29795. /** @hidden */
  29796. _syncGeometryWithMorphTargetManager(): void;
  29797. /** @hidden */
  29798. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29799. /**
  29800. * Returns a new Mesh object parsed from the source provided.
  29801. * @param parsedMesh is the source
  29802. * @param scene defines the hosting scene
  29803. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29804. * @returns a new Mesh
  29805. */
  29806. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29807. /**
  29808. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29810. * @param name defines the name of the mesh to create
  29811. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29812. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29813. * @param closePath creates a seam between the first and the last points of each path of the path array
  29814. * @param offset is taken in account only if the `pathArray` is containing a single path
  29815. * @param scene defines the hosting scene
  29816. * @param updatable defines if the mesh must be flagged as updatable
  29817. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29818. * @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)
  29819. * @returns a new Mesh
  29820. */
  29821. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29822. /**
  29823. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29824. * @param name defines the name of the mesh to create
  29825. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29826. * @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
  29827. * @param scene defines the hosting scene
  29828. * @param updatable defines if the mesh must be flagged as updatable
  29829. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29830. * @returns a new Mesh
  29831. */
  29832. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29833. /**
  29834. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29835. * @param name defines the name of the mesh to create
  29836. * @param size sets the size (float) of each box side (default 1)
  29837. * @param scene defines the hosting scene
  29838. * @param updatable defines if the mesh must be flagged as updatable
  29839. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29840. * @returns a new Mesh
  29841. */
  29842. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29843. /**
  29844. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29845. * @param name defines the name of the mesh to create
  29846. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29847. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29848. * @param scene defines the hosting scene
  29849. * @param updatable defines if the mesh must be flagged as updatable
  29850. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29851. * @returns a new Mesh
  29852. */
  29853. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29854. /**
  29855. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29856. * @param name defines the name of the mesh to create
  29857. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29858. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29859. * @param scene defines the hosting scene
  29860. * @returns a new Mesh
  29861. */
  29862. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29863. /**
  29864. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29865. * @param name defines the name of the mesh to create
  29866. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29867. * @param diameterTop set the top cap diameter (floats, default 1)
  29868. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29869. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29870. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29871. * @param scene defines the hosting scene
  29872. * @param updatable defines if the mesh must be flagged as updatable
  29873. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29874. * @returns a new Mesh
  29875. */
  29876. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29877. /**
  29878. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29879. * @param name defines the name of the mesh to create
  29880. * @param diameter sets the diameter size (float) of the torus (default 1)
  29881. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29882. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29883. * @param scene defines the hosting scene
  29884. * @param updatable defines if the mesh must be flagged as updatable
  29885. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29886. * @returns a new Mesh
  29887. */
  29888. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29889. /**
  29890. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29891. * @param name defines the name of the mesh to create
  29892. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29893. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29894. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29895. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29896. * @param p the number of windings on X axis (positive integers, default 2)
  29897. * @param q the number of windings on Y axis (positive integers, default 3)
  29898. * @param scene defines the hosting scene
  29899. * @param updatable defines if the mesh must be flagged as updatable
  29900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29901. * @returns a new Mesh
  29902. */
  29903. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29904. /**
  29905. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29906. * @param name defines the name of the mesh to create
  29907. * @param points is an array successive Vector3
  29908. * @param scene defines the hosting scene
  29909. * @param updatable defines if the mesh must be flagged as updatable
  29910. * @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).
  29911. * @returns a new Mesh
  29912. */
  29913. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29914. /**
  29915. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29916. * @param name defines the name of the mesh to create
  29917. * @param points is an array successive Vector3
  29918. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29919. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29920. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29921. * @param scene defines the hosting scene
  29922. * @param updatable defines if the mesh must be flagged as updatable
  29923. * @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)
  29924. * @returns a new Mesh
  29925. */
  29926. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29927. /**
  29928. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29929. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29930. * 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.
  29931. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29932. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29933. * Remember you can only change the shape positions, not their number when updating a polygon.
  29934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29935. * @param name defines the name of the mesh to create
  29936. * @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
  29937. * @param scene defines the hosting scene
  29938. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29939. * @param updatable defines if the mesh must be flagged as updatable
  29940. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29941. * @param earcutInjection can be used to inject your own earcut reference
  29942. * @returns a new Mesh
  29943. */
  29944. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29945. /**
  29946. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29948. * @param name defines the name of the mesh to create
  29949. * @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
  29950. * @param depth defines the height of extrusion
  29951. * @param scene defines the hosting scene
  29952. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29953. * @param updatable defines if the mesh must be flagged as updatable
  29954. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29955. * @param earcutInjection can be used to inject your own earcut reference
  29956. * @returns a new Mesh
  29957. */
  29958. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29959. /**
  29960. * Creates an extruded shape mesh.
  29961. * 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
  29962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29964. * @param name defines the name of the mesh to create
  29965. * @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
  29966. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29967. * @param scale is the value to scale the shape
  29968. * @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
  29969. * @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
  29970. * @param scene defines the hosting scene
  29971. * @param updatable defines if the mesh must be flagged as updatable
  29972. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29973. * @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)
  29974. * @returns a new Mesh
  29975. */
  29976. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29977. /**
  29978. * Creates an custom extruded shape mesh.
  29979. * The custom extrusion is a parametric shape.
  29980. * It has no predefined shape. Its final shape will depend on the input parameters.
  29981. * Please consider using the same method from the MeshBuilder class instead
  29982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29983. * @param name defines the name of the mesh to create
  29984. * @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
  29985. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29986. * @param scaleFunction is a custom Javascript function called on each path point
  29987. * @param rotationFunction is a custom Javascript function called on each path point
  29988. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29989. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29990. * @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
  29991. * @param scene defines the hosting scene
  29992. * @param updatable defines if the mesh must be flagged as updatable
  29993. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29994. * @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)
  29995. * @returns a new Mesh
  29996. */
  29997. 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;
  29998. /**
  29999. * Creates lathe mesh.
  30000. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30001. * Please consider using the same method from the MeshBuilder class instead
  30002. * @param name defines the name of the mesh to create
  30003. * @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
  30004. * @param radius is the radius value of the lathe
  30005. * @param tessellation is the side number of the lathe.
  30006. * @param scene defines the hosting scene
  30007. * @param updatable defines if the mesh must be flagged as updatable
  30008. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30009. * @returns a new Mesh
  30010. */
  30011. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30012. /**
  30013. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30014. * @param name defines the name of the mesh to create
  30015. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30016. * @param scene defines the hosting scene
  30017. * @param updatable defines if the mesh must be flagged as updatable
  30018. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30019. * @returns a new Mesh
  30020. */
  30021. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30022. /**
  30023. * Creates a ground mesh.
  30024. * Please consider using the same method from the MeshBuilder class instead
  30025. * @param name defines the name of the mesh to create
  30026. * @param width set the width of the ground
  30027. * @param height set the height of the ground
  30028. * @param subdivisions sets the number of subdivisions per side
  30029. * @param scene defines the hosting scene
  30030. * @param updatable defines if the mesh must be flagged as updatable
  30031. * @returns a new Mesh
  30032. */
  30033. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30034. /**
  30035. * Creates a tiled ground mesh.
  30036. * Please consider using the same method from the MeshBuilder class instead
  30037. * @param name defines the name of the mesh to create
  30038. * @param xmin set the ground minimum X coordinate
  30039. * @param zmin set the ground minimum Y coordinate
  30040. * @param xmax set the ground maximum X coordinate
  30041. * @param zmax set the ground maximum Z coordinate
  30042. * @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
  30043. * @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
  30044. * @param scene defines the hosting scene
  30045. * @param updatable defines if the mesh must be flagged as updatable
  30046. * @returns a new Mesh
  30047. */
  30048. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30049. w: number;
  30050. h: number;
  30051. }, precision: {
  30052. w: number;
  30053. h: number;
  30054. }, scene: Scene, updatable?: boolean): Mesh;
  30055. /**
  30056. * Creates a ground mesh from a height map.
  30057. * Please consider using the same method from the MeshBuilder class instead
  30058. * @see https://doc.babylonjs.com/babylon101/height_map
  30059. * @param name defines the name of the mesh to create
  30060. * @param url sets the URL of the height map image resource
  30061. * @param width set the ground width size
  30062. * @param height set the ground height size
  30063. * @param subdivisions sets the number of subdivision per side
  30064. * @param minHeight is the minimum altitude on the ground
  30065. * @param maxHeight is the maximum altitude on the ground
  30066. * @param scene defines the hosting scene
  30067. * @param updatable defines if the mesh must be flagged as updatable
  30068. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30069. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30070. * @returns a new Mesh
  30071. */
  30072. 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;
  30073. /**
  30074. * Creates a tube mesh.
  30075. * The tube is a parametric shape.
  30076. * It has no predefined shape. Its final shape will depend on the input parameters.
  30077. * Please consider using the same method from the MeshBuilder class instead
  30078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30079. * @param name defines the name of the mesh to create
  30080. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30081. * @param radius sets the tube radius size
  30082. * @param tessellation is the number of sides on the tubular surface
  30083. * @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
  30084. * @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
  30085. * @param scene defines the hosting scene
  30086. * @param updatable defines if the mesh must be flagged as updatable
  30087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30088. * @param instance 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)
  30089. * @returns a new Mesh
  30090. */
  30091. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30092. (i: number, distance: number): number;
  30093. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30094. /**
  30095. * Creates a polyhedron mesh.
  30096. * Please consider using the same method from the MeshBuilder class instead.
  30097. * * 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
  30098. * * The parameter `size` (positive float, default 1) sets the polygon size
  30099. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30100. * * 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`
  30101. * * 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
  30102. * * 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)`)
  30103. * * 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
  30104. * * 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
  30105. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30108. * @param name defines the name of the mesh to create
  30109. * @param options defines the options used to create the mesh
  30110. * @param scene defines the hosting scene
  30111. * @returns a new Mesh
  30112. */
  30113. static CreatePolyhedron(name: string, options: {
  30114. type?: number;
  30115. size?: number;
  30116. sizeX?: number;
  30117. sizeY?: number;
  30118. sizeZ?: number;
  30119. custom?: any;
  30120. faceUV?: Vector4[];
  30121. faceColors?: Color4[];
  30122. updatable?: boolean;
  30123. sideOrientation?: number;
  30124. }, scene: Scene): Mesh;
  30125. /**
  30126. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30127. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30128. * * 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`)
  30129. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30130. * * 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
  30131. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30134. * @param name defines the name of the mesh
  30135. * @param options defines the options used to create the mesh
  30136. * @param scene defines the hosting scene
  30137. * @returns a new Mesh
  30138. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30139. */
  30140. static CreateIcoSphere(name: string, options: {
  30141. radius?: number;
  30142. flat?: boolean;
  30143. subdivisions?: number;
  30144. sideOrientation?: number;
  30145. updatable?: boolean;
  30146. }, scene: Scene): Mesh;
  30147. /**
  30148. * Creates a decal mesh.
  30149. * Please consider using the same method from the MeshBuilder class instead.
  30150. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30151. * @param name defines the name of the mesh
  30152. * @param sourceMesh defines the mesh receiving the decal
  30153. * @param position sets the position of the decal in world coordinates
  30154. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30155. * @param size sets the decal scaling
  30156. * @param angle sets the angle to rotate the decal
  30157. * @returns a new Mesh
  30158. */
  30159. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30160. /**
  30161. * Prepare internal position array for software CPU skinning
  30162. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30163. */
  30164. setPositionsForCPUSkinning(): Float32Array;
  30165. /**
  30166. * Prepare internal normal array for software CPU skinning
  30167. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30168. */
  30169. setNormalsForCPUSkinning(): Float32Array;
  30170. /**
  30171. * Updates the vertex buffer by applying transformation from the bones
  30172. * @param skeleton defines the skeleton to apply to current mesh
  30173. * @returns the current mesh
  30174. */
  30175. applySkeleton(skeleton: Skeleton): Mesh;
  30176. /**
  30177. * 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
  30178. * @param meshes defines the list of meshes to scan
  30179. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30180. */
  30181. static MinMax(meshes: AbstractMesh[]): {
  30182. min: Vector3;
  30183. max: Vector3;
  30184. };
  30185. /**
  30186. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30187. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30188. * @returns a vector3
  30189. */
  30190. static Center(meshesOrMinMaxVector: {
  30191. min: Vector3;
  30192. max: Vector3;
  30193. } | AbstractMesh[]): Vector3;
  30194. /**
  30195. * Merge the array of meshes into a single mesh for performance reasons.
  30196. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30197. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30198. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30199. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30200. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30201. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30202. * @returns a new mesh
  30203. */
  30204. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30205. /** @hidden */
  30206. addInstance(instance: InstancedMesh): void;
  30207. /** @hidden */
  30208. removeInstance(instance: InstancedMesh): void;
  30209. }
  30210. }
  30211. declare module "babylonjs/Cameras/camera" {
  30212. import { SmartArray } from "babylonjs/Misc/smartArray";
  30213. import { Observable } from "babylonjs/Misc/observable";
  30214. import { Nullable } from "babylonjs/types";
  30215. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30216. import { Scene } from "babylonjs/scene";
  30217. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30218. import { Node } from "babylonjs/node";
  30219. import { Mesh } from "babylonjs/Meshes/mesh";
  30220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30221. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30222. import { Viewport } from "babylonjs/Maths/math.viewport";
  30223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30224. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30226. import { Ray } from "babylonjs/Culling/ray";
  30227. /**
  30228. * This is the base class of all the camera used in the application.
  30229. * @see https://doc.babylonjs.com/features/cameras
  30230. */
  30231. export class Camera extends Node {
  30232. /** @hidden */
  30233. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30234. /**
  30235. * This is the default projection mode used by the cameras.
  30236. * It helps recreating a feeling of perspective and better appreciate depth.
  30237. * This is the best way to simulate real life cameras.
  30238. */
  30239. static readonly PERSPECTIVE_CAMERA: number;
  30240. /**
  30241. * This helps creating camera with an orthographic mode.
  30242. * 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.
  30243. */
  30244. static readonly ORTHOGRAPHIC_CAMERA: number;
  30245. /**
  30246. * This is the default FOV mode for perspective cameras.
  30247. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30248. */
  30249. static readonly FOVMODE_VERTICAL_FIXED: number;
  30250. /**
  30251. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30252. */
  30253. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30254. /**
  30255. * This specifies ther is no need for a camera rig.
  30256. * Basically only one eye is rendered corresponding to the camera.
  30257. */
  30258. static readonly RIG_MODE_NONE: number;
  30259. /**
  30260. * Simulates a camera Rig with one blue eye and one red eye.
  30261. * This can be use with 3d blue and red glasses.
  30262. */
  30263. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30264. /**
  30265. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30266. */
  30267. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30268. /**
  30269. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30270. */
  30271. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30272. /**
  30273. * Defines that both eyes of the camera will be rendered over under each other.
  30274. */
  30275. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30276. /**
  30277. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30278. */
  30279. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30280. /**
  30281. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30282. */
  30283. static readonly RIG_MODE_VR: number;
  30284. /**
  30285. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30286. */
  30287. static readonly RIG_MODE_WEBVR: number;
  30288. /**
  30289. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30290. */
  30291. static readonly RIG_MODE_CUSTOM: number;
  30292. /**
  30293. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30294. */
  30295. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30296. /**
  30297. * Define the input manager associated with the camera.
  30298. */
  30299. inputs: CameraInputsManager<Camera>;
  30300. /** @hidden */
  30301. _position: Vector3;
  30302. /**
  30303. * Define the current local position of the camera in the scene
  30304. */
  30305. get position(): Vector3;
  30306. set position(newPosition: Vector3);
  30307. /**
  30308. * The vector the camera should consider as up.
  30309. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30310. */
  30311. upVector: Vector3;
  30312. /**
  30313. * Define the current limit on the left side for an orthographic camera
  30314. * In scene unit
  30315. */
  30316. orthoLeft: Nullable<number>;
  30317. /**
  30318. * Define the current limit on the right side for an orthographic camera
  30319. * In scene unit
  30320. */
  30321. orthoRight: Nullable<number>;
  30322. /**
  30323. * Define the current limit on the bottom side for an orthographic camera
  30324. * In scene unit
  30325. */
  30326. orthoBottom: Nullable<number>;
  30327. /**
  30328. * Define the current limit on the top side for an orthographic camera
  30329. * In scene unit
  30330. */
  30331. orthoTop: Nullable<number>;
  30332. /**
  30333. * Field Of View is set in Radians. (default is 0.8)
  30334. */
  30335. fov: number;
  30336. /**
  30337. * Define the minimum distance the camera can see from.
  30338. * This is important to note that the depth buffer are not infinite and the closer it starts
  30339. * the more your scene might encounter depth fighting issue.
  30340. */
  30341. minZ: number;
  30342. /**
  30343. * Define the maximum distance the camera can see to.
  30344. * This is important to note that the depth buffer are not infinite and the further it end
  30345. * the more your scene might encounter depth fighting issue.
  30346. */
  30347. maxZ: number;
  30348. /**
  30349. * Define the default inertia of the camera.
  30350. * This helps giving a smooth feeling to the camera movement.
  30351. */
  30352. inertia: number;
  30353. /**
  30354. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30355. */
  30356. mode: number;
  30357. /**
  30358. * Define whether the camera is intermediate.
  30359. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30360. */
  30361. isIntermediate: boolean;
  30362. /**
  30363. * Define the viewport of the camera.
  30364. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30365. */
  30366. viewport: Viewport;
  30367. /**
  30368. * Restricts the camera to viewing objects with the same layerMask.
  30369. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30370. */
  30371. layerMask: number;
  30372. /**
  30373. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30374. */
  30375. fovMode: number;
  30376. /**
  30377. * Rig mode of the camera.
  30378. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30379. * This is normally controlled byt the camera themselves as internal use.
  30380. */
  30381. cameraRigMode: number;
  30382. /**
  30383. * Defines the distance between both "eyes" in case of a RIG
  30384. */
  30385. interaxialDistance: number;
  30386. /**
  30387. * Defines if stereoscopic rendering is done side by side or over under.
  30388. */
  30389. isStereoscopicSideBySide: boolean;
  30390. /**
  30391. * 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
  30392. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30393. * else in the scene. (Eg. security camera)
  30394. *
  30395. * 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)
  30396. */
  30397. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30398. /**
  30399. * When set, the camera will render to this render target instead of the default canvas
  30400. *
  30401. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30402. */
  30403. outputRenderTarget: Nullable<RenderTargetTexture>;
  30404. /**
  30405. * Observable triggered when the camera view matrix has changed.
  30406. */
  30407. onViewMatrixChangedObservable: Observable<Camera>;
  30408. /**
  30409. * Observable triggered when the camera Projection matrix has changed.
  30410. */
  30411. onProjectionMatrixChangedObservable: Observable<Camera>;
  30412. /**
  30413. * Observable triggered when the inputs have been processed.
  30414. */
  30415. onAfterCheckInputsObservable: Observable<Camera>;
  30416. /**
  30417. * Observable triggered when reset has been called and applied to the camera.
  30418. */
  30419. onRestoreStateObservable: Observable<Camera>;
  30420. /**
  30421. * Is this camera a part of a rig system?
  30422. */
  30423. isRigCamera: boolean;
  30424. /**
  30425. * If isRigCamera set to true this will be set with the parent camera.
  30426. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30427. */
  30428. rigParent?: Camera;
  30429. /** @hidden */
  30430. _cameraRigParams: any;
  30431. /** @hidden */
  30432. _rigCameras: Camera[];
  30433. /** @hidden */
  30434. _rigPostProcess: Nullable<PostProcess>;
  30435. protected _webvrViewMatrix: Matrix;
  30436. /** @hidden */
  30437. _skipRendering: boolean;
  30438. /** @hidden */
  30439. _projectionMatrix: Matrix;
  30440. /** @hidden */
  30441. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30442. /** @hidden */
  30443. _activeMeshes: SmartArray<AbstractMesh>;
  30444. protected _globalPosition: Vector3;
  30445. /** @hidden */
  30446. _computedViewMatrix: Matrix;
  30447. private _doNotComputeProjectionMatrix;
  30448. private _transformMatrix;
  30449. private _frustumPlanes;
  30450. private _refreshFrustumPlanes;
  30451. private _storedFov;
  30452. private _stateStored;
  30453. /**
  30454. * Instantiates a new camera object.
  30455. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30456. * @see https://doc.babylonjs.com/features/cameras
  30457. * @param name Defines the name of the camera in the scene
  30458. * @param position Defines the position of the camera
  30459. * @param scene Defines the scene the camera belongs too
  30460. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30461. */
  30462. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30463. /**
  30464. * Store current camera state (fov, position, etc..)
  30465. * @returns the camera
  30466. */
  30467. storeState(): Camera;
  30468. /**
  30469. * Restores the camera state values if it has been stored. You must call storeState() first
  30470. */
  30471. protected _restoreStateValues(): boolean;
  30472. /**
  30473. * Restored camera state. You must call storeState() first.
  30474. * @returns true if restored and false otherwise
  30475. */
  30476. restoreState(): boolean;
  30477. /**
  30478. * Gets the class name of the camera.
  30479. * @returns the class name
  30480. */
  30481. getClassName(): string;
  30482. /** @hidden */
  30483. readonly _isCamera: boolean;
  30484. /**
  30485. * Gets a string representation of the camera useful for debug purpose.
  30486. * @param fullDetails Defines that a more verboe level of logging is required
  30487. * @returns the string representation
  30488. */
  30489. toString(fullDetails?: boolean): string;
  30490. /**
  30491. * Gets the current world space position of the camera.
  30492. */
  30493. get globalPosition(): Vector3;
  30494. /**
  30495. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30496. * @returns the active meshe list
  30497. */
  30498. getActiveMeshes(): SmartArray<AbstractMesh>;
  30499. /**
  30500. * Check whether a mesh is part of the current active mesh list of the camera
  30501. * @param mesh Defines the mesh to check
  30502. * @returns true if active, false otherwise
  30503. */
  30504. isActiveMesh(mesh: Mesh): boolean;
  30505. /**
  30506. * Is this camera ready to be used/rendered
  30507. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30508. * @return true if the camera is ready
  30509. */
  30510. isReady(completeCheck?: boolean): boolean;
  30511. /** @hidden */
  30512. _initCache(): void;
  30513. /** @hidden */
  30514. _updateCache(ignoreParentClass?: boolean): void;
  30515. /** @hidden */
  30516. _isSynchronized(): boolean;
  30517. /** @hidden */
  30518. _isSynchronizedViewMatrix(): boolean;
  30519. /** @hidden */
  30520. _isSynchronizedProjectionMatrix(): boolean;
  30521. /**
  30522. * Attach the input controls to a specific dom element to get the input from.
  30523. * @param element Defines the element the controls should be listened from
  30524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30525. */
  30526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30527. /**
  30528. * Detach the current controls from the specified dom element.
  30529. * @param element Defines the element to stop listening the inputs from
  30530. */
  30531. detachControl(element: HTMLElement): void;
  30532. /**
  30533. * Update the camera state according to the different inputs gathered during the frame.
  30534. */
  30535. update(): void;
  30536. /** @hidden */
  30537. _checkInputs(): void;
  30538. /** @hidden */
  30539. get rigCameras(): Camera[];
  30540. /**
  30541. * Gets the post process used by the rig cameras
  30542. */
  30543. get rigPostProcess(): Nullable<PostProcess>;
  30544. /**
  30545. * Internal, gets the first post proces.
  30546. * @returns the first post process to be run on this camera.
  30547. */
  30548. _getFirstPostProcess(): Nullable<PostProcess>;
  30549. private _cascadePostProcessesToRigCams;
  30550. /**
  30551. * Attach a post process to the camera.
  30552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30553. * @param postProcess The post process to attach to the camera
  30554. * @param insertAt The position of the post process in case several of them are in use in the scene
  30555. * @returns the position the post process has been inserted at
  30556. */
  30557. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30558. /**
  30559. * Detach a post process to the camera.
  30560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30561. * @param postProcess The post process to detach from the camera
  30562. */
  30563. detachPostProcess(postProcess: PostProcess): void;
  30564. /**
  30565. * Gets the current world matrix of the camera
  30566. */
  30567. getWorldMatrix(): Matrix;
  30568. /** @hidden */
  30569. _getViewMatrix(): Matrix;
  30570. /**
  30571. * Gets the current view matrix of the camera.
  30572. * @param force forces the camera to recompute the matrix without looking at the cached state
  30573. * @returns the view matrix
  30574. */
  30575. getViewMatrix(force?: boolean): Matrix;
  30576. /**
  30577. * Freeze the projection matrix.
  30578. * It will prevent the cache check of the camera projection compute and can speed up perf
  30579. * if no parameter of the camera are meant to change
  30580. * @param projection Defines manually a projection if necessary
  30581. */
  30582. freezeProjectionMatrix(projection?: Matrix): void;
  30583. /**
  30584. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30585. */
  30586. unfreezeProjectionMatrix(): void;
  30587. /**
  30588. * Gets the current projection matrix of the camera.
  30589. * @param force forces the camera to recompute the matrix without looking at the cached state
  30590. * @returns the projection matrix
  30591. */
  30592. getProjectionMatrix(force?: boolean): Matrix;
  30593. /**
  30594. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30595. * @returns a Matrix
  30596. */
  30597. getTransformationMatrix(): Matrix;
  30598. private _updateFrustumPlanes;
  30599. /**
  30600. * Checks if a cullable object (mesh...) is in the camera frustum
  30601. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30602. * @param target The object to check
  30603. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30604. * @returns true if the object is in frustum otherwise false
  30605. */
  30606. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30607. /**
  30608. * Checks if a cullable object (mesh...) is in the camera frustum
  30609. * Unlike isInFrustum this cheks the full bounding box
  30610. * @param target The object to check
  30611. * @returns true if the object is in frustum otherwise false
  30612. */
  30613. isCompletelyInFrustum(target: ICullable): boolean;
  30614. /**
  30615. * Gets a ray in the forward direction from the camera.
  30616. * @param length Defines the length of the ray to create
  30617. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30618. * @param origin Defines the start point of the ray which defaults to the camera position
  30619. * @returns the forward ray
  30620. */
  30621. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30622. /**
  30623. * Gets a ray in the forward direction from the camera.
  30624. * @param refRay the ray to (re)use when setting the values
  30625. * @param length Defines the length of the ray to create
  30626. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30627. * @param origin Defines the start point of the ray which defaults to the camera position
  30628. * @returns the forward ray
  30629. */
  30630. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30631. /**
  30632. * Releases resources associated with this node.
  30633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30635. */
  30636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30637. /** @hidden */
  30638. _isLeftCamera: boolean;
  30639. /**
  30640. * Gets the left camera of a rig setup in case of Rigged Camera
  30641. */
  30642. get isLeftCamera(): boolean;
  30643. /** @hidden */
  30644. _isRightCamera: boolean;
  30645. /**
  30646. * Gets the right camera of a rig setup in case of Rigged Camera
  30647. */
  30648. get isRightCamera(): boolean;
  30649. /**
  30650. * Gets the left camera of a rig setup in case of Rigged Camera
  30651. */
  30652. get leftCamera(): Nullable<FreeCamera>;
  30653. /**
  30654. * Gets the right camera of a rig setup in case of Rigged Camera
  30655. */
  30656. get rightCamera(): Nullable<FreeCamera>;
  30657. /**
  30658. * Gets the left camera target of a rig setup in case of Rigged Camera
  30659. * @returns the target position
  30660. */
  30661. getLeftTarget(): Nullable<Vector3>;
  30662. /**
  30663. * Gets the right camera target of a rig setup in case of Rigged Camera
  30664. * @returns the target position
  30665. */
  30666. getRightTarget(): Nullable<Vector3>;
  30667. /**
  30668. * @hidden
  30669. */
  30670. setCameraRigMode(mode: number, rigParams: any): void;
  30671. /** @hidden */
  30672. static _setStereoscopicRigMode(camera: Camera): void;
  30673. /** @hidden */
  30674. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30675. /** @hidden */
  30676. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30677. /** @hidden */
  30678. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30679. /** @hidden */
  30680. _getVRProjectionMatrix(): Matrix;
  30681. protected _updateCameraRotationMatrix(): void;
  30682. protected _updateWebVRCameraRotationMatrix(): void;
  30683. /**
  30684. * This function MUST be overwritten by the different WebVR cameras available.
  30685. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30686. * @hidden
  30687. */
  30688. _getWebVRProjectionMatrix(): Matrix;
  30689. /**
  30690. * This function MUST be overwritten by the different WebVR cameras available.
  30691. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30692. * @hidden
  30693. */
  30694. _getWebVRViewMatrix(): Matrix;
  30695. /** @hidden */
  30696. setCameraRigParameter(name: string, value: any): void;
  30697. /**
  30698. * needs to be overridden by children so sub has required properties to be copied
  30699. * @hidden
  30700. */
  30701. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30702. /**
  30703. * May need to be overridden by children
  30704. * @hidden
  30705. */
  30706. _updateRigCameras(): void;
  30707. /** @hidden */
  30708. _setupInputs(): void;
  30709. /**
  30710. * Serialiaze the camera setup to a json represention
  30711. * @returns the JSON representation
  30712. */
  30713. serialize(): any;
  30714. /**
  30715. * Clones the current camera.
  30716. * @param name The cloned camera name
  30717. * @returns the cloned camera
  30718. */
  30719. clone(name: string): Camera;
  30720. /**
  30721. * Gets the direction of the camera relative to a given local axis.
  30722. * @param localAxis Defines the reference axis to provide a relative direction.
  30723. * @return the direction
  30724. */
  30725. getDirection(localAxis: Vector3): Vector3;
  30726. /**
  30727. * Returns the current camera absolute rotation
  30728. */
  30729. get absoluteRotation(): Quaternion;
  30730. /**
  30731. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30732. * @param localAxis Defines the reference axis to provide a relative direction.
  30733. * @param result Defines the vector to store the result in
  30734. */
  30735. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30736. /**
  30737. * Gets a camera constructor for a given camera type
  30738. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30739. * @param name The name of the camera the result will be able to instantiate
  30740. * @param scene The scene the result will construct the camera in
  30741. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30742. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30743. * @returns a factory method to construc the camera
  30744. */
  30745. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30746. /**
  30747. * Compute the world matrix of the camera.
  30748. * @returns the camera world matrix
  30749. */
  30750. computeWorldMatrix(): Matrix;
  30751. /**
  30752. * Parse a JSON and creates the camera from the parsed information
  30753. * @param parsedCamera The JSON to parse
  30754. * @param scene The scene to instantiate the camera in
  30755. * @returns the newly constructed camera
  30756. */
  30757. static Parse(parsedCamera: any, scene: Scene): Camera;
  30758. }
  30759. }
  30760. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30761. import { Nullable } from "babylonjs/types";
  30762. import { Scene } from "babylonjs/scene";
  30763. import { Vector4 } from "babylonjs/Maths/math.vector";
  30764. import { Mesh } from "babylonjs/Meshes/mesh";
  30765. /**
  30766. * Class containing static functions to help procedurally build meshes
  30767. */
  30768. export class DiscBuilder {
  30769. /**
  30770. * Creates a plane polygonal mesh. By default, this is a disc
  30771. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30772. * * 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
  30773. * * 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
  30774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30777. * @param name defines the name of the mesh
  30778. * @param options defines the options used to create the mesh
  30779. * @param scene defines the hosting scene
  30780. * @returns the plane polygonal mesh
  30781. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30782. */
  30783. static CreateDisc(name: string, options: {
  30784. radius?: number;
  30785. tessellation?: number;
  30786. arc?: number;
  30787. updatable?: boolean;
  30788. sideOrientation?: number;
  30789. frontUVs?: Vector4;
  30790. backUVs?: Vector4;
  30791. }, scene?: Nullable<Scene>): Mesh;
  30792. }
  30793. }
  30794. declare module "babylonjs/Materials/fresnelParameters" {
  30795. import { DeepImmutable } from "babylonjs/types";
  30796. import { Color3 } from "babylonjs/Maths/math.color";
  30797. /**
  30798. * Options to be used when creating a FresnelParameters.
  30799. */
  30800. export type IFresnelParametersCreationOptions = {
  30801. /**
  30802. * Define the color used on edges (grazing angle)
  30803. */
  30804. leftColor?: Color3;
  30805. /**
  30806. * Define the color used on center
  30807. */
  30808. rightColor?: Color3;
  30809. /**
  30810. * Define bias applied to computed fresnel term
  30811. */
  30812. bias?: number;
  30813. /**
  30814. * Defined the power exponent applied to fresnel term
  30815. */
  30816. power?: number;
  30817. /**
  30818. * Define if the fresnel effect is enable or not.
  30819. */
  30820. isEnabled?: boolean;
  30821. };
  30822. /**
  30823. * Serialized format for FresnelParameters.
  30824. */
  30825. export type IFresnelParametersSerialized = {
  30826. /**
  30827. * Define the color used on edges (grazing angle) [as an array]
  30828. */
  30829. leftColor: number[];
  30830. /**
  30831. * Define the color used on center [as an array]
  30832. */
  30833. rightColor: number[];
  30834. /**
  30835. * Define bias applied to computed fresnel term
  30836. */
  30837. bias: number;
  30838. /**
  30839. * Defined the power exponent applied to fresnel term
  30840. */
  30841. power?: number;
  30842. /**
  30843. * Define if the fresnel effect is enable or not.
  30844. */
  30845. isEnabled: boolean;
  30846. };
  30847. /**
  30848. * This represents all the required information to add a fresnel effect on a material:
  30849. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30850. */
  30851. export class FresnelParameters {
  30852. private _isEnabled;
  30853. /**
  30854. * Define if the fresnel effect is enable or not.
  30855. */
  30856. get isEnabled(): boolean;
  30857. set isEnabled(value: boolean);
  30858. /**
  30859. * Define the color used on edges (grazing angle)
  30860. */
  30861. leftColor: Color3;
  30862. /**
  30863. * Define the color used on center
  30864. */
  30865. rightColor: Color3;
  30866. /**
  30867. * Define bias applied to computed fresnel term
  30868. */
  30869. bias: number;
  30870. /**
  30871. * Defined the power exponent applied to fresnel term
  30872. */
  30873. power: number;
  30874. /**
  30875. * Creates a new FresnelParameters object.
  30876. *
  30877. * @param options provide your own settings to optionally to override defaults
  30878. */
  30879. constructor(options?: IFresnelParametersCreationOptions);
  30880. /**
  30881. * Clones the current fresnel and its valuues
  30882. * @returns a clone fresnel configuration
  30883. */
  30884. clone(): FresnelParameters;
  30885. /**
  30886. * Determines equality between FresnelParameters objects
  30887. * @param otherFresnelParameters defines the second operand
  30888. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30889. */
  30890. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30891. /**
  30892. * Serializes the current fresnel parameters to a JSON representation.
  30893. * @return the JSON serialization
  30894. */
  30895. serialize(): IFresnelParametersSerialized;
  30896. /**
  30897. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30898. * @param parsedFresnelParameters Define the JSON representation
  30899. * @returns the parsed parameters
  30900. */
  30901. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30902. }
  30903. }
  30904. declare module "babylonjs/Materials/materialFlags" {
  30905. /**
  30906. * This groups all the flags used to control the materials channel.
  30907. */
  30908. export class MaterialFlags {
  30909. private static _DiffuseTextureEnabled;
  30910. /**
  30911. * Are diffuse textures enabled in the application.
  30912. */
  30913. static get DiffuseTextureEnabled(): boolean;
  30914. static set DiffuseTextureEnabled(value: boolean);
  30915. private static _DetailTextureEnabled;
  30916. /**
  30917. * Are detail textures enabled in the application.
  30918. */
  30919. static get DetailTextureEnabled(): boolean;
  30920. static set DetailTextureEnabled(value: boolean);
  30921. private static _AmbientTextureEnabled;
  30922. /**
  30923. * Are ambient textures enabled in the application.
  30924. */
  30925. static get AmbientTextureEnabled(): boolean;
  30926. static set AmbientTextureEnabled(value: boolean);
  30927. private static _OpacityTextureEnabled;
  30928. /**
  30929. * Are opacity textures enabled in the application.
  30930. */
  30931. static get OpacityTextureEnabled(): boolean;
  30932. static set OpacityTextureEnabled(value: boolean);
  30933. private static _ReflectionTextureEnabled;
  30934. /**
  30935. * Are reflection textures enabled in the application.
  30936. */
  30937. static get ReflectionTextureEnabled(): boolean;
  30938. static set ReflectionTextureEnabled(value: boolean);
  30939. private static _EmissiveTextureEnabled;
  30940. /**
  30941. * Are emissive textures enabled in the application.
  30942. */
  30943. static get EmissiveTextureEnabled(): boolean;
  30944. static set EmissiveTextureEnabled(value: boolean);
  30945. private static _SpecularTextureEnabled;
  30946. /**
  30947. * Are specular textures enabled in the application.
  30948. */
  30949. static get SpecularTextureEnabled(): boolean;
  30950. static set SpecularTextureEnabled(value: boolean);
  30951. private static _BumpTextureEnabled;
  30952. /**
  30953. * Are bump textures enabled in the application.
  30954. */
  30955. static get BumpTextureEnabled(): boolean;
  30956. static set BumpTextureEnabled(value: boolean);
  30957. private static _LightmapTextureEnabled;
  30958. /**
  30959. * Are lightmap textures enabled in the application.
  30960. */
  30961. static get LightmapTextureEnabled(): boolean;
  30962. static set LightmapTextureEnabled(value: boolean);
  30963. private static _RefractionTextureEnabled;
  30964. /**
  30965. * Are refraction textures enabled in the application.
  30966. */
  30967. static get RefractionTextureEnabled(): boolean;
  30968. static set RefractionTextureEnabled(value: boolean);
  30969. private static _ColorGradingTextureEnabled;
  30970. /**
  30971. * Are color grading textures enabled in the application.
  30972. */
  30973. static get ColorGradingTextureEnabled(): boolean;
  30974. static set ColorGradingTextureEnabled(value: boolean);
  30975. private static _FresnelEnabled;
  30976. /**
  30977. * Are fresnels enabled in the application.
  30978. */
  30979. static get FresnelEnabled(): boolean;
  30980. static set FresnelEnabled(value: boolean);
  30981. private static _ClearCoatTextureEnabled;
  30982. /**
  30983. * Are clear coat textures enabled in the application.
  30984. */
  30985. static get ClearCoatTextureEnabled(): boolean;
  30986. static set ClearCoatTextureEnabled(value: boolean);
  30987. private static _ClearCoatBumpTextureEnabled;
  30988. /**
  30989. * Are clear coat bump textures enabled in the application.
  30990. */
  30991. static get ClearCoatBumpTextureEnabled(): boolean;
  30992. static set ClearCoatBumpTextureEnabled(value: boolean);
  30993. private static _ClearCoatTintTextureEnabled;
  30994. /**
  30995. * Are clear coat tint textures enabled in the application.
  30996. */
  30997. static get ClearCoatTintTextureEnabled(): boolean;
  30998. static set ClearCoatTintTextureEnabled(value: boolean);
  30999. private static _SheenTextureEnabled;
  31000. /**
  31001. * Are sheen textures enabled in the application.
  31002. */
  31003. static get SheenTextureEnabled(): boolean;
  31004. static set SheenTextureEnabled(value: boolean);
  31005. private static _AnisotropicTextureEnabled;
  31006. /**
  31007. * Are anisotropic textures enabled in the application.
  31008. */
  31009. static get AnisotropicTextureEnabled(): boolean;
  31010. static set AnisotropicTextureEnabled(value: boolean);
  31011. private static _ThicknessTextureEnabled;
  31012. /**
  31013. * Are thickness textures enabled in the application.
  31014. */
  31015. static get ThicknessTextureEnabled(): boolean;
  31016. static set ThicknessTextureEnabled(value: boolean);
  31017. }
  31018. }
  31019. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31020. /** @hidden */
  31021. export var defaultFragmentDeclaration: {
  31022. name: string;
  31023. shader: string;
  31024. };
  31025. }
  31026. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31027. /** @hidden */
  31028. export var defaultUboDeclaration: {
  31029. name: string;
  31030. shader: string;
  31031. };
  31032. }
  31033. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31034. /** @hidden */
  31035. export var prePassDeclaration: {
  31036. name: string;
  31037. shader: string;
  31038. };
  31039. }
  31040. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31041. /** @hidden */
  31042. export var lightFragmentDeclaration: {
  31043. name: string;
  31044. shader: string;
  31045. };
  31046. }
  31047. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31048. /** @hidden */
  31049. export var lightUboDeclaration: {
  31050. name: string;
  31051. shader: string;
  31052. };
  31053. }
  31054. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31055. /** @hidden */
  31056. export var lightsFragmentFunctions: {
  31057. name: string;
  31058. shader: string;
  31059. };
  31060. }
  31061. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31062. /** @hidden */
  31063. export var shadowsFragmentFunctions: {
  31064. name: string;
  31065. shader: string;
  31066. };
  31067. }
  31068. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31069. /** @hidden */
  31070. export var fresnelFunction: {
  31071. name: string;
  31072. shader: string;
  31073. };
  31074. }
  31075. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31076. /** @hidden */
  31077. export var bumpFragmentMainFunctions: {
  31078. name: string;
  31079. shader: string;
  31080. };
  31081. }
  31082. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31083. /** @hidden */
  31084. export var bumpFragmentFunctions: {
  31085. name: string;
  31086. shader: string;
  31087. };
  31088. }
  31089. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31090. /** @hidden */
  31091. export var logDepthDeclaration: {
  31092. name: string;
  31093. shader: string;
  31094. };
  31095. }
  31096. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31097. /** @hidden */
  31098. export var bumpFragment: {
  31099. name: string;
  31100. shader: string;
  31101. };
  31102. }
  31103. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31104. /** @hidden */
  31105. export var depthPrePass: {
  31106. name: string;
  31107. shader: string;
  31108. };
  31109. }
  31110. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31111. /** @hidden */
  31112. export var lightFragment: {
  31113. name: string;
  31114. shader: string;
  31115. };
  31116. }
  31117. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31118. /** @hidden */
  31119. export var logDepthFragment: {
  31120. name: string;
  31121. shader: string;
  31122. };
  31123. }
  31124. declare module "babylonjs/Shaders/default.fragment" {
  31125. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31126. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31127. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31129. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31130. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31131. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31132. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31133. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31134. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31135. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31136. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31137. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31138. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31139. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31140. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31141. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31142. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31143. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31144. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31145. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31146. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31147. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31148. /** @hidden */
  31149. export var defaultPixelShader: {
  31150. name: string;
  31151. shader: string;
  31152. };
  31153. }
  31154. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31155. /** @hidden */
  31156. export var defaultVertexDeclaration: {
  31157. name: string;
  31158. shader: string;
  31159. };
  31160. }
  31161. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31162. /** @hidden */
  31163. export var bumpVertexDeclaration: {
  31164. name: string;
  31165. shader: string;
  31166. };
  31167. }
  31168. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31169. /** @hidden */
  31170. export var bumpVertex: {
  31171. name: string;
  31172. shader: string;
  31173. };
  31174. }
  31175. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31176. /** @hidden */
  31177. export var fogVertex: {
  31178. name: string;
  31179. shader: string;
  31180. };
  31181. }
  31182. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31183. /** @hidden */
  31184. export var shadowsVertex: {
  31185. name: string;
  31186. shader: string;
  31187. };
  31188. }
  31189. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31190. /** @hidden */
  31191. export var pointCloudVertex: {
  31192. name: string;
  31193. shader: string;
  31194. };
  31195. }
  31196. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31197. /** @hidden */
  31198. export var logDepthVertex: {
  31199. name: string;
  31200. shader: string;
  31201. };
  31202. }
  31203. declare module "babylonjs/Shaders/default.vertex" {
  31204. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31205. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31206. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31207. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31208. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31209. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31210. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31211. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31212. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31213. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31214. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31215. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31216. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31218. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31219. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31220. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31222. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31223. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31224. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31225. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31226. /** @hidden */
  31227. export var defaultVertexShader: {
  31228. name: string;
  31229. shader: string;
  31230. };
  31231. }
  31232. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31233. import { Nullable } from "babylonjs/types";
  31234. import { Scene } from "babylonjs/scene";
  31235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31236. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31238. /**
  31239. * @hidden
  31240. */
  31241. export interface IMaterialDetailMapDefines {
  31242. DETAIL: boolean;
  31243. DETAILDIRECTUV: number;
  31244. DETAIL_NORMALBLENDMETHOD: number;
  31245. /** @hidden */
  31246. _areTexturesDirty: boolean;
  31247. }
  31248. /**
  31249. * Define the code related to the detail map parameters of a material
  31250. *
  31251. * Inspired from:
  31252. * 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
  31253. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31254. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31255. */
  31256. export class DetailMapConfiguration {
  31257. private _texture;
  31258. /**
  31259. * The detail texture of the material.
  31260. */
  31261. texture: Nullable<BaseTexture>;
  31262. /**
  31263. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31264. * Bigger values mean stronger blending
  31265. */
  31266. diffuseBlendLevel: number;
  31267. /**
  31268. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31269. * Bigger values mean stronger blending. Only used with PBR materials
  31270. */
  31271. roughnessBlendLevel: number;
  31272. /**
  31273. * Defines how strong the bump effect from the detail map is
  31274. * Bigger values mean stronger effect
  31275. */
  31276. bumpLevel: number;
  31277. private _normalBlendMethod;
  31278. /**
  31279. * The method used to blend the bump and detail normals together
  31280. */
  31281. normalBlendMethod: number;
  31282. private _isEnabled;
  31283. /**
  31284. * Enable or disable the detail map on this material
  31285. */
  31286. isEnabled: boolean;
  31287. /** @hidden */
  31288. private _internalMarkAllSubMeshesAsTexturesDirty;
  31289. /** @hidden */
  31290. _markAllSubMeshesAsTexturesDirty(): void;
  31291. /**
  31292. * Instantiate a new detail map
  31293. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31294. */
  31295. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31296. /**
  31297. * Gets whether the submesh is ready to be used or not.
  31298. * @param defines the list of "defines" to update.
  31299. * @param scene defines the scene the material belongs to.
  31300. * @returns - boolean indicating that the submesh is ready or not.
  31301. */
  31302. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31303. /**
  31304. * Update the defines for detail map usage
  31305. * @param defines the list of "defines" to update.
  31306. * @param scene defines the scene the material belongs to.
  31307. */
  31308. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31309. /**
  31310. * Binds the material data.
  31311. * @param uniformBuffer defines the Uniform buffer to fill in.
  31312. * @param scene defines the scene the material belongs to.
  31313. * @param isFrozen defines whether the material is frozen or not.
  31314. */
  31315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31316. /**
  31317. * Checks to see if a texture is used in the material.
  31318. * @param texture - Base texture to use.
  31319. * @returns - Boolean specifying if a texture is used in the material.
  31320. */
  31321. hasTexture(texture: BaseTexture): boolean;
  31322. /**
  31323. * Returns an array of the actively used textures.
  31324. * @param activeTextures Array of BaseTextures
  31325. */
  31326. getActiveTextures(activeTextures: BaseTexture[]): void;
  31327. /**
  31328. * Returns the animatable textures.
  31329. * @param animatables Array of animatable textures.
  31330. */
  31331. getAnimatables(animatables: IAnimatable[]): void;
  31332. /**
  31333. * Disposes the resources of the material.
  31334. * @param forceDisposeTextures - Forces the disposal of all textures.
  31335. */
  31336. dispose(forceDisposeTextures?: boolean): void;
  31337. /**
  31338. * Get the current class name useful for serialization or dynamic coding.
  31339. * @returns "DetailMap"
  31340. */
  31341. getClassName(): string;
  31342. /**
  31343. * Add the required uniforms to the current list.
  31344. * @param uniforms defines the current uniform list.
  31345. */
  31346. static AddUniforms(uniforms: string[]): void;
  31347. /**
  31348. * Add the required samplers to the current list.
  31349. * @param samplers defines the current sampler list.
  31350. */
  31351. static AddSamplers(samplers: string[]): void;
  31352. /**
  31353. * Add the required uniforms to the current buffer.
  31354. * @param uniformBuffer defines the current uniform buffer.
  31355. */
  31356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31357. /**
  31358. * Makes a duplicate of the current instance into another one.
  31359. * @param detailMap define the instance where to copy the info
  31360. */
  31361. copyTo(detailMap: DetailMapConfiguration): void;
  31362. /**
  31363. * Serializes this detail map instance
  31364. * @returns - An object with the serialized instance.
  31365. */
  31366. serialize(): any;
  31367. /**
  31368. * Parses a detail map setting from a serialized object.
  31369. * @param source - Serialized object.
  31370. * @param scene Defines the scene we are parsing for
  31371. * @param rootUrl Defines the rootUrl to load from
  31372. */
  31373. parse(source: any, scene: Scene, rootUrl: string): void;
  31374. }
  31375. }
  31376. declare module "babylonjs/Materials/standardMaterial" {
  31377. import { SmartArray } from "babylonjs/Misc/smartArray";
  31378. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31379. import { Nullable } from "babylonjs/types";
  31380. import { Scene } from "babylonjs/scene";
  31381. import { Matrix } from "babylonjs/Maths/math.vector";
  31382. import { Color3 } from "babylonjs/Maths/math.color";
  31383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31385. import { Mesh } from "babylonjs/Meshes/mesh";
  31386. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31387. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31388. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31389. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31390. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31393. import "babylonjs/Shaders/default.fragment";
  31394. import "babylonjs/Shaders/default.vertex";
  31395. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31396. /** @hidden */
  31397. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31398. MAINUV1: boolean;
  31399. MAINUV2: boolean;
  31400. DIFFUSE: boolean;
  31401. DIFFUSEDIRECTUV: number;
  31402. DETAIL: boolean;
  31403. DETAILDIRECTUV: number;
  31404. DETAIL_NORMALBLENDMETHOD: number;
  31405. AMBIENT: boolean;
  31406. AMBIENTDIRECTUV: number;
  31407. OPACITY: boolean;
  31408. OPACITYDIRECTUV: number;
  31409. OPACITYRGB: boolean;
  31410. REFLECTION: boolean;
  31411. EMISSIVE: boolean;
  31412. EMISSIVEDIRECTUV: number;
  31413. SPECULAR: boolean;
  31414. SPECULARDIRECTUV: number;
  31415. BUMP: boolean;
  31416. BUMPDIRECTUV: number;
  31417. PARALLAX: boolean;
  31418. PARALLAXOCCLUSION: boolean;
  31419. SPECULAROVERALPHA: boolean;
  31420. CLIPPLANE: boolean;
  31421. CLIPPLANE2: boolean;
  31422. CLIPPLANE3: boolean;
  31423. CLIPPLANE4: boolean;
  31424. CLIPPLANE5: boolean;
  31425. CLIPPLANE6: boolean;
  31426. ALPHATEST: boolean;
  31427. DEPTHPREPASS: boolean;
  31428. ALPHAFROMDIFFUSE: boolean;
  31429. POINTSIZE: boolean;
  31430. FOG: boolean;
  31431. SPECULARTERM: boolean;
  31432. DIFFUSEFRESNEL: boolean;
  31433. OPACITYFRESNEL: boolean;
  31434. REFLECTIONFRESNEL: boolean;
  31435. REFRACTIONFRESNEL: boolean;
  31436. EMISSIVEFRESNEL: boolean;
  31437. FRESNEL: boolean;
  31438. NORMAL: boolean;
  31439. UV1: boolean;
  31440. UV2: boolean;
  31441. VERTEXCOLOR: boolean;
  31442. VERTEXALPHA: boolean;
  31443. NUM_BONE_INFLUENCERS: number;
  31444. BonesPerMesh: number;
  31445. BONETEXTURE: boolean;
  31446. INSTANCES: boolean;
  31447. THIN_INSTANCES: boolean;
  31448. GLOSSINESS: boolean;
  31449. ROUGHNESS: boolean;
  31450. EMISSIVEASILLUMINATION: boolean;
  31451. LINKEMISSIVEWITHDIFFUSE: boolean;
  31452. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31453. LIGHTMAP: boolean;
  31454. LIGHTMAPDIRECTUV: number;
  31455. OBJECTSPACE_NORMALMAP: boolean;
  31456. USELIGHTMAPASSHADOWMAP: boolean;
  31457. REFLECTIONMAP_3D: boolean;
  31458. REFLECTIONMAP_SPHERICAL: boolean;
  31459. REFLECTIONMAP_PLANAR: boolean;
  31460. REFLECTIONMAP_CUBIC: boolean;
  31461. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31462. REFLECTIONMAP_PROJECTION: boolean;
  31463. REFLECTIONMAP_SKYBOX: boolean;
  31464. REFLECTIONMAP_EXPLICIT: boolean;
  31465. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31466. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31467. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31468. INVERTCUBICMAP: boolean;
  31469. LOGARITHMICDEPTH: boolean;
  31470. REFRACTION: boolean;
  31471. REFRACTIONMAP_3D: boolean;
  31472. REFLECTIONOVERALPHA: boolean;
  31473. TWOSIDEDLIGHTING: boolean;
  31474. SHADOWFLOAT: boolean;
  31475. MORPHTARGETS: boolean;
  31476. MORPHTARGETS_NORMAL: boolean;
  31477. MORPHTARGETS_TANGENT: boolean;
  31478. MORPHTARGETS_UV: boolean;
  31479. NUM_MORPH_INFLUENCERS: number;
  31480. NONUNIFORMSCALING: boolean;
  31481. PREMULTIPLYALPHA: boolean;
  31482. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31483. ALPHABLEND: boolean;
  31484. PREPASS: boolean;
  31485. SCENE_MRT_COUNT: number;
  31486. RGBDLIGHTMAP: boolean;
  31487. RGBDREFLECTION: boolean;
  31488. RGBDREFRACTION: boolean;
  31489. IMAGEPROCESSING: boolean;
  31490. VIGNETTE: boolean;
  31491. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31492. VIGNETTEBLENDMODEOPAQUE: boolean;
  31493. TONEMAPPING: boolean;
  31494. TONEMAPPING_ACES: boolean;
  31495. CONTRAST: boolean;
  31496. COLORCURVES: boolean;
  31497. COLORGRADING: boolean;
  31498. COLORGRADING3D: boolean;
  31499. SAMPLER3DGREENDEPTH: boolean;
  31500. SAMPLER3DBGRMAP: boolean;
  31501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31502. MULTIVIEW: boolean;
  31503. /**
  31504. * If the reflection texture on this material is in linear color space
  31505. * @hidden
  31506. */
  31507. IS_REFLECTION_LINEAR: boolean;
  31508. /**
  31509. * If the refraction texture on this material is in linear color space
  31510. * @hidden
  31511. */
  31512. IS_REFRACTION_LINEAR: boolean;
  31513. EXPOSURE: boolean;
  31514. constructor();
  31515. setReflectionMode(modeToEnable: string): void;
  31516. }
  31517. /**
  31518. * This is the default material used in Babylon. It is the best trade off between quality
  31519. * and performances.
  31520. * @see https://doc.babylonjs.com/babylon101/materials
  31521. */
  31522. export class StandardMaterial extends PushMaterial {
  31523. private _diffuseTexture;
  31524. /**
  31525. * The basic texture of the material as viewed under a light.
  31526. */
  31527. diffuseTexture: Nullable<BaseTexture>;
  31528. private _ambientTexture;
  31529. /**
  31530. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31531. */
  31532. ambientTexture: Nullable<BaseTexture>;
  31533. private _opacityTexture;
  31534. /**
  31535. * Define the transparency of the material from a texture.
  31536. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31537. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31538. */
  31539. opacityTexture: Nullable<BaseTexture>;
  31540. private _reflectionTexture;
  31541. /**
  31542. * Define the texture used to display the reflection.
  31543. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31544. */
  31545. reflectionTexture: Nullable<BaseTexture>;
  31546. private _emissiveTexture;
  31547. /**
  31548. * Define texture of the material as if self lit.
  31549. * This will be mixed in the final result even in the absence of light.
  31550. */
  31551. emissiveTexture: Nullable<BaseTexture>;
  31552. private _specularTexture;
  31553. /**
  31554. * Define how the color and intensity of the highlight given by the light in the material.
  31555. */
  31556. specularTexture: Nullable<BaseTexture>;
  31557. private _bumpTexture;
  31558. /**
  31559. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31560. * 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.
  31561. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31562. */
  31563. bumpTexture: Nullable<BaseTexture>;
  31564. private _lightmapTexture;
  31565. /**
  31566. * Complex lighting can be computationally expensive to compute at runtime.
  31567. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31568. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31569. */
  31570. lightmapTexture: Nullable<BaseTexture>;
  31571. private _refractionTexture;
  31572. /**
  31573. * Define the texture used to display the refraction.
  31574. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31575. */
  31576. refractionTexture: Nullable<BaseTexture>;
  31577. /**
  31578. * The color of the material lit by the environmental background lighting.
  31579. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31580. */
  31581. ambientColor: Color3;
  31582. /**
  31583. * The basic color of the material as viewed under a light.
  31584. */
  31585. diffuseColor: Color3;
  31586. /**
  31587. * Define how the color and intensity of the highlight given by the light in the material.
  31588. */
  31589. specularColor: Color3;
  31590. /**
  31591. * Define the color of the material as if self lit.
  31592. * This will be mixed in the final result even in the absence of light.
  31593. */
  31594. emissiveColor: Color3;
  31595. /**
  31596. * Defines how sharp are the highlights in the material.
  31597. * The bigger the value the sharper giving a more glossy feeling to the result.
  31598. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31599. */
  31600. specularPower: number;
  31601. private _useAlphaFromDiffuseTexture;
  31602. /**
  31603. * Does the transparency come from the diffuse texture alpha channel.
  31604. */
  31605. useAlphaFromDiffuseTexture: boolean;
  31606. private _useEmissiveAsIllumination;
  31607. /**
  31608. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31609. */
  31610. useEmissiveAsIllumination: boolean;
  31611. private _linkEmissiveWithDiffuse;
  31612. /**
  31613. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31614. * the emissive level when the final color is close to one.
  31615. */
  31616. linkEmissiveWithDiffuse: boolean;
  31617. private _useSpecularOverAlpha;
  31618. /**
  31619. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31620. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31621. */
  31622. useSpecularOverAlpha: boolean;
  31623. private _useReflectionOverAlpha;
  31624. /**
  31625. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31626. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31627. */
  31628. useReflectionOverAlpha: boolean;
  31629. private _disableLighting;
  31630. /**
  31631. * Does lights from the scene impacts this material.
  31632. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31633. */
  31634. disableLighting: boolean;
  31635. private _useObjectSpaceNormalMap;
  31636. /**
  31637. * Allows using an object space normal map (instead of tangent space).
  31638. */
  31639. useObjectSpaceNormalMap: boolean;
  31640. private _useParallax;
  31641. /**
  31642. * Is parallax enabled or not.
  31643. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31644. */
  31645. useParallax: boolean;
  31646. private _useParallaxOcclusion;
  31647. /**
  31648. * Is parallax occlusion enabled or not.
  31649. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31650. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31651. */
  31652. useParallaxOcclusion: boolean;
  31653. /**
  31654. * 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.
  31655. */
  31656. parallaxScaleBias: number;
  31657. private _roughness;
  31658. /**
  31659. * Helps to define how blurry the reflections should appears in the material.
  31660. */
  31661. roughness: number;
  31662. /**
  31663. * In case of refraction, define the value of the index of refraction.
  31664. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31665. */
  31666. indexOfRefraction: number;
  31667. /**
  31668. * Invert the refraction texture alongside the y axis.
  31669. * It can be useful with procedural textures or probe for instance.
  31670. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31671. */
  31672. invertRefractionY: boolean;
  31673. /**
  31674. * Defines the alpha limits in alpha test mode.
  31675. */
  31676. alphaCutOff: number;
  31677. private _useLightmapAsShadowmap;
  31678. /**
  31679. * In case of light mapping, define whether the map contains light or shadow informations.
  31680. */
  31681. useLightmapAsShadowmap: boolean;
  31682. private _diffuseFresnelParameters;
  31683. /**
  31684. * Define the diffuse fresnel parameters of the material.
  31685. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31686. */
  31687. diffuseFresnelParameters: FresnelParameters;
  31688. private _opacityFresnelParameters;
  31689. /**
  31690. * Define the opacity fresnel parameters of the material.
  31691. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31692. */
  31693. opacityFresnelParameters: FresnelParameters;
  31694. private _reflectionFresnelParameters;
  31695. /**
  31696. * Define the reflection fresnel parameters of the material.
  31697. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31698. */
  31699. reflectionFresnelParameters: FresnelParameters;
  31700. private _refractionFresnelParameters;
  31701. /**
  31702. * Define the refraction fresnel parameters of the material.
  31703. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31704. */
  31705. refractionFresnelParameters: FresnelParameters;
  31706. private _emissiveFresnelParameters;
  31707. /**
  31708. * Define the emissive fresnel parameters of the material.
  31709. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31710. */
  31711. emissiveFresnelParameters: FresnelParameters;
  31712. private _useReflectionFresnelFromSpecular;
  31713. /**
  31714. * If true automatically deducts the fresnels values from the material specularity.
  31715. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31716. */
  31717. useReflectionFresnelFromSpecular: boolean;
  31718. private _useGlossinessFromSpecularMapAlpha;
  31719. /**
  31720. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31721. */
  31722. useGlossinessFromSpecularMapAlpha: boolean;
  31723. private _maxSimultaneousLights;
  31724. /**
  31725. * Defines the maximum number of lights that can be used in the material
  31726. */
  31727. maxSimultaneousLights: number;
  31728. private _invertNormalMapX;
  31729. /**
  31730. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31731. */
  31732. invertNormalMapX: boolean;
  31733. private _invertNormalMapY;
  31734. /**
  31735. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31736. */
  31737. invertNormalMapY: boolean;
  31738. private _twoSidedLighting;
  31739. /**
  31740. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31741. */
  31742. twoSidedLighting: boolean;
  31743. /**
  31744. * Default configuration related to image processing available in the standard Material.
  31745. */
  31746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31747. /**
  31748. * Gets the image processing configuration used either in this material.
  31749. */
  31750. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31751. /**
  31752. * Sets the Default image processing configuration used either in the this material.
  31753. *
  31754. * If sets to null, the scene one is in use.
  31755. */
  31756. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31757. /**
  31758. * Keep track of the image processing observer to allow dispose and replace.
  31759. */
  31760. private _imageProcessingObserver;
  31761. /**
  31762. * Attaches a new image processing configuration to the Standard Material.
  31763. * @param configuration
  31764. */
  31765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31766. /**
  31767. * Gets wether the color curves effect is enabled.
  31768. */
  31769. get cameraColorCurvesEnabled(): boolean;
  31770. /**
  31771. * Sets wether the color curves effect is enabled.
  31772. */
  31773. set cameraColorCurvesEnabled(value: boolean);
  31774. /**
  31775. * Gets wether the color grading effect is enabled.
  31776. */
  31777. get cameraColorGradingEnabled(): boolean;
  31778. /**
  31779. * Gets wether the color grading effect is enabled.
  31780. */
  31781. set cameraColorGradingEnabled(value: boolean);
  31782. /**
  31783. * Gets wether tonemapping is enabled or not.
  31784. */
  31785. get cameraToneMappingEnabled(): boolean;
  31786. /**
  31787. * Sets wether tonemapping is enabled or not
  31788. */
  31789. set cameraToneMappingEnabled(value: boolean);
  31790. /**
  31791. * The camera exposure used on this material.
  31792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31793. * This corresponds to a photographic exposure.
  31794. */
  31795. get cameraExposure(): number;
  31796. /**
  31797. * The camera exposure used on this material.
  31798. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31799. * This corresponds to a photographic exposure.
  31800. */
  31801. set cameraExposure(value: number);
  31802. /**
  31803. * Gets The camera contrast used on this material.
  31804. */
  31805. get cameraContrast(): number;
  31806. /**
  31807. * Sets The camera contrast used on this material.
  31808. */
  31809. set cameraContrast(value: number);
  31810. /**
  31811. * Gets the Color Grading 2D Lookup Texture.
  31812. */
  31813. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31814. /**
  31815. * Sets the Color Grading 2D Lookup Texture.
  31816. */
  31817. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31818. /**
  31819. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31820. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31821. * 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;
  31822. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31823. */
  31824. get cameraColorCurves(): Nullable<ColorCurves>;
  31825. /**
  31826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31828. * 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;
  31829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31830. */
  31831. set cameraColorCurves(value: Nullable<ColorCurves>);
  31832. /**
  31833. * Can this material render to several textures at once
  31834. */
  31835. get canRenderToMRT(): boolean;
  31836. /**
  31837. * Defines the detail map parameters for the material.
  31838. */
  31839. readonly detailMap: DetailMapConfiguration;
  31840. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31841. protected _worldViewProjectionMatrix: Matrix;
  31842. protected _globalAmbientColor: Color3;
  31843. protected _useLogarithmicDepth: boolean;
  31844. protected _rebuildInParallel: boolean;
  31845. /**
  31846. * Instantiates a new standard material.
  31847. * This is the default material used in Babylon. It is the best trade off between quality
  31848. * and performances.
  31849. * @see https://doc.babylonjs.com/babylon101/materials
  31850. * @param name Define the name of the material in the scene
  31851. * @param scene Define the scene the material belong to
  31852. */
  31853. constructor(name: string, scene: Scene);
  31854. /**
  31855. * Gets a boolean indicating that current material needs to register RTT
  31856. */
  31857. get hasRenderTargetTextures(): boolean;
  31858. /**
  31859. * Gets the current class name of the material e.g. "StandardMaterial"
  31860. * Mainly use in serialization.
  31861. * @returns the class name
  31862. */
  31863. getClassName(): string;
  31864. /**
  31865. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31866. * You can try switching to logarithmic depth.
  31867. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31868. */
  31869. get useLogarithmicDepth(): boolean;
  31870. set useLogarithmicDepth(value: boolean);
  31871. /**
  31872. * Specifies if the material will require alpha blending
  31873. * @returns a boolean specifying if alpha blending is needed
  31874. */
  31875. needAlphaBlending(): boolean;
  31876. /**
  31877. * Specifies if this material should be rendered in alpha test mode
  31878. * @returns a boolean specifying if an alpha test is needed.
  31879. */
  31880. needAlphaTesting(): boolean;
  31881. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31882. /**
  31883. * Get the texture used for alpha test purpose.
  31884. * @returns the diffuse texture in case of the standard material.
  31885. */
  31886. getAlphaTestTexture(): Nullable<BaseTexture>;
  31887. /**
  31888. * Get if the submesh is ready to be used and all its information available.
  31889. * Child classes can use it to update shaders
  31890. * @param mesh defines the mesh to check
  31891. * @param subMesh defines which submesh to check
  31892. * @param useInstances specifies that instances should be used
  31893. * @returns a boolean indicating that the submesh is ready or not
  31894. */
  31895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31896. /**
  31897. * Builds the material UBO layouts.
  31898. * Used internally during the effect preparation.
  31899. */
  31900. buildUniformLayout(): void;
  31901. /**
  31902. * Unbinds the material from the mesh
  31903. */
  31904. unbind(): void;
  31905. /**
  31906. * Binds the submesh to this material by preparing the effect and shader to draw
  31907. * @param world defines the world transformation matrix
  31908. * @param mesh defines the mesh containing the submesh
  31909. * @param subMesh defines the submesh to bind the material to
  31910. */
  31911. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31912. /**
  31913. * Get the list of animatables in the material.
  31914. * @returns the list of animatables object used in the material
  31915. */
  31916. getAnimatables(): IAnimatable[];
  31917. /**
  31918. * Gets the active textures from the material
  31919. * @returns an array of textures
  31920. */
  31921. getActiveTextures(): BaseTexture[];
  31922. /**
  31923. * Specifies if the material uses a texture
  31924. * @param texture defines the texture to check against the material
  31925. * @returns a boolean specifying if the material uses the texture
  31926. */
  31927. hasTexture(texture: BaseTexture): boolean;
  31928. /**
  31929. * Disposes the material
  31930. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31931. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31932. */
  31933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31934. /**
  31935. * Makes a duplicate of the material, and gives it a new name
  31936. * @param name defines the new name for the duplicated material
  31937. * @returns the cloned material
  31938. */
  31939. clone(name: string): StandardMaterial;
  31940. /**
  31941. * Serializes this material in a JSON representation
  31942. * @returns the serialized material object
  31943. */
  31944. serialize(): any;
  31945. /**
  31946. * Creates a standard material from parsed material data
  31947. * @param source defines the JSON representation of the material
  31948. * @param scene defines the hosting scene
  31949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31950. * @returns a new standard material
  31951. */
  31952. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31953. /**
  31954. * Are diffuse textures enabled in the application.
  31955. */
  31956. static get DiffuseTextureEnabled(): boolean;
  31957. static set DiffuseTextureEnabled(value: boolean);
  31958. /**
  31959. * Are detail textures enabled in the application.
  31960. */
  31961. static get DetailTextureEnabled(): boolean;
  31962. static set DetailTextureEnabled(value: boolean);
  31963. /**
  31964. * Are ambient textures enabled in the application.
  31965. */
  31966. static get AmbientTextureEnabled(): boolean;
  31967. static set AmbientTextureEnabled(value: boolean);
  31968. /**
  31969. * Are opacity textures enabled in the application.
  31970. */
  31971. static get OpacityTextureEnabled(): boolean;
  31972. static set OpacityTextureEnabled(value: boolean);
  31973. /**
  31974. * Are reflection textures enabled in the application.
  31975. */
  31976. static get ReflectionTextureEnabled(): boolean;
  31977. static set ReflectionTextureEnabled(value: boolean);
  31978. /**
  31979. * Are emissive textures enabled in the application.
  31980. */
  31981. static get EmissiveTextureEnabled(): boolean;
  31982. static set EmissiveTextureEnabled(value: boolean);
  31983. /**
  31984. * Are specular textures enabled in the application.
  31985. */
  31986. static get SpecularTextureEnabled(): boolean;
  31987. static set SpecularTextureEnabled(value: boolean);
  31988. /**
  31989. * Are bump textures enabled in the application.
  31990. */
  31991. static get BumpTextureEnabled(): boolean;
  31992. static set BumpTextureEnabled(value: boolean);
  31993. /**
  31994. * Are lightmap textures enabled in the application.
  31995. */
  31996. static get LightmapTextureEnabled(): boolean;
  31997. static set LightmapTextureEnabled(value: boolean);
  31998. /**
  31999. * Are refraction textures enabled in the application.
  32000. */
  32001. static get RefractionTextureEnabled(): boolean;
  32002. static set RefractionTextureEnabled(value: boolean);
  32003. /**
  32004. * Are color grading textures enabled in the application.
  32005. */
  32006. static get ColorGradingTextureEnabled(): boolean;
  32007. static set ColorGradingTextureEnabled(value: boolean);
  32008. /**
  32009. * Are fresnels enabled in the application.
  32010. */
  32011. static get FresnelEnabled(): boolean;
  32012. static set FresnelEnabled(value: boolean);
  32013. }
  32014. }
  32015. declare module "babylonjs/Particles/solidParticleSystem" {
  32016. import { Nullable } from "babylonjs/types";
  32017. import { Mesh } from "babylonjs/Meshes/mesh";
  32018. import { Scene, IDisposable } from "babylonjs/scene";
  32019. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32020. import { Material } from "babylonjs/Materials/material";
  32021. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32022. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32023. /**
  32024. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32025. *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.
  32026. * The SPS is also a particle system. It provides some methods to manage the particles.
  32027. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32028. *
  32029. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32030. */
  32031. export class SolidParticleSystem implements IDisposable {
  32032. /**
  32033. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32034. * Example : var p = SPS.particles[i];
  32035. */
  32036. particles: SolidParticle[];
  32037. /**
  32038. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32039. */
  32040. nbParticles: number;
  32041. /**
  32042. * If the particles must ever face the camera (default false). Useful for planar particles.
  32043. */
  32044. billboard: boolean;
  32045. /**
  32046. * Recompute normals when adding a shape
  32047. */
  32048. recomputeNormals: boolean;
  32049. /**
  32050. * This a counter ofr your own usage. It's not set by any SPS functions.
  32051. */
  32052. counter: number;
  32053. /**
  32054. * The SPS name. This name is also given to the underlying mesh.
  32055. */
  32056. name: string;
  32057. /**
  32058. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32059. */
  32060. mesh: Mesh;
  32061. /**
  32062. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32063. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32064. */
  32065. vars: any;
  32066. /**
  32067. * This array is populated when the SPS is set as 'pickable'.
  32068. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32069. * Each element of this array is an object `{idx: int, faceId: int}`.
  32070. * `idx` is the picked particle index in the `SPS.particles` array
  32071. * `faceId` is the picked face index counted within this particle.
  32072. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32073. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32074. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32075. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32076. */
  32077. pickedParticles: {
  32078. idx: number;
  32079. faceId: number;
  32080. }[];
  32081. /**
  32082. * This array is populated when the SPS is set as 'pickable'
  32083. * Each key of this array is a submesh index.
  32084. * Each element of this array is a second array defined like this :
  32085. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32086. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32087. * `idx` is the picked particle index in the `SPS.particles` array
  32088. * `faceId` is the picked face index counted within this particle.
  32089. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32090. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32091. */
  32092. pickedBySubMesh: {
  32093. idx: number;
  32094. faceId: number;
  32095. }[][];
  32096. /**
  32097. * This array is populated when `enableDepthSort` is set to true.
  32098. * Each element of this array is an instance of the class DepthSortedParticle.
  32099. */
  32100. depthSortedParticles: DepthSortedParticle[];
  32101. /**
  32102. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32103. * @hidden
  32104. */
  32105. _bSphereOnly: boolean;
  32106. /**
  32107. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32108. * @hidden
  32109. */
  32110. _bSphereRadiusFactor: number;
  32111. private _scene;
  32112. private _positions;
  32113. private _indices;
  32114. private _normals;
  32115. private _colors;
  32116. private _uvs;
  32117. private _indices32;
  32118. private _positions32;
  32119. private _normals32;
  32120. private _fixedNormal32;
  32121. private _colors32;
  32122. private _uvs32;
  32123. private _index;
  32124. private _updatable;
  32125. private _pickable;
  32126. private _isVisibilityBoxLocked;
  32127. private _alwaysVisible;
  32128. private _depthSort;
  32129. private _expandable;
  32130. private _shapeCounter;
  32131. private _copy;
  32132. private _color;
  32133. private _computeParticleColor;
  32134. private _computeParticleTexture;
  32135. private _computeParticleRotation;
  32136. private _computeParticleVertex;
  32137. private _computeBoundingBox;
  32138. private _depthSortParticles;
  32139. private _camera;
  32140. private _mustUnrotateFixedNormals;
  32141. private _particlesIntersect;
  32142. private _needs32Bits;
  32143. private _isNotBuilt;
  32144. private _lastParticleId;
  32145. private _idxOfId;
  32146. private _multimaterialEnabled;
  32147. private _useModelMaterial;
  32148. private _indicesByMaterial;
  32149. private _materialIndexes;
  32150. private _depthSortFunction;
  32151. private _materialSortFunction;
  32152. private _materials;
  32153. private _multimaterial;
  32154. private _materialIndexesById;
  32155. private _defaultMaterial;
  32156. private _autoUpdateSubMeshes;
  32157. private _tmpVertex;
  32158. /**
  32159. * Creates a SPS (Solid Particle System) object.
  32160. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32161. * @param scene (Scene) is the scene in which the SPS is added.
  32162. * @param options defines the options of the sps e.g.
  32163. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32164. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32165. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32166. * * 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.
  32167. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32168. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32169. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32170. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32171. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32172. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32173. */
  32174. constructor(name: string, scene: Scene, options?: {
  32175. updatable?: boolean;
  32176. isPickable?: boolean;
  32177. enableDepthSort?: boolean;
  32178. particleIntersection?: boolean;
  32179. boundingSphereOnly?: boolean;
  32180. bSphereRadiusFactor?: number;
  32181. expandable?: boolean;
  32182. useModelMaterial?: boolean;
  32183. enableMultiMaterial?: boolean;
  32184. });
  32185. /**
  32186. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32187. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32188. * @returns the created mesh
  32189. */
  32190. buildMesh(): Mesh;
  32191. /**
  32192. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32193. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32194. * Thus the particles generated from `digest()` have their property `position` set yet.
  32195. * @param mesh ( Mesh ) is the mesh to be digested
  32196. * @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
  32197. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32198. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32199. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32200. * @returns the current SPS
  32201. */
  32202. digest(mesh: Mesh, options?: {
  32203. facetNb?: number;
  32204. number?: number;
  32205. delta?: number;
  32206. storage?: [];
  32207. }): SolidParticleSystem;
  32208. /**
  32209. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32210. * @hidden
  32211. */
  32212. private _unrotateFixedNormals;
  32213. /**
  32214. * Resets the temporary working copy particle
  32215. * @hidden
  32216. */
  32217. private _resetCopy;
  32218. /**
  32219. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32220. * @param p the current index in the positions array to be updated
  32221. * @param ind the current index in the indices array
  32222. * @param shape a Vector3 array, the shape geometry
  32223. * @param positions the positions array to be updated
  32224. * @param meshInd the shape indices array
  32225. * @param indices the indices array to be updated
  32226. * @param meshUV the shape uv array
  32227. * @param uvs the uv array to be updated
  32228. * @param meshCol the shape color array
  32229. * @param colors the color array to be updated
  32230. * @param meshNor the shape normals array
  32231. * @param normals the normals array to be updated
  32232. * @param idx the particle index
  32233. * @param idxInShape the particle index in its shape
  32234. * @param options the addShape() method passed options
  32235. * @model the particle model
  32236. * @hidden
  32237. */
  32238. private _meshBuilder;
  32239. /**
  32240. * Returns a shape Vector3 array from positions float array
  32241. * @param positions float array
  32242. * @returns a vector3 array
  32243. * @hidden
  32244. */
  32245. private _posToShape;
  32246. /**
  32247. * Returns a shapeUV array from a float uvs (array deep copy)
  32248. * @param uvs as a float array
  32249. * @returns a shapeUV array
  32250. * @hidden
  32251. */
  32252. private _uvsToShapeUV;
  32253. /**
  32254. * Adds a new particle object in the particles array
  32255. * @param idx particle index in particles array
  32256. * @param id particle id
  32257. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32258. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32259. * @param model particle ModelShape object
  32260. * @param shapeId model shape identifier
  32261. * @param idxInShape index of the particle in the current model
  32262. * @param bInfo model bounding info object
  32263. * @param storage target storage array, if any
  32264. * @hidden
  32265. */
  32266. private _addParticle;
  32267. /**
  32268. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32269. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32270. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32271. * @param nb (positive integer) the number of particles to be created from this model
  32272. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32273. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32274. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32275. * @returns the number of shapes in the system
  32276. */
  32277. addShape(mesh: Mesh, nb: number, options?: {
  32278. positionFunction?: any;
  32279. vertexFunction?: any;
  32280. storage?: [];
  32281. }): number;
  32282. /**
  32283. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32284. * @hidden
  32285. */
  32286. private _rebuildParticle;
  32287. /**
  32288. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32289. * @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.
  32290. * @returns the SPS.
  32291. */
  32292. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32293. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32294. * Returns an array with the removed particles.
  32295. * 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.
  32296. * The SPS can't be empty so at least one particle needs to remain in place.
  32297. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32298. * @param start index of the first particle to remove
  32299. * @param end index of the last particle to remove (included)
  32300. * @returns an array populated with the removed particles
  32301. */
  32302. removeParticles(start: number, end: number): SolidParticle[];
  32303. /**
  32304. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32305. * @param solidParticleArray an array populated with Solid Particles objects
  32306. * @returns the SPS
  32307. */
  32308. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32309. /**
  32310. * Creates a new particle and modifies the SPS mesh geometry :
  32311. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32312. * - calls _addParticle() to populate the particle array
  32313. * factorized code from addShape() and insertParticlesFromArray()
  32314. * @param idx particle index in the particles array
  32315. * @param i particle index in its shape
  32316. * @param modelShape particle ModelShape object
  32317. * @param shape shape vertex array
  32318. * @param meshInd shape indices array
  32319. * @param meshUV shape uv array
  32320. * @param meshCol shape color array
  32321. * @param meshNor shape normals array
  32322. * @param bbInfo shape bounding info
  32323. * @param storage target particle storage
  32324. * @options addShape() passed options
  32325. * @hidden
  32326. */
  32327. private _insertNewParticle;
  32328. /**
  32329. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32330. * This method calls `updateParticle()` for each particle of the SPS.
  32331. * For an animated SPS, it is usually called within the render loop.
  32332. * 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.
  32333. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32334. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32335. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32336. * @returns the SPS.
  32337. */
  32338. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32339. /**
  32340. * Disposes the SPS.
  32341. */
  32342. dispose(): void;
  32343. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32344. * idx is the particle index in the SPS
  32345. * faceId is the picked face index counted within this particle.
  32346. * Returns null if the pickInfo can't identify a picked particle.
  32347. * @param pickingInfo (PickingInfo object)
  32348. * @returns {idx: number, faceId: number} or null
  32349. */
  32350. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32351. idx: number;
  32352. faceId: number;
  32353. }>;
  32354. /**
  32355. * Returns a SolidParticle object from its identifier : particle.id
  32356. * @param id (integer) the particle Id
  32357. * @returns the searched particle or null if not found in the SPS.
  32358. */
  32359. getParticleById(id: number): Nullable<SolidParticle>;
  32360. /**
  32361. * Returns a new array populated with the particles having the passed shapeId.
  32362. * @param shapeId (integer) the shape identifier
  32363. * @returns a new solid particle array
  32364. */
  32365. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32366. /**
  32367. * Populates the passed array "ref" with the particles having the passed shapeId.
  32368. * @param shapeId the shape identifier
  32369. * @returns the SPS
  32370. * @param ref
  32371. */
  32372. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32373. /**
  32374. * Computes the required SubMeshes according the materials assigned to the particles.
  32375. * @returns the solid particle system.
  32376. * Does nothing if called before the SPS mesh is built.
  32377. */
  32378. computeSubMeshes(): SolidParticleSystem;
  32379. /**
  32380. * Sorts the solid particles by material when MultiMaterial is enabled.
  32381. * Updates the indices32 array.
  32382. * Updates the indicesByMaterial array.
  32383. * Updates the mesh indices array.
  32384. * @returns the SPS
  32385. * @hidden
  32386. */
  32387. private _sortParticlesByMaterial;
  32388. /**
  32389. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32390. * @hidden
  32391. */
  32392. private _setMaterialIndexesById;
  32393. /**
  32394. * Returns an array with unique values of Materials from the passed array
  32395. * @param array the material array to be checked and filtered
  32396. * @hidden
  32397. */
  32398. private _filterUniqueMaterialId;
  32399. /**
  32400. * Sets a new Standard Material as _defaultMaterial if not already set.
  32401. * @hidden
  32402. */
  32403. private _setDefaultMaterial;
  32404. /**
  32405. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32406. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32407. * @returns the SPS.
  32408. */
  32409. refreshVisibleSize(): SolidParticleSystem;
  32410. /**
  32411. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32412. * @param size the size (float) of the visibility box
  32413. * note : this doesn't lock the SPS mesh bounding box.
  32414. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32415. */
  32416. setVisibilityBox(size: number): void;
  32417. /**
  32418. * Gets whether the SPS as always visible or not
  32419. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32420. */
  32421. get isAlwaysVisible(): boolean;
  32422. /**
  32423. * Sets the SPS as always visible or not
  32424. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32425. */
  32426. set isAlwaysVisible(val: boolean);
  32427. /**
  32428. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32429. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32430. */
  32431. set isVisibilityBoxLocked(val: boolean);
  32432. /**
  32433. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32434. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32435. */
  32436. get isVisibilityBoxLocked(): boolean;
  32437. /**
  32438. * Tells to `setParticles()` to compute the particle rotations or not.
  32439. * Default value : true. The SPS is faster when it's set to false.
  32440. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32441. */
  32442. set computeParticleRotation(val: boolean);
  32443. /**
  32444. * Tells to `setParticles()` to compute the particle colors or not.
  32445. * Default value : true. The SPS is faster when it's set to false.
  32446. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32447. */
  32448. set computeParticleColor(val: boolean);
  32449. set computeParticleTexture(val: boolean);
  32450. /**
  32451. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32452. * Default value : false. The SPS is faster when it's set to false.
  32453. * Note : the particle custom vertex positions aren't stored values.
  32454. */
  32455. set computeParticleVertex(val: boolean);
  32456. /**
  32457. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32458. */
  32459. set computeBoundingBox(val: boolean);
  32460. /**
  32461. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32462. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32463. * Default : `true`
  32464. */
  32465. set depthSortParticles(val: boolean);
  32466. /**
  32467. * Gets if `setParticles()` computes the particle rotations or not.
  32468. * Default value : true. The SPS is faster when it's set to false.
  32469. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32470. */
  32471. get computeParticleRotation(): boolean;
  32472. /**
  32473. * Gets if `setParticles()` computes the particle colors or not.
  32474. * Default value : true. The SPS is faster when it's set to false.
  32475. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32476. */
  32477. get computeParticleColor(): boolean;
  32478. /**
  32479. * Gets if `setParticles()` computes the particle textures or not.
  32480. * Default value : true. The SPS is faster when it's set to false.
  32481. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32482. */
  32483. get computeParticleTexture(): boolean;
  32484. /**
  32485. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32486. * Default value : false. The SPS is faster when it's set to false.
  32487. * Note : the particle custom vertex positions aren't stored values.
  32488. */
  32489. get computeParticleVertex(): boolean;
  32490. /**
  32491. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32492. */
  32493. get computeBoundingBox(): boolean;
  32494. /**
  32495. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32496. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32497. * Default : `true`
  32498. */
  32499. get depthSortParticles(): boolean;
  32500. /**
  32501. * Gets if the SPS is created as expandable at construction time.
  32502. * Default : `false`
  32503. */
  32504. get expandable(): boolean;
  32505. /**
  32506. * Gets if the SPS supports the Multi Materials
  32507. */
  32508. get multimaterialEnabled(): boolean;
  32509. /**
  32510. * Gets if the SPS uses the model materials for its own multimaterial.
  32511. */
  32512. get useModelMaterial(): boolean;
  32513. /**
  32514. * The SPS used material array.
  32515. */
  32516. get materials(): Material[];
  32517. /**
  32518. * Sets the SPS MultiMaterial from the passed materials.
  32519. * Note : the passed array is internally copied and not used then by reference.
  32520. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32521. */
  32522. setMultiMaterial(materials: Material[]): void;
  32523. /**
  32524. * The SPS computed multimaterial object
  32525. */
  32526. get multimaterial(): MultiMaterial;
  32527. set multimaterial(mm: MultiMaterial);
  32528. /**
  32529. * If the subMeshes must be updated on the next call to setParticles()
  32530. */
  32531. get autoUpdateSubMeshes(): boolean;
  32532. set autoUpdateSubMeshes(val: boolean);
  32533. /**
  32534. * This function does nothing. It may be overwritten to set all the particle first values.
  32535. * The SPS doesn't call this function, you may have to call it by your own.
  32536. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32537. */
  32538. initParticles(): void;
  32539. /**
  32540. * This function does nothing. It may be overwritten to recycle a particle.
  32541. * The SPS doesn't call this function, you may have to call it by your own.
  32542. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32543. * @param particle The particle to recycle
  32544. * @returns the recycled particle
  32545. */
  32546. recycleParticle(particle: SolidParticle): SolidParticle;
  32547. /**
  32548. * Updates a particle : this function should be overwritten by the user.
  32549. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32550. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32551. * @example : just set a particle position or velocity and recycle conditions
  32552. * @param particle The particle to update
  32553. * @returns the updated particle
  32554. */
  32555. updateParticle(particle: SolidParticle): SolidParticle;
  32556. /**
  32557. * Updates a vertex of a particle : it can be overwritten by the user.
  32558. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32559. * @param particle the current particle
  32560. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32561. * @param pt the index of the current vertex in the particle shape
  32562. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32563. * @example : just set a vertex particle position or color
  32564. * @returns the sps
  32565. */
  32566. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32567. /**
  32568. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32569. * This does nothing and may be overwritten by the user.
  32570. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32571. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32572. * @param update the boolean update value actually passed to setParticles()
  32573. */
  32574. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32575. /**
  32576. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32577. * This will be passed three parameters.
  32578. * This does nothing and may be overwritten by the user.
  32579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32581. * @param update the boolean update value actually passed to setParticles()
  32582. */
  32583. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32584. }
  32585. }
  32586. declare module "babylonjs/Particles/solidParticle" {
  32587. import { Nullable } from "babylonjs/types";
  32588. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32589. import { Color4 } from "babylonjs/Maths/math.color";
  32590. import { Mesh } from "babylonjs/Meshes/mesh";
  32591. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32592. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32593. import { Plane } from "babylonjs/Maths/math.plane";
  32594. import { Material } from "babylonjs/Materials/material";
  32595. /**
  32596. * Represents one particle of a solid particle system.
  32597. */
  32598. export class SolidParticle {
  32599. /**
  32600. * particle global index
  32601. */
  32602. idx: number;
  32603. /**
  32604. * particle identifier
  32605. */
  32606. id: number;
  32607. /**
  32608. * The color of the particle
  32609. */
  32610. color: Nullable<Color4>;
  32611. /**
  32612. * The world space position of the particle.
  32613. */
  32614. position: Vector3;
  32615. /**
  32616. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32617. */
  32618. rotation: Vector3;
  32619. /**
  32620. * The world space rotation quaternion of the particle.
  32621. */
  32622. rotationQuaternion: Nullable<Quaternion>;
  32623. /**
  32624. * The scaling of the particle.
  32625. */
  32626. scaling: Vector3;
  32627. /**
  32628. * The uvs of the particle.
  32629. */
  32630. uvs: Vector4;
  32631. /**
  32632. * The current speed of the particle.
  32633. */
  32634. velocity: Vector3;
  32635. /**
  32636. * The pivot point in the particle local space.
  32637. */
  32638. pivot: Vector3;
  32639. /**
  32640. * Must the particle be translated from its pivot point in its local space ?
  32641. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32642. * Default : false
  32643. */
  32644. translateFromPivot: boolean;
  32645. /**
  32646. * Is the particle active or not ?
  32647. */
  32648. alive: boolean;
  32649. /**
  32650. * Is the particle visible or not ?
  32651. */
  32652. isVisible: boolean;
  32653. /**
  32654. * Index of this particle in the global "positions" array (Internal use)
  32655. * @hidden
  32656. */
  32657. _pos: number;
  32658. /**
  32659. * @hidden Index of this particle in the global "indices" array (Internal use)
  32660. */
  32661. _ind: number;
  32662. /**
  32663. * @hidden ModelShape of this particle (Internal use)
  32664. */
  32665. _model: ModelShape;
  32666. /**
  32667. * ModelShape id of this particle
  32668. */
  32669. shapeId: number;
  32670. /**
  32671. * Index of the particle in its shape id
  32672. */
  32673. idxInShape: number;
  32674. /**
  32675. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32676. */
  32677. _modelBoundingInfo: BoundingInfo;
  32678. /**
  32679. * @hidden Particle BoundingInfo object (Internal use)
  32680. */
  32681. _boundingInfo: BoundingInfo;
  32682. /**
  32683. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32684. */
  32685. _sps: SolidParticleSystem;
  32686. /**
  32687. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32688. */
  32689. _stillInvisible: boolean;
  32690. /**
  32691. * @hidden Last computed particle rotation matrix
  32692. */
  32693. _rotationMatrix: number[];
  32694. /**
  32695. * Parent particle Id, if any.
  32696. * Default null.
  32697. */
  32698. parentId: Nullable<number>;
  32699. /**
  32700. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32701. */
  32702. materialIndex: Nullable<number>;
  32703. /**
  32704. * Custom object or properties.
  32705. */
  32706. props: Nullable<any>;
  32707. /**
  32708. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32709. * The possible values are :
  32710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32714. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32715. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32716. * */
  32717. cullingStrategy: number;
  32718. /**
  32719. * @hidden Internal global position in the SPS.
  32720. */
  32721. _globalPosition: Vector3;
  32722. /**
  32723. * Creates a Solid Particle object.
  32724. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32725. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32726. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32727. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32728. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32729. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32730. * @param shapeId (integer) is the model shape identifier in the SPS.
  32731. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32732. * @param sps defines the sps it is associated to
  32733. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32734. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32735. */
  32736. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32737. /**
  32738. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32739. * @param target the particle target
  32740. * @returns the current particle
  32741. */
  32742. copyToRef(target: SolidParticle): SolidParticle;
  32743. /**
  32744. * Legacy support, changed scale to scaling
  32745. */
  32746. get scale(): Vector3;
  32747. /**
  32748. * Legacy support, changed scale to scaling
  32749. */
  32750. set scale(scale: Vector3);
  32751. /**
  32752. * Legacy support, changed quaternion to rotationQuaternion
  32753. */
  32754. get quaternion(): Nullable<Quaternion>;
  32755. /**
  32756. * Legacy support, changed quaternion to rotationQuaternion
  32757. */
  32758. set quaternion(q: Nullable<Quaternion>);
  32759. /**
  32760. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32761. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32762. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32763. * @returns true if it intersects
  32764. */
  32765. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32766. /**
  32767. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32768. * A particle is in the frustum if its bounding box intersects the frustum
  32769. * @param frustumPlanes defines the frustum to test
  32770. * @returns true if the particle is in the frustum planes
  32771. */
  32772. isInFrustum(frustumPlanes: Plane[]): boolean;
  32773. /**
  32774. * get the rotation matrix of the particle
  32775. * @hidden
  32776. */
  32777. getRotationMatrix(m: Matrix): void;
  32778. }
  32779. /**
  32780. * Represents the shape of the model used by one particle of a solid particle system.
  32781. * SPS internal tool, don't use it manually.
  32782. */
  32783. export class ModelShape {
  32784. /**
  32785. * The shape id
  32786. * @hidden
  32787. */
  32788. shapeID: number;
  32789. /**
  32790. * flat array of model positions (internal use)
  32791. * @hidden
  32792. */
  32793. _shape: Vector3[];
  32794. /**
  32795. * flat array of model UVs (internal use)
  32796. * @hidden
  32797. */
  32798. _shapeUV: number[];
  32799. /**
  32800. * color array of the model
  32801. * @hidden
  32802. */
  32803. _shapeColors: number[];
  32804. /**
  32805. * indices array of the model
  32806. * @hidden
  32807. */
  32808. _indices: number[];
  32809. /**
  32810. * normals array of the model
  32811. * @hidden
  32812. */
  32813. _normals: number[];
  32814. /**
  32815. * length of the shape in the model indices array (internal use)
  32816. * @hidden
  32817. */
  32818. _indicesLength: number;
  32819. /**
  32820. * Custom position function (internal use)
  32821. * @hidden
  32822. */
  32823. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32824. /**
  32825. * Custom vertex function (internal use)
  32826. * @hidden
  32827. */
  32828. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32829. /**
  32830. * Model material (internal use)
  32831. * @hidden
  32832. */
  32833. _material: Nullable<Material>;
  32834. /**
  32835. * 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.
  32836. * SPS internal tool, don't use it manually.
  32837. * @hidden
  32838. */
  32839. 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>);
  32840. }
  32841. /**
  32842. * Represents a Depth Sorted Particle in the solid particle system.
  32843. * @hidden
  32844. */
  32845. export class DepthSortedParticle {
  32846. /**
  32847. * Particle index
  32848. */
  32849. idx: number;
  32850. /**
  32851. * Index of the particle in the "indices" array
  32852. */
  32853. ind: number;
  32854. /**
  32855. * Length of the particle shape in the "indices" array
  32856. */
  32857. indicesLength: number;
  32858. /**
  32859. * Squared distance from the particle to the camera
  32860. */
  32861. sqDistance: number;
  32862. /**
  32863. * Material index when used with MultiMaterials
  32864. */
  32865. materialIndex: number;
  32866. /**
  32867. * Creates a new sorted particle
  32868. * @param materialIndex
  32869. */
  32870. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32871. }
  32872. /**
  32873. * Represents a solid particle vertex
  32874. */
  32875. export class SolidParticleVertex {
  32876. /**
  32877. * Vertex position
  32878. */
  32879. position: Vector3;
  32880. /**
  32881. * Vertex color
  32882. */
  32883. color: Color4;
  32884. /**
  32885. * Vertex UV
  32886. */
  32887. uv: Vector2;
  32888. /**
  32889. * Creates a new solid particle vertex
  32890. */
  32891. constructor();
  32892. /** Vertex x coordinate */
  32893. get x(): number;
  32894. set x(val: number);
  32895. /** Vertex y coordinate */
  32896. get y(): number;
  32897. set y(val: number);
  32898. /** Vertex z coordinate */
  32899. get z(): number;
  32900. set z(val: number);
  32901. }
  32902. }
  32903. declare module "babylonjs/Collisions/meshCollisionData" {
  32904. import { Collider } from "babylonjs/Collisions/collider";
  32905. import { Vector3 } from "babylonjs/Maths/math.vector";
  32906. import { Nullable } from "babylonjs/types";
  32907. import { Observer } from "babylonjs/Misc/observable";
  32908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32909. /**
  32910. * @hidden
  32911. */
  32912. export class _MeshCollisionData {
  32913. _checkCollisions: boolean;
  32914. _collisionMask: number;
  32915. _collisionGroup: number;
  32916. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32917. _collider: Nullable<Collider>;
  32918. _oldPositionForCollisions: Vector3;
  32919. _diffPositionForCollisions: Vector3;
  32920. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32921. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32922. }
  32923. }
  32924. declare module "babylonjs/Meshes/abstractMesh" {
  32925. import { Observable } from "babylonjs/Misc/observable";
  32926. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32927. import { Camera } from "babylonjs/Cameras/camera";
  32928. import { Scene, IDisposable } from "babylonjs/scene";
  32929. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32930. import { Node } from "babylonjs/node";
  32931. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32933. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32934. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32935. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32936. import { Material } from "babylonjs/Materials/material";
  32937. import { Light } from "babylonjs/Lights/light";
  32938. import { Skeleton } from "babylonjs/Bones/skeleton";
  32939. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32940. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32941. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32942. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32943. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32944. import { Plane } from "babylonjs/Maths/math.plane";
  32945. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32946. import { Ray } from "babylonjs/Culling/ray";
  32947. import { Collider } from "babylonjs/Collisions/collider";
  32948. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32949. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32950. /** @hidden */
  32951. class _FacetDataStorage {
  32952. facetPositions: Vector3[];
  32953. facetNormals: Vector3[];
  32954. facetPartitioning: number[][];
  32955. facetNb: number;
  32956. partitioningSubdivisions: number;
  32957. partitioningBBoxRatio: number;
  32958. facetDataEnabled: boolean;
  32959. facetParameters: any;
  32960. bbSize: Vector3;
  32961. subDiv: {
  32962. max: number;
  32963. X: number;
  32964. Y: number;
  32965. Z: number;
  32966. };
  32967. facetDepthSort: boolean;
  32968. facetDepthSortEnabled: boolean;
  32969. depthSortedIndices: IndicesArray;
  32970. depthSortedFacets: {
  32971. ind: number;
  32972. sqDistance: number;
  32973. }[];
  32974. facetDepthSortFunction: (f1: {
  32975. ind: number;
  32976. sqDistance: number;
  32977. }, f2: {
  32978. ind: number;
  32979. sqDistance: number;
  32980. }) => number;
  32981. facetDepthSortFrom: Vector3;
  32982. facetDepthSortOrigin: Vector3;
  32983. invertedMatrix: Matrix;
  32984. }
  32985. /**
  32986. * @hidden
  32987. **/
  32988. class _InternalAbstractMeshDataInfo {
  32989. _hasVertexAlpha: boolean;
  32990. _useVertexColors: boolean;
  32991. _numBoneInfluencers: number;
  32992. _applyFog: boolean;
  32993. _receiveShadows: boolean;
  32994. _facetData: _FacetDataStorage;
  32995. _visibility: number;
  32996. _skeleton: Nullable<Skeleton>;
  32997. _layerMask: number;
  32998. _computeBonesUsingShaders: boolean;
  32999. _isActive: boolean;
  33000. _onlyForInstances: boolean;
  33001. _isActiveIntermediate: boolean;
  33002. _onlyForInstancesIntermediate: boolean;
  33003. _actAsRegularMesh: boolean;
  33004. }
  33005. /**
  33006. * Class used to store all common mesh properties
  33007. */
  33008. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33009. /** No occlusion */
  33010. static OCCLUSION_TYPE_NONE: number;
  33011. /** Occlusion set to optimisitic */
  33012. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33013. /** Occlusion set to strict */
  33014. static OCCLUSION_TYPE_STRICT: number;
  33015. /** Use an accurante occlusion algorithm */
  33016. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33017. /** Use a conservative occlusion algorithm */
  33018. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33019. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33020. * Test order :
  33021. * Is the bounding sphere outside the frustum ?
  33022. * If not, are the bounding box vertices outside the frustum ?
  33023. * It not, then the cullable object is in the frustum.
  33024. */
  33025. static readonly CULLINGSTRATEGY_STANDARD: number;
  33026. /** Culling strategy : Bounding Sphere Only.
  33027. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33028. * It's also less accurate than the standard because some not visible objects can still be selected.
  33029. * Test : is the bounding sphere outside the frustum ?
  33030. * If not, then the cullable object is in the frustum.
  33031. */
  33032. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33033. /** Culling strategy : Optimistic Inclusion.
  33034. * This in an inclusion test first, then the standard exclusion test.
  33035. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33036. * 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.
  33037. * Anyway, it's as accurate as the standard strategy.
  33038. * Test :
  33039. * Is the cullable object bounding sphere center in the frustum ?
  33040. * If not, apply the default culling strategy.
  33041. */
  33042. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33043. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33044. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33045. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33046. * 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.
  33047. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33048. * Test :
  33049. * Is the cullable object bounding sphere center in the frustum ?
  33050. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33051. */
  33052. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33053. /**
  33054. * No billboard
  33055. */
  33056. static get BILLBOARDMODE_NONE(): number;
  33057. /** Billboard on X axis */
  33058. static get BILLBOARDMODE_X(): number;
  33059. /** Billboard on Y axis */
  33060. static get BILLBOARDMODE_Y(): number;
  33061. /** Billboard on Z axis */
  33062. static get BILLBOARDMODE_Z(): number;
  33063. /** Billboard on all axes */
  33064. static get BILLBOARDMODE_ALL(): number;
  33065. /** Billboard on using position instead of orientation */
  33066. static get BILLBOARDMODE_USE_POSITION(): number;
  33067. /** @hidden */
  33068. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33069. /**
  33070. * The culling strategy to use to check whether the mesh must be rendered or not.
  33071. * This value can be changed at any time and will be used on the next render mesh selection.
  33072. * The possible values are :
  33073. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33074. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33075. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33077. * Please read each static variable documentation to get details about the culling process.
  33078. * */
  33079. cullingStrategy: number;
  33080. /**
  33081. * Gets the number of facets in the mesh
  33082. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33083. */
  33084. get facetNb(): number;
  33085. /**
  33086. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33087. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33088. */
  33089. get partitioningSubdivisions(): number;
  33090. set partitioningSubdivisions(nb: number);
  33091. /**
  33092. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33093. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33095. */
  33096. get partitioningBBoxRatio(): number;
  33097. set partitioningBBoxRatio(ratio: number);
  33098. /**
  33099. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33100. * Works only for updatable meshes.
  33101. * Doesn't work with multi-materials
  33102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33103. */
  33104. get mustDepthSortFacets(): boolean;
  33105. set mustDepthSortFacets(sort: boolean);
  33106. /**
  33107. * The location (Vector3) where the facet depth sort must be computed from.
  33108. * By default, the active camera position.
  33109. * Used only when facet depth sort is enabled
  33110. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33111. */
  33112. get facetDepthSortFrom(): Vector3;
  33113. set facetDepthSortFrom(location: Vector3);
  33114. /**
  33115. * gets a boolean indicating if facetData is enabled
  33116. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33117. */
  33118. get isFacetDataEnabled(): boolean;
  33119. /** @hidden */
  33120. _updateNonUniformScalingState(value: boolean): boolean;
  33121. /**
  33122. * An event triggered when this mesh collides with another one
  33123. */
  33124. onCollideObservable: Observable<AbstractMesh>;
  33125. /** Set a function to call when this mesh collides with another one */
  33126. set onCollide(callback: () => void);
  33127. /**
  33128. * An event triggered when the collision's position changes
  33129. */
  33130. onCollisionPositionChangeObservable: Observable<Vector3>;
  33131. /** Set a function to call when the collision's position changes */
  33132. set onCollisionPositionChange(callback: () => void);
  33133. /**
  33134. * An event triggered when material is changed
  33135. */
  33136. onMaterialChangedObservable: Observable<AbstractMesh>;
  33137. /**
  33138. * Gets or sets the orientation for POV movement & rotation
  33139. */
  33140. definedFacingForward: boolean;
  33141. /** @hidden */
  33142. _occlusionQuery: Nullable<WebGLQuery>;
  33143. /** @hidden */
  33144. _renderingGroup: Nullable<RenderingGroup>;
  33145. /**
  33146. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33147. */
  33148. get visibility(): number;
  33149. /**
  33150. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33151. */
  33152. set visibility(value: number);
  33153. /** Gets or sets the alpha index used to sort transparent meshes
  33154. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33155. */
  33156. alphaIndex: number;
  33157. /**
  33158. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33159. */
  33160. isVisible: boolean;
  33161. /**
  33162. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33163. */
  33164. isPickable: boolean;
  33165. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33166. showSubMeshesBoundingBox: boolean;
  33167. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33168. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33169. */
  33170. isBlocker: boolean;
  33171. /**
  33172. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33173. */
  33174. enablePointerMoveEvents: boolean;
  33175. /**
  33176. * Specifies the rendering group id for this mesh (0 by default)
  33177. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33178. */
  33179. renderingGroupId: number;
  33180. private _material;
  33181. /** Gets or sets current material */
  33182. get material(): Nullable<Material>;
  33183. set material(value: Nullable<Material>);
  33184. /**
  33185. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33186. * @see https://doc.babylonjs.com/babylon101/shadows
  33187. */
  33188. get receiveShadows(): boolean;
  33189. set receiveShadows(value: boolean);
  33190. /** Defines color to use when rendering outline */
  33191. outlineColor: Color3;
  33192. /** Define width to use when rendering outline */
  33193. outlineWidth: number;
  33194. /** Defines color to use when rendering overlay */
  33195. overlayColor: Color3;
  33196. /** Defines alpha to use when rendering overlay */
  33197. overlayAlpha: number;
  33198. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33199. get hasVertexAlpha(): boolean;
  33200. set hasVertexAlpha(value: boolean);
  33201. /** 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) */
  33202. get useVertexColors(): boolean;
  33203. set useVertexColors(value: boolean);
  33204. /**
  33205. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33206. */
  33207. get computeBonesUsingShaders(): boolean;
  33208. set computeBonesUsingShaders(value: boolean);
  33209. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33210. get numBoneInfluencers(): number;
  33211. set numBoneInfluencers(value: number);
  33212. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33213. get applyFog(): boolean;
  33214. set applyFog(value: boolean);
  33215. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33216. useOctreeForRenderingSelection: boolean;
  33217. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33218. useOctreeForPicking: boolean;
  33219. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33220. useOctreeForCollisions: boolean;
  33221. /**
  33222. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33223. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33224. */
  33225. get layerMask(): number;
  33226. set layerMask(value: number);
  33227. /**
  33228. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33229. */
  33230. alwaysSelectAsActiveMesh: boolean;
  33231. /**
  33232. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33233. */
  33234. doNotSyncBoundingInfo: boolean;
  33235. /**
  33236. * Gets or sets the current action manager
  33237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33238. */
  33239. actionManager: Nullable<AbstractActionManager>;
  33240. private _meshCollisionData;
  33241. /**
  33242. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33243. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33244. */
  33245. ellipsoid: Vector3;
  33246. /**
  33247. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33248. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33249. */
  33250. ellipsoidOffset: Vector3;
  33251. /**
  33252. * Gets or sets a collision mask used to mask collisions (default is -1).
  33253. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33254. */
  33255. get collisionMask(): number;
  33256. set collisionMask(mask: number);
  33257. /**
  33258. * Gets or sets the current collision group mask (-1 by default).
  33259. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33260. */
  33261. get collisionGroup(): number;
  33262. set collisionGroup(mask: number);
  33263. /**
  33264. * Gets or sets current surrounding meshes (null by default).
  33265. *
  33266. * By default collision detection is tested against every mesh in the scene.
  33267. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33268. * meshes will be tested for the collision.
  33269. *
  33270. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33271. */
  33272. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33273. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33274. /**
  33275. * Defines edge width used when edgesRenderer is enabled
  33276. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33277. */
  33278. edgesWidth: number;
  33279. /**
  33280. * Defines edge color used when edgesRenderer is enabled
  33281. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33282. */
  33283. edgesColor: Color4;
  33284. /** @hidden */
  33285. _edgesRenderer: Nullable<IEdgesRenderer>;
  33286. /** @hidden */
  33287. _masterMesh: Nullable<AbstractMesh>;
  33288. /** @hidden */
  33289. _boundingInfo: Nullable<BoundingInfo>;
  33290. /** @hidden */
  33291. _renderId: number;
  33292. /**
  33293. * Gets or sets the list of subMeshes
  33294. * @see https://doc.babylonjs.com/how_to/multi_materials
  33295. */
  33296. subMeshes: SubMesh[];
  33297. /** @hidden */
  33298. _intersectionsInProgress: AbstractMesh[];
  33299. /** @hidden */
  33300. _unIndexed: boolean;
  33301. /** @hidden */
  33302. _lightSources: Light[];
  33303. /** Gets the list of lights affecting that mesh */
  33304. get lightSources(): Light[];
  33305. /** @hidden */
  33306. get _positions(): Nullable<Vector3[]>;
  33307. /** @hidden */
  33308. _waitingData: {
  33309. lods: Nullable<any>;
  33310. actions: Nullable<any>;
  33311. freezeWorldMatrix: Nullable<boolean>;
  33312. };
  33313. /** @hidden */
  33314. _bonesTransformMatrices: Nullable<Float32Array>;
  33315. /** @hidden */
  33316. _transformMatrixTexture: Nullable<RawTexture>;
  33317. /**
  33318. * Gets or sets a skeleton to apply skining transformations
  33319. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33320. */
  33321. set skeleton(value: Nullable<Skeleton>);
  33322. get skeleton(): Nullable<Skeleton>;
  33323. /**
  33324. * An event triggered when the mesh is rebuilt.
  33325. */
  33326. onRebuildObservable: Observable<AbstractMesh>;
  33327. /**
  33328. * Creates a new AbstractMesh
  33329. * @param name defines the name of the mesh
  33330. * @param scene defines the hosting scene
  33331. */
  33332. constructor(name: string, scene?: Nullable<Scene>);
  33333. /**
  33334. * Returns the string "AbstractMesh"
  33335. * @returns "AbstractMesh"
  33336. */
  33337. getClassName(): string;
  33338. /**
  33339. * Gets a string representation of the current mesh
  33340. * @param fullDetails defines a boolean indicating if full details must be included
  33341. * @returns a string representation of the current mesh
  33342. */
  33343. toString(fullDetails?: boolean): string;
  33344. /**
  33345. * @hidden
  33346. */
  33347. protected _getEffectiveParent(): Nullable<Node>;
  33348. /** @hidden */
  33349. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33350. /** @hidden */
  33351. _rebuild(): void;
  33352. /** @hidden */
  33353. _resyncLightSources(): void;
  33354. /** @hidden */
  33355. _resyncLightSource(light: Light): void;
  33356. /** @hidden */
  33357. _unBindEffect(): void;
  33358. /** @hidden */
  33359. _removeLightSource(light: Light, dispose: boolean): void;
  33360. private _markSubMeshesAsDirty;
  33361. /** @hidden */
  33362. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33363. /** @hidden */
  33364. _markSubMeshesAsAttributesDirty(): void;
  33365. /** @hidden */
  33366. _markSubMeshesAsMiscDirty(): void;
  33367. /**
  33368. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33369. */
  33370. get scaling(): Vector3;
  33371. set scaling(newScaling: Vector3);
  33372. /**
  33373. * Returns true if the mesh is blocked. Implemented by child classes
  33374. */
  33375. get isBlocked(): boolean;
  33376. /**
  33377. * Returns the mesh itself by default. Implemented by child classes
  33378. * @param camera defines the camera to use to pick the right LOD level
  33379. * @returns the currentAbstractMesh
  33380. */
  33381. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33382. /**
  33383. * Returns 0 by default. Implemented by child classes
  33384. * @returns an integer
  33385. */
  33386. getTotalVertices(): number;
  33387. /**
  33388. * Returns a positive integer : the total number of indices in this mesh geometry.
  33389. * @returns the numner of indices or zero if the mesh has no geometry.
  33390. */
  33391. getTotalIndices(): number;
  33392. /**
  33393. * Returns null by default. Implemented by child classes
  33394. * @returns null
  33395. */
  33396. getIndices(): Nullable<IndicesArray>;
  33397. /**
  33398. * Returns the array of the requested vertex data kind. Implemented by child classes
  33399. * @param kind defines the vertex data kind to use
  33400. * @returns null
  33401. */
  33402. getVerticesData(kind: string): Nullable<FloatArray>;
  33403. /**
  33404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33406. * Note that a new underlying VertexBuffer object is created each call.
  33407. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33408. * @param kind defines vertex data kind:
  33409. * * VertexBuffer.PositionKind
  33410. * * VertexBuffer.UVKind
  33411. * * VertexBuffer.UV2Kind
  33412. * * VertexBuffer.UV3Kind
  33413. * * VertexBuffer.UV4Kind
  33414. * * VertexBuffer.UV5Kind
  33415. * * VertexBuffer.UV6Kind
  33416. * * VertexBuffer.ColorKind
  33417. * * VertexBuffer.MatricesIndicesKind
  33418. * * VertexBuffer.MatricesIndicesExtraKind
  33419. * * VertexBuffer.MatricesWeightsKind
  33420. * * VertexBuffer.MatricesWeightsExtraKind
  33421. * @param data defines the data source
  33422. * @param updatable defines if the data must be flagged as updatable (or static)
  33423. * @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
  33424. * @returns the current mesh
  33425. */
  33426. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33427. /**
  33428. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33429. * If the mesh has no geometry, it is simply returned as it is.
  33430. * @param kind defines vertex data kind:
  33431. * * VertexBuffer.PositionKind
  33432. * * VertexBuffer.UVKind
  33433. * * VertexBuffer.UV2Kind
  33434. * * VertexBuffer.UV3Kind
  33435. * * VertexBuffer.UV4Kind
  33436. * * VertexBuffer.UV5Kind
  33437. * * VertexBuffer.UV6Kind
  33438. * * VertexBuffer.ColorKind
  33439. * * VertexBuffer.MatricesIndicesKind
  33440. * * VertexBuffer.MatricesIndicesExtraKind
  33441. * * VertexBuffer.MatricesWeightsKind
  33442. * * VertexBuffer.MatricesWeightsExtraKind
  33443. * @param data defines the data source
  33444. * @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
  33445. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33446. * @returns the current mesh
  33447. */
  33448. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33449. /**
  33450. * Sets the mesh indices,
  33451. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33452. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33453. * @param totalVertices Defines the total number of vertices
  33454. * @returns the current mesh
  33455. */
  33456. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33457. /**
  33458. * Gets a boolean indicating if specific vertex data is present
  33459. * @param kind defines the vertex data kind to use
  33460. * @returns true is data kind is present
  33461. */
  33462. isVerticesDataPresent(kind: string): boolean;
  33463. /**
  33464. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33465. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33466. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33467. * @returns a BoundingInfo
  33468. */
  33469. getBoundingInfo(): BoundingInfo;
  33470. /**
  33471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33475. * @returns the current mesh
  33476. */
  33477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33478. /**
  33479. * Overwrite the current bounding info
  33480. * @param boundingInfo defines the new bounding info
  33481. * @returns the current mesh
  33482. */
  33483. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33484. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33485. get useBones(): boolean;
  33486. /** @hidden */
  33487. _preActivate(): void;
  33488. /** @hidden */
  33489. _preActivateForIntermediateRendering(renderId: number): void;
  33490. /** @hidden */
  33491. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33492. /** @hidden */
  33493. _postActivate(): void;
  33494. /** @hidden */
  33495. _freeze(): void;
  33496. /** @hidden */
  33497. _unFreeze(): void;
  33498. /**
  33499. * Gets the current world matrix
  33500. * @returns a Matrix
  33501. */
  33502. getWorldMatrix(): Matrix;
  33503. /** @hidden */
  33504. _getWorldMatrixDeterminant(): number;
  33505. /**
  33506. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33507. */
  33508. get isAnInstance(): boolean;
  33509. /**
  33510. * Gets a boolean indicating if this mesh has instances
  33511. */
  33512. get hasInstances(): boolean;
  33513. /**
  33514. * Gets a boolean indicating if this mesh has thin instances
  33515. */
  33516. get hasThinInstances(): boolean;
  33517. /**
  33518. * Perform relative position change from the point of view of behind the front of the mesh.
  33519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33520. * Supports definition of mesh facing forward or backward
  33521. * @param amountRight defines the distance on the right axis
  33522. * @param amountUp defines the distance on the up axis
  33523. * @param amountForward defines the distance on the forward axis
  33524. * @returns the current mesh
  33525. */
  33526. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33527. /**
  33528. * Calculate relative position change from the point of view of behind the front of the mesh.
  33529. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33530. * Supports definition of mesh facing forward or backward
  33531. * @param amountRight defines the distance on the right axis
  33532. * @param amountUp defines the distance on the up axis
  33533. * @param amountForward defines the distance on the forward axis
  33534. * @returns the new displacement vector
  33535. */
  33536. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33537. /**
  33538. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33539. * Supports definition of mesh facing forward or backward
  33540. * @param flipBack defines the flip
  33541. * @param twirlClockwise defines the twirl
  33542. * @param tiltRight defines the tilt
  33543. * @returns the current mesh
  33544. */
  33545. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33546. /**
  33547. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33548. * Supports definition of mesh facing forward or backward.
  33549. * @param flipBack defines the flip
  33550. * @param twirlClockwise defines the twirl
  33551. * @param tiltRight defines the tilt
  33552. * @returns the new rotation vector
  33553. */
  33554. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33555. /**
  33556. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33557. * This means the mesh underlying bounding box and sphere are recomputed.
  33558. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33559. * @returns the current mesh
  33560. */
  33561. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33562. /** @hidden */
  33563. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33564. /** @hidden */
  33565. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33566. /** @hidden */
  33567. _updateBoundingInfo(): AbstractMesh;
  33568. /** @hidden */
  33569. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33570. /** @hidden */
  33571. protected _afterComputeWorldMatrix(): void;
  33572. /** @hidden */
  33573. get _effectiveMesh(): AbstractMesh;
  33574. /**
  33575. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33576. * A mesh is in the frustum if its bounding box intersects the frustum
  33577. * @param frustumPlanes defines the frustum to test
  33578. * @returns true if the mesh is in the frustum planes
  33579. */
  33580. isInFrustum(frustumPlanes: Plane[]): boolean;
  33581. /**
  33582. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33583. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33584. * @param frustumPlanes defines the frustum to test
  33585. * @returns true if the mesh is completely in the frustum planes
  33586. */
  33587. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33588. /**
  33589. * True if the mesh intersects another mesh or a SolidParticle object
  33590. * @param mesh defines a target mesh or SolidParticle to test
  33591. * @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)
  33592. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33593. * @returns true if there is an intersection
  33594. */
  33595. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33596. /**
  33597. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33598. * @param point defines the point to test
  33599. * @returns true if there is an intersection
  33600. */
  33601. intersectsPoint(point: Vector3): boolean;
  33602. /**
  33603. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33604. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33605. */
  33606. get checkCollisions(): boolean;
  33607. set checkCollisions(collisionEnabled: boolean);
  33608. /**
  33609. * Gets Collider object used to compute collisions (not physics)
  33610. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33611. */
  33612. get collider(): Nullable<Collider>;
  33613. /**
  33614. * Move the mesh using collision engine
  33615. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33616. * @param displacement defines the requested displacement vector
  33617. * @returns the current mesh
  33618. */
  33619. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33620. private _onCollisionPositionChange;
  33621. /** @hidden */
  33622. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33623. /** @hidden */
  33624. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33625. /** @hidden */
  33626. _checkCollision(collider: Collider): AbstractMesh;
  33627. /** @hidden */
  33628. _generatePointsArray(): boolean;
  33629. /**
  33630. * Checks if the passed Ray intersects with the mesh
  33631. * @param ray defines the ray to use
  33632. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33633. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33634. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33635. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33636. * @returns the picking info
  33637. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33638. */
  33639. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33640. /**
  33641. * Clones the current mesh
  33642. * @param name defines the mesh name
  33643. * @param newParent defines the new mesh parent
  33644. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33645. * @returns the new mesh
  33646. */
  33647. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33648. /**
  33649. * Disposes all the submeshes of the current meshnp
  33650. * @returns the current mesh
  33651. */
  33652. releaseSubMeshes(): AbstractMesh;
  33653. /**
  33654. * Releases resources associated with this abstract mesh.
  33655. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33656. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33657. */
  33658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33659. /**
  33660. * Adds the passed mesh as a child to the current mesh
  33661. * @param mesh defines the child mesh
  33662. * @returns the current mesh
  33663. */
  33664. addChild(mesh: AbstractMesh): AbstractMesh;
  33665. /**
  33666. * Removes the passed mesh from the current mesh children list
  33667. * @param mesh defines the child mesh
  33668. * @returns the current mesh
  33669. */
  33670. removeChild(mesh: AbstractMesh): AbstractMesh;
  33671. /** @hidden */
  33672. private _initFacetData;
  33673. /**
  33674. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33675. * This method can be called within the render loop.
  33676. * 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
  33677. * @returns the current mesh
  33678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33679. */
  33680. updateFacetData(): AbstractMesh;
  33681. /**
  33682. * Returns the facetLocalNormals array.
  33683. * The normals are expressed in the mesh local spac
  33684. * @returns an array of Vector3
  33685. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33686. */
  33687. getFacetLocalNormals(): Vector3[];
  33688. /**
  33689. * Returns the facetLocalPositions array.
  33690. * The facet positions are expressed in the mesh local space
  33691. * @returns an array of Vector3
  33692. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33693. */
  33694. getFacetLocalPositions(): Vector3[];
  33695. /**
  33696. * Returns the facetLocalPartioning array
  33697. * @returns an array of array of numbers
  33698. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33699. */
  33700. getFacetLocalPartitioning(): number[][];
  33701. /**
  33702. * Returns the i-th facet position in the world system.
  33703. * This method allocates a new Vector3 per call
  33704. * @param i defines the facet index
  33705. * @returns a new Vector3
  33706. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33707. */
  33708. getFacetPosition(i: number): Vector3;
  33709. /**
  33710. * Sets the reference Vector3 with the i-th facet position in the world system
  33711. * @param i defines the facet index
  33712. * @param ref defines the target vector
  33713. * @returns the current mesh
  33714. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33715. */
  33716. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33717. /**
  33718. * Returns the i-th facet normal in the world system.
  33719. * This method allocates a new Vector3 per call
  33720. * @param i defines the facet index
  33721. * @returns a new Vector3
  33722. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33723. */
  33724. getFacetNormal(i: number): Vector3;
  33725. /**
  33726. * Sets the reference Vector3 with the i-th facet normal in the world system
  33727. * @param i defines the facet index
  33728. * @param ref defines the target vector
  33729. * @returns the current mesh
  33730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33731. */
  33732. getFacetNormalToRef(i: number, ref: Vector3): this;
  33733. /**
  33734. * 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)
  33735. * @param x defines x coordinate
  33736. * @param y defines y coordinate
  33737. * @param z defines z coordinate
  33738. * @returns the array of facet indexes
  33739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33740. */
  33741. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33742. /**
  33743. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33744. * @param projected sets as the (x,y,z) world projection on the facet
  33745. * @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
  33746. * @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
  33747. * @param x defines x coordinate
  33748. * @param y defines y coordinate
  33749. * @param z defines z coordinate
  33750. * @returns the face index if found (or null instead)
  33751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33752. */
  33753. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33754. /**
  33755. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33756. * @param projected sets as the (x,y,z) local projection on the facet
  33757. * @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
  33758. * @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
  33759. * @param x defines x coordinate
  33760. * @param y defines y coordinate
  33761. * @param z defines z coordinate
  33762. * @returns the face index if found (or null instead)
  33763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33764. */
  33765. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33766. /**
  33767. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33768. * @returns the parameters
  33769. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33770. */
  33771. getFacetDataParameters(): any;
  33772. /**
  33773. * Disables the feature FacetData and frees the related memory
  33774. * @returns the current mesh
  33775. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33776. */
  33777. disableFacetData(): AbstractMesh;
  33778. /**
  33779. * Updates the AbstractMesh indices array
  33780. * @param indices defines the data source
  33781. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33782. * @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)
  33783. * @returns the current mesh
  33784. */
  33785. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33786. /**
  33787. * Creates new normals data for the mesh
  33788. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33789. * @returns the current mesh
  33790. */
  33791. createNormals(updatable: boolean): AbstractMesh;
  33792. /**
  33793. * Align the mesh with a normal
  33794. * @param normal defines the normal to use
  33795. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33796. * @returns the current mesh
  33797. */
  33798. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33799. /** @hidden */
  33800. _checkOcclusionQuery(): boolean;
  33801. /**
  33802. * Disables the mesh edge rendering mode
  33803. * @returns the currentAbstractMesh
  33804. */
  33805. disableEdgesRendering(): AbstractMesh;
  33806. /**
  33807. * Enables the edge rendering mode on the mesh.
  33808. * This mode makes the mesh edges visible
  33809. * @param epsilon defines the maximal distance between two angles to detect a face
  33810. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33811. * @returns the currentAbstractMesh
  33812. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33813. */
  33814. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33815. /**
  33816. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33817. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33818. */
  33819. getConnectedParticleSystems(): IParticleSystem[];
  33820. }
  33821. }
  33822. declare module "babylonjs/Actions/actionEvent" {
  33823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33824. import { Nullable } from "babylonjs/types";
  33825. import { Sprite } from "babylonjs/Sprites/sprite";
  33826. import { Scene } from "babylonjs/scene";
  33827. import { Vector2 } from "babylonjs/Maths/math.vector";
  33828. /**
  33829. * Interface used to define ActionEvent
  33830. */
  33831. export interface IActionEvent {
  33832. /** The mesh or sprite that triggered the action */
  33833. source: any;
  33834. /** The X mouse cursor position at the time of the event */
  33835. pointerX: number;
  33836. /** The Y mouse cursor position at the time of the event */
  33837. pointerY: number;
  33838. /** The mesh that is currently pointed at (can be null) */
  33839. meshUnderPointer: Nullable<AbstractMesh>;
  33840. /** the original (browser) event that triggered the ActionEvent */
  33841. sourceEvent?: any;
  33842. /** additional data for the event */
  33843. additionalData?: any;
  33844. }
  33845. /**
  33846. * ActionEvent is the event being sent when an action is triggered.
  33847. */
  33848. export class ActionEvent implements IActionEvent {
  33849. /** The mesh or sprite that triggered the action */
  33850. source: any;
  33851. /** The X mouse cursor position at the time of the event */
  33852. pointerX: number;
  33853. /** The Y mouse cursor position at the time of the event */
  33854. pointerY: number;
  33855. /** The mesh that is currently pointed at (can be null) */
  33856. meshUnderPointer: Nullable<AbstractMesh>;
  33857. /** the original (browser) event that triggered the ActionEvent */
  33858. sourceEvent?: any;
  33859. /** additional data for the event */
  33860. additionalData?: any;
  33861. /**
  33862. * Creates a new ActionEvent
  33863. * @param source The mesh or sprite that triggered the action
  33864. * @param pointerX The X mouse cursor position at the time of the event
  33865. * @param pointerY The Y mouse cursor position at the time of the event
  33866. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33867. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33868. * @param additionalData additional data for the event
  33869. */
  33870. constructor(
  33871. /** The mesh or sprite that triggered the action */
  33872. source: any,
  33873. /** The X mouse cursor position at the time of the event */
  33874. pointerX: number,
  33875. /** The Y mouse cursor position at the time of the event */
  33876. pointerY: number,
  33877. /** The mesh that is currently pointed at (can be null) */
  33878. meshUnderPointer: Nullable<AbstractMesh>,
  33879. /** the original (browser) event that triggered the ActionEvent */
  33880. sourceEvent?: any,
  33881. /** additional data for the event */
  33882. additionalData?: any);
  33883. /**
  33884. * Helper function to auto-create an ActionEvent from a source mesh.
  33885. * @param source The source mesh that triggered the event
  33886. * @param evt The original (browser) event
  33887. * @param additionalData additional data for the event
  33888. * @returns the new ActionEvent
  33889. */
  33890. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33891. /**
  33892. * Helper function to auto-create an ActionEvent from a source sprite
  33893. * @param source The source sprite that triggered the event
  33894. * @param scene Scene associated with the sprite
  33895. * @param evt The original (browser) event
  33896. * @param additionalData additional data for the event
  33897. * @returns the new ActionEvent
  33898. */
  33899. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33900. /**
  33901. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33902. * @param scene the scene where the event occurred
  33903. * @param evt The original (browser) event
  33904. * @returns the new ActionEvent
  33905. */
  33906. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33907. /**
  33908. * Helper function to auto-create an ActionEvent from a primitive
  33909. * @param prim defines the target primitive
  33910. * @param pointerPos defines the pointer position
  33911. * @param evt The original (browser) event
  33912. * @param additionalData additional data for the event
  33913. * @returns the new ActionEvent
  33914. */
  33915. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33916. }
  33917. }
  33918. declare module "babylonjs/Actions/abstractActionManager" {
  33919. import { IDisposable } from "babylonjs/scene";
  33920. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33921. import { IAction } from "babylonjs/Actions/action";
  33922. import { Nullable } from "babylonjs/types";
  33923. /**
  33924. * Abstract class used to decouple action Manager from scene and meshes.
  33925. * Do not instantiate.
  33926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33927. */
  33928. export abstract class AbstractActionManager implements IDisposable {
  33929. /** Gets the list of active triggers */
  33930. static Triggers: {
  33931. [key: string]: number;
  33932. };
  33933. /** Gets the cursor to use when hovering items */
  33934. hoverCursor: string;
  33935. /** Gets the list of actions */
  33936. actions: IAction[];
  33937. /**
  33938. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33939. */
  33940. isRecursive: boolean;
  33941. /**
  33942. * Releases all associated resources
  33943. */
  33944. abstract dispose(): void;
  33945. /**
  33946. * Does this action manager has pointer triggers
  33947. */
  33948. abstract get hasPointerTriggers(): boolean;
  33949. /**
  33950. * Does this action manager has pick triggers
  33951. */
  33952. abstract get hasPickTriggers(): boolean;
  33953. /**
  33954. * Process a specific trigger
  33955. * @param trigger defines the trigger to process
  33956. * @param evt defines the event details to be processed
  33957. */
  33958. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33959. /**
  33960. * Does this action manager handles actions of any of the given triggers
  33961. * @param triggers defines the triggers to be tested
  33962. * @return a boolean indicating whether one (or more) of the triggers is handled
  33963. */
  33964. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33965. /**
  33966. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33967. * speed.
  33968. * @param triggerA defines the trigger to be tested
  33969. * @param triggerB defines the trigger to be tested
  33970. * @return a boolean indicating whether one (or more) of the triggers is handled
  33971. */
  33972. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33973. /**
  33974. * Does this action manager handles actions of a given trigger
  33975. * @param trigger defines the trigger to be tested
  33976. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33977. * @return whether the trigger is handled
  33978. */
  33979. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33980. /**
  33981. * Serialize this manager to a JSON object
  33982. * @param name defines the property name to store this manager
  33983. * @returns a JSON representation of this manager
  33984. */
  33985. abstract serialize(name: string): any;
  33986. /**
  33987. * Registers an action to this action manager
  33988. * @param action defines the action to be registered
  33989. * @return the action amended (prepared) after registration
  33990. */
  33991. abstract registerAction(action: IAction): Nullable<IAction>;
  33992. /**
  33993. * Unregisters an action to this action manager
  33994. * @param action defines the action to be unregistered
  33995. * @return a boolean indicating whether the action has been unregistered
  33996. */
  33997. abstract unregisterAction(action: IAction): Boolean;
  33998. /**
  33999. * Does exist one action manager with at least one trigger
  34000. **/
  34001. static get HasTriggers(): boolean;
  34002. /**
  34003. * Does exist one action manager with at least one pick trigger
  34004. **/
  34005. static get HasPickTriggers(): boolean;
  34006. /**
  34007. * Does exist one action manager that handles actions of a given trigger
  34008. * @param trigger defines the trigger to be tested
  34009. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34010. **/
  34011. static HasSpecificTrigger(trigger: number): boolean;
  34012. }
  34013. }
  34014. declare module "babylonjs/node" {
  34015. import { Scene } from "babylonjs/scene";
  34016. import { Nullable } from "babylonjs/types";
  34017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34018. import { Engine } from "babylonjs/Engines/engine";
  34019. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34020. import { Observable } from "babylonjs/Misc/observable";
  34021. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34022. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34023. import { Animatable } from "babylonjs/Animations/animatable";
  34024. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34025. import { Animation } from "babylonjs/Animations/animation";
  34026. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34028. /**
  34029. * Defines how a node can be built from a string name.
  34030. */
  34031. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34032. /**
  34033. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34034. */
  34035. export class Node implements IBehaviorAware<Node> {
  34036. /** @hidden */
  34037. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34038. private static _NodeConstructors;
  34039. /**
  34040. * Add a new node constructor
  34041. * @param type defines the type name of the node to construct
  34042. * @param constructorFunc defines the constructor function
  34043. */
  34044. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34045. /**
  34046. * Returns a node constructor based on type name
  34047. * @param type defines the type name
  34048. * @param name defines the new node name
  34049. * @param scene defines the hosting scene
  34050. * @param options defines optional options to transmit to constructors
  34051. * @returns the new constructor or null
  34052. */
  34053. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34054. /**
  34055. * Gets or sets the name of the node
  34056. */
  34057. name: string;
  34058. /**
  34059. * Gets or sets the id of the node
  34060. */
  34061. id: string;
  34062. /**
  34063. * Gets or sets the unique id of the node
  34064. */
  34065. uniqueId: number;
  34066. /**
  34067. * Gets or sets a string used to store user defined state for the node
  34068. */
  34069. state: string;
  34070. /**
  34071. * Gets or sets an object used to store user defined information for the node
  34072. */
  34073. metadata: any;
  34074. /**
  34075. * For internal use only. Please do not use.
  34076. */
  34077. reservedDataStore: any;
  34078. /**
  34079. * List of inspectable custom properties (used by the Inspector)
  34080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34081. */
  34082. inspectableCustomProperties: IInspectable[];
  34083. private _doNotSerialize;
  34084. /**
  34085. * Gets or sets a boolean used to define if the node must be serialized
  34086. */
  34087. get doNotSerialize(): boolean;
  34088. set doNotSerialize(value: boolean);
  34089. /** @hidden */
  34090. _isDisposed: boolean;
  34091. /**
  34092. * Gets a list of Animations associated with the node
  34093. */
  34094. animations: import("babylonjs/Animations/animation").Animation[];
  34095. protected _ranges: {
  34096. [name: string]: Nullable<AnimationRange>;
  34097. };
  34098. /**
  34099. * Callback raised when the node is ready to be used
  34100. */
  34101. onReady: Nullable<(node: Node) => void>;
  34102. private _isEnabled;
  34103. private _isParentEnabled;
  34104. private _isReady;
  34105. /** @hidden */
  34106. _currentRenderId: number;
  34107. private _parentUpdateId;
  34108. /** @hidden */
  34109. _childUpdateId: number;
  34110. /** @hidden */
  34111. _waitingParentId: Nullable<string>;
  34112. /** @hidden */
  34113. _scene: Scene;
  34114. /** @hidden */
  34115. _cache: any;
  34116. private _parentNode;
  34117. private _children;
  34118. /** @hidden */
  34119. _worldMatrix: Matrix;
  34120. /** @hidden */
  34121. _worldMatrixDeterminant: number;
  34122. /** @hidden */
  34123. _worldMatrixDeterminantIsDirty: boolean;
  34124. /** @hidden */
  34125. private _sceneRootNodesIndex;
  34126. /**
  34127. * Gets a boolean indicating if the node has been disposed
  34128. * @returns true if the node was disposed
  34129. */
  34130. isDisposed(): boolean;
  34131. /**
  34132. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34133. * @see https://doc.babylonjs.com/how_to/parenting
  34134. */
  34135. set parent(parent: Nullable<Node>);
  34136. get parent(): Nullable<Node>;
  34137. /** @hidden */
  34138. _addToSceneRootNodes(): void;
  34139. /** @hidden */
  34140. _removeFromSceneRootNodes(): void;
  34141. private _animationPropertiesOverride;
  34142. /**
  34143. * Gets or sets the animation properties override
  34144. */
  34145. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34146. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34147. /**
  34148. * Gets a string idenfifying the name of the class
  34149. * @returns "Node" string
  34150. */
  34151. getClassName(): string;
  34152. /** @hidden */
  34153. readonly _isNode: boolean;
  34154. /**
  34155. * An event triggered when the mesh is disposed
  34156. */
  34157. onDisposeObservable: Observable<Node>;
  34158. private _onDisposeObserver;
  34159. /**
  34160. * Sets a callback that will be raised when the node will be disposed
  34161. */
  34162. set onDispose(callback: () => void);
  34163. /**
  34164. * Creates a new Node
  34165. * @param name the name and id to be given to this node
  34166. * @param scene the scene this node will be added to
  34167. */
  34168. constructor(name: string, scene?: Nullable<Scene>);
  34169. /**
  34170. * Gets the scene of the node
  34171. * @returns a scene
  34172. */
  34173. getScene(): Scene;
  34174. /**
  34175. * Gets the engine of the node
  34176. * @returns a Engine
  34177. */
  34178. getEngine(): Engine;
  34179. private _behaviors;
  34180. /**
  34181. * Attach a behavior to the node
  34182. * @see https://doc.babylonjs.com/features/behaviour
  34183. * @param behavior defines the behavior to attach
  34184. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34185. * @returns the current Node
  34186. */
  34187. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34188. /**
  34189. * Remove an attached behavior
  34190. * @see https://doc.babylonjs.com/features/behaviour
  34191. * @param behavior defines the behavior to attach
  34192. * @returns the current Node
  34193. */
  34194. removeBehavior(behavior: Behavior<Node>): Node;
  34195. /**
  34196. * Gets the list of attached behaviors
  34197. * @see https://doc.babylonjs.com/features/behaviour
  34198. */
  34199. get behaviors(): Behavior<Node>[];
  34200. /**
  34201. * Gets an attached behavior by name
  34202. * @param name defines the name of the behavior to look for
  34203. * @see https://doc.babylonjs.com/features/behaviour
  34204. * @returns null if behavior was not found else the requested behavior
  34205. */
  34206. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34207. /**
  34208. * Returns the latest update of the World matrix
  34209. * @returns a Matrix
  34210. */
  34211. getWorldMatrix(): Matrix;
  34212. /** @hidden */
  34213. _getWorldMatrixDeterminant(): number;
  34214. /**
  34215. * Returns directly the latest state of the mesh World matrix.
  34216. * A Matrix is returned.
  34217. */
  34218. get worldMatrixFromCache(): Matrix;
  34219. /** @hidden */
  34220. _initCache(): void;
  34221. /** @hidden */
  34222. updateCache(force?: boolean): void;
  34223. /** @hidden */
  34224. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34225. /** @hidden */
  34226. _updateCache(ignoreParentClass?: boolean): void;
  34227. /** @hidden */
  34228. _isSynchronized(): boolean;
  34229. /** @hidden */
  34230. _markSyncedWithParent(): void;
  34231. /** @hidden */
  34232. isSynchronizedWithParent(): boolean;
  34233. /** @hidden */
  34234. isSynchronized(): boolean;
  34235. /**
  34236. * Is this node ready to be used/rendered
  34237. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34238. * @return true if the node is ready
  34239. */
  34240. isReady(completeCheck?: boolean): boolean;
  34241. /**
  34242. * Is this node enabled?
  34243. * 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
  34244. * @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
  34245. * @return whether this node (and its parent) is enabled
  34246. */
  34247. isEnabled(checkAncestors?: boolean): boolean;
  34248. /** @hidden */
  34249. protected _syncParentEnabledState(): void;
  34250. /**
  34251. * Set the enabled state of this node
  34252. * @param value defines the new enabled state
  34253. */
  34254. setEnabled(value: boolean): void;
  34255. /**
  34256. * Is this node a descendant of the given node?
  34257. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34258. * @param ancestor defines the parent node to inspect
  34259. * @returns a boolean indicating if this node is a descendant of the given node
  34260. */
  34261. isDescendantOf(ancestor: Node): boolean;
  34262. /** @hidden */
  34263. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34264. /**
  34265. * Will return all nodes that have this node as ascendant
  34266. * @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
  34267. * @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
  34268. * @return all children nodes of all types
  34269. */
  34270. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34271. /**
  34272. * Get all child-meshes of this node
  34273. * @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)
  34274. * @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
  34275. * @returns an array of AbstractMesh
  34276. */
  34277. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34278. /**
  34279. * Get all direct children of this node
  34280. * @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
  34281. * @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)
  34282. * @returns an array of Node
  34283. */
  34284. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34285. /** @hidden */
  34286. _setReady(state: boolean): void;
  34287. /**
  34288. * Get an animation by name
  34289. * @param name defines the name of the animation to look for
  34290. * @returns null if not found else the requested animation
  34291. */
  34292. getAnimationByName(name: string): Nullable<Animation>;
  34293. /**
  34294. * Creates an animation range for this node
  34295. * @param name defines the name of the range
  34296. * @param from defines the starting key
  34297. * @param to defines the end key
  34298. */
  34299. createAnimationRange(name: string, from: number, to: number): void;
  34300. /**
  34301. * Delete a specific animation range
  34302. * @param name defines the name of the range to delete
  34303. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34304. */
  34305. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34306. /**
  34307. * Get an animation range by name
  34308. * @param name defines the name of the animation range to look for
  34309. * @returns null if not found else the requested animation range
  34310. */
  34311. getAnimationRange(name: string): Nullable<AnimationRange>;
  34312. /**
  34313. * Gets the list of all animation ranges defined on this node
  34314. * @returns an array
  34315. */
  34316. getAnimationRanges(): Nullable<AnimationRange>[];
  34317. /**
  34318. * Will start the animation sequence
  34319. * @param name defines the range frames for animation sequence
  34320. * @param loop defines if the animation should loop (false by default)
  34321. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34322. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34323. * @returns the object created for this animation. If range does not exist, it will return null
  34324. */
  34325. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34326. /**
  34327. * Serialize animation ranges into a JSON compatible object
  34328. * @returns serialization object
  34329. */
  34330. serializeAnimationRanges(): any;
  34331. /**
  34332. * Computes the world matrix of the node
  34333. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34334. * @returns the world matrix
  34335. */
  34336. computeWorldMatrix(force?: boolean): Matrix;
  34337. /**
  34338. * Releases resources associated with this node.
  34339. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34340. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34341. */
  34342. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34343. /**
  34344. * Parse animation range data from a serialization object and store them into a given node
  34345. * @param node defines where to store the animation ranges
  34346. * @param parsedNode defines the serialization object to read data from
  34347. * @param scene defines the hosting scene
  34348. */
  34349. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34350. /**
  34351. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34352. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34353. * @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
  34354. * @returns the new bounding vectors
  34355. */
  34356. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34357. min: Vector3;
  34358. max: Vector3;
  34359. };
  34360. }
  34361. }
  34362. declare module "babylonjs/Animations/animation" {
  34363. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34364. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34365. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34366. import { Nullable } from "babylonjs/types";
  34367. import { Scene } from "babylonjs/scene";
  34368. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34369. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34370. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34371. import { Node } from "babylonjs/node";
  34372. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34373. import { Size } from "babylonjs/Maths/math.size";
  34374. import { Animatable } from "babylonjs/Animations/animatable";
  34375. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34376. /**
  34377. * @hidden
  34378. */
  34379. export class _IAnimationState {
  34380. key: number;
  34381. repeatCount: number;
  34382. workValue?: any;
  34383. loopMode?: number;
  34384. offsetValue?: any;
  34385. highLimitValue?: any;
  34386. }
  34387. /**
  34388. * Class used to store any kind of animation
  34389. */
  34390. export class Animation {
  34391. /**Name of the animation */
  34392. name: string;
  34393. /**Property to animate */
  34394. targetProperty: string;
  34395. /**The frames per second of the animation */
  34396. framePerSecond: number;
  34397. /**The data type of the animation */
  34398. dataType: number;
  34399. /**The loop mode of the animation */
  34400. loopMode?: number | undefined;
  34401. /**Specifies if blending should be enabled */
  34402. enableBlending?: boolean | undefined;
  34403. /**
  34404. * Use matrix interpolation instead of using direct key value when animating matrices
  34405. */
  34406. static AllowMatricesInterpolation: boolean;
  34407. /**
  34408. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34409. */
  34410. static AllowMatrixDecomposeForInterpolation: boolean;
  34411. /** Define the Url to load snippets */
  34412. static SnippetUrl: string;
  34413. /** Snippet ID if the animation was created from the snippet server */
  34414. snippetId: string;
  34415. /**
  34416. * Stores the key frames of the animation
  34417. */
  34418. private _keys;
  34419. /**
  34420. * Stores the easing function of the animation
  34421. */
  34422. private _easingFunction;
  34423. /**
  34424. * @hidden Internal use only
  34425. */
  34426. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34427. /**
  34428. * The set of event that will be linked to this animation
  34429. */
  34430. private _events;
  34431. /**
  34432. * Stores an array of target property paths
  34433. */
  34434. targetPropertyPath: string[];
  34435. /**
  34436. * Stores the blending speed of the animation
  34437. */
  34438. blendingSpeed: number;
  34439. /**
  34440. * Stores the animation ranges for the animation
  34441. */
  34442. private _ranges;
  34443. /**
  34444. * @hidden Internal use
  34445. */
  34446. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34447. /**
  34448. * Sets up an animation
  34449. * @param property The property to animate
  34450. * @param animationType The animation type to apply
  34451. * @param framePerSecond The frames per second of the animation
  34452. * @param easingFunction The easing function used in the animation
  34453. * @returns The created animation
  34454. */
  34455. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34456. /**
  34457. * Create and start an animation on a node
  34458. * @param name defines the name of the global animation that will be run on all nodes
  34459. * @param node defines the root node where the animation will take place
  34460. * @param targetProperty defines property to animate
  34461. * @param framePerSecond defines the number of frame per second yo use
  34462. * @param totalFrame defines the number of frames in total
  34463. * @param from defines the initial value
  34464. * @param to defines the final value
  34465. * @param loopMode defines which loop mode you want to use (off by default)
  34466. * @param easingFunction defines the easing function to use (linear by default)
  34467. * @param onAnimationEnd defines the callback to call when animation end
  34468. * @returns the animatable created for this animation
  34469. */
  34470. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34471. /**
  34472. * Create and start an animation on a node and its descendants
  34473. * @param name defines the name of the global animation that will be run on all nodes
  34474. * @param node defines the root node where the animation will take place
  34475. * @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
  34476. * @param targetProperty defines property to animate
  34477. * @param framePerSecond defines the number of frame per second to use
  34478. * @param totalFrame defines the number of frames in total
  34479. * @param from defines the initial value
  34480. * @param to defines the final value
  34481. * @param loopMode defines which loop mode you want to use (off by default)
  34482. * @param easingFunction defines the easing function to use (linear by default)
  34483. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34484. * @returns the list of animatables created for all nodes
  34485. * @example https://www.babylonjs-playground.com/#MH0VLI
  34486. */
  34487. 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[]>;
  34488. /**
  34489. * Creates a new animation, merges it with the existing animations and starts it
  34490. * @param name Name of the animation
  34491. * @param node Node which contains the scene that begins the animations
  34492. * @param targetProperty Specifies which property to animate
  34493. * @param framePerSecond The frames per second of the animation
  34494. * @param totalFrame The total number of frames
  34495. * @param from The frame at the beginning of the animation
  34496. * @param to The frame at the end of the animation
  34497. * @param loopMode Specifies the loop mode of the animation
  34498. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34499. * @param onAnimationEnd Callback to run once the animation is complete
  34500. * @returns Nullable animation
  34501. */
  34502. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34503. /**
  34504. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34505. * @param sourceAnimation defines the Animation containing keyframes to convert
  34506. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34507. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34508. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34509. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34510. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34511. */
  34512. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34513. /**
  34514. * Transition property of an host to the target Value
  34515. * @param property The property to transition
  34516. * @param targetValue The target Value of the property
  34517. * @param host The object where the property to animate belongs
  34518. * @param scene Scene used to run the animation
  34519. * @param frameRate Framerate (in frame/s) to use
  34520. * @param transition The transition type we want to use
  34521. * @param duration The duration of the animation, in milliseconds
  34522. * @param onAnimationEnd Callback trigger at the end of the animation
  34523. * @returns Nullable animation
  34524. */
  34525. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34526. /**
  34527. * Return the array of runtime animations currently using this animation
  34528. */
  34529. get runtimeAnimations(): RuntimeAnimation[];
  34530. /**
  34531. * Specifies if any of the runtime animations are currently running
  34532. */
  34533. get hasRunningRuntimeAnimations(): boolean;
  34534. /**
  34535. * Initializes the animation
  34536. * @param name Name of the animation
  34537. * @param targetProperty Property to animate
  34538. * @param framePerSecond The frames per second of the animation
  34539. * @param dataType The data type of the animation
  34540. * @param loopMode The loop mode of the animation
  34541. * @param enableBlending Specifies if blending should be enabled
  34542. */
  34543. constructor(
  34544. /**Name of the animation */
  34545. name: string,
  34546. /**Property to animate */
  34547. targetProperty: string,
  34548. /**The frames per second of the animation */
  34549. framePerSecond: number,
  34550. /**The data type of the animation */
  34551. dataType: number,
  34552. /**The loop mode of the animation */
  34553. loopMode?: number | undefined,
  34554. /**Specifies if blending should be enabled */
  34555. enableBlending?: boolean | undefined);
  34556. /**
  34557. * Converts the animation to a string
  34558. * @param fullDetails support for multiple levels of logging within scene loading
  34559. * @returns String form of the animation
  34560. */
  34561. toString(fullDetails?: boolean): string;
  34562. /**
  34563. * Add an event to this animation
  34564. * @param event Event to add
  34565. */
  34566. addEvent(event: AnimationEvent): void;
  34567. /**
  34568. * Remove all events found at the given frame
  34569. * @param frame The frame to remove events from
  34570. */
  34571. removeEvents(frame: number): void;
  34572. /**
  34573. * Retrieves all the events from the animation
  34574. * @returns Events from the animation
  34575. */
  34576. getEvents(): AnimationEvent[];
  34577. /**
  34578. * Creates an animation range
  34579. * @param name Name of the animation range
  34580. * @param from Starting frame of the animation range
  34581. * @param to Ending frame of the animation
  34582. */
  34583. createRange(name: string, from: number, to: number): void;
  34584. /**
  34585. * Deletes an animation range by name
  34586. * @param name Name of the animation range to delete
  34587. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34588. */
  34589. deleteRange(name: string, deleteFrames?: boolean): void;
  34590. /**
  34591. * Gets the animation range by name, or null if not defined
  34592. * @param name Name of the animation range
  34593. * @returns Nullable animation range
  34594. */
  34595. getRange(name: string): Nullable<AnimationRange>;
  34596. /**
  34597. * Gets the key frames from the animation
  34598. * @returns The key frames of the animation
  34599. */
  34600. getKeys(): Array<IAnimationKey>;
  34601. /**
  34602. * Gets the highest frame rate of the animation
  34603. * @returns Highest frame rate of the animation
  34604. */
  34605. getHighestFrame(): number;
  34606. /**
  34607. * Gets the easing function of the animation
  34608. * @returns Easing function of the animation
  34609. */
  34610. getEasingFunction(): IEasingFunction;
  34611. /**
  34612. * Sets the easing function of the animation
  34613. * @param easingFunction A custom mathematical formula for animation
  34614. */
  34615. setEasingFunction(easingFunction: EasingFunction): void;
  34616. /**
  34617. * Interpolates a scalar linearly
  34618. * @param startValue Start value of the animation curve
  34619. * @param endValue End value of the animation curve
  34620. * @param gradient Scalar amount to interpolate
  34621. * @returns Interpolated scalar value
  34622. */
  34623. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34624. /**
  34625. * Interpolates a scalar cubically
  34626. * @param startValue Start value of the animation curve
  34627. * @param outTangent End tangent of the animation
  34628. * @param endValue End value of the animation curve
  34629. * @param inTangent Start tangent of the animation curve
  34630. * @param gradient Scalar amount to interpolate
  34631. * @returns Interpolated scalar value
  34632. */
  34633. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34634. /**
  34635. * Interpolates a quaternion using a spherical linear interpolation
  34636. * @param startValue Start value of the animation curve
  34637. * @param endValue End value of the animation curve
  34638. * @param gradient Scalar amount to interpolate
  34639. * @returns Interpolated quaternion value
  34640. */
  34641. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34642. /**
  34643. * Interpolates a quaternion cubically
  34644. * @param startValue Start value of the animation curve
  34645. * @param outTangent End tangent of the animation curve
  34646. * @param endValue End value of the animation curve
  34647. * @param inTangent Start tangent of the animation curve
  34648. * @param gradient Scalar amount to interpolate
  34649. * @returns Interpolated quaternion value
  34650. */
  34651. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34652. /**
  34653. * Interpolates a Vector3 linearl
  34654. * @param startValue Start value of the animation curve
  34655. * @param endValue End value of the animation curve
  34656. * @param gradient Scalar amount to interpolate
  34657. * @returns Interpolated scalar value
  34658. */
  34659. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34660. /**
  34661. * Interpolates a Vector3 cubically
  34662. * @param startValue Start value of the animation curve
  34663. * @param outTangent End tangent of the animation
  34664. * @param endValue End value of the animation curve
  34665. * @param inTangent Start tangent of the animation curve
  34666. * @param gradient Scalar amount to interpolate
  34667. * @returns InterpolatedVector3 value
  34668. */
  34669. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34670. /**
  34671. * Interpolates a Vector2 linearly
  34672. * @param startValue Start value of the animation curve
  34673. * @param endValue End value of the animation curve
  34674. * @param gradient Scalar amount to interpolate
  34675. * @returns Interpolated Vector2 value
  34676. */
  34677. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34678. /**
  34679. * Interpolates a Vector2 cubically
  34680. * @param startValue Start value of the animation curve
  34681. * @param outTangent End tangent of the animation
  34682. * @param endValue End value of the animation curve
  34683. * @param inTangent Start tangent of the animation curve
  34684. * @param gradient Scalar amount to interpolate
  34685. * @returns Interpolated Vector2 value
  34686. */
  34687. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34688. /**
  34689. * Interpolates a size linearly
  34690. * @param startValue Start value of the animation curve
  34691. * @param endValue End value of the animation curve
  34692. * @param gradient Scalar amount to interpolate
  34693. * @returns Interpolated Size value
  34694. */
  34695. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34696. /**
  34697. * Interpolates a Color3 linearly
  34698. * @param startValue Start value of the animation curve
  34699. * @param endValue End value of the animation curve
  34700. * @param gradient Scalar amount to interpolate
  34701. * @returns Interpolated Color3 value
  34702. */
  34703. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34704. /**
  34705. * Interpolates a Color4 linearly
  34706. * @param startValue Start value of the animation curve
  34707. * @param endValue End value of the animation curve
  34708. * @param gradient Scalar amount to interpolate
  34709. * @returns Interpolated Color3 value
  34710. */
  34711. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34712. /**
  34713. * @hidden Internal use only
  34714. */
  34715. _getKeyValue(value: any): any;
  34716. /**
  34717. * @hidden Internal use only
  34718. */
  34719. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34720. /**
  34721. * Defines the function to use to interpolate matrices
  34722. * @param startValue defines the start matrix
  34723. * @param endValue defines the end matrix
  34724. * @param gradient defines the gradient between both matrices
  34725. * @param result defines an optional target matrix where to store the interpolation
  34726. * @returns the interpolated matrix
  34727. */
  34728. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34729. /**
  34730. * Makes a copy of the animation
  34731. * @returns Cloned animation
  34732. */
  34733. clone(): Animation;
  34734. /**
  34735. * Sets the key frames of the animation
  34736. * @param values The animation key frames to set
  34737. */
  34738. setKeys(values: Array<IAnimationKey>): void;
  34739. /**
  34740. * Serializes the animation to an object
  34741. * @returns Serialized object
  34742. */
  34743. serialize(): any;
  34744. /**
  34745. * Float animation type
  34746. */
  34747. static readonly ANIMATIONTYPE_FLOAT: number;
  34748. /**
  34749. * Vector3 animation type
  34750. */
  34751. static readonly ANIMATIONTYPE_VECTOR3: number;
  34752. /**
  34753. * Quaternion animation type
  34754. */
  34755. static readonly ANIMATIONTYPE_QUATERNION: number;
  34756. /**
  34757. * Matrix animation type
  34758. */
  34759. static readonly ANIMATIONTYPE_MATRIX: number;
  34760. /**
  34761. * Color3 animation type
  34762. */
  34763. static readonly ANIMATIONTYPE_COLOR3: number;
  34764. /**
  34765. * Color3 animation type
  34766. */
  34767. static readonly ANIMATIONTYPE_COLOR4: number;
  34768. /**
  34769. * Vector2 animation type
  34770. */
  34771. static readonly ANIMATIONTYPE_VECTOR2: number;
  34772. /**
  34773. * Size animation type
  34774. */
  34775. static readonly ANIMATIONTYPE_SIZE: number;
  34776. /**
  34777. * Relative Loop Mode
  34778. */
  34779. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34780. /**
  34781. * Cycle Loop Mode
  34782. */
  34783. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34784. /**
  34785. * Constant Loop Mode
  34786. */
  34787. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34788. /** @hidden */
  34789. static _UniversalLerp(left: any, right: any, amount: number): any;
  34790. /**
  34791. * Parses an animation object and creates an animation
  34792. * @param parsedAnimation Parsed animation object
  34793. * @returns Animation object
  34794. */
  34795. static Parse(parsedAnimation: any): Animation;
  34796. /**
  34797. * Appends the serialized animations from the source animations
  34798. * @param source Source containing the animations
  34799. * @param destination Target to store the animations
  34800. */
  34801. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34802. /**
  34803. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34804. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34805. * @param url defines the url to load from
  34806. * @returns a promise that will resolve to the new animation or an array of animations
  34807. */
  34808. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34809. /**
  34810. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34811. * @param snippetId defines the snippet to load
  34812. * @returns a promise that will resolve to the new animation or a new array of animations
  34813. */
  34814. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34815. }
  34816. }
  34817. declare module "babylonjs/Animations/animatable.interface" {
  34818. import { Nullable } from "babylonjs/types";
  34819. import { Animation } from "babylonjs/Animations/animation";
  34820. /**
  34821. * Interface containing an array of animations
  34822. */
  34823. export interface IAnimatable {
  34824. /**
  34825. * Array of animations
  34826. */
  34827. animations: Nullable<Array<Animation>>;
  34828. }
  34829. }
  34830. declare module "babylonjs/Misc/decorators" {
  34831. import { Nullable } from "babylonjs/types";
  34832. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34833. import { Scene } from "babylonjs/scene";
  34834. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34835. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34836. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34838. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34839. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34840. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34841. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34842. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34843. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34844. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34845. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34846. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34847. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34848. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34849. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34850. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34851. /**
  34852. * Decorator used to define property that can be serialized as reference to a camera
  34853. * @param sourceName defines the name of the property to decorate
  34854. */
  34855. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34856. /**
  34857. * Class used to help serialization objects
  34858. */
  34859. export class SerializationHelper {
  34860. /** @hidden */
  34861. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34862. /** @hidden */
  34863. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34864. /** @hidden */
  34865. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34866. /** @hidden */
  34867. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34868. /**
  34869. * Appends the serialized animations from the source animations
  34870. * @param source Source containing the animations
  34871. * @param destination Target to store the animations
  34872. */
  34873. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34874. /**
  34875. * Static function used to serialized a specific entity
  34876. * @param entity defines the entity to serialize
  34877. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34878. * @returns a JSON compatible object representing the serialization of the entity
  34879. */
  34880. static Serialize<T>(entity: T, serializationObject?: any): any;
  34881. /**
  34882. * Creates a new entity from a serialization data object
  34883. * @param creationFunction defines a function used to instanciated the new entity
  34884. * @param source defines the source serialization data
  34885. * @param scene defines the hosting scene
  34886. * @param rootUrl defines the root url for resources
  34887. * @returns a new entity
  34888. */
  34889. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34890. /**
  34891. * Clones an object
  34892. * @param creationFunction defines the function used to instanciate the new object
  34893. * @param source defines the source object
  34894. * @returns the cloned object
  34895. */
  34896. static Clone<T>(creationFunction: () => T, source: T): T;
  34897. /**
  34898. * Instanciates a new object based on a source one (some data will be shared between both object)
  34899. * @param creationFunction defines the function used to instanciate the new object
  34900. * @param source defines the source object
  34901. * @returns the new object
  34902. */
  34903. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34904. }
  34905. }
  34906. declare module "babylonjs/Materials/Textures/baseTexture" {
  34907. import { Observable } from "babylonjs/Misc/observable";
  34908. import { Nullable } from "babylonjs/types";
  34909. import { Scene } from "babylonjs/scene";
  34910. import { Matrix } from "babylonjs/Maths/math.vector";
  34911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34912. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34913. import { ISize } from "babylonjs/Maths/math.size";
  34914. import "babylonjs/Misc/fileTools";
  34915. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34916. /**
  34917. * Base class of all the textures in babylon.
  34918. * It groups all the common properties the materials, post process, lights... might need
  34919. * in order to make a correct use of the texture.
  34920. */
  34921. export class BaseTexture implements IAnimatable {
  34922. /**
  34923. * Default anisotropic filtering level for the application.
  34924. * It is set to 4 as a good tradeoff between perf and quality.
  34925. */
  34926. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34927. /**
  34928. * Gets or sets the unique id of the texture
  34929. */
  34930. uniqueId: number;
  34931. /**
  34932. * Define the name of the texture.
  34933. */
  34934. name: string;
  34935. /**
  34936. * Gets or sets an object used to store user defined information.
  34937. */
  34938. metadata: any;
  34939. /**
  34940. * For internal use only. Please do not use.
  34941. */
  34942. reservedDataStore: any;
  34943. private _hasAlpha;
  34944. /**
  34945. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34946. */
  34947. set hasAlpha(value: boolean);
  34948. get hasAlpha(): boolean;
  34949. /**
  34950. * Defines if the alpha value should be determined via the rgb values.
  34951. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34952. */
  34953. getAlphaFromRGB: boolean;
  34954. /**
  34955. * Intensity or strength of the texture.
  34956. * It is commonly used by materials to fine tune the intensity of the texture
  34957. */
  34958. level: number;
  34959. /**
  34960. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34961. * This is part of the texture as textures usually maps to one uv set.
  34962. */
  34963. coordinatesIndex: number;
  34964. private _coordinatesMode;
  34965. /**
  34966. * How a texture is mapped.
  34967. *
  34968. * | Value | Type | Description |
  34969. * | ----- | ----------------------------------- | ----------- |
  34970. * | 0 | EXPLICIT_MODE | |
  34971. * | 1 | SPHERICAL_MODE | |
  34972. * | 2 | PLANAR_MODE | |
  34973. * | 3 | CUBIC_MODE | |
  34974. * | 4 | PROJECTION_MODE | |
  34975. * | 5 | SKYBOX_MODE | |
  34976. * | 6 | INVCUBIC_MODE | |
  34977. * | 7 | EQUIRECTANGULAR_MODE | |
  34978. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34979. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34980. */
  34981. set coordinatesMode(value: number);
  34982. get coordinatesMode(): number;
  34983. /**
  34984. * | Value | Type | Description |
  34985. * | ----- | ------------------ | ----------- |
  34986. * | 0 | CLAMP_ADDRESSMODE | |
  34987. * | 1 | WRAP_ADDRESSMODE | |
  34988. * | 2 | MIRROR_ADDRESSMODE | |
  34989. */
  34990. wrapU: number;
  34991. /**
  34992. * | Value | Type | Description |
  34993. * | ----- | ------------------ | ----------- |
  34994. * | 0 | CLAMP_ADDRESSMODE | |
  34995. * | 1 | WRAP_ADDRESSMODE | |
  34996. * | 2 | MIRROR_ADDRESSMODE | |
  34997. */
  34998. wrapV: number;
  34999. /**
  35000. * | Value | Type | Description |
  35001. * | ----- | ------------------ | ----------- |
  35002. * | 0 | CLAMP_ADDRESSMODE | |
  35003. * | 1 | WRAP_ADDRESSMODE | |
  35004. * | 2 | MIRROR_ADDRESSMODE | |
  35005. */
  35006. wrapR: number;
  35007. /**
  35008. * With compliant hardware and browser (supporting anisotropic filtering)
  35009. * this defines the level of anisotropic filtering in the texture.
  35010. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35011. */
  35012. anisotropicFilteringLevel: number;
  35013. /**
  35014. * Define if the texture is a cube texture or if false a 2d texture.
  35015. */
  35016. get isCube(): boolean;
  35017. set isCube(value: boolean);
  35018. /**
  35019. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35020. */
  35021. get is3D(): boolean;
  35022. set is3D(value: boolean);
  35023. /**
  35024. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35025. */
  35026. get is2DArray(): boolean;
  35027. set is2DArray(value: boolean);
  35028. /**
  35029. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35030. * HDR texture are usually stored in linear space.
  35031. * This only impacts the PBR and Background materials
  35032. */
  35033. gammaSpace: boolean;
  35034. /**
  35035. * Gets or sets whether or not the texture contains RGBD data.
  35036. */
  35037. get isRGBD(): boolean;
  35038. set isRGBD(value: boolean);
  35039. /**
  35040. * Is Z inverted in the texture (useful in a cube texture).
  35041. */
  35042. invertZ: boolean;
  35043. /**
  35044. * Are mip maps generated for this texture or not.
  35045. */
  35046. get noMipmap(): boolean;
  35047. /**
  35048. * @hidden
  35049. */
  35050. lodLevelInAlpha: boolean;
  35051. /**
  35052. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35053. */
  35054. get lodGenerationOffset(): number;
  35055. set lodGenerationOffset(value: number);
  35056. /**
  35057. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35058. */
  35059. get lodGenerationScale(): number;
  35060. set lodGenerationScale(value: number);
  35061. /**
  35062. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35063. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35064. * average roughness values.
  35065. */
  35066. get linearSpecularLOD(): boolean;
  35067. set linearSpecularLOD(value: boolean);
  35068. /**
  35069. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35070. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35071. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35072. */
  35073. get irradianceTexture(): Nullable<BaseTexture>;
  35074. set irradianceTexture(value: Nullable<BaseTexture>);
  35075. /**
  35076. * Define if the texture is a render target.
  35077. */
  35078. isRenderTarget: boolean;
  35079. /**
  35080. * Define the unique id of the texture in the scene.
  35081. */
  35082. get uid(): string;
  35083. /** @hidden */
  35084. _prefiltered: boolean;
  35085. /**
  35086. * Return a string representation of the texture.
  35087. * @returns the texture as a string
  35088. */
  35089. toString(): string;
  35090. /**
  35091. * Get the class name of the texture.
  35092. * @returns "BaseTexture"
  35093. */
  35094. getClassName(): string;
  35095. /**
  35096. * Define the list of animation attached to the texture.
  35097. */
  35098. animations: import("babylonjs/Animations/animation").Animation[];
  35099. /**
  35100. * An event triggered when the texture is disposed.
  35101. */
  35102. onDisposeObservable: Observable<BaseTexture>;
  35103. private _onDisposeObserver;
  35104. /**
  35105. * Callback triggered when the texture has been disposed.
  35106. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35107. */
  35108. set onDispose(callback: () => void);
  35109. /**
  35110. * Define the current state of the loading sequence when in delayed load mode.
  35111. */
  35112. delayLoadState: number;
  35113. protected _scene: Nullable<Scene>;
  35114. protected _engine: Nullable<ThinEngine>;
  35115. /** @hidden */
  35116. _texture: Nullable<InternalTexture>;
  35117. private _uid;
  35118. /**
  35119. * Define if the texture is preventinga material to render or not.
  35120. * If not and the texture is not ready, the engine will use a default black texture instead.
  35121. */
  35122. get isBlocking(): boolean;
  35123. /**
  35124. * Instantiates a new BaseTexture.
  35125. * Base class of all the textures in babylon.
  35126. * It groups all the common properties the materials, post process, lights... might need
  35127. * in order to make a correct use of the texture.
  35128. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35129. */
  35130. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35131. /**
  35132. * Get the scene the texture belongs to.
  35133. * @returns the scene or null if undefined
  35134. */
  35135. getScene(): Nullable<Scene>;
  35136. /** @hidden */
  35137. protected _getEngine(): Nullable<ThinEngine>;
  35138. /**
  35139. * Get the texture transform matrix used to offset tile the texture for istance.
  35140. * @returns the transformation matrix
  35141. */
  35142. getTextureMatrix(): Matrix;
  35143. /**
  35144. * Get the texture reflection matrix used to rotate/transform the reflection.
  35145. * @returns the reflection matrix
  35146. */
  35147. getReflectionTextureMatrix(): Matrix;
  35148. /**
  35149. * Get the underlying lower level texture from Babylon.
  35150. * @returns the insternal texture
  35151. */
  35152. getInternalTexture(): Nullable<InternalTexture>;
  35153. /**
  35154. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35155. * @returns true if ready or not blocking
  35156. */
  35157. isReadyOrNotBlocking(): boolean;
  35158. /**
  35159. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35160. * @returns true if fully ready
  35161. */
  35162. isReady(): boolean;
  35163. private _cachedSize;
  35164. /**
  35165. * Get the size of the texture.
  35166. * @returns the texture size.
  35167. */
  35168. getSize(): ISize;
  35169. /**
  35170. * Get the base size of the texture.
  35171. * It can be different from the size if the texture has been resized for POT for instance
  35172. * @returns the base size
  35173. */
  35174. getBaseSize(): ISize;
  35175. /**
  35176. * Update the sampling mode of the texture.
  35177. * Default is Trilinear mode.
  35178. *
  35179. * | Value | Type | Description |
  35180. * | ----- | ------------------ | ----------- |
  35181. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35182. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35183. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35184. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35185. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35186. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35187. * | 7 | NEAREST_LINEAR | |
  35188. * | 8 | NEAREST_NEAREST | |
  35189. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35190. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35191. * | 11 | LINEAR_LINEAR | |
  35192. * | 12 | LINEAR_NEAREST | |
  35193. *
  35194. * > _mag_: magnification filter (close to the viewer)
  35195. * > _min_: minification filter (far from the viewer)
  35196. * > _mip_: filter used between mip map levels
  35197. *@param samplingMode Define the new sampling mode of the texture
  35198. */
  35199. updateSamplingMode(samplingMode: number): void;
  35200. /**
  35201. * Scales the texture if is `canRescale()`
  35202. * @param ratio the resize factor we want to use to rescale
  35203. */
  35204. scale(ratio: number): void;
  35205. /**
  35206. * Get if the texture can rescale.
  35207. */
  35208. get canRescale(): boolean;
  35209. /** @hidden */
  35210. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35211. /** @hidden */
  35212. _rebuild(): void;
  35213. /**
  35214. * Triggers the load sequence in delayed load mode.
  35215. */
  35216. delayLoad(): void;
  35217. /**
  35218. * Clones the texture.
  35219. * @returns the cloned texture
  35220. */
  35221. clone(): Nullable<BaseTexture>;
  35222. /**
  35223. * Get the texture underlying type (INT, FLOAT...)
  35224. */
  35225. get textureType(): number;
  35226. /**
  35227. * Get the texture underlying format (RGB, RGBA...)
  35228. */
  35229. get textureFormat(): number;
  35230. /**
  35231. * Indicates that textures need to be re-calculated for all materials
  35232. */
  35233. protected _markAllSubMeshesAsTexturesDirty(): void;
  35234. /**
  35235. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35236. * This will returns an RGBA array buffer containing either in values (0-255) or
  35237. * float values (0-1) depending of the underlying buffer type.
  35238. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35239. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35240. * @param buffer defines a user defined buffer to fill with data (can be null)
  35241. * @returns The Array buffer containing the pixels data.
  35242. */
  35243. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35244. /**
  35245. * Release and destroy the underlying lower level texture aka internalTexture.
  35246. */
  35247. releaseInternalTexture(): void;
  35248. /** @hidden */
  35249. get _lodTextureHigh(): Nullable<BaseTexture>;
  35250. /** @hidden */
  35251. get _lodTextureMid(): Nullable<BaseTexture>;
  35252. /** @hidden */
  35253. get _lodTextureLow(): Nullable<BaseTexture>;
  35254. /**
  35255. * Dispose the texture and release its associated resources.
  35256. */
  35257. dispose(): void;
  35258. /**
  35259. * Serialize the texture into a JSON representation that can be parsed later on.
  35260. * @returns the JSON representation of the texture
  35261. */
  35262. serialize(): any;
  35263. /**
  35264. * Helper function to be called back once a list of texture contains only ready textures.
  35265. * @param textures Define the list of textures to wait for
  35266. * @param callback Define the callback triggered once the entire list will be ready
  35267. */
  35268. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35269. private static _isScene;
  35270. }
  35271. }
  35272. declare module "babylonjs/Materials/effect" {
  35273. import { Observable } from "babylonjs/Misc/observable";
  35274. import { Nullable } from "babylonjs/types";
  35275. import { IDisposable } from "babylonjs/scene";
  35276. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35278. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35279. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35280. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35281. import { Engine } from "babylonjs/Engines/engine";
  35282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35285. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35286. /**
  35287. * Options to be used when creating an effect.
  35288. */
  35289. export interface IEffectCreationOptions {
  35290. /**
  35291. * Atrributes that will be used in the shader.
  35292. */
  35293. attributes: string[];
  35294. /**
  35295. * Uniform varible names that will be set in the shader.
  35296. */
  35297. uniformsNames: string[];
  35298. /**
  35299. * Uniform buffer variable names that will be set in the shader.
  35300. */
  35301. uniformBuffersNames: string[];
  35302. /**
  35303. * Sampler texture variable names that will be set in the shader.
  35304. */
  35305. samplers: string[];
  35306. /**
  35307. * Define statements that will be set in the shader.
  35308. */
  35309. defines: any;
  35310. /**
  35311. * Possible fallbacks for this effect to improve performance when needed.
  35312. */
  35313. fallbacks: Nullable<IEffectFallbacks>;
  35314. /**
  35315. * Callback that will be called when the shader is compiled.
  35316. */
  35317. onCompiled: Nullable<(effect: Effect) => void>;
  35318. /**
  35319. * Callback that will be called if an error occurs during shader compilation.
  35320. */
  35321. onError: Nullable<(effect: Effect, errors: string) => void>;
  35322. /**
  35323. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35324. */
  35325. indexParameters?: any;
  35326. /**
  35327. * Max number of lights that can be used in the shader.
  35328. */
  35329. maxSimultaneousLights?: number;
  35330. /**
  35331. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35332. */
  35333. transformFeedbackVaryings?: Nullable<string[]>;
  35334. /**
  35335. * 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
  35336. */
  35337. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35338. /**
  35339. * Is this effect rendering to several color attachments ?
  35340. */
  35341. multiTarget?: boolean;
  35342. }
  35343. /**
  35344. * Effect containing vertex and fragment shader that can be executed on an object.
  35345. */
  35346. export class Effect implements IDisposable {
  35347. /**
  35348. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35349. */
  35350. static ShadersRepository: string;
  35351. /**
  35352. * Enable logging of the shader code when a compilation error occurs
  35353. */
  35354. static LogShaderCodeOnCompilationError: boolean;
  35355. /**
  35356. * Name of the effect.
  35357. */
  35358. name: any;
  35359. /**
  35360. * String container all the define statements that should be set on the shader.
  35361. */
  35362. defines: string;
  35363. /**
  35364. * Callback that will be called when the shader is compiled.
  35365. */
  35366. onCompiled: Nullable<(effect: Effect) => void>;
  35367. /**
  35368. * Callback that will be called if an error occurs during shader compilation.
  35369. */
  35370. onError: Nullable<(effect: Effect, errors: string) => void>;
  35371. /**
  35372. * Callback that will be called when effect is bound.
  35373. */
  35374. onBind: Nullable<(effect: Effect) => void>;
  35375. /**
  35376. * Unique ID of the effect.
  35377. */
  35378. uniqueId: number;
  35379. /**
  35380. * Observable that will be called when the shader is compiled.
  35381. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35382. */
  35383. onCompileObservable: Observable<Effect>;
  35384. /**
  35385. * Observable that will be called if an error occurs during shader compilation.
  35386. */
  35387. onErrorObservable: Observable<Effect>;
  35388. /** @hidden */
  35389. _onBindObservable: Nullable<Observable<Effect>>;
  35390. /**
  35391. * @hidden
  35392. * Specifies if the effect was previously ready
  35393. */
  35394. _wasPreviouslyReady: boolean;
  35395. /**
  35396. * Observable that will be called when effect is bound.
  35397. */
  35398. get onBindObservable(): Observable<Effect>;
  35399. /** @hidden */
  35400. _bonesComputationForcedToCPU: boolean;
  35401. /** @hidden */
  35402. _multiTarget: boolean;
  35403. private static _uniqueIdSeed;
  35404. private _engine;
  35405. private _uniformBuffersNames;
  35406. private _uniformBuffersNamesList;
  35407. private _uniformsNames;
  35408. private _samplerList;
  35409. private _samplers;
  35410. private _isReady;
  35411. private _compilationError;
  35412. private _allFallbacksProcessed;
  35413. private _attributesNames;
  35414. private _attributes;
  35415. private _attributeLocationByName;
  35416. private _uniforms;
  35417. /**
  35418. * Key for the effect.
  35419. * @hidden
  35420. */
  35421. _key: string;
  35422. private _indexParameters;
  35423. private _fallbacks;
  35424. private _vertexSourceCode;
  35425. private _fragmentSourceCode;
  35426. private _vertexSourceCodeOverride;
  35427. private _fragmentSourceCodeOverride;
  35428. private _transformFeedbackVaryings;
  35429. /**
  35430. * Compiled shader to webGL program.
  35431. * @hidden
  35432. */
  35433. _pipelineContext: Nullable<IPipelineContext>;
  35434. private _valueCache;
  35435. private static _baseCache;
  35436. /**
  35437. * Instantiates an effect.
  35438. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35439. * @param baseName Name of the effect.
  35440. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35441. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35442. * @param samplers List of sampler variables that will be passed to the shader.
  35443. * @param engine Engine to be used to render the effect
  35444. * @param defines Define statements to be added to the shader.
  35445. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35446. * @param onCompiled Callback that will be called when the shader is compiled.
  35447. * @param onError Callback that will be called if an error occurs during shader compilation.
  35448. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35449. */
  35450. 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);
  35451. private _useFinalCode;
  35452. /**
  35453. * Unique key for this effect
  35454. */
  35455. get key(): string;
  35456. /**
  35457. * If the effect has been compiled and prepared.
  35458. * @returns if the effect is compiled and prepared.
  35459. */
  35460. isReady(): boolean;
  35461. private _isReadyInternal;
  35462. /**
  35463. * The engine the effect was initialized with.
  35464. * @returns the engine.
  35465. */
  35466. getEngine(): Engine;
  35467. /**
  35468. * The pipeline context for this effect
  35469. * @returns the associated pipeline context
  35470. */
  35471. getPipelineContext(): Nullable<IPipelineContext>;
  35472. /**
  35473. * The set of names of attribute variables for the shader.
  35474. * @returns An array of attribute names.
  35475. */
  35476. getAttributesNames(): string[];
  35477. /**
  35478. * Returns the attribute at the given index.
  35479. * @param index The index of the attribute.
  35480. * @returns The location of the attribute.
  35481. */
  35482. getAttributeLocation(index: number): number;
  35483. /**
  35484. * Returns the attribute based on the name of the variable.
  35485. * @param name of the attribute to look up.
  35486. * @returns the attribute location.
  35487. */
  35488. getAttributeLocationByName(name: string): number;
  35489. /**
  35490. * The number of attributes.
  35491. * @returns the numnber of attributes.
  35492. */
  35493. getAttributesCount(): number;
  35494. /**
  35495. * Gets the index of a uniform variable.
  35496. * @param uniformName of the uniform to look up.
  35497. * @returns the index.
  35498. */
  35499. getUniformIndex(uniformName: string): number;
  35500. /**
  35501. * Returns the attribute based on the name of the variable.
  35502. * @param uniformName of the uniform to look up.
  35503. * @returns the location of the uniform.
  35504. */
  35505. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35506. /**
  35507. * Returns an array of sampler variable names
  35508. * @returns The array of sampler variable names.
  35509. */
  35510. getSamplers(): string[];
  35511. /**
  35512. * Returns an array of uniform variable names
  35513. * @returns The array of uniform variable names.
  35514. */
  35515. getUniformNames(): string[];
  35516. /**
  35517. * Returns an array of uniform buffer variable names
  35518. * @returns The array of uniform buffer variable names.
  35519. */
  35520. getUniformBuffersNames(): string[];
  35521. /**
  35522. * Returns the index parameters used to create the effect
  35523. * @returns The index parameters object
  35524. */
  35525. getIndexParameters(): any;
  35526. /**
  35527. * The error from the last compilation.
  35528. * @returns the error string.
  35529. */
  35530. getCompilationError(): string;
  35531. /**
  35532. * Gets a boolean indicating that all fallbacks were used during compilation
  35533. * @returns true if all fallbacks were used
  35534. */
  35535. allFallbacksProcessed(): boolean;
  35536. /**
  35537. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35538. * @param func The callback to be used.
  35539. */
  35540. executeWhenCompiled(func: (effect: Effect) => void): void;
  35541. private _checkIsReady;
  35542. private _loadShader;
  35543. /**
  35544. * Gets the vertex shader source code of this effect
  35545. */
  35546. get vertexSourceCode(): string;
  35547. /**
  35548. * Gets the fragment shader source code of this effect
  35549. */
  35550. get fragmentSourceCode(): string;
  35551. /**
  35552. * Recompiles the webGL program
  35553. * @param vertexSourceCode The source code for the vertex shader.
  35554. * @param fragmentSourceCode The source code for the fragment shader.
  35555. * @param onCompiled Callback called when completed.
  35556. * @param onError Callback called on error.
  35557. * @hidden
  35558. */
  35559. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35560. /**
  35561. * Prepares the effect
  35562. * @hidden
  35563. */
  35564. _prepareEffect(): void;
  35565. private _getShaderCodeAndErrorLine;
  35566. private _processCompilationErrors;
  35567. /**
  35568. * Checks if the effect is supported. (Must be called after compilation)
  35569. */
  35570. get isSupported(): boolean;
  35571. /**
  35572. * Binds a texture to the engine to be used as output of the shader.
  35573. * @param channel Name of the output variable.
  35574. * @param texture Texture to bind.
  35575. * @hidden
  35576. */
  35577. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35578. /**
  35579. * Sets a texture on the engine to be used in the shader.
  35580. * @param channel Name of the sampler variable.
  35581. * @param texture Texture to set.
  35582. */
  35583. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35584. /**
  35585. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35586. * @param channel Name of the sampler variable.
  35587. * @param texture Texture to set.
  35588. */
  35589. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35590. /**
  35591. * Sets an array of textures on the engine to be used in the shader.
  35592. * @param channel Name of the variable.
  35593. * @param textures Textures to set.
  35594. */
  35595. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35596. /**
  35597. * 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)
  35598. * @param channel Name of the sampler variable.
  35599. * @param postProcess Post process to get the input texture from.
  35600. */
  35601. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35602. /**
  35603. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35604. * 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)
  35605. * @param channel Name of the sampler variable.
  35606. * @param postProcess Post process to get the output texture from.
  35607. */
  35608. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35609. /** @hidden */
  35610. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35611. /** @hidden */
  35612. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35613. /** @hidden */
  35614. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35615. /** @hidden */
  35616. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35617. /**
  35618. * Binds a buffer to a uniform.
  35619. * @param buffer Buffer to bind.
  35620. * @param name Name of the uniform variable to bind to.
  35621. */
  35622. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35623. /**
  35624. * Binds block to a uniform.
  35625. * @param blockName Name of the block to bind.
  35626. * @param index Index to bind.
  35627. */
  35628. bindUniformBlock(blockName: string, index: number): void;
  35629. /**
  35630. * Sets an interger value on a uniform variable.
  35631. * @param uniformName Name of the variable.
  35632. * @param value Value to be set.
  35633. * @returns this effect.
  35634. */
  35635. setInt(uniformName: string, value: number): Effect;
  35636. /**
  35637. * Sets an int array on a uniform variable.
  35638. * @param uniformName Name of the variable.
  35639. * @param array array to be set.
  35640. * @returns this effect.
  35641. */
  35642. setIntArray(uniformName: string, array: Int32Array): Effect;
  35643. /**
  35644. * 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)
  35645. * @param uniformName Name of the variable.
  35646. * @param array array to be set.
  35647. * @returns this effect.
  35648. */
  35649. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35650. /**
  35651. * 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)
  35652. * @param uniformName Name of the variable.
  35653. * @param array array to be set.
  35654. * @returns this effect.
  35655. */
  35656. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35657. /**
  35658. * 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)
  35659. * @param uniformName Name of the variable.
  35660. * @param array array to be set.
  35661. * @returns this effect.
  35662. */
  35663. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35664. /**
  35665. * Sets an float array on a uniform variable.
  35666. * @param uniformName Name of the variable.
  35667. * @param array array to be set.
  35668. * @returns this effect.
  35669. */
  35670. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35671. /**
  35672. * 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)
  35673. * @param uniformName Name of the variable.
  35674. * @param array array to be set.
  35675. * @returns this effect.
  35676. */
  35677. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35678. /**
  35679. * 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)
  35680. * @param uniformName Name of the variable.
  35681. * @param array array to be set.
  35682. * @returns this effect.
  35683. */
  35684. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35685. /**
  35686. * 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)
  35687. * @param uniformName Name of the variable.
  35688. * @param array array to be set.
  35689. * @returns this effect.
  35690. */
  35691. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35692. /**
  35693. * Sets an array on a uniform variable.
  35694. * @param uniformName Name of the variable.
  35695. * @param array array to be set.
  35696. * @returns this effect.
  35697. */
  35698. setArray(uniformName: string, array: number[]): Effect;
  35699. /**
  35700. * 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)
  35701. * @param uniformName Name of the variable.
  35702. * @param array array to be set.
  35703. * @returns this effect.
  35704. */
  35705. setArray2(uniformName: string, array: number[]): Effect;
  35706. /**
  35707. * 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)
  35708. * @param uniformName Name of the variable.
  35709. * @param array array to be set.
  35710. * @returns this effect.
  35711. */
  35712. setArray3(uniformName: string, array: number[]): Effect;
  35713. /**
  35714. * 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)
  35715. * @param uniformName Name of the variable.
  35716. * @param array array to be set.
  35717. * @returns this effect.
  35718. */
  35719. setArray4(uniformName: string, array: number[]): Effect;
  35720. /**
  35721. * Sets matrices on a uniform variable.
  35722. * @param uniformName Name of the variable.
  35723. * @param matrices matrices to be set.
  35724. * @returns this effect.
  35725. */
  35726. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35727. /**
  35728. * Sets matrix on a uniform variable.
  35729. * @param uniformName Name of the variable.
  35730. * @param matrix matrix to be set.
  35731. * @returns this effect.
  35732. */
  35733. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35734. /**
  35735. * 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)
  35736. * @param uniformName Name of the variable.
  35737. * @param matrix matrix to be set.
  35738. * @returns this effect.
  35739. */
  35740. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35741. /**
  35742. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35743. * @param uniformName Name of the variable.
  35744. * @param matrix matrix to be set.
  35745. * @returns this effect.
  35746. */
  35747. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35748. /**
  35749. * Sets a float on a uniform variable.
  35750. * @param uniformName Name of the variable.
  35751. * @param value value to be set.
  35752. * @returns this effect.
  35753. */
  35754. setFloat(uniformName: string, value: number): Effect;
  35755. /**
  35756. * Sets a boolean on a uniform variable.
  35757. * @param uniformName Name of the variable.
  35758. * @param bool value to be set.
  35759. * @returns this effect.
  35760. */
  35761. setBool(uniformName: string, bool: boolean): Effect;
  35762. /**
  35763. * Sets a Vector2 on a uniform variable.
  35764. * @param uniformName Name of the variable.
  35765. * @param vector2 vector2 to be set.
  35766. * @returns this effect.
  35767. */
  35768. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35769. /**
  35770. * Sets a float2 on a uniform variable.
  35771. * @param uniformName Name of the variable.
  35772. * @param x First float in float2.
  35773. * @param y Second float in float2.
  35774. * @returns this effect.
  35775. */
  35776. setFloat2(uniformName: string, x: number, y: number): Effect;
  35777. /**
  35778. * Sets a Vector3 on a uniform variable.
  35779. * @param uniformName Name of the variable.
  35780. * @param vector3 Value to be set.
  35781. * @returns this effect.
  35782. */
  35783. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35784. /**
  35785. * Sets a float3 on a uniform variable.
  35786. * @param uniformName Name of the variable.
  35787. * @param x First float in float3.
  35788. * @param y Second float in float3.
  35789. * @param z Third float in float3.
  35790. * @returns this effect.
  35791. */
  35792. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35793. /**
  35794. * Sets a Vector4 on a uniform variable.
  35795. * @param uniformName Name of the variable.
  35796. * @param vector4 Value to be set.
  35797. * @returns this effect.
  35798. */
  35799. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35800. /**
  35801. * Sets a float4 on a uniform variable.
  35802. * @param uniformName Name of the variable.
  35803. * @param x First float in float4.
  35804. * @param y Second float in float4.
  35805. * @param z Third float in float4.
  35806. * @param w Fourth float in float4.
  35807. * @returns this effect.
  35808. */
  35809. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35810. /**
  35811. * Sets a Color3 on a uniform variable.
  35812. * @param uniformName Name of the variable.
  35813. * @param color3 Value to be set.
  35814. * @returns this effect.
  35815. */
  35816. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35817. /**
  35818. * Sets a Color4 on a uniform variable.
  35819. * @param uniformName Name of the variable.
  35820. * @param color3 Value to be set.
  35821. * @param alpha Alpha value to be set.
  35822. * @returns this effect.
  35823. */
  35824. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35825. /**
  35826. * Sets a Color4 on a uniform variable
  35827. * @param uniformName defines the name of the variable
  35828. * @param color4 defines the value to be set
  35829. * @returns this effect.
  35830. */
  35831. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35832. /** Release all associated resources */
  35833. dispose(): void;
  35834. /**
  35835. * This function will add a new shader to the shader store
  35836. * @param name the name of the shader
  35837. * @param pixelShader optional pixel shader content
  35838. * @param vertexShader optional vertex shader content
  35839. */
  35840. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35841. /**
  35842. * Store of each shader (The can be looked up using effect.key)
  35843. */
  35844. static ShadersStore: {
  35845. [key: string]: string;
  35846. };
  35847. /**
  35848. * Store of each included file for a shader (The can be looked up using effect.key)
  35849. */
  35850. static IncludesShadersStore: {
  35851. [key: string]: string;
  35852. };
  35853. /**
  35854. * Resets the cache of effects.
  35855. */
  35856. static ResetCache(): void;
  35857. }
  35858. }
  35859. declare module "babylonjs/Engines/engineCapabilities" {
  35860. /**
  35861. * Interface used to describe the capabilities of the engine relatively to the current browser
  35862. */
  35863. export interface EngineCapabilities {
  35864. /** Maximum textures units per fragment shader */
  35865. maxTexturesImageUnits: number;
  35866. /** Maximum texture units per vertex shader */
  35867. maxVertexTextureImageUnits: number;
  35868. /** Maximum textures units in the entire pipeline */
  35869. maxCombinedTexturesImageUnits: number;
  35870. /** Maximum texture size */
  35871. maxTextureSize: number;
  35872. /** Maximum texture samples */
  35873. maxSamples?: number;
  35874. /** Maximum cube texture size */
  35875. maxCubemapTextureSize: number;
  35876. /** Maximum render texture size */
  35877. maxRenderTextureSize: number;
  35878. /** Maximum number of vertex attributes */
  35879. maxVertexAttribs: number;
  35880. /** Maximum number of varyings */
  35881. maxVaryingVectors: number;
  35882. /** Maximum number of uniforms per vertex shader */
  35883. maxVertexUniformVectors: number;
  35884. /** Maximum number of uniforms per fragment shader */
  35885. maxFragmentUniformVectors: number;
  35886. /** Defines if standard derivates (dx/dy) are supported */
  35887. standardDerivatives: boolean;
  35888. /** Defines if s3tc texture compression is supported */
  35889. s3tc?: WEBGL_compressed_texture_s3tc;
  35890. /** Defines if pvrtc texture compression is supported */
  35891. pvrtc: any;
  35892. /** Defines if etc1 texture compression is supported */
  35893. etc1: any;
  35894. /** Defines if etc2 texture compression is supported */
  35895. etc2: any;
  35896. /** Defines if astc texture compression is supported */
  35897. astc: any;
  35898. /** Defines if float textures are supported */
  35899. textureFloat: boolean;
  35900. /** Defines if vertex array objects are supported */
  35901. vertexArrayObject: boolean;
  35902. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35903. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35904. /** Gets the maximum level of anisotropy supported */
  35905. maxAnisotropy: number;
  35906. /** Defines if instancing is supported */
  35907. instancedArrays: boolean;
  35908. /** Defines if 32 bits indices are supported */
  35909. uintIndices: boolean;
  35910. /** Defines if high precision shaders are supported */
  35911. highPrecisionShaderSupported: boolean;
  35912. /** Defines if depth reading in the fragment shader is supported */
  35913. fragmentDepthSupported: boolean;
  35914. /** Defines if float texture linear filtering is supported*/
  35915. textureFloatLinearFiltering: boolean;
  35916. /** Defines if rendering to float textures is supported */
  35917. textureFloatRender: boolean;
  35918. /** Defines if half float textures are supported*/
  35919. textureHalfFloat: boolean;
  35920. /** Defines if half float texture linear filtering is supported*/
  35921. textureHalfFloatLinearFiltering: boolean;
  35922. /** Defines if rendering to half float textures is supported */
  35923. textureHalfFloatRender: boolean;
  35924. /** Defines if textureLOD shader command is supported */
  35925. textureLOD: boolean;
  35926. /** Defines if draw buffers extension is supported */
  35927. drawBuffersExtension: boolean;
  35928. /** Defines if depth textures are supported */
  35929. depthTextureExtension: boolean;
  35930. /** Defines if float color buffer are supported */
  35931. colorBufferFloat: boolean;
  35932. /** Gets disjoint timer query extension (null if not supported) */
  35933. timerQuery?: EXT_disjoint_timer_query;
  35934. /** Defines if timestamp can be used with timer query */
  35935. canUseTimestampForTimerQuery: boolean;
  35936. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35937. multiview?: any;
  35938. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35939. oculusMultiview?: any;
  35940. /** Function used to let the system compiles shaders in background */
  35941. parallelShaderCompile?: {
  35942. COMPLETION_STATUS_KHR: number;
  35943. };
  35944. /** Max number of texture samples for MSAA */
  35945. maxMSAASamples: number;
  35946. /** Defines if the blend min max extension is supported */
  35947. blendMinMax: boolean;
  35948. }
  35949. }
  35950. declare module "babylonjs/States/depthCullingState" {
  35951. import { Nullable } from "babylonjs/types";
  35952. /**
  35953. * @hidden
  35954. **/
  35955. export class DepthCullingState {
  35956. private _isDepthTestDirty;
  35957. private _isDepthMaskDirty;
  35958. private _isDepthFuncDirty;
  35959. private _isCullFaceDirty;
  35960. private _isCullDirty;
  35961. private _isZOffsetDirty;
  35962. private _isFrontFaceDirty;
  35963. private _depthTest;
  35964. private _depthMask;
  35965. private _depthFunc;
  35966. private _cull;
  35967. private _cullFace;
  35968. private _zOffset;
  35969. private _frontFace;
  35970. /**
  35971. * Initializes the state.
  35972. */
  35973. constructor();
  35974. get isDirty(): boolean;
  35975. get zOffset(): number;
  35976. set zOffset(value: number);
  35977. get cullFace(): Nullable<number>;
  35978. set cullFace(value: Nullable<number>);
  35979. get cull(): Nullable<boolean>;
  35980. set cull(value: Nullable<boolean>);
  35981. get depthFunc(): Nullable<number>;
  35982. set depthFunc(value: Nullable<number>);
  35983. get depthMask(): boolean;
  35984. set depthMask(value: boolean);
  35985. get depthTest(): boolean;
  35986. set depthTest(value: boolean);
  35987. get frontFace(): Nullable<number>;
  35988. set frontFace(value: Nullable<number>);
  35989. reset(): void;
  35990. apply(gl: WebGLRenderingContext): void;
  35991. }
  35992. }
  35993. declare module "babylonjs/States/stencilState" {
  35994. /**
  35995. * @hidden
  35996. **/
  35997. export class StencilState {
  35998. /** 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 */
  35999. static readonly ALWAYS: number;
  36000. /** Passed to stencilOperation to specify that stencil value must be kept */
  36001. static readonly KEEP: number;
  36002. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36003. static readonly REPLACE: number;
  36004. private _isStencilTestDirty;
  36005. private _isStencilMaskDirty;
  36006. private _isStencilFuncDirty;
  36007. private _isStencilOpDirty;
  36008. private _stencilTest;
  36009. private _stencilMask;
  36010. private _stencilFunc;
  36011. private _stencilFuncRef;
  36012. private _stencilFuncMask;
  36013. private _stencilOpStencilFail;
  36014. private _stencilOpDepthFail;
  36015. private _stencilOpStencilDepthPass;
  36016. get isDirty(): boolean;
  36017. get stencilFunc(): number;
  36018. set stencilFunc(value: number);
  36019. get stencilFuncRef(): number;
  36020. set stencilFuncRef(value: number);
  36021. get stencilFuncMask(): number;
  36022. set stencilFuncMask(value: number);
  36023. get stencilOpStencilFail(): number;
  36024. set stencilOpStencilFail(value: number);
  36025. get stencilOpDepthFail(): number;
  36026. set stencilOpDepthFail(value: number);
  36027. get stencilOpStencilDepthPass(): number;
  36028. set stencilOpStencilDepthPass(value: number);
  36029. get stencilMask(): number;
  36030. set stencilMask(value: number);
  36031. get stencilTest(): boolean;
  36032. set stencilTest(value: boolean);
  36033. constructor();
  36034. reset(): void;
  36035. apply(gl: WebGLRenderingContext): void;
  36036. }
  36037. }
  36038. declare module "babylonjs/States/alphaCullingState" {
  36039. /**
  36040. * @hidden
  36041. **/
  36042. export class AlphaState {
  36043. private _isAlphaBlendDirty;
  36044. private _isBlendFunctionParametersDirty;
  36045. private _isBlendEquationParametersDirty;
  36046. private _isBlendConstantsDirty;
  36047. private _alphaBlend;
  36048. private _blendFunctionParameters;
  36049. private _blendEquationParameters;
  36050. private _blendConstants;
  36051. /**
  36052. * Initializes the state.
  36053. */
  36054. constructor();
  36055. get isDirty(): boolean;
  36056. get alphaBlend(): boolean;
  36057. set alphaBlend(value: boolean);
  36058. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36059. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36060. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36061. reset(): void;
  36062. apply(gl: WebGLRenderingContext): void;
  36063. }
  36064. }
  36065. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36066. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36067. /** @hidden */
  36068. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36069. attributeProcessor(attribute: string): string;
  36070. varyingProcessor(varying: string, isFragment: boolean): string;
  36071. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36072. }
  36073. }
  36074. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36075. /**
  36076. * Interface for attribute information associated with buffer instanciation
  36077. */
  36078. export interface InstancingAttributeInfo {
  36079. /**
  36080. * Name of the GLSL attribute
  36081. * if attribute index is not specified, this is used to retrieve the index from the effect
  36082. */
  36083. attributeName: string;
  36084. /**
  36085. * Index/offset of the attribute in the vertex shader
  36086. * if not specified, this will be computes from the name.
  36087. */
  36088. index?: number;
  36089. /**
  36090. * size of the attribute, 1, 2, 3 or 4
  36091. */
  36092. attributeSize: number;
  36093. /**
  36094. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36095. */
  36096. offset: number;
  36097. /**
  36098. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36099. * default to 1
  36100. */
  36101. divisor?: number;
  36102. /**
  36103. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36104. * default is FLOAT
  36105. */
  36106. attributeType?: number;
  36107. /**
  36108. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36109. */
  36110. normalized?: boolean;
  36111. }
  36112. }
  36113. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36114. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36115. import { Nullable } from "babylonjs/types";
  36116. module "babylonjs/Engines/thinEngine" {
  36117. interface ThinEngine {
  36118. /**
  36119. * Update a video texture
  36120. * @param texture defines the texture to update
  36121. * @param video defines the video element to use
  36122. * @param invertY defines if data must be stored with Y axis inverted
  36123. */
  36124. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36125. }
  36126. }
  36127. }
  36128. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36130. import { Nullable } from "babylonjs/types";
  36131. module "babylonjs/Engines/thinEngine" {
  36132. interface ThinEngine {
  36133. /**
  36134. * Creates a dynamic texture
  36135. * @param width defines the width of the texture
  36136. * @param height defines the height of the texture
  36137. * @param generateMipMaps defines if the engine should generate the mip levels
  36138. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36139. * @returns the dynamic texture inside an InternalTexture
  36140. */
  36141. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36142. /**
  36143. * Update the content of a dynamic texture
  36144. * @param texture defines the texture to update
  36145. * @param canvas defines the canvas containing the source
  36146. * @param invertY defines if data must be stored with Y axis inverted
  36147. * @param premulAlpha defines if alpha is stored as premultiplied
  36148. * @param format defines the format of the data
  36149. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36150. */
  36151. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36152. }
  36153. }
  36154. }
  36155. declare module "babylonjs/Materials/Textures/videoTexture" {
  36156. import { Observable } from "babylonjs/Misc/observable";
  36157. import { Nullable } from "babylonjs/types";
  36158. import { Scene } from "babylonjs/scene";
  36159. import { Texture } from "babylonjs/Materials/Textures/texture";
  36160. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36161. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36162. /**
  36163. * Settings for finer control over video usage
  36164. */
  36165. export interface VideoTextureSettings {
  36166. /**
  36167. * Applies `autoplay` to video, if specified
  36168. */
  36169. autoPlay?: boolean;
  36170. /**
  36171. * Applies `loop` to video, if specified
  36172. */
  36173. loop?: boolean;
  36174. /**
  36175. * Automatically updates internal texture from video at every frame in the render loop
  36176. */
  36177. autoUpdateTexture: boolean;
  36178. /**
  36179. * Image src displayed during the video loading or until the user interacts with the video.
  36180. */
  36181. poster?: string;
  36182. }
  36183. /**
  36184. * If you want to display a video in your scene, this is the special texture for that.
  36185. * This special texture works similar to other textures, with the exception of a few parameters.
  36186. * @see https://doc.babylonjs.com/how_to/video_texture
  36187. */
  36188. export class VideoTexture extends Texture {
  36189. /**
  36190. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36191. */
  36192. readonly autoUpdateTexture: boolean;
  36193. /**
  36194. * The video instance used by the texture internally
  36195. */
  36196. readonly video: HTMLVideoElement;
  36197. private _onUserActionRequestedObservable;
  36198. /**
  36199. * Event triggerd when a dom action is required by the user to play the video.
  36200. * This happens due to recent changes in browser policies preventing video to auto start.
  36201. */
  36202. get onUserActionRequestedObservable(): Observable<Texture>;
  36203. private _generateMipMaps;
  36204. private _stillImageCaptured;
  36205. private _displayingPosterTexture;
  36206. private _settings;
  36207. private _createInternalTextureOnEvent;
  36208. private _frameId;
  36209. private _currentSrc;
  36210. /**
  36211. * Creates a video texture.
  36212. * If you want to display a video in your scene, this is the special texture for that.
  36213. * This special texture works similar to other textures, with the exception of a few parameters.
  36214. * @see https://doc.babylonjs.com/how_to/video_texture
  36215. * @param name optional name, will detect from video source, if not defined
  36216. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36217. * @param scene is obviously the current scene.
  36218. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36219. * @param invertY is false by default but can be used to invert video on Y axis
  36220. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36221. * @param settings allows finer control over video usage
  36222. */
  36223. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36224. private _getName;
  36225. private _getVideo;
  36226. private _createInternalTexture;
  36227. private reset;
  36228. /**
  36229. * @hidden Internal method to initiate `update`.
  36230. */
  36231. _rebuild(): void;
  36232. /**
  36233. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36234. */
  36235. update(): void;
  36236. /**
  36237. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36238. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36239. */
  36240. updateTexture(isVisible: boolean): void;
  36241. protected _updateInternalTexture: () => void;
  36242. /**
  36243. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36244. * @param url New url.
  36245. */
  36246. updateURL(url: string): void;
  36247. /**
  36248. * Clones the texture.
  36249. * @returns the cloned texture
  36250. */
  36251. clone(): VideoTexture;
  36252. /**
  36253. * Dispose the texture and release its associated resources.
  36254. */
  36255. dispose(): void;
  36256. /**
  36257. * Creates a video texture straight from a stream.
  36258. * @param scene Define the scene the texture should be created in
  36259. * @param stream Define the stream the texture should be created from
  36260. * @returns The created video texture as a promise
  36261. */
  36262. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36263. /**
  36264. * Creates a video texture straight from your WebCam video feed.
  36265. * @param scene Define the scene the texture should be created in
  36266. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36267. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36268. * @returns The created video texture as a promise
  36269. */
  36270. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36271. minWidth: number;
  36272. maxWidth: number;
  36273. minHeight: number;
  36274. maxHeight: number;
  36275. deviceId: string;
  36276. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36277. /**
  36278. * Creates a video texture straight from your WebCam video feed.
  36279. * @param scene Define the scene the texture should be created in
  36280. * @param onReady Define a callback to triggered once the texture will be ready
  36281. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36282. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36283. */
  36284. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36285. minWidth: number;
  36286. maxWidth: number;
  36287. minHeight: number;
  36288. maxHeight: number;
  36289. deviceId: string;
  36290. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36291. }
  36292. }
  36293. declare module "babylonjs/Engines/thinEngine" {
  36294. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36295. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36296. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36297. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36298. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36299. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36300. import { Observable } from "babylonjs/Misc/observable";
  36301. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36302. import { StencilState } from "babylonjs/States/stencilState";
  36303. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36305. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36307. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36308. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36309. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36310. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36311. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36313. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36314. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36315. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36316. import { WebRequest } from "babylonjs/Misc/webRequest";
  36317. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36318. /**
  36319. * Defines the interface used by objects working like Scene
  36320. * @hidden
  36321. */
  36322. export interface ISceneLike {
  36323. _addPendingData(data: any): void;
  36324. _removePendingData(data: any): void;
  36325. offlineProvider: IOfflineProvider;
  36326. }
  36327. /** Interface defining initialization parameters for Engine class */
  36328. export interface EngineOptions extends WebGLContextAttributes {
  36329. /**
  36330. * Defines if the engine should no exceed a specified device ratio
  36331. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36332. */
  36333. limitDeviceRatio?: number;
  36334. /**
  36335. * Defines if webvr should be enabled automatically
  36336. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36337. */
  36338. autoEnableWebVR?: boolean;
  36339. /**
  36340. * Defines if webgl2 should be turned off even if supported
  36341. * @see https://doc.babylonjs.com/features/webgl2
  36342. */
  36343. disableWebGL2Support?: boolean;
  36344. /**
  36345. * Defines if webaudio should be initialized as well
  36346. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36347. */
  36348. audioEngine?: boolean;
  36349. /**
  36350. * Defines if animations should run using a deterministic lock step
  36351. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36352. */
  36353. deterministicLockstep?: boolean;
  36354. /** Defines the maximum steps to use with deterministic lock step mode */
  36355. lockstepMaxSteps?: number;
  36356. /** Defines the seconds between each deterministic lock step */
  36357. timeStep?: number;
  36358. /**
  36359. * Defines that engine should ignore context lost events
  36360. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36361. */
  36362. doNotHandleContextLost?: boolean;
  36363. /**
  36364. * Defines that engine should ignore modifying touch action attribute and style
  36365. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36366. */
  36367. doNotHandleTouchAction?: boolean;
  36368. /**
  36369. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36370. */
  36371. useHighPrecisionFloats?: boolean;
  36372. /**
  36373. * Make the canvas XR Compatible for XR sessions
  36374. */
  36375. xrCompatible?: boolean;
  36376. /**
  36377. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36378. */
  36379. useHighPrecisionMatrix?: boolean;
  36380. }
  36381. /**
  36382. * The base engine class (root of all engines)
  36383. */
  36384. export class ThinEngine {
  36385. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36386. static ExceptionList: ({
  36387. key: string;
  36388. capture: string;
  36389. captureConstraint: number;
  36390. targets: string[];
  36391. } | {
  36392. key: string;
  36393. capture: null;
  36394. captureConstraint: null;
  36395. targets: string[];
  36396. })[];
  36397. /** @hidden */
  36398. static _TextureLoaders: IInternalTextureLoader[];
  36399. /**
  36400. * Returns the current npm package of the sdk
  36401. */
  36402. static get NpmPackage(): string;
  36403. /**
  36404. * Returns the current version of the framework
  36405. */
  36406. static get Version(): string;
  36407. /**
  36408. * Returns a string describing the current engine
  36409. */
  36410. get description(): string;
  36411. /**
  36412. * Gets or sets the epsilon value used by collision engine
  36413. */
  36414. static CollisionsEpsilon: number;
  36415. /**
  36416. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36417. */
  36418. static get ShadersRepository(): string;
  36419. static set ShadersRepository(value: string);
  36420. /** @hidden */
  36421. _shaderProcessor: IShaderProcessor;
  36422. /**
  36423. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36424. */
  36425. forcePOTTextures: boolean;
  36426. /**
  36427. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36428. */
  36429. isFullscreen: boolean;
  36430. /**
  36431. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36432. */
  36433. cullBackFaces: boolean;
  36434. /**
  36435. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36436. */
  36437. renderEvenInBackground: boolean;
  36438. /**
  36439. * Gets or sets a boolean indicating that cache can be kept between frames
  36440. */
  36441. preventCacheWipeBetweenFrames: boolean;
  36442. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36443. validateShaderPrograms: boolean;
  36444. /**
  36445. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36446. * This can provide greater z depth for distant objects.
  36447. */
  36448. useReverseDepthBuffer: boolean;
  36449. /**
  36450. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36451. */
  36452. disableUniformBuffers: boolean;
  36453. /** @hidden */
  36454. _uniformBuffers: UniformBuffer[];
  36455. /**
  36456. * Gets a boolean indicating that the engine supports uniform buffers
  36457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36458. */
  36459. get supportsUniformBuffers(): boolean;
  36460. /** @hidden */
  36461. _gl: WebGLRenderingContext;
  36462. /** @hidden */
  36463. _webGLVersion: number;
  36464. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36465. protected _windowIsBackground: boolean;
  36466. protected _creationOptions: EngineOptions;
  36467. protected _highPrecisionShadersAllowed: boolean;
  36468. /** @hidden */
  36469. get _shouldUseHighPrecisionShader(): boolean;
  36470. /**
  36471. * Gets a boolean indicating that only power of 2 textures are supported
  36472. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36473. */
  36474. get needPOTTextures(): boolean;
  36475. /** @hidden */
  36476. _badOS: boolean;
  36477. /** @hidden */
  36478. _badDesktopOS: boolean;
  36479. private _hardwareScalingLevel;
  36480. /** @hidden */
  36481. _caps: EngineCapabilities;
  36482. private _isStencilEnable;
  36483. private _glVersion;
  36484. private _glRenderer;
  36485. private _glVendor;
  36486. /** @hidden */
  36487. _videoTextureSupported: boolean;
  36488. protected _renderingQueueLaunched: boolean;
  36489. protected _activeRenderLoops: (() => void)[];
  36490. /**
  36491. * Observable signaled when a context lost event is raised
  36492. */
  36493. onContextLostObservable: Observable<ThinEngine>;
  36494. /**
  36495. * Observable signaled when a context restored event is raised
  36496. */
  36497. onContextRestoredObservable: Observable<ThinEngine>;
  36498. private _onContextLost;
  36499. private _onContextRestored;
  36500. protected _contextWasLost: boolean;
  36501. /** @hidden */
  36502. _doNotHandleContextLost: boolean;
  36503. /**
  36504. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36505. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36506. */
  36507. get doNotHandleContextLost(): boolean;
  36508. set doNotHandleContextLost(value: boolean);
  36509. /**
  36510. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36511. */
  36512. disableVertexArrayObjects: boolean;
  36513. /** @hidden */
  36514. protected _colorWrite: boolean;
  36515. /** @hidden */
  36516. protected _colorWriteChanged: boolean;
  36517. /** @hidden */
  36518. protected _depthCullingState: DepthCullingState;
  36519. /** @hidden */
  36520. protected _stencilState: StencilState;
  36521. /** @hidden */
  36522. _alphaState: AlphaState;
  36523. /** @hidden */
  36524. _alphaMode: number;
  36525. /** @hidden */
  36526. _alphaEquation: number;
  36527. /** @hidden */
  36528. _internalTexturesCache: InternalTexture[];
  36529. /** @hidden */
  36530. protected _activeChannel: number;
  36531. private _currentTextureChannel;
  36532. /** @hidden */
  36533. protected _boundTexturesCache: {
  36534. [key: string]: Nullable<InternalTexture>;
  36535. };
  36536. /** @hidden */
  36537. protected _currentEffect: Nullable<Effect>;
  36538. /** @hidden */
  36539. protected _currentProgram: Nullable<WebGLProgram>;
  36540. private _compiledEffects;
  36541. private _vertexAttribArraysEnabled;
  36542. /** @hidden */
  36543. protected _cachedViewport: Nullable<IViewportLike>;
  36544. private _cachedVertexArrayObject;
  36545. /** @hidden */
  36546. protected _cachedVertexBuffers: any;
  36547. /** @hidden */
  36548. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36549. /** @hidden */
  36550. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36551. /** @hidden */
  36552. _currentRenderTarget: Nullable<InternalTexture>;
  36553. private _uintIndicesCurrentlySet;
  36554. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36555. /** @hidden */
  36556. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36557. /** @hidden */
  36558. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36559. private _currentBufferPointers;
  36560. private _currentInstanceLocations;
  36561. private _currentInstanceBuffers;
  36562. private _textureUnits;
  36563. /** @hidden */
  36564. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36565. /** @hidden */
  36566. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36567. /** @hidden */
  36568. _boundRenderFunction: any;
  36569. private _vaoRecordInProgress;
  36570. private _mustWipeVertexAttributes;
  36571. private _emptyTexture;
  36572. private _emptyCubeTexture;
  36573. private _emptyTexture3D;
  36574. private _emptyTexture2DArray;
  36575. /** @hidden */
  36576. _frameHandler: number;
  36577. private _nextFreeTextureSlots;
  36578. private _maxSimultaneousTextures;
  36579. private _activeRequests;
  36580. /** @hidden */
  36581. _transformTextureUrl: Nullable<(url: string) => string>;
  36582. protected get _supportsHardwareTextureRescaling(): boolean;
  36583. private _framebufferDimensionsObject;
  36584. /**
  36585. * sets the object from which width and height will be taken from when getting render width and height
  36586. * Will fallback to the gl object
  36587. * @param dimensions the framebuffer width and height that will be used.
  36588. */
  36589. set framebufferDimensionsObject(dimensions: Nullable<{
  36590. framebufferWidth: number;
  36591. framebufferHeight: number;
  36592. }>);
  36593. /**
  36594. * Gets the current viewport
  36595. */
  36596. get currentViewport(): Nullable<IViewportLike>;
  36597. /**
  36598. * Gets the default empty texture
  36599. */
  36600. get emptyTexture(): InternalTexture;
  36601. /**
  36602. * Gets the default empty 3D texture
  36603. */
  36604. get emptyTexture3D(): InternalTexture;
  36605. /**
  36606. * Gets the default empty 2D array texture
  36607. */
  36608. get emptyTexture2DArray(): InternalTexture;
  36609. /**
  36610. * Gets the default empty cube texture
  36611. */
  36612. get emptyCubeTexture(): InternalTexture;
  36613. /**
  36614. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36615. */
  36616. readonly premultipliedAlpha: boolean;
  36617. /**
  36618. * Observable event triggered before each texture is initialized
  36619. */
  36620. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36621. /**
  36622. * Creates a new engine
  36623. * @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
  36624. * @param antialias defines enable antialiasing (default: false)
  36625. * @param options defines further options to be sent to the getContext() function
  36626. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36627. */
  36628. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36629. private _rebuildInternalTextures;
  36630. private _rebuildEffects;
  36631. /**
  36632. * Gets a boolean indicating if all created effects are ready
  36633. * @returns true if all effects are ready
  36634. */
  36635. areAllEffectsReady(): boolean;
  36636. protected _rebuildBuffers(): void;
  36637. protected _initGLContext(): void;
  36638. /**
  36639. * Gets version of the current webGL context
  36640. */
  36641. get webGLVersion(): number;
  36642. /**
  36643. * Gets a string idenfifying the name of the class
  36644. * @returns "Engine" string
  36645. */
  36646. getClassName(): string;
  36647. /**
  36648. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36649. */
  36650. get isStencilEnable(): boolean;
  36651. /** @hidden */
  36652. _prepareWorkingCanvas(): void;
  36653. /**
  36654. * Reset the texture cache to empty state
  36655. */
  36656. resetTextureCache(): void;
  36657. /**
  36658. * Gets an object containing information about the current webGL context
  36659. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36660. */
  36661. getGlInfo(): {
  36662. vendor: string;
  36663. renderer: string;
  36664. version: string;
  36665. };
  36666. /**
  36667. * Defines the hardware scaling level.
  36668. * By default the hardware scaling level is computed from the window device ratio.
  36669. * 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.
  36670. * @param level defines the level to use
  36671. */
  36672. setHardwareScalingLevel(level: number): void;
  36673. /**
  36674. * Gets the current hardware scaling level.
  36675. * By default the hardware scaling level is computed from the window device ratio.
  36676. * 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.
  36677. * @returns a number indicating the current hardware scaling level
  36678. */
  36679. getHardwareScalingLevel(): number;
  36680. /**
  36681. * Gets the list of loaded textures
  36682. * @returns an array containing all loaded textures
  36683. */
  36684. getLoadedTexturesCache(): InternalTexture[];
  36685. /**
  36686. * Gets the object containing all engine capabilities
  36687. * @returns the EngineCapabilities object
  36688. */
  36689. getCaps(): EngineCapabilities;
  36690. /**
  36691. * stop executing a render loop function and remove it from the execution array
  36692. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36693. */
  36694. stopRenderLoop(renderFunction?: () => void): void;
  36695. /** @hidden */
  36696. _renderLoop(): void;
  36697. /**
  36698. * Gets the HTML canvas attached with the current webGL context
  36699. * @returns a HTML canvas
  36700. */
  36701. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36702. /**
  36703. * Gets host window
  36704. * @returns the host window object
  36705. */
  36706. getHostWindow(): Nullable<Window>;
  36707. /**
  36708. * Gets the current render width
  36709. * @param useScreen defines if screen size must be used (or the current render target if any)
  36710. * @returns a number defining the current render width
  36711. */
  36712. getRenderWidth(useScreen?: boolean): number;
  36713. /**
  36714. * Gets the current render height
  36715. * @param useScreen defines if screen size must be used (or the current render target if any)
  36716. * @returns a number defining the current render height
  36717. */
  36718. getRenderHeight(useScreen?: boolean): number;
  36719. /**
  36720. * Can be used to override the current requestAnimationFrame requester.
  36721. * @hidden
  36722. */
  36723. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36724. /**
  36725. * Register and execute a render loop. The engine can have more than one render function
  36726. * @param renderFunction defines the function to continuously execute
  36727. */
  36728. runRenderLoop(renderFunction: () => void): void;
  36729. /**
  36730. * Clear the current render buffer or the current render target (if any is set up)
  36731. * @param color defines the color to use
  36732. * @param backBuffer defines if the back buffer must be cleared
  36733. * @param depth defines if the depth buffer must be cleared
  36734. * @param stencil defines if the stencil buffer must be cleared
  36735. */
  36736. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36737. private _viewportCached;
  36738. /** @hidden */
  36739. _viewport(x: number, y: number, width: number, height: number): void;
  36740. /**
  36741. * Set the WebGL's viewport
  36742. * @param viewport defines the viewport element to be used
  36743. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36744. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36745. */
  36746. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36747. /**
  36748. * Begin a new frame
  36749. */
  36750. beginFrame(): void;
  36751. /**
  36752. * Enf the current frame
  36753. */
  36754. endFrame(): void;
  36755. /**
  36756. * Resize the view according to the canvas' size
  36757. */
  36758. resize(): void;
  36759. /**
  36760. * Force a specific size of the canvas
  36761. * @param width defines the new canvas' width
  36762. * @param height defines the new canvas' height
  36763. * @returns true if the size was changed
  36764. */
  36765. setSize(width: number, height: number): boolean;
  36766. /**
  36767. * Binds the frame buffer to the specified texture.
  36768. * @param texture The texture to render to or null for the default canvas
  36769. * @param faceIndex The face of the texture to render to in case of cube texture
  36770. * @param requiredWidth The width of the target to render to
  36771. * @param requiredHeight The height of the target to render to
  36772. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36773. * @param lodLevel defines the lod level to bind to the frame buffer
  36774. * @param layer defines the 2d array index to bind to frame buffer to
  36775. */
  36776. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36777. /** @hidden */
  36778. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36779. /**
  36780. * Unbind the current render target texture from the webGL context
  36781. * @param texture defines the render target texture to unbind
  36782. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36783. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36784. */
  36785. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36786. /**
  36787. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36788. */
  36789. flushFramebuffer(): void;
  36790. /**
  36791. * Unbind the current render target and bind the default framebuffer
  36792. */
  36793. restoreDefaultFramebuffer(): void;
  36794. /** @hidden */
  36795. protected _resetVertexBufferBinding(): void;
  36796. /**
  36797. * Creates a vertex buffer
  36798. * @param data the data for the vertex buffer
  36799. * @returns the new WebGL static buffer
  36800. */
  36801. createVertexBuffer(data: DataArray): DataBuffer;
  36802. private _createVertexBuffer;
  36803. /**
  36804. * Creates a dynamic vertex buffer
  36805. * @param data the data for the dynamic vertex buffer
  36806. * @returns the new WebGL dynamic buffer
  36807. */
  36808. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36809. protected _resetIndexBufferBinding(): void;
  36810. /**
  36811. * Creates a new index buffer
  36812. * @param indices defines the content of the index buffer
  36813. * @param updatable defines if the index buffer must be updatable
  36814. * @returns a new webGL buffer
  36815. */
  36816. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36817. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36818. /**
  36819. * Bind a webGL buffer to the webGL context
  36820. * @param buffer defines the buffer to bind
  36821. */
  36822. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36823. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36824. private bindBuffer;
  36825. /**
  36826. * update the bound buffer with the given data
  36827. * @param data defines the data to update
  36828. */
  36829. updateArrayBuffer(data: Float32Array): void;
  36830. private _vertexAttribPointer;
  36831. /** @hidden */
  36832. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36833. private _bindVertexBuffersAttributes;
  36834. /**
  36835. * Records a vertex array object
  36836. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36837. * @param vertexBuffers defines the list of vertex buffers to store
  36838. * @param indexBuffer defines the index buffer to store
  36839. * @param effect defines the effect to store
  36840. * @returns the new vertex array object
  36841. */
  36842. recordVertexArrayObject(vertexBuffers: {
  36843. [key: string]: VertexBuffer;
  36844. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36845. /**
  36846. * Bind a specific vertex array object
  36847. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36848. * @param vertexArrayObject defines the vertex array object to bind
  36849. * @param indexBuffer defines the index buffer to bind
  36850. */
  36851. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36852. /**
  36853. * Bind webGl buffers directly to the webGL context
  36854. * @param vertexBuffer defines the vertex buffer to bind
  36855. * @param indexBuffer defines the index buffer to bind
  36856. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36857. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36858. * @param effect defines the effect associated with the vertex buffer
  36859. */
  36860. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36861. private _unbindVertexArrayObject;
  36862. /**
  36863. * Bind a list of vertex buffers to the webGL context
  36864. * @param vertexBuffers defines the list of vertex buffers to bind
  36865. * @param indexBuffer defines the index buffer to bind
  36866. * @param effect defines the effect associated with the vertex buffers
  36867. */
  36868. bindBuffers(vertexBuffers: {
  36869. [key: string]: Nullable<VertexBuffer>;
  36870. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36871. /**
  36872. * Unbind all instance attributes
  36873. */
  36874. unbindInstanceAttributes(): void;
  36875. /**
  36876. * Release and free the memory of a vertex array object
  36877. * @param vao defines the vertex array object to delete
  36878. */
  36879. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36880. /** @hidden */
  36881. _releaseBuffer(buffer: DataBuffer): boolean;
  36882. protected _deleteBuffer(buffer: DataBuffer): void;
  36883. /**
  36884. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36885. * @param instancesBuffer defines the webGL buffer to update and bind
  36886. * @param data defines the data to store in the buffer
  36887. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36888. */
  36889. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36890. /**
  36891. * Bind the content of a webGL buffer used with instantiation
  36892. * @param instancesBuffer defines the webGL buffer to bind
  36893. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36894. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36895. */
  36896. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36897. /**
  36898. * Disable the instance attribute corresponding to the name in parameter
  36899. * @param name defines the name of the attribute to disable
  36900. */
  36901. disableInstanceAttributeByName(name: string): void;
  36902. /**
  36903. * Disable the instance attribute corresponding to the location in parameter
  36904. * @param attributeLocation defines the attribute location of the attribute to disable
  36905. */
  36906. disableInstanceAttribute(attributeLocation: number): void;
  36907. /**
  36908. * Disable the attribute corresponding to the location in parameter
  36909. * @param attributeLocation defines the attribute location of the attribute to disable
  36910. */
  36911. disableAttributeByIndex(attributeLocation: number): void;
  36912. /**
  36913. * Send a draw order
  36914. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36915. * @param indexStart defines the starting index
  36916. * @param indexCount defines the number of index to draw
  36917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36918. */
  36919. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36920. /**
  36921. * Draw a list of points
  36922. * @param verticesStart defines the index of first vertex to draw
  36923. * @param verticesCount defines the count of vertices to draw
  36924. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36925. */
  36926. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36927. /**
  36928. * Draw a list of unindexed primitives
  36929. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36930. * @param verticesStart defines the index of first vertex to draw
  36931. * @param verticesCount defines the count of vertices to draw
  36932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36933. */
  36934. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36935. /**
  36936. * Draw a list of indexed primitives
  36937. * @param fillMode defines the primitive to use
  36938. * @param indexStart defines the starting index
  36939. * @param indexCount defines the number of index to draw
  36940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36941. */
  36942. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36943. /**
  36944. * Draw a list of unindexed primitives
  36945. * @param fillMode defines the primitive to use
  36946. * @param verticesStart defines the index of first vertex to draw
  36947. * @param verticesCount defines the count of vertices to draw
  36948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36949. */
  36950. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36951. private _drawMode;
  36952. /** @hidden */
  36953. protected _reportDrawCall(): void;
  36954. /** @hidden */
  36955. _releaseEffect(effect: Effect): void;
  36956. /** @hidden */
  36957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36958. /**
  36959. * Create a new effect (used to store vertex/fragment shaders)
  36960. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36961. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36962. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36963. * @param samplers defines an array of string used to represent textures
  36964. * @param defines defines the string containing the defines to use to compile the shaders
  36965. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36966. * @param onCompiled defines a function to call when the effect creation is successful
  36967. * @param onError defines a function to call when the effect creation has failed
  36968. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36969. * @returns the new Effect
  36970. */
  36971. 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;
  36972. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36973. private _compileShader;
  36974. private _compileRawShader;
  36975. /** @hidden */
  36976. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36977. /**
  36978. * Directly creates a webGL program
  36979. * @param pipelineContext defines the pipeline context to attach to
  36980. * @param vertexCode defines the vertex shader code to use
  36981. * @param fragmentCode defines the fragment shader code to use
  36982. * @param context defines the webGL context to use (if not set, the current one will be used)
  36983. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36984. * @returns the new webGL program
  36985. */
  36986. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36987. /**
  36988. * Creates a webGL program
  36989. * @param pipelineContext defines the pipeline context to attach to
  36990. * @param vertexCode defines the vertex shader code to use
  36991. * @param fragmentCode defines the fragment shader code to use
  36992. * @param defines defines the string containing the defines to use to compile the shaders
  36993. * @param context defines the webGL context to use (if not set, the current one will be used)
  36994. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36995. * @returns the new webGL program
  36996. */
  36997. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36998. /**
  36999. * Creates a new pipeline context
  37000. * @returns the new pipeline
  37001. */
  37002. createPipelineContext(): IPipelineContext;
  37003. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37004. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37005. /** @hidden */
  37006. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37007. /** @hidden */
  37008. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37009. /** @hidden */
  37010. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37011. /**
  37012. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37013. * @param pipelineContext defines the pipeline context to use
  37014. * @param uniformsNames defines the list of uniform names
  37015. * @returns an array of webGL uniform locations
  37016. */
  37017. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37018. /**
  37019. * Gets the lsit of active attributes for a given webGL program
  37020. * @param pipelineContext defines the pipeline context to use
  37021. * @param attributesNames defines the list of attribute names to get
  37022. * @returns an array of indices indicating the offset of each attribute
  37023. */
  37024. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37025. /**
  37026. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37027. * @param effect defines the effect to activate
  37028. */
  37029. enableEffect(effect: Nullable<Effect>): void;
  37030. /**
  37031. * Set the value of an uniform to a number (int)
  37032. * @param uniform defines the webGL uniform location where to store the value
  37033. * @param value defines the int number to store
  37034. */
  37035. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37036. /**
  37037. * Set the value of an uniform to an array of int32
  37038. * @param uniform defines the webGL uniform location where to store the value
  37039. * @param array defines the array of int32 to store
  37040. */
  37041. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37042. /**
  37043. * Set the value of an uniform to an array of int32 (stored as vec2)
  37044. * @param uniform defines the webGL uniform location where to store the value
  37045. * @param array defines the array of int32 to store
  37046. */
  37047. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37048. /**
  37049. * Set the value of an uniform to an array of int32 (stored as vec3)
  37050. * @param uniform defines the webGL uniform location where to store the value
  37051. * @param array defines the array of int32 to store
  37052. */
  37053. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37054. /**
  37055. * Set the value of an uniform to an array of int32 (stored as vec4)
  37056. * @param uniform defines the webGL uniform location where to store the value
  37057. * @param array defines the array of int32 to store
  37058. */
  37059. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37060. /**
  37061. * Set the value of an uniform to an array of number
  37062. * @param uniform defines the webGL uniform location where to store the value
  37063. * @param array defines the array of number to store
  37064. */
  37065. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37066. /**
  37067. * Set the value of an uniform to an array of number (stored as vec2)
  37068. * @param uniform defines the webGL uniform location where to store the value
  37069. * @param array defines the array of number to store
  37070. */
  37071. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37072. /**
  37073. * Set the value of an uniform to an array of number (stored as vec3)
  37074. * @param uniform defines the webGL uniform location where to store the value
  37075. * @param array defines the array of number to store
  37076. */
  37077. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37078. /**
  37079. * Set the value of an uniform to an array of number (stored as vec4)
  37080. * @param uniform defines the webGL uniform location where to store the value
  37081. * @param array defines the array of number to store
  37082. */
  37083. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37084. /**
  37085. * Set the value of an uniform to an array of float32 (stored as matrices)
  37086. * @param uniform defines the webGL uniform location where to store the value
  37087. * @param matrices defines the array of float32 to store
  37088. */
  37089. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37090. /**
  37091. * Set the value of an uniform to a matrix (3x3)
  37092. * @param uniform defines the webGL uniform location where to store the value
  37093. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37094. */
  37095. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37096. /**
  37097. * Set the value of an uniform to a matrix (2x2)
  37098. * @param uniform defines the webGL uniform location where to store the value
  37099. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37100. */
  37101. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37102. /**
  37103. * Set the value of an uniform to a number (float)
  37104. * @param uniform defines the webGL uniform location where to store the value
  37105. * @param value defines the float number to store
  37106. */
  37107. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37108. /**
  37109. * Set the value of an uniform to a vec2
  37110. * @param uniform defines the webGL uniform location where to store the value
  37111. * @param x defines the 1st component of the value
  37112. * @param y defines the 2nd component of the value
  37113. */
  37114. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37115. /**
  37116. * Set the value of an uniform to a vec3
  37117. * @param uniform defines the webGL uniform location where to store the value
  37118. * @param x defines the 1st component of the value
  37119. * @param y defines the 2nd component of the value
  37120. * @param z defines the 3rd component of the value
  37121. */
  37122. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37123. /**
  37124. * Set the value of an uniform to a vec4
  37125. * @param uniform defines the webGL uniform location where to store the value
  37126. * @param x defines the 1st component of the value
  37127. * @param y defines the 2nd component of the value
  37128. * @param z defines the 3rd component of the value
  37129. * @param w defines the 4th component of the value
  37130. */
  37131. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37132. /**
  37133. * Apply all cached states (depth, culling, stencil and alpha)
  37134. */
  37135. applyStates(): void;
  37136. /**
  37137. * Enable or disable color writing
  37138. * @param enable defines the state to set
  37139. */
  37140. setColorWrite(enable: boolean): void;
  37141. /**
  37142. * Gets a boolean indicating if color writing is enabled
  37143. * @returns the current color writing state
  37144. */
  37145. getColorWrite(): boolean;
  37146. /**
  37147. * Gets the depth culling state manager
  37148. */
  37149. get depthCullingState(): DepthCullingState;
  37150. /**
  37151. * Gets the alpha state manager
  37152. */
  37153. get alphaState(): AlphaState;
  37154. /**
  37155. * Gets the stencil state manager
  37156. */
  37157. get stencilState(): StencilState;
  37158. /**
  37159. * Clears the list of texture accessible through engine.
  37160. * This can help preventing texture load conflict due to name collision.
  37161. */
  37162. clearInternalTexturesCache(): void;
  37163. /**
  37164. * Force the entire cache to be cleared
  37165. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37166. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37167. */
  37168. wipeCaches(bruteForce?: boolean): void;
  37169. /** @hidden */
  37170. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37171. min: number;
  37172. mag: number;
  37173. };
  37174. /** @hidden */
  37175. _createTexture(): WebGLTexture;
  37176. /**
  37177. * Usually called from Texture.ts.
  37178. * Passed information to create a WebGLTexture
  37179. * @param url defines a value which contains one of the following:
  37180. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37181. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37182. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37183. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37184. * @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)
  37185. * @param scene needed for loading to the correct scene
  37186. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37187. * @param onLoad optional callback to be called upon successful completion
  37188. * @param onError optional callback to be called upon failure
  37189. * @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
  37190. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37191. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37192. * @param forcedExtension defines the extension to use to pick the right loader
  37193. * @param mimeType defines an optional mime type
  37194. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37195. */
  37196. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  37197. /**
  37198. * Loads an image as an HTMLImageElement.
  37199. * @param input url string, ArrayBuffer, or Blob to load
  37200. * @param onLoad callback called when the image successfully loads
  37201. * @param onError callback called when the image fails to load
  37202. * @param offlineProvider offline provider for caching
  37203. * @param mimeType optional mime type
  37204. * @returns the HTMLImageElement of the loaded image
  37205. * @hidden
  37206. */
  37207. 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>;
  37208. /**
  37209. * @hidden
  37210. */
  37211. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37212. private _unpackFlipYCached;
  37213. /**
  37214. * In case you are sharing the context with other applications, it might
  37215. * be interested to not cache the unpack flip y state to ensure a consistent
  37216. * value would be set.
  37217. */
  37218. enableUnpackFlipYCached: boolean;
  37219. /** @hidden */
  37220. _unpackFlipY(value: boolean): void;
  37221. /** @hidden */
  37222. _getUnpackAlignement(): number;
  37223. private _getTextureTarget;
  37224. /**
  37225. * Update the sampling mode of a given texture
  37226. * @param samplingMode defines the required sampling mode
  37227. * @param texture defines the texture to update
  37228. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37229. */
  37230. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37231. /**
  37232. * Update the sampling mode of a given texture
  37233. * @param texture defines the texture to update
  37234. * @param wrapU defines the texture wrap mode of the u coordinates
  37235. * @param wrapV defines the texture wrap mode of the v coordinates
  37236. * @param wrapR defines the texture wrap mode of the r coordinates
  37237. */
  37238. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37239. /** @hidden */
  37240. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37241. width: number;
  37242. height: number;
  37243. layers?: number;
  37244. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37245. /** @hidden */
  37246. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37247. /** @hidden */
  37248. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37249. /**
  37250. * Update a portion of an internal texture
  37251. * @param texture defines the texture to update
  37252. * @param imageData defines the data to store into the texture
  37253. * @param xOffset defines the x coordinates of the update rectangle
  37254. * @param yOffset defines the y coordinates of the update rectangle
  37255. * @param width defines the width of the update rectangle
  37256. * @param height defines the height of the update rectangle
  37257. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37258. * @param lod defines the lod level to update (0 by default)
  37259. */
  37260. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37261. /** @hidden */
  37262. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37263. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37264. private _prepareWebGLTexture;
  37265. /** @hidden */
  37266. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37267. private _getDepthStencilBuffer;
  37268. /** @hidden */
  37269. _releaseFramebufferObjects(texture: InternalTexture): void;
  37270. /** @hidden */
  37271. _releaseTexture(texture: InternalTexture): void;
  37272. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37273. protected _setProgram(program: WebGLProgram): void;
  37274. protected _boundUniforms: {
  37275. [key: number]: WebGLUniformLocation;
  37276. };
  37277. /**
  37278. * Binds an effect to the webGL context
  37279. * @param effect defines the effect to bind
  37280. */
  37281. bindSamplers(effect: Effect): void;
  37282. private _activateCurrentTexture;
  37283. /** @hidden */
  37284. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37285. /** @hidden */
  37286. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37287. /**
  37288. * Unbind all textures from the webGL context
  37289. */
  37290. unbindAllTextures(): void;
  37291. /**
  37292. * Sets a texture to the according uniform.
  37293. * @param channel The texture channel
  37294. * @param uniform The uniform to set
  37295. * @param texture The texture to apply
  37296. */
  37297. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37298. private _bindSamplerUniformToChannel;
  37299. private _getTextureWrapMode;
  37300. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37301. /**
  37302. * Sets an array of texture to the webGL context
  37303. * @param channel defines the channel where the texture array must be set
  37304. * @param uniform defines the associated uniform location
  37305. * @param textures defines the array of textures to bind
  37306. */
  37307. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37308. /** @hidden */
  37309. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37310. private _setTextureParameterFloat;
  37311. private _setTextureParameterInteger;
  37312. /**
  37313. * Unbind all vertex attributes from the webGL context
  37314. */
  37315. unbindAllAttributes(): void;
  37316. /**
  37317. * 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
  37318. */
  37319. releaseEffects(): void;
  37320. /**
  37321. * Dispose and release all associated resources
  37322. */
  37323. dispose(): void;
  37324. /**
  37325. * Attach a new callback raised when context lost event is fired
  37326. * @param callback defines the callback to call
  37327. */
  37328. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37329. /**
  37330. * Attach a new callback raised when context restored event is fired
  37331. * @param callback defines the callback to call
  37332. */
  37333. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37334. /**
  37335. * Get the current error code of the webGL context
  37336. * @returns the error code
  37337. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37338. */
  37339. getError(): number;
  37340. private _canRenderToFloatFramebuffer;
  37341. private _canRenderToHalfFloatFramebuffer;
  37342. private _canRenderToFramebuffer;
  37343. /** @hidden */
  37344. _getWebGLTextureType(type: number): number;
  37345. /** @hidden */
  37346. _getInternalFormat(format: number): number;
  37347. /** @hidden */
  37348. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37349. /** @hidden */
  37350. _getRGBAMultiSampleBufferFormat(type: number): number;
  37351. /** @hidden */
  37352. _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;
  37353. /**
  37354. * Loads a file from a url
  37355. * @param url url to load
  37356. * @param onSuccess callback called when the file successfully loads
  37357. * @param onProgress callback called while file is loading (if the server supports this mode)
  37358. * @param offlineProvider defines the offline provider for caching
  37359. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37360. * @param onError callback called when the file fails to load
  37361. * @returns a file request object
  37362. * @hidden
  37363. */
  37364. 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;
  37365. /**
  37366. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37367. * @param x defines the x coordinate of the rectangle where pixels must be read
  37368. * @param y defines the y coordinate of the rectangle where pixels must be read
  37369. * @param width defines the width of the rectangle where pixels must be read
  37370. * @param height defines the height of the rectangle where pixels must be read
  37371. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37372. * @returns a Uint8Array containing RGBA colors
  37373. */
  37374. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37375. private static _isSupported;
  37376. /**
  37377. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37378. * @returns true if the engine can be created
  37379. * @ignorenaming
  37380. */
  37381. static isSupported(): boolean;
  37382. /**
  37383. * Find the next highest power of two.
  37384. * @param x Number to start search from.
  37385. * @return Next highest power of two.
  37386. */
  37387. static CeilingPOT(x: number): number;
  37388. /**
  37389. * Find the next lowest power of two.
  37390. * @param x Number to start search from.
  37391. * @return Next lowest power of two.
  37392. */
  37393. static FloorPOT(x: number): number;
  37394. /**
  37395. * Find the nearest power of two.
  37396. * @param x Number to start search from.
  37397. * @return Next nearest power of two.
  37398. */
  37399. static NearestPOT(x: number): number;
  37400. /**
  37401. * Get the closest exponent of two
  37402. * @param value defines the value to approximate
  37403. * @param max defines the maximum value to return
  37404. * @param mode defines how to define the closest value
  37405. * @returns closest exponent of two of the given value
  37406. */
  37407. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37408. /**
  37409. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37410. * @param func - the function to be called
  37411. * @param requester - the object that will request the next frame. Falls back to window.
  37412. * @returns frame number
  37413. */
  37414. static QueueNewFrame(func: () => void, requester?: any): number;
  37415. /**
  37416. * Gets host document
  37417. * @returns the host document object
  37418. */
  37419. getHostDocument(): Nullable<Document>;
  37420. }
  37421. }
  37422. declare module "babylonjs/Maths/sphericalPolynomial" {
  37423. import { Vector3 } from "babylonjs/Maths/math.vector";
  37424. import { Color3 } from "babylonjs/Maths/math.color";
  37425. /**
  37426. * Class representing spherical harmonics coefficients to the 3rd degree
  37427. */
  37428. export class SphericalHarmonics {
  37429. /**
  37430. * Defines whether or not the harmonics have been prescaled for rendering.
  37431. */
  37432. preScaled: boolean;
  37433. /**
  37434. * The l0,0 coefficients of the spherical harmonics
  37435. */
  37436. l00: Vector3;
  37437. /**
  37438. * The l1,-1 coefficients of the spherical harmonics
  37439. */
  37440. l1_1: Vector3;
  37441. /**
  37442. * The l1,0 coefficients of the spherical harmonics
  37443. */
  37444. l10: Vector3;
  37445. /**
  37446. * The l1,1 coefficients of the spherical harmonics
  37447. */
  37448. l11: Vector3;
  37449. /**
  37450. * The l2,-2 coefficients of the spherical harmonics
  37451. */
  37452. l2_2: Vector3;
  37453. /**
  37454. * The l2,-1 coefficients of the spherical harmonics
  37455. */
  37456. l2_1: Vector3;
  37457. /**
  37458. * The l2,0 coefficients of the spherical harmonics
  37459. */
  37460. l20: Vector3;
  37461. /**
  37462. * The l2,1 coefficients of the spherical harmonics
  37463. */
  37464. l21: Vector3;
  37465. /**
  37466. * The l2,2 coefficients of the spherical harmonics
  37467. */
  37468. l22: Vector3;
  37469. /**
  37470. * Adds a light to the spherical harmonics
  37471. * @param direction the direction of the light
  37472. * @param color the color of the light
  37473. * @param deltaSolidAngle the delta solid angle of the light
  37474. */
  37475. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37476. /**
  37477. * Scales the spherical harmonics by the given amount
  37478. * @param scale the amount to scale
  37479. */
  37480. scaleInPlace(scale: number): void;
  37481. /**
  37482. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37483. *
  37484. * ```
  37485. * E_lm = A_l * L_lm
  37486. * ```
  37487. *
  37488. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37489. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37490. * the scaling factors are given in equation 9.
  37491. */
  37492. convertIncidentRadianceToIrradiance(): void;
  37493. /**
  37494. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37495. *
  37496. * ```
  37497. * L = (1/pi) * E * rho
  37498. * ```
  37499. *
  37500. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37501. */
  37502. convertIrradianceToLambertianRadiance(): void;
  37503. /**
  37504. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37505. * required operations at run time.
  37506. *
  37507. * This is simply done by scaling back the SH with Ylm constants parameter.
  37508. * The trigonometric part being applied by the shader at run time.
  37509. */
  37510. preScaleForRendering(): void;
  37511. /**
  37512. * Constructs a spherical harmonics from an array.
  37513. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37514. * @returns the spherical harmonics
  37515. */
  37516. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37517. /**
  37518. * Gets the spherical harmonics from polynomial
  37519. * @param polynomial the spherical polynomial
  37520. * @returns the spherical harmonics
  37521. */
  37522. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37523. }
  37524. /**
  37525. * Class representing spherical polynomial coefficients to the 3rd degree
  37526. */
  37527. export class SphericalPolynomial {
  37528. private _harmonics;
  37529. /**
  37530. * The spherical harmonics used to create the polynomials.
  37531. */
  37532. get preScaledHarmonics(): SphericalHarmonics;
  37533. /**
  37534. * The x coefficients of the spherical polynomial
  37535. */
  37536. x: Vector3;
  37537. /**
  37538. * The y coefficients of the spherical polynomial
  37539. */
  37540. y: Vector3;
  37541. /**
  37542. * The z coefficients of the spherical polynomial
  37543. */
  37544. z: Vector3;
  37545. /**
  37546. * The xx coefficients of the spherical polynomial
  37547. */
  37548. xx: Vector3;
  37549. /**
  37550. * The yy coefficients of the spherical polynomial
  37551. */
  37552. yy: Vector3;
  37553. /**
  37554. * The zz coefficients of the spherical polynomial
  37555. */
  37556. zz: Vector3;
  37557. /**
  37558. * The xy coefficients of the spherical polynomial
  37559. */
  37560. xy: Vector3;
  37561. /**
  37562. * The yz coefficients of the spherical polynomial
  37563. */
  37564. yz: Vector3;
  37565. /**
  37566. * The zx coefficients of the spherical polynomial
  37567. */
  37568. zx: Vector3;
  37569. /**
  37570. * Adds an ambient color to the spherical polynomial
  37571. * @param color the color to add
  37572. */
  37573. addAmbient(color: Color3): void;
  37574. /**
  37575. * Scales the spherical polynomial by the given amount
  37576. * @param scale the amount to scale
  37577. */
  37578. scaleInPlace(scale: number): void;
  37579. /**
  37580. * Gets the spherical polynomial from harmonics
  37581. * @param harmonics the spherical harmonics
  37582. * @returns the spherical polynomial
  37583. */
  37584. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37585. /**
  37586. * Constructs a spherical polynomial from an array.
  37587. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37588. * @returns the spherical polynomial
  37589. */
  37590. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37591. }
  37592. }
  37593. declare module "babylonjs/Materials/Textures/internalTexture" {
  37594. import { Observable } from "babylonjs/Misc/observable";
  37595. import { Nullable, int } from "babylonjs/types";
  37596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37598. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37599. /**
  37600. * Defines the source of the internal texture
  37601. */
  37602. export enum InternalTextureSource {
  37603. /**
  37604. * The source of the texture data is unknown
  37605. */
  37606. Unknown = 0,
  37607. /**
  37608. * Texture data comes from an URL
  37609. */
  37610. Url = 1,
  37611. /**
  37612. * Texture data is only used for temporary storage
  37613. */
  37614. Temp = 2,
  37615. /**
  37616. * Texture data comes from raw data (ArrayBuffer)
  37617. */
  37618. Raw = 3,
  37619. /**
  37620. * Texture content is dynamic (video or dynamic texture)
  37621. */
  37622. Dynamic = 4,
  37623. /**
  37624. * Texture content is generated by rendering to it
  37625. */
  37626. RenderTarget = 5,
  37627. /**
  37628. * Texture content is part of a multi render target process
  37629. */
  37630. MultiRenderTarget = 6,
  37631. /**
  37632. * Texture data comes from a cube data file
  37633. */
  37634. Cube = 7,
  37635. /**
  37636. * Texture data comes from a raw cube data
  37637. */
  37638. CubeRaw = 8,
  37639. /**
  37640. * Texture data come from a prefiltered cube data file
  37641. */
  37642. CubePrefiltered = 9,
  37643. /**
  37644. * Texture content is raw 3D data
  37645. */
  37646. Raw3D = 10,
  37647. /**
  37648. * Texture content is raw 2D array data
  37649. */
  37650. Raw2DArray = 11,
  37651. /**
  37652. * Texture content is a depth texture
  37653. */
  37654. Depth = 12,
  37655. /**
  37656. * Texture data comes from a raw cube data encoded with RGBD
  37657. */
  37658. CubeRawRGBD = 13
  37659. }
  37660. /**
  37661. * Class used to store data associated with WebGL texture data for the engine
  37662. * This class should not be used directly
  37663. */
  37664. export class InternalTexture {
  37665. /** @hidden */
  37666. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37667. /**
  37668. * Defines if the texture is ready
  37669. */
  37670. isReady: boolean;
  37671. /**
  37672. * Defines if the texture is a cube texture
  37673. */
  37674. isCube: boolean;
  37675. /**
  37676. * Defines if the texture contains 3D data
  37677. */
  37678. is3D: boolean;
  37679. /**
  37680. * Defines if the texture contains 2D array data
  37681. */
  37682. is2DArray: boolean;
  37683. /**
  37684. * Defines if the texture contains multiview data
  37685. */
  37686. isMultiview: boolean;
  37687. /**
  37688. * Gets the URL used to load this texture
  37689. */
  37690. url: string;
  37691. /**
  37692. * Gets the sampling mode of the texture
  37693. */
  37694. samplingMode: number;
  37695. /**
  37696. * Gets a boolean indicating if the texture needs mipmaps generation
  37697. */
  37698. generateMipMaps: boolean;
  37699. /**
  37700. * Gets the number of samples used by the texture (WebGL2+ only)
  37701. */
  37702. samples: number;
  37703. /**
  37704. * Gets the type of the texture (int, float...)
  37705. */
  37706. type: number;
  37707. /**
  37708. * Gets the format of the texture (RGB, RGBA...)
  37709. */
  37710. format: number;
  37711. /**
  37712. * Observable called when the texture is loaded
  37713. */
  37714. onLoadedObservable: Observable<InternalTexture>;
  37715. /**
  37716. * Gets the width of the texture
  37717. */
  37718. width: number;
  37719. /**
  37720. * Gets the height of the texture
  37721. */
  37722. height: number;
  37723. /**
  37724. * Gets the depth of the texture
  37725. */
  37726. depth: number;
  37727. /**
  37728. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37729. */
  37730. baseWidth: number;
  37731. /**
  37732. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37733. */
  37734. baseHeight: number;
  37735. /**
  37736. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37737. */
  37738. baseDepth: number;
  37739. /**
  37740. * Gets a boolean indicating if the texture is inverted on Y axis
  37741. */
  37742. invertY: boolean;
  37743. /** @hidden */
  37744. _invertVScale: boolean;
  37745. /** @hidden */
  37746. _associatedChannel: number;
  37747. /** @hidden */
  37748. _source: InternalTextureSource;
  37749. /** @hidden */
  37750. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37751. /** @hidden */
  37752. _bufferView: Nullable<ArrayBufferView>;
  37753. /** @hidden */
  37754. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37755. /** @hidden */
  37756. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37757. /** @hidden */
  37758. _size: number;
  37759. /** @hidden */
  37760. _extension: string;
  37761. /** @hidden */
  37762. _files: Nullable<string[]>;
  37763. /** @hidden */
  37764. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37765. /** @hidden */
  37766. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37767. /** @hidden */
  37768. _framebuffer: Nullable<WebGLFramebuffer>;
  37769. /** @hidden */
  37770. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37771. /** @hidden */
  37772. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37773. /** @hidden */
  37774. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37775. /** @hidden */
  37776. _attachments: Nullable<number[]>;
  37777. /** @hidden */
  37778. _textureArray: Nullable<InternalTexture[]>;
  37779. /** @hidden */
  37780. _cachedCoordinatesMode: Nullable<number>;
  37781. /** @hidden */
  37782. _cachedWrapU: Nullable<number>;
  37783. /** @hidden */
  37784. _cachedWrapV: Nullable<number>;
  37785. /** @hidden */
  37786. _cachedWrapR: Nullable<number>;
  37787. /** @hidden */
  37788. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37789. /** @hidden */
  37790. _isDisabled: boolean;
  37791. /** @hidden */
  37792. _compression: Nullable<string>;
  37793. /** @hidden */
  37794. _generateStencilBuffer: boolean;
  37795. /** @hidden */
  37796. _generateDepthBuffer: boolean;
  37797. /** @hidden */
  37798. _comparisonFunction: number;
  37799. /** @hidden */
  37800. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37801. /** @hidden */
  37802. _lodGenerationScale: number;
  37803. /** @hidden */
  37804. _lodGenerationOffset: number;
  37805. /** @hidden */
  37806. _depthStencilTexture: Nullable<InternalTexture>;
  37807. /** @hidden */
  37808. _colorTextureArray: Nullable<WebGLTexture>;
  37809. /** @hidden */
  37810. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37811. /** @hidden */
  37812. _lodTextureHigh: Nullable<BaseTexture>;
  37813. /** @hidden */
  37814. _lodTextureMid: Nullable<BaseTexture>;
  37815. /** @hidden */
  37816. _lodTextureLow: Nullable<BaseTexture>;
  37817. /** @hidden */
  37818. _isRGBD: boolean;
  37819. /** @hidden */
  37820. _linearSpecularLOD: boolean;
  37821. /** @hidden */
  37822. _irradianceTexture: Nullable<BaseTexture>;
  37823. /** @hidden */
  37824. _webGLTexture: Nullable<WebGLTexture>;
  37825. /** @hidden */
  37826. _references: number;
  37827. private _engine;
  37828. /**
  37829. * Gets the Engine the texture belongs to.
  37830. * @returns The babylon engine
  37831. */
  37832. getEngine(): ThinEngine;
  37833. /**
  37834. * Gets the data source type of the texture
  37835. */
  37836. get source(): InternalTextureSource;
  37837. /**
  37838. * Creates a new InternalTexture
  37839. * @param engine defines the engine to use
  37840. * @param source defines the type of data that will be used
  37841. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37842. */
  37843. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37844. /**
  37845. * Increments the number of references (ie. the number of Texture that point to it)
  37846. */
  37847. incrementReferences(): void;
  37848. /**
  37849. * Change the size of the texture (not the size of the content)
  37850. * @param width defines the new width
  37851. * @param height defines the new height
  37852. * @param depth defines the new depth (1 by default)
  37853. */
  37854. updateSize(width: int, height: int, depth?: int): void;
  37855. /** @hidden */
  37856. _rebuild(): void;
  37857. /** @hidden */
  37858. _swapAndDie(target: InternalTexture): void;
  37859. /**
  37860. * Dispose the current allocated resources
  37861. */
  37862. dispose(): void;
  37863. }
  37864. }
  37865. declare module "babylonjs/Audio/analyser" {
  37866. import { Scene } from "babylonjs/scene";
  37867. /**
  37868. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37870. */
  37871. export class Analyser {
  37872. /**
  37873. * Gets or sets the smoothing
  37874. * @ignorenaming
  37875. */
  37876. SMOOTHING: number;
  37877. /**
  37878. * Gets or sets the FFT table size
  37879. * @ignorenaming
  37880. */
  37881. FFT_SIZE: number;
  37882. /**
  37883. * Gets or sets the bar graph amplitude
  37884. * @ignorenaming
  37885. */
  37886. BARGRAPHAMPLITUDE: number;
  37887. /**
  37888. * Gets or sets the position of the debug canvas
  37889. * @ignorenaming
  37890. */
  37891. DEBUGCANVASPOS: {
  37892. x: number;
  37893. y: number;
  37894. };
  37895. /**
  37896. * Gets or sets the debug canvas size
  37897. * @ignorenaming
  37898. */
  37899. DEBUGCANVASSIZE: {
  37900. width: number;
  37901. height: number;
  37902. };
  37903. private _byteFreqs;
  37904. private _byteTime;
  37905. private _floatFreqs;
  37906. private _webAudioAnalyser;
  37907. private _debugCanvas;
  37908. private _debugCanvasContext;
  37909. private _scene;
  37910. private _registerFunc;
  37911. private _audioEngine;
  37912. /**
  37913. * Creates a new analyser
  37914. * @param scene defines hosting scene
  37915. */
  37916. constructor(scene: Scene);
  37917. /**
  37918. * Get the number of data values you will have to play with for the visualization
  37919. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37920. * @returns a number
  37921. */
  37922. getFrequencyBinCount(): number;
  37923. /**
  37924. * Gets the current frequency data as a byte array
  37925. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37926. * @returns a Uint8Array
  37927. */
  37928. getByteFrequencyData(): Uint8Array;
  37929. /**
  37930. * Gets the current waveform as a byte array
  37931. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37932. * @returns a Uint8Array
  37933. */
  37934. getByteTimeDomainData(): Uint8Array;
  37935. /**
  37936. * Gets the current frequency data as a float array
  37937. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37938. * @returns a Float32Array
  37939. */
  37940. getFloatFrequencyData(): Float32Array;
  37941. /**
  37942. * Renders the debug canvas
  37943. */
  37944. drawDebugCanvas(): void;
  37945. /**
  37946. * Stops rendering the debug canvas and removes it
  37947. */
  37948. stopDebugCanvas(): void;
  37949. /**
  37950. * Connects two audio nodes
  37951. * @param inputAudioNode defines first node to connect
  37952. * @param outputAudioNode defines second node to connect
  37953. */
  37954. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37955. /**
  37956. * Releases all associated resources
  37957. */
  37958. dispose(): void;
  37959. }
  37960. }
  37961. declare module "babylonjs/Audio/audioEngine" {
  37962. import { IDisposable } from "babylonjs/scene";
  37963. import { Analyser } from "babylonjs/Audio/analyser";
  37964. import { Nullable } from "babylonjs/types";
  37965. import { Observable } from "babylonjs/Misc/observable";
  37966. /**
  37967. * This represents an audio engine and it is responsible
  37968. * to play, synchronize and analyse sounds throughout the application.
  37969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37970. */
  37971. export interface IAudioEngine extends IDisposable {
  37972. /**
  37973. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37974. */
  37975. readonly canUseWebAudio: boolean;
  37976. /**
  37977. * Gets the current AudioContext if available.
  37978. */
  37979. readonly audioContext: Nullable<AudioContext>;
  37980. /**
  37981. * The master gain node defines the global audio volume of your audio engine.
  37982. */
  37983. readonly masterGain: GainNode;
  37984. /**
  37985. * Gets whether or not mp3 are supported by your browser.
  37986. */
  37987. readonly isMP3supported: boolean;
  37988. /**
  37989. * Gets whether or not ogg are supported by your browser.
  37990. */
  37991. readonly isOGGsupported: boolean;
  37992. /**
  37993. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37994. * @ignoreNaming
  37995. */
  37996. WarnedWebAudioUnsupported: boolean;
  37997. /**
  37998. * Defines if the audio engine relies on a custom unlocked button.
  37999. * In this case, the embedded button will not be displayed.
  38000. */
  38001. useCustomUnlockedButton: boolean;
  38002. /**
  38003. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38004. */
  38005. readonly unlocked: boolean;
  38006. /**
  38007. * Event raised when audio has been unlocked on the browser.
  38008. */
  38009. onAudioUnlockedObservable: Observable<AudioEngine>;
  38010. /**
  38011. * Event raised when audio has been locked on the browser.
  38012. */
  38013. onAudioLockedObservable: Observable<AudioEngine>;
  38014. /**
  38015. * Flags the audio engine in Locked state.
  38016. * This happens due to new browser policies preventing audio to autoplay.
  38017. */
  38018. lock(): void;
  38019. /**
  38020. * Unlocks the audio engine once a user action has been done on the dom.
  38021. * This is helpful to resume play once browser policies have been satisfied.
  38022. */
  38023. unlock(): void;
  38024. /**
  38025. * Gets the global volume sets on the master gain.
  38026. * @returns the global volume if set or -1 otherwise
  38027. */
  38028. getGlobalVolume(): number;
  38029. /**
  38030. * Sets the global volume of your experience (sets on the master gain).
  38031. * @param newVolume Defines the new global volume of the application
  38032. */
  38033. setGlobalVolume(newVolume: number): void;
  38034. /**
  38035. * Connect the audio engine to an audio analyser allowing some amazing
  38036. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38038. * @param analyser The analyser to connect to the engine
  38039. */
  38040. connectToAnalyser(analyser: Analyser): void;
  38041. }
  38042. /**
  38043. * This represents the default audio engine used in babylon.
  38044. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38046. */
  38047. export class AudioEngine implements IAudioEngine {
  38048. private _audioContext;
  38049. private _audioContextInitialized;
  38050. private _muteButton;
  38051. private _hostElement;
  38052. /**
  38053. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38054. */
  38055. canUseWebAudio: boolean;
  38056. /**
  38057. * The master gain node defines the global audio volume of your audio engine.
  38058. */
  38059. masterGain: GainNode;
  38060. /**
  38061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38062. * @ignoreNaming
  38063. */
  38064. WarnedWebAudioUnsupported: boolean;
  38065. /**
  38066. * Gets whether or not mp3 are supported by your browser.
  38067. */
  38068. isMP3supported: boolean;
  38069. /**
  38070. * Gets whether or not ogg are supported by your browser.
  38071. */
  38072. isOGGsupported: boolean;
  38073. /**
  38074. * Gets whether audio has been unlocked on the device.
  38075. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38076. * a user interaction has happened.
  38077. */
  38078. unlocked: boolean;
  38079. /**
  38080. * Defines if the audio engine relies on a custom unlocked button.
  38081. * In this case, the embedded button will not be displayed.
  38082. */
  38083. useCustomUnlockedButton: boolean;
  38084. /**
  38085. * Event raised when audio has been unlocked on the browser.
  38086. */
  38087. onAudioUnlockedObservable: Observable<AudioEngine>;
  38088. /**
  38089. * Event raised when audio has been locked on the browser.
  38090. */
  38091. onAudioLockedObservable: Observable<AudioEngine>;
  38092. /**
  38093. * Gets the current AudioContext if available.
  38094. */
  38095. get audioContext(): Nullable<AudioContext>;
  38096. private _connectedAnalyser;
  38097. /**
  38098. * Instantiates a new audio engine.
  38099. *
  38100. * There should be only one per page as some browsers restrict the number
  38101. * of audio contexts you can create.
  38102. * @param hostElement defines the host element where to display the mute icon if necessary
  38103. */
  38104. constructor(hostElement?: Nullable<HTMLElement>);
  38105. /**
  38106. * Flags the audio engine in Locked state.
  38107. * This happens due to new browser policies preventing audio to autoplay.
  38108. */
  38109. lock(): void;
  38110. /**
  38111. * Unlocks the audio engine once a user action has been done on the dom.
  38112. * This is helpful to resume play once browser policies have been satisfied.
  38113. */
  38114. unlock(): void;
  38115. private _resumeAudioContext;
  38116. private _initializeAudioContext;
  38117. private _tryToRun;
  38118. private _triggerRunningState;
  38119. private _triggerSuspendedState;
  38120. private _displayMuteButton;
  38121. private _moveButtonToTopLeft;
  38122. private _onResize;
  38123. private _hideMuteButton;
  38124. /**
  38125. * Destroy and release the resources associated with the audio ccontext.
  38126. */
  38127. dispose(): void;
  38128. /**
  38129. * Gets the global volume sets on the master gain.
  38130. * @returns the global volume if set or -1 otherwise
  38131. */
  38132. getGlobalVolume(): number;
  38133. /**
  38134. * Sets the global volume of your experience (sets on the master gain).
  38135. * @param newVolume Defines the new global volume of the application
  38136. */
  38137. setGlobalVolume(newVolume: number): void;
  38138. /**
  38139. * Connect the audio engine to an audio analyser allowing some amazing
  38140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38142. * @param analyser The analyser to connect to the engine
  38143. */
  38144. connectToAnalyser(analyser: Analyser): void;
  38145. }
  38146. }
  38147. declare module "babylonjs/Loading/loadingScreen" {
  38148. /**
  38149. * Interface used to present a loading screen while loading a scene
  38150. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38151. */
  38152. export interface ILoadingScreen {
  38153. /**
  38154. * Function called to display the loading screen
  38155. */
  38156. displayLoadingUI: () => void;
  38157. /**
  38158. * Function called to hide the loading screen
  38159. */
  38160. hideLoadingUI: () => void;
  38161. /**
  38162. * Gets or sets the color to use for the background
  38163. */
  38164. loadingUIBackgroundColor: string;
  38165. /**
  38166. * Gets or sets the text to display while loading
  38167. */
  38168. loadingUIText: string;
  38169. }
  38170. /**
  38171. * Class used for the default loading screen
  38172. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38173. */
  38174. export class DefaultLoadingScreen implements ILoadingScreen {
  38175. private _renderingCanvas;
  38176. private _loadingText;
  38177. private _loadingDivBackgroundColor;
  38178. private _loadingDiv;
  38179. private _loadingTextDiv;
  38180. /** Gets or sets the logo url to use for the default loading screen */
  38181. static DefaultLogoUrl: string;
  38182. /** Gets or sets the spinner url to use for the default loading screen */
  38183. static DefaultSpinnerUrl: string;
  38184. /**
  38185. * Creates a new default loading screen
  38186. * @param _renderingCanvas defines the canvas used to render the scene
  38187. * @param _loadingText defines the default text to display
  38188. * @param _loadingDivBackgroundColor defines the default background color
  38189. */
  38190. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38191. /**
  38192. * Function called to display the loading screen
  38193. */
  38194. displayLoadingUI(): void;
  38195. /**
  38196. * Function called to hide the loading screen
  38197. */
  38198. hideLoadingUI(): void;
  38199. /**
  38200. * Gets or sets the text to display while loading
  38201. */
  38202. set loadingUIText(text: string);
  38203. get loadingUIText(): string;
  38204. /**
  38205. * Gets or sets the color to use for the background
  38206. */
  38207. get loadingUIBackgroundColor(): string;
  38208. set loadingUIBackgroundColor(color: string);
  38209. private _resizeLoadingUI;
  38210. }
  38211. }
  38212. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38213. /**
  38214. * Interface for any object that can request an animation frame
  38215. */
  38216. export interface ICustomAnimationFrameRequester {
  38217. /**
  38218. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38219. */
  38220. renderFunction?: Function;
  38221. /**
  38222. * Called to request the next frame to render to
  38223. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38224. */
  38225. requestAnimationFrame: Function;
  38226. /**
  38227. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38228. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38229. */
  38230. requestID?: number;
  38231. }
  38232. }
  38233. declare module "babylonjs/Misc/performanceMonitor" {
  38234. /**
  38235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38236. */
  38237. export class PerformanceMonitor {
  38238. private _enabled;
  38239. private _rollingFrameTime;
  38240. private _lastFrameTimeMs;
  38241. /**
  38242. * constructor
  38243. * @param frameSampleSize The number of samples required to saturate the sliding window
  38244. */
  38245. constructor(frameSampleSize?: number);
  38246. /**
  38247. * Samples current frame
  38248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38249. */
  38250. sampleFrame(timeMs?: number): void;
  38251. /**
  38252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38253. */
  38254. get averageFrameTime(): number;
  38255. /**
  38256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38257. */
  38258. get averageFrameTimeVariance(): number;
  38259. /**
  38260. * Returns the frame time of the most recent frame
  38261. */
  38262. get instantaneousFrameTime(): number;
  38263. /**
  38264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38265. */
  38266. get averageFPS(): number;
  38267. /**
  38268. * Returns the average framerate in frames per second using the most recent frame time
  38269. */
  38270. get instantaneousFPS(): number;
  38271. /**
  38272. * Returns true if enough samples have been taken to completely fill the sliding window
  38273. */
  38274. get isSaturated(): boolean;
  38275. /**
  38276. * Enables contributions to the sliding window sample set
  38277. */
  38278. enable(): void;
  38279. /**
  38280. * Disables contributions to the sliding window sample set
  38281. * Samples will not be interpolated over the disabled period
  38282. */
  38283. disable(): void;
  38284. /**
  38285. * Returns true if sampling is enabled
  38286. */
  38287. get isEnabled(): boolean;
  38288. /**
  38289. * Resets performance monitor
  38290. */
  38291. reset(): void;
  38292. }
  38293. /**
  38294. * RollingAverage
  38295. *
  38296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38297. */
  38298. export class RollingAverage {
  38299. /**
  38300. * Current average
  38301. */
  38302. average: number;
  38303. /**
  38304. * Current variance
  38305. */
  38306. variance: number;
  38307. protected _samples: Array<number>;
  38308. protected _sampleCount: number;
  38309. protected _pos: number;
  38310. protected _m2: number;
  38311. /**
  38312. * constructor
  38313. * @param length The number of samples required to saturate the sliding window
  38314. */
  38315. constructor(length: number);
  38316. /**
  38317. * Adds a sample to the sample set
  38318. * @param v The sample value
  38319. */
  38320. add(v: number): void;
  38321. /**
  38322. * Returns previously added values or null if outside of history or outside the sliding window domain
  38323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38324. * @return Value previously recorded with add() or null if outside of range
  38325. */
  38326. history(i: number): number;
  38327. /**
  38328. * Returns true if enough samples have been taken to completely fill the sliding window
  38329. * @return true if sample-set saturated
  38330. */
  38331. isSaturated(): boolean;
  38332. /**
  38333. * Resets the rolling average (equivalent to 0 samples taken so far)
  38334. */
  38335. reset(): void;
  38336. /**
  38337. * Wraps a value around the sample range boundaries
  38338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38339. * @return Wrapped position in sample range
  38340. */
  38341. protected _wrapPosition(i: number): number;
  38342. }
  38343. }
  38344. declare module "babylonjs/Misc/perfCounter" {
  38345. /**
  38346. * This class is used to track a performance counter which is number based.
  38347. * The user has access to many properties which give statistics of different nature.
  38348. *
  38349. * The implementer can track two kinds of Performance Counter: time and count.
  38350. * 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.
  38351. * 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.
  38352. */
  38353. export class PerfCounter {
  38354. /**
  38355. * Gets or sets a global boolean to turn on and off all the counters
  38356. */
  38357. static Enabled: boolean;
  38358. /**
  38359. * Returns the smallest value ever
  38360. */
  38361. get min(): number;
  38362. /**
  38363. * Returns the biggest value ever
  38364. */
  38365. get max(): number;
  38366. /**
  38367. * Returns the average value since the performance counter is running
  38368. */
  38369. get average(): number;
  38370. /**
  38371. * Returns the average value of the last second the counter was monitored
  38372. */
  38373. get lastSecAverage(): number;
  38374. /**
  38375. * Returns the current value
  38376. */
  38377. get current(): number;
  38378. /**
  38379. * Gets the accumulated total
  38380. */
  38381. get total(): number;
  38382. /**
  38383. * Gets the total value count
  38384. */
  38385. get count(): number;
  38386. /**
  38387. * Creates a new counter
  38388. */
  38389. constructor();
  38390. /**
  38391. * Call this method to start monitoring a new frame.
  38392. * 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.
  38393. */
  38394. fetchNewFrame(): void;
  38395. /**
  38396. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38397. * @param newCount the count value to add to the monitored count
  38398. * @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.
  38399. */
  38400. addCount(newCount: number, fetchResult: boolean): void;
  38401. /**
  38402. * Start monitoring this performance counter
  38403. */
  38404. beginMonitoring(): void;
  38405. /**
  38406. * Compute the time lapsed since the previous beginMonitoring() call.
  38407. * @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
  38408. */
  38409. endMonitoring(newFrame?: boolean): void;
  38410. private _fetchResult;
  38411. private _startMonitoringTime;
  38412. private _min;
  38413. private _max;
  38414. private _average;
  38415. private _current;
  38416. private _totalValueCount;
  38417. private _totalAccumulated;
  38418. private _lastSecAverage;
  38419. private _lastSecAccumulated;
  38420. private _lastSecTime;
  38421. private _lastSecValueCount;
  38422. }
  38423. }
  38424. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38425. module "babylonjs/Engines/thinEngine" {
  38426. interface ThinEngine {
  38427. /**
  38428. * Sets alpha constants used by some alpha blending modes
  38429. * @param r defines the red component
  38430. * @param g defines the green component
  38431. * @param b defines the blue component
  38432. * @param a defines the alpha component
  38433. */
  38434. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38435. /**
  38436. * Sets the current alpha mode
  38437. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38438. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38439. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38440. */
  38441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38442. /**
  38443. * Gets the current alpha mode
  38444. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38445. * @returns the current alpha mode
  38446. */
  38447. getAlphaMode(): number;
  38448. /**
  38449. * Sets the current alpha equation
  38450. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38451. */
  38452. setAlphaEquation(equation: number): void;
  38453. /**
  38454. * Gets the current alpha equation.
  38455. * @returns the current alpha equation
  38456. */
  38457. getAlphaEquation(): number;
  38458. }
  38459. }
  38460. }
  38461. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38463. import { Nullable } from "babylonjs/types";
  38464. module "babylonjs/Engines/thinEngine" {
  38465. interface ThinEngine {
  38466. /** @hidden */
  38467. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38468. }
  38469. }
  38470. }
  38471. declare module "babylonjs/Engines/engine" {
  38472. import { Observable } from "babylonjs/Misc/observable";
  38473. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38474. import { Scene } from "babylonjs/scene";
  38475. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38476. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38478. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38479. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38480. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38481. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38482. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38483. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38484. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38485. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38486. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38487. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38488. import "babylonjs/Engines/Extensions/engine.alpha";
  38489. import "babylonjs/Engines/Extensions/engine.readTexture";
  38490. import { Material } from "babylonjs/Materials/material";
  38491. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38492. /**
  38493. * Defines the interface used by display changed events
  38494. */
  38495. export interface IDisplayChangedEventArgs {
  38496. /** Gets the vrDisplay object (if any) */
  38497. vrDisplay: Nullable<any>;
  38498. /** Gets a boolean indicating if webVR is supported */
  38499. vrSupported: boolean;
  38500. }
  38501. /**
  38502. * Defines the interface used by objects containing a viewport (like a camera)
  38503. */
  38504. interface IViewportOwnerLike {
  38505. /**
  38506. * Gets or sets the viewport
  38507. */
  38508. viewport: IViewportLike;
  38509. }
  38510. /**
  38511. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38512. */
  38513. export class Engine extends ThinEngine {
  38514. /** Defines that alpha blending is disabled */
  38515. static readonly ALPHA_DISABLE: number;
  38516. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38517. static readonly ALPHA_ADD: number;
  38518. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38519. static readonly ALPHA_COMBINE: number;
  38520. /** Defines that alpha blending to DEST - SRC * DEST */
  38521. static readonly ALPHA_SUBTRACT: number;
  38522. /** Defines that alpha blending to SRC * DEST */
  38523. static readonly ALPHA_MULTIPLY: number;
  38524. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38525. static readonly ALPHA_MAXIMIZED: number;
  38526. /** Defines that alpha blending to SRC + DEST */
  38527. static readonly ALPHA_ONEONE: number;
  38528. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38529. static readonly ALPHA_PREMULTIPLIED: number;
  38530. /**
  38531. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38532. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38533. */
  38534. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38535. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38536. static readonly ALPHA_INTERPOLATE: number;
  38537. /**
  38538. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38539. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38540. */
  38541. static readonly ALPHA_SCREENMODE: number;
  38542. /** Defines that the ressource is not delayed*/
  38543. static readonly DELAYLOADSTATE_NONE: number;
  38544. /** Defines that the ressource was successfully delay loaded */
  38545. static readonly DELAYLOADSTATE_LOADED: number;
  38546. /** Defines that the ressource is currently delay loading */
  38547. static readonly DELAYLOADSTATE_LOADING: number;
  38548. /** Defines that the ressource is delayed and has not started loading */
  38549. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38550. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38551. static readonly NEVER: number;
  38552. /** 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 */
  38553. static readonly ALWAYS: number;
  38554. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38555. static readonly LESS: number;
  38556. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38557. static readonly EQUAL: number;
  38558. /** 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 */
  38559. static readonly LEQUAL: number;
  38560. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38561. static readonly GREATER: number;
  38562. /** 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 */
  38563. static readonly GEQUAL: number;
  38564. /** 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 */
  38565. static readonly NOTEQUAL: number;
  38566. /** Passed to stencilOperation to specify that stencil value must be kept */
  38567. static readonly KEEP: number;
  38568. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38569. static readonly REPLACE: number;
  38570. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38571. static readonly INCR: number;
  38572. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38573. static readonly DECR: number;
  38574. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38575. static readonly INVERT: number;
  38576. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38577. static readonly INCR_WRAP: number;
  38578. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38579. static readonly DECR_WRAP: number;
  38580. /** Texture is not repeating outside of 0..1 UVs */
  38581. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38582. /** Texture is repeating outside of 0..1 UVs */
  38583. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38584. /** Texture is repeating and mirrored */
  38585. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38586. /** ALPHA */
  38587. static readonly TEXTUREFORMAT_ALPHA: number;
  38588. /** LUMINANCE */
  38589. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38590. /** LUMINANCE_ALPHA */
  38591. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38592. /** RGB */
  38593. static readonly TEXTUREFORMAT_RGB: number;
  38594. /** RGBA */
  38595. static readonly TEXTUREFORMAT_RGBA: number;
  38596. /** RED */
  38597. static readonly TEXTUREFORMAT_RED: number;
  38598. /** RED (2nd reference) */
  38599. static readonly TEXTUREFORMAT_R: number;
  38600. /** RG */
  38601. static readonly TEXTUREFORMAT_RG: number;
  38602. /** RED_INTEGER */
  38603. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38604. /** RED_INTEGER (2nd reference) */
  38605. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38606. /** RG_INTEGER */
  38607. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38608. /** RGB_INTEGER */
  38609. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38610. /** RGBA_INTEGER */
  38611. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38612. /** UNSIGNED_BYTE */
  38613. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38614. /** UNSIGNED_BYTE (2nd reference) */
  38615. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38616. /** FLOAT */
  38617. static readonly TEXTURETYPE_FLOAT: number;
  38618. /** HALF_FLOAT */
  38619. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38620. /** BYTE */
  38621. static readonly TEXTURETYPE_BYTE: number;
  38622. /** SHORT */
  38623. static readonly TEXTURETYPE_SHORT: number;
  38624. /** UNSIGNED_SHORT */
  38625. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38626. /** INT */
  38627. static readonly TEXTURETYPE_INT: number;
  38628. /** UNSIGNED_INT */
  38629. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38630. /** UNSIGNED_SHORT_4_4_4_4 */
  38631. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38632. /** UNSIGNED_SHORT_5_5_5_1 */
  38633. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38634. /** UNSIGNED_SHORT_5_6_5 */
  38635. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38636. /** UNSIGNED_INT_2_10_10_10_REV */
  38637. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38638. /** UNSIGNED_INT_24_8 */
  38639. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38640. /** UNSIGNED_INT_10F_11F_11F_REV */
  38641. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38642. /** UNSIGNED_INT_5_9_9_9_REV */
  38643. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38644. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38645. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38646. /** nearest is mag = nearest and min = nearest and mip = linear */
  38647. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38648. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38649. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38650. /** Trilinear is mag = linear and min = linear and mip = linear */
  38651. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38652. /** nearest is mag = nearest and min = nearest and mip = linear */
  38653. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38654. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38655. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38656. /** Trilinear is mag = linear and min = linear and mip = linear */
  38657. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38658. /** mag = nearest and min = nearest and mip = nearest */
  38659. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38660. /** mag = nearest and min = linear and mip = nearest */
  38661. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38662. /** mag = nearest and min = linear and mip = linear */
  38663. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38664. /** mag = nearest and min = linear and mip = none */
  38665. static readonly TEXTURE_NEAREST_LINEAR: number;
  38666. /** mag = nearest and min = nearest and mip = none */
  38667. static readonly TEXTURE_NEAREST_NEAREST: number;
  38668. /** mag = linear and min = nearest and mip = nearest */
  38669. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38670. /** mag = linear and min = nearest and mip = linear */
  38671. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38672. /** mag = linear and min = linear and mip = none */
  38673. static readonly TEXTURE_LINEAR_LINEAR: number;
  38674. /** mag = linear and min = nearest and mip = none */
  38675. static readonly TEXTURE_LINEAR_NEAREST: number;
  38676. /** Explicit coordinates mode */
  38677. static readonly TEXTURE_EXPLICIT_MODE: number;
  38678. /** Spherical coordinates mode */
  38679. static readonly TEXTURE_SPHERICAL_MODE: number;
  38680. /** Planar coordinates mode */
  38681. static readonly TEXTURE_PLANAR_MODE: number;
  38682. /** Cubic coordinates mode */
  38683. static readonly TEXTURE_CUBIC_MODE: number;
  38684. /** Projection coordinates mode */
  38685. static readonly TEXTURE_PROJECTION_MODE: number;
  38686. /** Skybox coordinates mode */
  38687. static readonly TEXTURE_SKYBOX_MODE: number;
  38688. /** Inverse Cubic coordinates mode */
  38689. static readonly TEXTURE_INVCUBIC_MODE: number;
  38690. /** Equirectangular coordinates mode */
  38691. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38692. /** Equirectangular Fixed coordinates mode */
  38693. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38694. /** Equirectangular Fixed Mirrored coordinates mode */
  38695. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38696. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38697. static readonly SCALEMODE_FLOOR: number;
  38698. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38699. static readonly SCALEMODE_NEAREST: number;
  38700. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38701. static readonly SCALEMODE_CEILING: number;
  38702. /**
  38703. * Returns the current npm package of the sdk
  38704. */
  38705. static get NpmPackage(): string;
  38706. /**
  38707. * Returns the current version of the framework
  38708. */
  38709. static get Version(): string;
  38710. /** Gets the list of created engines */
  38711. static get Instances(): Engine[];
  38712. /**
  38713. * Gets the latest created engine
  38714. */
  38715. static get LastCreatedEngine(): Nullable<Engine>;
  38716. /**
  38717. * Gets the latest created scene
  38718. */
  38719. static get LastCreatedScene(): Nullable<Scene>;
  38720. /**
  38721. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38722. * @param flag defines which part of the materials must be marked as dirty
  38723. * @param predicate defines a predicate used to filter which materials should be affected
  38724. */
  38725. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38726. /**
  38727. * Method called to create the default loading screen.
  38728. * This can be overriden in your own app.
  38729. * @param canvas The rendering canvas element
  38730. * @returns The loading screen
  38731. */
  38732. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38733. /**
  38734. * Method called to create the default rescale post process on each engine.
  38735. */
  38736. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38737. /**
  38738. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38739. **/
  38740. enableOfflineSupport: boolean;
  38741. /**
  38742. * 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)
  38743. **/
  38744. disableManifestCheck: boolean;
  38745. /**
  38746. * Gets the list of created scenes
  38747. */
  38748. scenes: Scene[];
  38749. /**
  38750. * Event raised when a new scene is created
  38751. */
  38752. onNewSceneAddedObservable: Observable<Scene>;
  38753. /**
  38754. * Gets the list of created postprocesses
  38755. */
  38756. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38757. /**
  38758. * Gets a boolean indicating if the pointer is currently locked
  38759. */
  38760. isPointerLock: boolean;
  38761. /**
  38762. * Observable event triggered each time the rendering canvas is resized
  38763. */
  38764. onResizeObservable: Observable<Engine>;
  38765. /**
  38766. * Observable event triggered each time the canvas loses focus
  38767. */
  38768. onCanvasBlurObservable: Observable<Engine>;
  38769. /**
  38770. * Observable event triggered each time the canvas gains focus
  38771. */
  38772. onCanvasFocusObservable: Observable<Engine>;
  38773. /**
  38774. * Observable event triggered each time the canvas receives pointerout event
  38775. */
  38776. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38777. /**
  38778. * Observable raised when the engine begins a new frame
  38779. */
  38780. onBeginFrameObservable: Observable<Engine>;
  38781. /**
  38782. * If set, will be used to request the next animation frame for the render loop
  38783. */
  38784. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38785. /**
  38786. * Observable raised when the engine ends the current frame
  38787. */
  38788. onEndFrameObservable: Observable<Engine>;
  38789. /**
  38790. * Observable raised when the engine is about to compile a shader
  38791. */
  38792. onBeforeShaderCompilationObservable: Observable<Engine>;
  38793. /**
  38794. * Observable raised when the engine has jsut compiled a shader
  38795. */
  38796. onAfterShaderCompilationObservable: Observable<Engine>;
  38797. /**
  38798. * Gets the audio engine
  38799. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38800. * @ignorenaming
  38801. */
  38802. static audioEngine: IAudioEngine;
  38803. /**
  38804. * Default AudioEngine factory responsible of creating the Audio Engine.
  38805. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38806. */
  38807. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38808. /**
  38809. * Default offline support factory responsible of creating a tool used to store data locally.
  38810. * By default, this will create a Database object if the workload has been embedded.
  38811. */
  38812. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38813. private _loadingScreen;
  38814. private _pointerLockRequested;
  38815. private _rescalePostProcess;
  38816. private _deterministicLockstep;
  38817. private _lockstepMaxSteps;
  38818. private _timeStep;
  38819. protected get _supportsHardwareTextureRescaling(): boolean;
  38820. private _fps;
  38821. private _deltaTime;
  38822. /** @hidden */
  38823. _drawCalls: PerfCounter;
  38824. /** 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 */
  38825. canvasTabIndex: number;
  38826. /**
  38827. * Turn this value on if you want to pause FPS computation when in background
  38828. */
  38829. disablePerformanceMonitorInBackground: boolean;
  38830. private _performanceMonitor;
  38831. /**
  38832. * Gets the performance monitor attached to this engine
  38833. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38834. */
  38835. get performanceMonitor(): PerformanceMonitor;
  38836. private _onFocus;
  38837. private _onBlur;
  38838. private _onCanvasPointerOut;
  38839. private _onCanvasBlur;
  38840. private _onCanvasFocus;
  38841. private _onFullscreenChange;
  38842. private _onPointerLockChange;
  38843. /**
  38844. * Gets the HTML element used to attach event listeners
  38845. * @returns a HTML element
  38846. */
  38847. getInputElement(): Nullable<HTMLElement>;
  38848. /**
  38849. * Creates a new engine
  38850. * @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
  38851. * @param antialias defines enable antialiasing (default: false)
  38852. * @param options defines further options to be sent to the getContext() function
  38853. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38854. */
  38855. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38856. /**
  38857. * Gets current aspect ratio
  38858. * @param viewportOwner defines the camera to use to get the aspect ratio
  38859. * @param useScreen defines if screen size must be used (or the current render target if any)
  38860. * @returns a number defining the aspect ratio
  38861. */
  38862. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38863. /**
  38864. * Gets current screen aspect ratio
  38865. * @returns a number defining the aspect ratio
  38866. */
  38867. getScreenAspectRatio(): number;
  38868. /**
  38869. * Gets the client rect of the HTML canvas attached with the current webGL context
  38870. * @returns a client rectanglee
  38871. */
  38872. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38873. /**
  38874. * Gets the client rect of the HTML element used for events
  38875. * @returns a client rectanglee
  38876. */
  38877. getInputElementClientRect(): Nullable<ClientRect>;
  38878. /**
  38879. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38881. * @returns true if engine is in deterministic lock step mode
  38882. */
  38883. isDeterministicLockStep(): boolean;
  38884. /**
  38885. * Gets the max steps when engine is running in deterministic lock step
  38886. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38887. * @returns the max steps
  38888. */
  38889. getLockstepMaxSteps(): number;
  38890. /**
  38891. * Returns the time in ms between steps when using deterministic lock step.
  38892. * @returns time step in (ms)
  38893. */
  38894. getTimeStep(): number;
  38895. /**
  38896. * Force the mipmap generation for the given render target texture
  38897. * @param texture defines the render target texture to use
  38898. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38899. */
  38900. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38901. /** States */
  38902. /**
  38903. * Set various states to the webGL context
  38904. * @param culling defines backface culling state
  38905. * @param zOffset defines the value to apply to zOffset (0 by default)
  38906. * @param force defines if states must be applied even if cache is up to date
  38907. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38908. */
  38909. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38910. /**
  38911. * Set the z offset to apply to current rendering
  38912. * @param value defines the offset to apply
  38913. */
  38914. setZOffset(value: number): void;
  38915. /**
  38916. * Gets the current value of the zOffset
  38917. * @returns the current zOffset state
  38918. */
  38919. getZOffset(): number;
  38920. /**
  38921. * Enable or disable depth buffering
  38922. * @param enable defines the state to set
  38923. */
  38924. setDepthBuffer(enable: boolean): void;
  38925. /**
  38926. * Gets a boolean indicating if depth writing is enabled
  38927. * @returns the current depth writing state
  38928. */
  38929. getDepthWrite(): boolean;
  38930. /**
  38931. * Enable or disable depth writing
  38932. * @param enable defines the state to set
  38933. */
  38934. setDepthWrite(enable: boolean): void;
  38935. /**
  38936. * Gets a boolean indicating if stencil buffer is enabled
  38937. * @returns the current stencil buffer state
  38938. */
  38939. getStencilBuffer(): boolean;
  38940. /**
  38941. * Enable or disable the stencil buffer
  38942. * @param enable defines if the stencil buffer must be enabled or disabled
  38943. */
  38944. setStencilBuffer(enable: boolean): void;
  38945. /**
  38946. * Gets the current stencil mask
  38947. * @returns a number defining the new stencil mask to use
  38948. */
  38949. getStencilMask(): number;
  38950. /**
  38951. * Sets the current stencil mask
  38952. * @param mask defines the new stencil mask to use
  38953. */
  38954. setStencilMask(mask: number): void;
  38955. /**
  38956. * Gets the current stencil function
  38957. * @returns a number defining the stencil function to use
  38958. */
  38959. getStencilFunction(): number;
  38960. /**
  38961. * Gets the current stencil reference value
  38962. * @returns a number defining the stencil reference value to use
  38963. */
  38964. getStencilFunctionReference(): number;
  38965. /**
  38966. * Gets the current stencil mask
  38967. * @returns a number defining the stencil mask to use
  38968. */
  38969. getStencilFunctionMask(): number;
  38970. /**
  38971. * Sets the current stencil function
  38972. * @param stencilFunc defines the new stencil function to use
  38973. */
  38974. setStencilFunction(stencilFunc: number): void;
  38975. /**
  38976. * Sets the current stencil reference
  38977. * @param reference defines the new stencil reference to use
  38978. */
  38979. setStencilFunctionReference(reference: number): void;
  38980. /**
  38981. * Sets the current stencil mask
  38982. * @param mask defines the new stencil mask to use
  38983. */
  38984. setStencilFunctionMask(mask: number): void;
  38985. /**
  38986. * Gets the current stencil operation when stencil fails
  38987. * @returns a number defining stencil operation to use when stencil fails
  38988. */
  38989. getStencilOperationFail(): number;
  38990. /**
  38991. * Gets the current stencil operation when depth fails
  38992. * @returns a number defining stencil operation to use when depth fails
  38993. */
  38994. getStencilOperationDepthFail(): number;
  38995. /**
  38996. * Gets the current stencil operation when stencil passes
  38997. * @returns a number defining stencil operation to use when stencil passes
  38998. */
  38999. getStencilOperationPass(): number;
  39000. /**
  39001. * Sets the stencil operation to use when stencil fails
  39002. * @param operation defines the stencil operation to use when stencil fails
  39003. */
  39004. setStencilOperationFail(operation: number): void;
  39005. /**
  39006. * Sets the stencil operation to use when depth fails
  39007. * @param operation defines the stencil operation to use when depth fails
  39008. */
  39009. setStencilOperationDepthFail(operation: number): void;
  39010. /**
  39011. * Sets the stencil operation to use when stencil passes
  39012. * @param operation defines the stencil operation to use when stencil passes
  39013. */
  39014. setStencilOperationPass(operation: number): void;
  39015. /**
  39016. * Sets a boolean indicating if the dithering state is enabled or disabled
  39017. * @param value defines the dithering state
  39018. */
  39019. setDitheringState(value: boolean): void;
  39020. /**
  39021. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39022. * @param value defines the rasterizer state
  39023. */
  39024. setRasterizerState(value: boolean): void;
  39025. /**
  39026. * Gets the current depth function
  39027. * @returns a number defining the depth function
  39028. */
  39029. getDepthFunction(): Nullable<number>;
  39030. /**
  39031. * Sets the current depth function
  39032. * @param depthFunc defines the function to use
  39033. */
  39034. setDepthFunction(depthFunc: number): void;
  39035. /**
  39036. * Sets the current depth function to GREATER
  39037. */
  39038. setDepthFunctionToGreater(): void;
  39039. /**
  39040. * Sets the current depth function to GEQUAL
  39041. */
  39042. setDepthFunctionToGreaterOrEqual(): void;
  39043. /**
  39044. * Sets the current depth function to LESS
  39045. */
  39046. setDepthFunctionToLess(): void;
  39047. /**
  39048. * Sets the current depth function to LEQUAL
  39049. */
  39050. setDepthFunctionToLessOrEqual(): void;
  39051. private _cachedStencilBuffer;
  39052. private _cachedStencilFunction;
  39053. private _cachedStencilMask;
  39054. private _cachedStencilOperationPass;
  39055. private _cachedStencilOperationFail;
  39056. private _cachedStencilOperationDepthFail;
  39057. private _cachedStencilReference;
  39058. /**
  39059. * Caches the the state of the stencil buffer
  39060. */
  39061. cacheStencilState(): void;
  39062. /**
  39063. * Restores the state of the stencil buffer
  39064. */
  39065. restoreStencilState(): void;
  39066. /**
  39067. * Directly set the WebGL Viewport
  39068. * @param x defines the x coordinate of the viewport (in screen space)
  39069. * @param y defines the y coordinate of the viewport (in screen space)
  39070. * @param width defines the width of the viewport (in screen space)
  39071. * @param height defines the height of the viewport (in screen space)
  39072. * @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
  39073. */
  39074. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39075. /**
  39076. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39077. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39078. * @param y defines the y-coordinate of the corner of the clear rectangle
  39079. * @param width defines the width of the clear rectangle
  39080. * @param height defines the height of the clear rectangle
  39081. * @param clearColor defines the clear color
  39082. */
  39083. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39084. /**
  39085. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39086. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39087. * @param y defines the y-coordinate of the corner of the clear rectangle
  39088. * @param width defines the width of the clear rectangle
  39089. * @param height defines the height of the clear rectangle
  39090. */
  39091. enableScissor(x: number, y: number, width: number, height: number): void;
  39092. /**
  39093. * Disable previously set scissor test rectangle
  39094. */
  39095. disableScissor(): void;
  39096. protected _reportDrawCall(): void;
  39097. /**
  39098. * Initializes a webVR display and starts listening to display change events
  39099. * The onVRDisplayChangedObservable will be notified upon these changes
  39100. * @returns The onVRDisplayChangedObservable
  39101. */
  39102. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39103. /** @hidden */
  39104. _prepareVRComponent(): void;
  39105. /** @hidden */
  39106. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39107. /** @hidden */
  39108. _submitVRFrame(): void;
  39109. /**
  39110. * Call this function to leave webVR mode
  39111. * Will do nothing if webVR is not supported or if there is no webVR device
  39112. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39113. */
  39114. disableVR(): void;
  39115. /**
  39116. * Gets a boolean indicating that the system is in VR mode and is presenting
  39117. * @returns true if VR mode is engaged
  39118. */
  39119. isVRPresenting(): boolean;
  39120. /** @hidden */
  39121. _requestVRFrame(): void;
  39122. /** @hidden */
  39123. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39124. /**
  39125. * Gets the source code of the vertex shader associated with a specific webGL program
  39126. * @param program defines the program to use
  39127. * @returns a string containing the source code of the vertex shader associated with the program
  39128. */
  39129. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39130. /**
  39131. * Gets the source code of the fragment shader associated with a specific webGL program
  39132. * @param program defines the program to use
  39133. * @returns a string containing the source code of the fragment shader associated with the program
  39134. */
  39135. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39136. /**
  39137. * Sets a depth stencil texture from a render target to the according uniform.
  39138. * @param channel The texture channel
  39139. * @param uniform The uniform to set
  39140. * @param texture The render target texture containing the depth stencil texture to apply
  39141. */
  39142. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39143. /**
  39144. * Sets a texture to the webGL context from a postprocess
  39145. * @param channel defines the channel to use
  39146. * @param postProcess defines the source postprocess
  39147. */
  39148. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39149. /**
  39150. * Binds the output of the passed in post process to the texture channel specified
  39151. * @param channel The channel the texture should be bound to
  39152. * @param postProcess The post process which's output should be bound
  39153. */
  39154. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39155. protected _rebuildBuffers(): void;
  39156. /** @hidden */
  39157. _renderFrame(): void;
  39158. _renderLoop(): void;
  39159. /** @hidden */
  39160. _renderViews(): boolean;
  39161. /**
  39162. * Toggle full screen mode
  39163. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39164. */
  39165. switchFullscreen(requestPointerLock: boolean): void;
  39166. /**
  39167. * Enters full screen mode
  39168. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39169. */
  39170. enterFullscreen(requestPointerLock: boolean): void;
  39171. /**
  39172. * Exits full screen mode
  39173. */
  39174. exitFullscreen(): void;
  39175. /**
  39176. * Enters Pointerlock mode
  39177. */
  39178. enterPointerlock(): void;
  39179. /**
  39180. * Exits Pointerlock mode
  39181. */
  39182. exitPointerlock(): void;
  39183. /**
  39184. * Begin a new frame
  39185. */
  39186. beginFrame(): void;
  39187. /**
  39188. * Enf the current frame
  39189. */
  39190. endFrame(): void;
  39191. resize(): void;
  39192. /**
  39193. * Force a specific size of the canvas
  39194. * @param width defines the new canvas' width
  39195. * @param height defines the new canvas' height
  39196. * @returns true if the size was changed
  39197. */
  39198. setSize(width: number, height: number): boolean;
  39199. /**
  39200. * Updates a dynamic vertex buffer.
  39201. * @param vertexBuffer the vertex buffer to update
  39202. * @param data the data used to update the vertex buffer
  39203. * @param byteOffset the byte offset of the data
  39204. * @param byteLength the byte length of the data
  39205. */
  39206. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39207. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39208. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39209. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39210. _releaseTexture(texture: InternalTexture): void;
  39211. /**
  39212. * @hidden
  39213. * Rescales a texture
  39214. * @param source input texutre
  39215. * @param destination destination texture
  39216. * @param scene scene to use to render the resize
  39217. * @param internalFormat format to use when resizing
  39218. * @param onComplete callback to be called when resize has completed
  39219. */
  39220. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39221. /**
  39222. * Gets the current framerate
  39223. * @returns a number representing the framerate
  39224. */
  39225. getFps(): number;
  39226. /**
  39227. * Gets the time spent between current and previous frame
  39228. * @returns a number representing the delta time in ms
  39229. */
  39230. getDeltaTime(): number;
  39231. private _measureFps;
  39232. /** @hidden */
  39233. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39234. /**
  39235. * Update a dynamic index buffer
  39236. * @param indexBuffer defines the target index buffer
  39237. * @param indices defines the data to update
  39238. * @param offset defines the offset in the target index buffer where update should start
  39239. */
  39240. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39241. /**
  39242. * Updates the sample count of a render target texture
  39243. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39244. * @param texture defines the texture to update
  39245. * @param samples defines the sample count to set
  39246. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39247. */
  39248. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39249. /**
  39250. * Updates a depth texture Comparison Mode and Function.
  39251. * If the comparison Function is equal to 0, the mode will be set to none.
  39252. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39253. * @param texture The texture to set the comparison function for
  39254. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39255. */
  39256. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39257. /**
  39258. * Creates a webGL buffer to use with instanciation
  39259. * @param capacity defines the size of the buffer
  39260. * @returns the webGL buffer
  39261. */
  39262. createInstancesBuffer(capacity: number): DataBuffer;
  39263. /**
  39264. * Delete a webGL buffer used with instanciation
  39265. * @param buffer defines the webGL buffer to delete
  39266. */
  39267. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39268. private _clientWaitAsync;
  39269. /** @hidden */
  39270. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39271. dispose(): void;
  39272. private _disableTouchAction;
  39273. /**
  39274. * Display the loading screen
  39275. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39276. */
  39277. displayLoadingUI(): void;
  39278. /**
  39279. * Hide the loading screen
  39280. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39281. */
  39282. hideLoadingUI(): void;
  39283. /**
  39284. * Gets the current loading screen object
  39285. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39286. */
  39287. get loadingScreen(): ILoadingScreen;
  39288. /**
  39289. * Sets the current loading screen object
  39290. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39291. */
  39292. set loadingScreen(loadingScreen: ILoadingScreen);
  39293. /**
  39294. * Sets the current loading screen text
  39295. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39296. */
  39297. set loadingUIText(text: string);
  39298. /**
  39299. * Sets the current loading screen background color
  39300. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39301. */
  39302. set loadingUIBackgroundColor(color: string);
  39303. /** Pointerlock and fullscreen */
  39304. /**
  39305. * Ask the browser to promote the current element to pointerlock mode
  39306. * @param element defines the DOM element to promote
  39307. */
  39308. static _RequestPointerlock(element: HTMLElement): void;
  39309. /**
  39310. * Asks the browser to exit pointerlock mode
  39311. */
  39312. static _ExitPointerlock(): void;
  39313. /**
  39314. * Ask the browser to promote the current element to fullscreen rendering mode
  39315. * @param element defines the DOM element to promote
  39316. */
  39317. static _RequestFullscreen(element: HTMLElement): void;
  39318. /**
  39319. * Asks the browser to exit fullscreen mode
  39320. */
  39321. static _ExitFullscreen(): void;
  39322. }
  39323. }
  39324. declare module "babylonjs/Engines/engineStore" {
  39325. import { Nullable } from "babylonjs/types";
  39326. import { Engine } from "babylonjs/Engines/engine";
  39327. import { Scene } from "babylonjs/scene";
  39328. /**
  39329. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39330. * during the life time of the application.
  39331. */
  39332. export class EngineStore {
  39333. /** Gets the list of created engines */
  39334. static Instances: import("babylonjs/Engines/engine").Engine[];
  39335. /** @hidden */
  39336. static _LastCreatedScene: Nullable<Scene>;
  39337. /**
  39338. * Gets the latest created engine
  39339. */
  39340. static get LastCreatedEngine(): Nullable<Engine>;
  39341. /**
  39342. * Gets the latest created scene
  39343. */
  39344. static get LastCreatedScene(): Nullable<Scene>;
  39345. /**
  39346. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39347. * @ignorenaming
  39348. */
  39349. static UseFallbackTexture: boolean;
  39350. /**
  39351. * Texture content used if a texture cannot loaded
  39352. * @ignorenaming
  39353. */
  39354. static FallbackTexture: string;
  39355. }
  39356. }
  39357. declare module "babylonjs/Misc/promise" {
  39358. /**
  39359. * Helper class that provides a small promise polyfill
  39360. */
  39361. export class PromisePolyfill {
  39362. /**
  39363. * Static function used to check if the polyfill is required
  39364. * If this is the case then the function will inject the polyfill to window.Promise
  39365. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39366. */
  39367. static Apply(force?: boolean): void;
  39368. }
  39369. }
  39370. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39371. /**
  39372. * Interface for screenshot methods with describe argument called `size` as object with options
  39373. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39374. */
  39375. export interface IScreenshotSize {
  39376. /**
  39377. * number in pixels for canvas height
  39378. */
  39379. height?: number;
  39380. /**
  39381. * multiplier allowing render at a higher or lower resolution
  39382. * If value is defined then height and width will be ignored and taken from camera
  39383. */
  39384. precision?: number;
  39385. /**
  39386. * number in pixels for canvas width
  39387. */
  39388. width?: number;
  39389. }
  39390. }
  39391. declare module "babylonjs/Misc/tools" {
  39392. import { Nullable, float } from "babylonjs/types";
  39393. import { DomManagement } from "babylonjs/Misc/domManagement";
  39394. import { WebRequest } from "babylonjs/Misc/webRequest";
  39395. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39396. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39397. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39398. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39399. import { Camera } from "babylonjs/Cameras/camera";
  39400. import { Engine } from "babylonjs/Engines/engine";
  39401. interface IColor4Like {
  39402. r: float;
  39403. g: float;
  39404. b: float;
  39405. a: float;
  39406. }
  39407. /**
  39408. * Class containing a set of static utilities functions
  39409. */
  39410. export class Tools {
  39411. /**
  39412. * Gets or sets the base URL to use to load assets
  39413. */
  39414. static get BaseUrl(): string;
  39415. static set BaseUrl(value: string);
  39416. /**
  39417. * Enable/Disable Custom HTTP Request Headers globally.
  39418. * default = false
  39419. * @see CustomRequestHeaders
  39420. */
  39421. static UseCustomRequestHeaders: boolean;
  39422. /**
  39423. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39424. * i.e. when loading files, where the server/service expects an Authorization header
  39425. */
  39426. static CustomRequestHeaders: {
  39427. [key: string]: string;
  39428. };
  39429. /**
  39430. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39431. */
  39432. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39433. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39434. /**
  39435. * Default behaviour for cors in the application.
  39436. * It can be a string if the expected behavior is identical in the entire app.
  39437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39438. */
  39439. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39440. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39441. /**
  39442. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39443. * @ignorenaming
  39444. */
  39445. static get UseFallbackTexture(): boolean;
  39446. static set UseFallbackTexture(value: boolean);
  39447. /**
  39448. * Use this object to register external classes like custom textures or material
  39449. * to allow the laoders to instantiate them
  39450. */
  39451. static get RegisteredExternalClasses(): {
  39452. [key: string]: Object;
  39453. };
  39454. static set RegisteredExternalClasses(classes: {
  39455. [key: string]: Object;
  39456. });
  39457. /**
  39458. * Texture content used if a texture cannot loaded
  39459. * @ignorenaming
  39460. */
  39461. static get fallbackTexture(): string;
  39462. static set fallbackTexture(value: string);
  39463. /**
  39464. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39465. * @param u defines the coordinate on X axis
  39466. * @param v defines the coordinate on Y axis
  39467. * @param width defines the width of the source data
  39468. * @param height defines the height of the source data
  39469. * @param pixels defines the source byte array
  39470. * @param color defines the output color
  39471. */
  39472. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39473. /**
  39474. * Interpolates between a and b via alpha
  39475. * @param a The lower value (returned when alpha = 0)
  39476. * @param b The upper value (returned when alpha = 1)
  39477. * @param alpha The interpolation-factor
  39478. * @return The mixed value
  39479. */
  39480. static Mix(a: number, b: number, alpha: number): number;
  39481. /**
  39482. * Tries to instantiate a new object from a given class name
  39483. * @param className defines the class name to instantiate
  39484. * @returns the new object or null if the system was not able to do the instantiation
  39485. */
  39486. static Instantiate(className: string): any;
  39487. /**
  39488. * Provides a slice function that will work even on IE
  39489. * @param data defines the array to slice
  39490. * @param start defines the start of the data (optional)
  39491. * @param end defines the end of the data (optional)
  39492. * @returns the new sliced array
  39493. */
  39494. static Slice<T>(data: T, start?: number, end?: number): T;
  39495. /**
  39496. * Polyfill for setImmediate
  39497. * @param action defines the action to execute after the current execution block
  39498. */
  39499. static SetImmediate(action: () => void): void;
  39500. /**
  39501. * Function indicating if a number is an exponent of 2
  39502. * @param value defines the value to test
  39503. * @returns true if the value is an exponent of 2
  39504. */
  39505. static IsExponentOfTwo(value: number): boolean;
  39506. private static _tmpFloatArray;
  39507. /**
  39508. * Returns the nearest 32-bit single precision float representation of a Number
  39509. * @param value A Number. If the parameter is of a different type, it will get converted
  39510. * to a number or to NaN if it cannot be converted
  39511. * @returns number
  39512. */
  39513. static FloatRound(value: number): number;
  39514. /**
  39515. * Extracts the filename from a path
  39516. * @param path defines the path to use
  39517. * @returns the filename
  39518. */
  39519. static GetFilename(path: string): string;
  39520. /**
  39521. * Extracts the "folder" part of a path (everything before the filename).
  39522. * @param uri The URI to extract the info from
  39523. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39524. * @returns The "folder" part of the path
  39525. */
  39526. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39527. /**
  39528. * Extracts text content from a DOM element hierarchy
  39529. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39530. */
  39531. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39532. /**
  39533. * Convert an angle in radians to degrees
  39534. * @param angle defines the angle to convert
  39535. * @returns the angle in degrees
  39536. */
  39537. static ToDegrees(angle: number): number;
  39538. /**
  39539. * Convert an angle in degrees to radians
  39540. * @param angle defines the angle to convert
  39541. * @returns the angle in radians
  39542. */
  39543. static ToRadians(angle: number): number;
  39544. /**
  39545. * Returns an array if obj is not an array
  39546. * @param obj defines the object to evaluate as an array
  39547. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39548. * @returns either obj directly if obj is an array or a new array containing obj
  39549. */
  39550. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39551. /**
  39552. * Gets the pointer prefix to use
  39553. * @param engine defines the engine we are finding the prefix for
  39554. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39555. */
  39556. static GetPointerPrefix(engine: Engine): string;
  39557. /**
  39558. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39559. * @param url define the url we are trying
  39560. * @param element define the dom element where to configure the cors policy
  39561. */
  39562. static SetCorsBehavior(url: string | string[], element: {
  39563. crossOrigin: string | null;
  39564. }): void;
  39565. /**
  39566. * Removes unwanted characters from an url
  39567. * @param url defines the url to clean
  39568. * @returns the cleaned url
  39569. */
  39570. static CleanUrl(url: string): string;
  39571. /**
  39572. * Gets or sets a function used to pre-process url before using them to load assets
  39573. */
  39574. static get PreprocessUrl(): (url: string) => string;
  39575. static set PreprocessUrl(processor: (url: string) => string);
  39576. /**
  39577. * Loads an image as an HTMLImageElement.
  39578. * @param input url string, ArrayBuffer, or Blob to load
  39579. * @param onLoad callback called when the image successfully loads
  39580. * @param onError callback called when the image fails to load
  39581. * @param offlineProvider offline provider for caching
  39582. * @param mimeType optional mime type
  39583. * @returns the HTMLImageElement of the loaded image
  39584. */
  39585. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39586. /**
  39587. * Loads a file from a url
  39588. * @param url url string, ArrayBuffer, or Blob to load
  39589. * @param onSuccess callback called when the file successfully loads
  39590. * @param onProgress callback called while file is loading (if the server supports this mode)
  39591. * @param offlineProvider defines the offline provider for caching
  39592. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39593. * @param onError callback called when the file fails to load
  39594. * @returns a file request object
  39595. */
  39596. 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;
  39597. /**
  39598. * Loads a file from a url
  39599. * @param url the file url to load
  39600. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39601. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39602. */
  39603. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39604. /**
  39605. * Load a script (identified by an url). When the url returns, the
  39606. * content of this file is added into a new script element, attached to the DOM (body element)
  39607. * @param scriptUrl defines the url of the script to laod
  39608. * @param onSuccess defines the callback called when the script is loaded
  39609. * @param onError defines the callback to call if an error occurs
  39610. * @param scriptId defines the id of the script element
  39611. */
  39612. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39613. /**
  39614. * Load an asynchronous script (identified by an url). When the url returns, the
  39615. * content of this file is added into a new script element, attached to the DOM (body element)
  39616. * @param scriptUrl defines the url of the script to laod
  39617. * @param scriptId defines the id of the script element
  39618. * @returns a promise request object
  39619. */
  39620. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39621. /**
  39622. * Loads a file from a blob
  39623. * @param fileToLoad defines the blob to use
  39624. * @param callback defines the callback to call when data is loaded
  39625. * @param progressCallback defines the callback to call during loading process
  39626. * @returns a file request object
  39627. */
  39628. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39629. /**
  39630. * Reads a file from a File object
  39631. * @param file defines the file to load
  39632. * @param onSuccess defines the callback to call when data is loaded
  39633. * @param onProgress defines the callback to call during loading process
  39634. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39635. * @param onError defines the callback to call when an error occurs
  39636. * @returns a file request object
  39637. */
  39638. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39639. /**
  39640. * Creates a data url from a given string content
  39641. * @param content defines the content to convert
  39642. * @returns the new data url link
  39643. */
  39644. static FileAsURL(content: string): string;
  39645. /**
  39646. * Format the given number to a specific decimal format
  39647. * @param value defines the number to format
  39648. * @param decimals defines the number of decimals to use
  39649. * @returns the formatted string
  39650. */
  39651. static Format(value: number, decimals?: number): string;
  39652. /**
  39653. * Tries to copy an object by duplicating every property
  39654. * @param source defines the source object
  39655. * @param destination defines the target object
  39656. * @param doNotCopyList defines a list of properties to avoid
  39657. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39658. */
  39659. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39660. /**
  39661. * Gets a boolean indicating if the given object has no own property
  39662. * @param obj defines the object to test
  39663. * @returns true if object has no own property
  39664. */
  39665. static IsEmpty(obj: any): boolean;
  39666. /**
  39667. * Function used to register events at window level
  39668. * @param windowElement defines the Window object to use
  39669. * @param events defines the events to register
  39670. */
  39671. static RegisterTopRootEvents(windowElement: Window, events: {
  39672. name: string;
  39673. handler: Nullable<(e: FocusEvent) => any>;
  39674. }[]): void;
  39675. /**
  39676. * Function used to unregister events from window level
  39677. * @param windowElement defines the Window object to use
  39678. * @param events defines the events to unregister
  39679. */
  39680. static UnregisterTopRootEvents(windowElement: Window, events: {
  39681. name: string;
  39682. handler: Nullable<(e: FocusEvent) => any>;
  39683. }[]): void;
  39684. /**
  39685. * @ignore
  39686. */
  39687. static _ScreenshotCanvas: HTMLCanvasElement;
  39688. /**
  39689. * Dumps the current bound framebuffer
  39690. * @param width defines the rendering width
  39691. * @param height defines the rendering height
  39692. * @param engine defines the hosting engine
  39693. * @param successCallback defines the callback triggered once the data are available
  39694. * @param mimeType defines the mime type of the result
  39695. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39696. */
  39697. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39698. /**
  39699. * Converts the canvas data to blob.
  39700. * This acts as a polyfill for browsers not supporting the to blob function.
  39701. * @param canvas Defines the canvas to extract the data from
  39702. * @param successCallback Defines the callback triggered once the data are available
  39703. * @param mimeType Defines the mime type of the result
  39704. */
  39705. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39706. /**
  39707. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39708. * @param successCallback defines the callback triggered once the data are available
  39709. * @param mimeType defines the mime type of the result
  39710. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39711. */
  39712. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39713. /**
  39714. * Downloads a blob in the browser
  39715. * @param blob defines the blob to download
  39716. * @param fileName defines the name of the downloaded file
  39717. */
  39718. static Download(blob: Blob, fileName: string): void;
  39719. /**
  39720. * Captures a screenshot of the current rendering
  39721. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39722. * @param engine defines the rendering engine
  39723. * @param camera defines the source camera
  39724. * @param size This parameter can be set to a single number or to an object with the
  39725. * following (optional) properties: precision, width, height. If a single number is passed,
  39726. * it will be used for both width and height. If an object is passed, the screenshot size
  39727. * will be derived from the parameters. The precision property is a multiplier allowing
  39728. * rendering at a higher or lower resolution
  39729. * @param successCallback defines the callback receives a single parameter which contains the
  39730. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39731. * src parameter of an <img> to display it
  39732. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39733. * Check your browser for supported MIME types
  39734. */
  39735. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39736. /**
  39737. * Captures a screenshot of the current rendering
  39738. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39739. * @param engine defines the rendering engine
  39740. * @param camera defines the source camera
  39741. * @param size This parameter can be set to a single number or to an object with the
  39742. * following (optional) properties: precision, width, height. If a single number is passed,
  39743. * it will be used for both width and height. If an object is passed, the screenshot size
  39744. * will be derived from the parameters. The precision property is a multiplier allowing
  39745. * rendering at a higher or lower resolution
  39746. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39747. * Check your browser for supported MIME types
  39748. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39749. * to the src parameter of an <img> to display it
  39750. */
  39751. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39752. /**
  39753. * Generates an image screenshot from the specified camera.
  39754. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39755. * @param engine The engine to use for rendering
  39756. * @param camera The camera to use for rendering
  39757. * @param size This parameter can be set to a single number or to an object with the
  39758. * following (optional) properties: precision, width, height. If a single number is passed,
  39759. * it will be used for both width and height. If an object is passed, the screenshot size
  39760. * will be derived from the parameters. The precision property is a multiplier allowing
  39761. * rendering at a higher or lower resolution
  39762. * @param successCallback The callback receives a single parameter which contains the
  39763. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39764. * src parameter of an <img> to display it
  39765. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39766. * Check your browser for supported MIME types
  39767. * @param samples Texture samples (default: 1)
  39768. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39769. * @param fileName A name for for the downloaded file.
  39770. */
  39771. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39772. /**
  39773. * Generates an image screenshot from the specified camera.
  39774. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39775. * @param engine The engine to use for rendering
  39776. * @param camera The camera to use for rendering
  39777. * @param size This parameter can be set to a single number or to an object with the
  39778. * following (optional) properties: precision, width, height. If a single number is passed,
  39779. * it will be used for both width and height. If an object is passed, the screenshot size
  39780. * will be derived from the parameters. The precision property is a multiplier allowing
  39781. * rendering at a higher or lower resolution
  39782. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39783. * Check your browser for supported MIME types
  39784. * @param samples Texture samples (default: 1)
  39785. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39786. * @param fileName A name for for the downloaded file.
  39787. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39788. * to the src parameter of an <img> to display it
  39789. */
  39790. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39791. /**
  39792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39793. * Be aware Math.random() could cause collisions, but:
  39794. * "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"
  39795. * @returns a pseudo random id
  39796. */
  39797. static RandomId(): string;
  39798. /**
  39799. * Test if the given uri is a base64 string
  39800. * @param uri The uri to test
  39801. * @return True if the uri is a base64 string or false otherwise
  39802. */
  39803. static IsBase64(uri: string): boolean;
  39804. /**
  39805. * Decode the given base64 uri.
  39806. * @param uri The uri to decode
  39807. * @return The decoded base64 data.
  39808. */
  39809. static DecodeBase64(uri: string): ArrayBuffer;
  39810. /**
  39811. * Gets the absolute url.
  39812. * @param url the input url
  39813. * @return the absolute url
  39814. */
  39815. static GetAbsoluteUrl(url: string): string;
  39816. /**
  39817. * No log
  39818. */
  39819. static readonly NoneLogLevel: number;
  39820. /**
  39821. * Only message logs
  39822. */
  39823. static readonly MessageLogLevel: number;
  39824. /**
  39825. * Only warning logs
  39826. */
  39827. static readonly WarningLogLevel: number;
  39828. /**
  39829. * Only error logs
  39830. */
  39831. static readonly ErrorLogLevel: number;
  39832. /**
  39833. * All logs
  39834. */
  39835. static readonly AllLogLevel: number;
  39836. /**
  39837. * Gets a value indicating the number of loading errors
  39838. * @ignorenaming
  39839. */
  39840. static get errorsCount(): number;
  39841. /**
  39842. * Callback called when a new log is added
  39843. */
  39844. static OnNewCacheEntry: (entry: string) => void;
  39845. /**
  39846. * Log a message to the console
  39847. * @param message defines the message to log
  39848. */
  39849. static Log(message: string): void;
  39850. /**
  39851. * Write a warning message to the console
  39852. * @param message defines the message to log
  39853. */
  39854. static Warn(message: string): void;
  39855. /**
  39856. * Write an error message to the console
  39857. * @param message defines the message to log
  39858. */
  39859. static Error(message: string): void;
  39860. /**
  39861. * Gets current log cache (list of logs)
  39862. */
  39863. static get LogCache(): string;
  39864. /**
  39865. * Clears the log cache
  39866. */
  39867. static ClearLogCache(): void;
  39868. /**
  39869. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39870. */
  39871. static set LogLevels(level: number);
  39872. /**
  39873. * Checks if the window object exists
  39874. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39875. */
  39876. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39877. /**
  39878. * No performance log
  39879. */
  39880. static readonly PerformanceNoneLogLevel: number;
  39881. /**
  39882. * Use user marks to log performance
  39883. */
  39884. static readonly PerformanceUserMarkLogLevel: number;
  39885. /**
  39886. * Log performance to the console
  39887. */
  39888. static readonly PerformanceConsoleLogLevel: number;
  39889. private static _performance;
  39890. /**
  39891. * Sets the current performance log level
  39892. */
  39893. static set PerformanceLogLevel(level: number);
  39894. private static _StartPerformanceCounterDisabled;
  39895. private static _EndPerformanceCounterDisabled;
  39896. private static _StartUserMark;
  39897. private static _EndUserMark;
  39898. private static _StartPerformanceConsole;
  39899. private static _EndPerformanceConsole;
  39900. /**
  39901. * Starts a performance counter
  39902. */
  39903. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39904. /**
  39905. * Ends a specific performance coutner
  39906. */
  39907. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39908. /**
  39909. * Gets either window.performance.now() if supported or Date.now() else
  39910. */
  39911. static get Now(): number;
  39912. /**
  39913. * This method will return the name of the class used to create the instance of the given object.
  39914. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39915. * @param object the object to get the class name from
  39916. * @param isType defines if the object is actually a type
  39917. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39918. */
  39919. static GetClassName(object: any, isType?: boolean): string;
  39920. /**
  39921. * Gets the first element of an array satisfying a given predicate
  39922. * @param array defines the array to browse
  39923. * @param predicate defines the predicate to use
  39924. * @returns null if not found or the element
  39925. */
  39926. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39927. /**
  39928. * This method will return the name of the full name of the class, including its owning module (if any).
  39929. * 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).
  39930. * @param object the object to get the class name from
  39931. * @param isType defines if the object is actually a type
  39932. * @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.
  39933. * @ignorenaming
  39934. */
  39935. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39936. /**
  39937. * Returns a promise that resolves after the given amount of time.
  39938. * @param delay Number of milliseconds to delay
  39939. * @returns Promise that resolves after the given amount of time
  39940. */
  39941. static DelayAsync(delay: number): Promise<void>;
  39942. /**
  39943. * Utility function to detect if the current user agent is Safari
  39944. * @returns whether or not the current user agent is safari
  39945. */
  39946. static IsSafari(): boolean;
  39947. }
  39948. /**
  39949. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39950. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39951. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39952. * @param name The name of the class, case should be preserved
  39953. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39954. */
  39955. export function className(name: string, module?: string): (target: Object) => void;
  39956. /**
  39957. * An implementation of a loop for asynchronous functions.
  39958. */
  39959. export class AsyncLoop {
  39960. /**
  39961. * Defines the number of iterations for the loop
  39962. */
  39963. iterations: number;
  39964. /**
  39965. * Defines the current index of the loop.
  39966. */
  39967. index: number;
  39968. private _done;
  39969. private _fn;
  39970. private _successCallback;
  39971. /**
  39972. * Constructor.
  39973. * @param iterations the number of iterations.
  39974. * @param func the function to run each iteration
  39975. * @param successCallback the callback that will be called upon succesful execution
  39976. * @param offset starting offset.
  39977. */
  39978. constructor(
  39979. /**
  39980. * Defines the number of iterations for the loop
  39981. */
  39982. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39983. /**
  39984. * Execute the next iteration. Must be called after the last iteration was finished.
  39985. */
  39986. executeNext(): void;
  39987. /**
  39988. * Break the loop and run the success callback.
  39989. */
  39990. breakLoop(): void;
  39991. /**
  39992. * Create and run an async loop.
  39993. * @param iterations the number of iterations.
  39994. * @param fn the function to run each iteration
  39995. * @param successCallback the callback that will be called upon succesful execution
  39996. * @param offset starting offset.
  39997. * @returns the created async loop object
  39998. */
  39999. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40000. /**
  40001. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40002. * @param iterations total number of iterations
  40003. * @param syncedIterations number of synchronous iterations in each async iteration.
  40004. * @param fn the function to call each iteration.
  40005. * @param callback a success call back that will be called when iterating stops.
  40006. * @param breakFunction a break condition (optional)
  40007. * @param timeout timeout settings for the setTimeout function. default - 0.
  40008. * @returns the created async loop object
  40009. */
  40010. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40011. }
  40012. }
  40013. declare module "babylonjs/Misc/stringDictionary" {
  40014. import { Nullable } from "babylonjs/types";
  40015. /**
  40016. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40017. * The underlying implementation relies on an associative array to ensure the best performances.
  40018. * The value can be anything including 'null' but except 'undefined'
  40019. */
  40020. export class StringDictionary<T> {
  40021. /**
  40022. * This will clear this dictionary and copy the content from the 'source' one.
  40023. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40024. * @param source the dictionary to take the content from and copy to this dictionary
  40025. */
  40026. copyFrom(source: StringDictionary<T>): void;
  40027. /**
  40028. * Get a value based from its key
  40029. * @param key the given key to get the matching value from
  40030. * @return the value if found, otherwise undefined is returned
  40031. */
  40032. get(key: string): T | undefined;
  40033. /**
  40034. * Get a value from its key or add it if it doesn't exist.
  40035. * This method will ensure you that a given key/data will be present in the dictionary.
  40036. * @param key the given key to get the matching value from
  40037. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40038. * The factory will only be invoked if there's no data for the given key.
  40039. * @return the value corresponding to the key.
  40040. */
  40041. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40042. /**
  40043. * Get a value from its key if present in the dictionary otherwise add it
  40044. * @param key the key to get the value from
  40045. * @param val if there's no such key/value pair in the dictionary add it with this value
  40046. * @return the value corresponding to the key
  40047. */
  40048. getOrAdd(key: string, val: T): T;
  40049. /**
  40050. * Check if there's a given key in the dictionary
  40051. * @param key the key to check for
  40052. * @return true if the key is present, false otherwise
  40053. */
  40054. contains(key: string): boolean;
  40055. /**
  40056. * Add a new key and its corresponding value
  40057. * @param key the key to add
  40058. * @param value the value corresponding to the key
  40059. * @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
  40060. */
  40061. add(key: string, value: T): boolean;
  40062. /**
  40063. * Update a specific value associated to a key
  40064. * @param key defines the key to use
  40065. * @param value defines the value to store
  40066. * @returns true if the value was updated (or false if the key was not found)
  40067. */
  40068. set(key: string, value: T): boolean;
  40069. /**
  40070. * Get the element of the given key and remove it from the dictionary
  40071. * @param key defines the key to search
  40072. * @returns the value associated with the key or null if not found
  40073. */
  40074. getAndRemove(key: string): Nullable<T>;
  40075. /**
  40076. * Remove a key/value from the dictionary.
  40077. * @param key the key to remove
  40078. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40079. */
  40080. remove(key: string): boolean;
  40081. /**
  40082. * Clear the whole content of the dictionary
  40083. */
  40084. clear(): void;
  40085. /**
  40086. * Gets the current count
  40087. */
  40088. get count(): number;
  40089. /**
  40090. * Execute a callback on each key/val of the dictionary.
  40091. * Note that you can remove any element in this dictionary in the callback implementation
  40092. * @param callback the callback to execute on a given key/value pair
  40093. */
  40094. forEach(callback: (key: string, val: T) => void): void;
  40095. /**
  40096. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40097. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40098. * Note that you can remove any element in this dictionary in the callback implementation
  40099. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40100. * @returns the first item
  40101. */
  40102. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40103. private _count;
  40104. private _data;
  40105. }
  40106. }
  40107. declare module "babylonjs/Collisions/collisionCoordinator" {
  40108. import { Nullable } from "babylonjs/types";
  40109. import { Scene } from "babylonjs/scene";
  40110. import { Vector3 } from "babylonjs/Maths/math.vector";
  40111. import { Collider } from "babylonjs/Collisions/collider";
  40112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40113. /** @hidden */
  40114. export interface ICollisionCoordinator {
  40115. createCollider(): Collider;
  40116. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40117. init(scene: Scene): void;
  40118. }
  40119. /** @hidden */
  40120. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40121. private _scene;
  40122. private _scaledPosition;
  40123. private _scaledVelocity;
  40124. private _finalPosition;
  40125. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40126. createCollider(): Collider;
  40127. init(scene: Scene): void;
  40128. private _collideWithWorld;
  40129. }
  40130. }
  40131. declare module "babylonjs/Inputs/scene.inputManager" {
  40132. import { Nullable } from "babylonjs/types";
  40133. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40134. import { Vector2 } from "babylonjs/Maths/math.vector";
  40135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40136. import { Scene } from "babylonjs/scene";
  40137. /**
  40138. * Class used to manage all inputs for the scene.
  40139. */
  40140. export class InputManager {
  40141. /** The distance in pixel that you have to move to prevent some events */
  40142. static DragMovementThreshold: number;
  40143. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40144. static LongPressDelay: number;
  40145. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40146. static DoubleClickDelay: number;
  40147. /** If you need to check double click without raising a single click at first click, enable this flag */
  40148. static ExclusiveDoubleClickMode: boolean;
  40149. /** 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. */
  40150. private _alreadyAttached;
  40151. private _wheelEventName;
  40152. private _onPointerMove;
  40153. private _onPointerDown;
  40154. private _onPointerUp;
  40155. private _initClickEvent;
  40156. private _initActionManager;
  40157. private _delayedSimpleClick;
  40158. private _delayedSimpleClickTimeout;
  40159. private _previousDelayedSimpleClickTimeout;
  40160. private _meshPickProceed;
  40161. private _previousButtonPressed;
  40162. private _currentPickResult;
  40163. private _previousPickResult;
  40164. private _totalPointersPressed;
  40165. private _doubleClickOccured;
  40166. private _pointerOverMesh;
  40167. private _pickedDownMesh;
  40168. private _pickedUpMesh;
  40169. private _pointerX;
  40170. private _pointerY;
  40171. private _unTranslatedPointerX;
  40172. private _unTranslatedPointerY;
  40173. private _startingPointerPosition;
  40174. private _previousStartingPointerPosition;
  40175. private _startingPointerTime;
  40176. private _previousStartingPointerTime;
  40177. private _pointerCaptures;
  40178. private _onKeyDown;
  40179. private _onKeyUp;
  40180. private _onCanvasFocusObserver;
  40181. private _onCanvasBlurObserver;
  40182. private _scene;
  40183. /**
  40184. * Creates a new InputManager
  40185. * @param scene defines the hosting scene
  40186. */
  40187. constructor(scene: Scene);
  40188. /**
  40189. * Gets the mesh that is currently under the pointer
  40190. */
  40191. get meshUnderPointer(): Nullable<AbstractMesh>;
  40192. /**
  40193. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40194. */
  40195. get unTranslatedPointer(): Vector2;
  40196. /**
  40197. * Gets or sets the current on-screen X position of the pointer
  40198. */
  40199. get pointerX(): number;
  40200. set pointerX(value: number);
  40201. /**
  40202. * Gets or sets the current on-screen Y position of the pointer
  40203. */
  40204. get pointerY(): number;
  40205. set pointerY(value: number);
  40206. private _updatePointerPosition;
  40207. private _processPointerMove;
  40208. private _setRayOnPointerInfo;
  40209. private _checkPrePointerObservable;
  40210. /**
  40211. * Use this method to simulate a pointer move on a mesh
  40212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40215. */
  40216. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40217. /**
  40218. * Use this method to simulate a pointer down on a mesh
  40219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40222. */
  40223. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40224. private _processPointerDown;
  40225. /** @hidden */
  40226. _isPointerSwiping(): boolean;
  40227. /**
  40228. * Use this method to simulate a pointer up on a mesh
  40229. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40230. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40231. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40232. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40233. */
  40234. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40235. private _processPointerUp;
  40236. /**
  40237. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40238. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40239. * @returns true if the pointer was captured
  40240. */
  40241. isPointerCaptured(pointerId?: number): boolean;
  40242. /**
  40243. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40244. * @param attachUp defines if you want to attach events to pointerup
  40245. * @param attachDown defines if you want to attach events to pointerdown
  40246. * @param attachMove defines if you want to attach events to pointermove
  40247. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40248. */
  40249. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40250. /**
  40251. * Detaches all event handlers
  40252. */
  40253. detachControl(): void;
  40254. /**
  40255. * Force the value of meshUnderPointer
  40256. * @param mesh defines the mesh to use
  40257. */
  40258. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40259. /**
  40260. * Gets the mesh under the pointer
  40261. * @returns a Mesh or null if no mesh is under the pointer
  40262. */
  40263. getPointerOverMesh(): Nullable<AbstractMesh>;
  40264. }
  40265. }
  40266. declare module "babylonjs/Animations/animationGroup" {
  40267. import { Animatable } from "babylonjs/Animations/animatable";
  40268. import { Animation } from "babylonjs/Animations/animation";
  40269. import { Scene, IDisposable } from "babylonjs/scene";
  40270. import { Observable } from "babylonjs/Misc/observable";
  40271. import { Nullable } from "babylonjs/types";
  40272. import "babylonjs/Animations/animatable";
  40273. /**
  40274. * This class defines the direct association between an animation and a target
  40275. */
  40276. export class TargetedAnimation {
  40277. /**
  40278. * Animation to perform
  40279. */
  40280. animation: Animation;
  40281. /**
  40282. * Target to animate
  40283. */
  40284. target: any;
  40285. /**
  40286. * Returns the string "TargetedAnimation"
  40287. * @returns "TargetedAnimation"
  40288. */
  40289. getClassName(): string;
  40290. /**
  40291. * Serialize the object
  40292. * @returns the JSON object representing the current entity
  40293. */
  40294. serialize(): any;
  40295. }
  40296. /**
  40297. * Use this class to create coordinated animations on multiple targets
  40298. */
  40299. export class AnimationGroup implements IDisposable {
  40300. /** The name of the animation group */
  40301. name: string;
  40302. private _scene;
  40303. private _targetedAnimations;
  40304. private _animatables;
  40305. private _from;
  40306. private _to;
  40307. private _isStarted;
  40308. private _isPaused;
  40309. private _speedRatio;
  40310. private _loopAnimation;
  40311. private _isAdditive;
  40312. /**
  40313. * Gets or sets the unique id of the node
  40314. */
  40315. uniqueId: number;
  40316. /**
  40317. * This observable will notify when one animation have ended
  40318. */
  40319. onAnimationEndObservable: Observable<TargetedAnimation>;
  40320. /**
  40321. * Observer raised when one animation loops
  40322. */
  40323. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40324. /**
  40325. * Observer raised when all animations have looped
  40326. */
  40327. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40328. /**
  40329. * This observable will notify when all animations have ended.
  40330. */
  40331. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40332. /**
  40333. * This observable will notify when all animations have paused.
  40334. */
  40335. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40336. /**
  40337. * This observable will notify when all animations are playing.
  40338. */
  40339. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40340. /**
  40341. * Gets the first frame
  40342. */
  40343. get from(): number;
  40344. /**
  40345. * Gets the last frame
  40346. */
  40347. get to(): number;
  40348. /**
  40349. * Define if the animations are started
  40350. */
  40351. get isStarted(): boolean;
  40352. /**
  40353. * Gets a value indicating that the current group is playing
  40354. */
  40355. get isPlaying(): boolean;
  40356. /**
  40357. * Gets or sets the speed ratio to use for all animations
  40358. */
  40359. get speedRatio(): number;
  40360. /**
  40361. * Gets or sets the speed ratio to use for all animations
  40362. */
  40363. set speedRatio(value: number);
  40364. /**
  40365. * Gets or sets if all animations should loop or not
  40366. */
  40367. get loopAnimation(): boolean;
  40368. set loopAnimation(value: boolean);
  40369. /**
  40370. * Gets or sets if all animations should be evaluated additively
  40371. */
  40372. get isAdditive(): boolean;
  40373. set isAdditive(value: boolean);
  40374. /**
  40375. * Gets the targeted animations for this animation group
  40376. */
  40377. get targetedAnimations(): Array<TargetedAnimation>;
  40378. /**
  40379. * returning the list of animatables controlled by this animation group.
  40380. */
  40381. get animatables(): Array<Animatable>;
  40382. /**
  40383. * Gets the list of target animations
  40384. */
  40385. get children(): TargetedAnimation[];
  40386. /**
  40387. * Instantiates a new Animation Group.
  40388. * This helps managing several animations at once.
  40389. * @see https://doc.babylonjs.com/how_to/group
  40390. * @param name Defines the name of the group
  40391. * @param scene Defines the scene the group belongs to
  40392. */
  40393. constructor(
  40394. /** The name of the animation group */
  40395. name: string, scene?: Nullable<Scene>);
  40396. /**
  40397. * Add an animation (with its target) in the group
  40398. * @param animation defines the animation we want to add
  40399. * @param target defines the target of the animation
  40400. * @returns the TargetedAnimation object
  40401. */
  40402. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40403. /**
  40404. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40405. * It can add constant keys at begin or end
  40406. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40407. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40408. * @returns the animation group
  40409. */
  40410. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40411. private _animationLoopCount;
  40412. private _animationLoopFlags;
  40413. private _processLoop;
  40414. /**
  40415. * Start all animations on given targets
  40416. * @param loop defines if animations must loop
  40417. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40418. * @param from defines the from key (optional)
  40419. * @param to defines the to key (optional)
  40420. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40421. * @returns the current animation group
  40422. */
  40423. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40424. /**
  40425. * Pause all animations
  40426. * @returns the animation group
  40427. */
  40428. pause(): AnimationGroup;
  40429. /**
  40430. * Play all animations to initial state
  40431. * This function will start() the animations if they were not started or will restart() them if they were paused
  40432. * @param loop defines if animations must loop
  40433. * @returns the animation group
  40434. */
  40435. play(loop?: boolean): AnimationGroup;
  40436. /**
  40437. * Reset all animations to initial state
  40438. * @returns the animation group
  40439. */
  40440. reset(): AnimationGroup;
  40441. /**
  40442. * Restart animations from key 0
  40443. * @returns the animation group
  40444. */
  40445. restart(): AnimationGroup;
  40446. /**
  40447. * Stop all animations
  40448. * @returns the animation group
  40449. */
  40450. stop(): AnimationGroup;
  40451. /**
  40452. * Set animation weight for all animatables
  40453. * @param weight defines the weight to use
  40454. * @return the animationGroup
  40455. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40456. */
  40457. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40458. /**
  40459. * Synchronize and normalize all animatables with a source animatable
  40460. * @param root defines the root animatable to synchronize with
  40461. * @return the animationGroup
  40462. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40463. */
  40464. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40465. /**
  40466. * Goes to a specific frame in this animation group
  40467. * @param frame the frame number to go to
  40468. * @return the animationGroup
  40469. */
  40470. goToFrame(frame: number): AnimationGroup;
  40471. /**
  40472. * Dispose all associated resources
  40473. */
  40474. dispose(): void;
  40475. private _checkAnimationGroupEnded;
  40476. /**
  40477. * Clone the current animation group and returns a copy
  40478. * @param newName defines the name of the new group
  40479. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40480. * @returns the new aniamtion group
  40481. */
  40482. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40483. /**
  40484. * Serializes the animationGroup to an object
  40485. * @returns Serialized object
  40486. */
  40487. serialize(): any;
  40488. /**
  40489. * Returns a new AnimationGroup object parsed from the source provided.
  40490. * @param parsedAnimationGroup defines the source
  40491. * @param scene defines the scene that will receive the animationGroup
  40492. * @returns a new AnimationGroup
  40493. */
  40494. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40495. /**
  40496. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40497. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40498. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40499. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40500. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40501. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40502. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40503. */
  40504. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40505. /**
  40506. * Returns the string "AnimationGroup"
  40507. * @returns "AnimationGroup"
  40508. */
  40509. getClassName(): string;
  40510. /**
  40511. * Creates a detailled string about the object
  40512. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40513. * @returns a string representing the object
  40514. */
  40515. toString(fullDetails?: boolean): string;
  40516. }
  40517. }
  40518. declare module "babylonjs/scene" {
  40519. import { Nullable } from "babylonjs/types";
  40520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40521. import { Observable } from "babylonjs/Misc/observable";
  40522. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40523. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40524. import { Geometry } from "babylonjs/Meshes/geometry";
  40525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40528. import { Mesh } from "babylonjs/Meshes/mesh";
  40529. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40530. import { Bone } from "babylonjs/Bones/bone";
  40531. import { Skeleton } from "babylonjs/Bones/skeleton";
  40532. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40533. import { Camera } from "babylonjs/Cameras/camera";
  40534. import { AbstractScene } from "babylonjs/abstractScene";
  40535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40537. import { Material } from "babylonjs/Materials/material";
  40538. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40539. import { Effect } from "babylonjs/Materials/effect";
  40540. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40541. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40542. import { Light } from "babylonjs/Lights/light";
  40543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40544. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40545. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40546. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40547. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40548. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40549. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40550. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40551. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40552. import { Engine } from "babylonjs/Engines/engine";
  40553. import { Node } from "babylonjs/node";
  40554. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40555. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40556. import { WebRequest } from "babylonjs/Misc/webRequest";
  40557. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40558. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40559. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40560. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40561. import { Plane } from "babylonjs/Maths/math.plane";
  40562. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40563. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40564. import { Ray } from "babylonjs/Culling/ray";
  40565. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40566. import { Animation } from "babylonjs/Animations/animation";
  40567. import { Animatable } from "babylonjs/Animations/animatable";
  40568. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40569. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40570. import { Collider } from "babylonjs/Collisions/collider";
  40571. /**
  40572. * Define an interface for all classes that will hold resources
  40573. */
  40574. export interface IDisposable {
  40575. /**
  40576. * Releases all held resources
  40577. */
  40578. dispose(): void;
  40579. }
  40580. /** Interface defining initialization parameters for Scene class */
  40581. export interface SceneOptions {
  40582. /**
  40583. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40584. * It will improve performance when the number of geometries becomes important.
  40585. */
  40586. useGeometryUniqueIdsMap?: boolean;
  40587. /**
  40588. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40589. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40590. */
  40591. useMaterialMeshMap?: boolean;
  40592. /**
  40593. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40594. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40595. */
  40596. useClonedMeshMap?: boolean;
  40597. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40598. virtual?: boolean;
  40599. }
  40600. /**
  40601. * Represents a scene to be rendered by the engine.
  40602. * @see https://doc.babylonjs.com/features/scene
  40603. */
  40604. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40605. /** The fog is deactivated */
  40606. static readonly FOGMODE_NONE: number;
  40607. /** The fog density is following an exponential function */
  40608. static readonly FOGMODE_EXP: number;
  40609. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40610. static readonly FOGMODE_EXP2: number;
  40611. /** The fog density is following a linear function. */
  40612. static readonly FOGMODE_LINEAR: number;
  40613. /**
  40614. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40615. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40616. */
  40617. static MinDeltaTime: number;
  40618. /**
  40619. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40620. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40621. */
  40622. static MaxDeltaTime: number;
  40623. /**
  40624. * Factory used to create the default material.
  40625. * @param name The name of the material to create
  40626. * @param scene The scene to create the material for
  40627. * @returns The default material
  40628. */
  40629. static DefaultMaterialFactory(scene: Scene): Material;
  40630. /**
  40631. * Factory used to create the a collision coordinator.
  40632. * @returns The collision coordinator
  40633. */
  40634. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40635. /** @hidden */
  40636. _inputManager: InputManager;
  40637. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40638. cameraToUseForPointers: Nullable<Camera>;
  40639. /** @hidden */
  40640. readonly _isScene: boolean;
  40641. /** @hidden */
  40642. _blockEntityCollection: boolean;
  40643. /**
  40644. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40645. */
  40646. autoClear: boolean;
  40647. /**
  40648. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40649. */
  40650. autoClearDepthAndStencil: boolean;
  40651. /**
  40652. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40653. */
  40654. clearColor: Color4;
  40655. /**
  40656. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40657. */
  40658. ambientColor: Color3;
  40659. /**
  40660. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40661. * It should only be one of the following (if not the default embedded one):
  40662. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40663. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40664. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40665. * The material properties need to be setup according to the type of texture in use.
  40666. */
  40667. environmentBRDFTexture: BaseTexture;
  40668. /** @hidden */
  40669. protected _environmentTexture: Nullable<BaseTexture>;
  40670. /**
  40671. * Texture used in all pbr material as the reflection texture.
  40672. * As in the majority of the scene they are the same (exception for multi room and so on),
  40673. * this is easier to reference from here than from all the materials.
  40674. */
  40675. get environmentTexture(): Nullable<BaseTexture>;
  40676. /**
  40677. * Texture used in all pbr material as the reflection texture.
  40678. * As in the majority of the scene they are the same (exception for multi room and so on),
  40679. * this is easier to set here than in all the materials.
  40680. */
  40681. set environmentTexture(value: Nullable<BaseTexture>);
  40682. /** @hidden */
  40683. protected _environmentIntensity: number;
  40684. /**
  40685. * Intensity of the environment in all pbr material.
  40686. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40687. * As in the majority of the scene they are the same (exception for multi room and so on),
  40688. * this is easier to reference from here than from all the materials.
  40689. */
  40690. get environmentIntensity(): number;
  40691. /**
  40692. * Intensity of the environment in all pbr material.
  40693. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40694. * As in the majority of the scene they are the same (exception for multi room and so on),
  40695. * this is easier to set here than in all the materials.
  40696. */
  40697. set environmentIntensity(value: number);
  40698. /** @hidden */
  40699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40700. /**
  40701. * Default image processing configuration used either in the rendering
  40702. * Forward main pass or through the imageProcessingPostProcess if present.
  40703. * As in the majority of the scene they are the same (exception for multi camera),
  40704. * this is easier to reference from here than from all the materials and post process.
  40705. *
  40706. * No setter as we it is a shared configuration, you can set the values instead.
  40707. */
  40708. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40709. private _forceWireframe;
  40710. /**
  40711. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40712. */
  40713. set forceWireframe(value: boolean);
  40714. get forceWireframe(): boolean;
  40715. private _skipFrustumClipping;
  40716. /**
  40717. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40718. */
  40719. set skipFrustumClipping(value: boolean);
  40720. get skipFrustumClipping(): boolean;
  40721. private _forcePointsCloud;
  40722. /**
  40723. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40724. */
  40725. set forcePointsCloud(value: boolean);
  40726. get forcePointsCloud(): boolean;
  40727. /**
  40728. * Gets or sets the active clipplane 1
  40729. */
  40730. clipPlane: Nullable<Plane>;
  40731. /**
  40732. * Gets or sets the active clipplane 2
  40733. */
  40734. clipPlane2: Nullable<Plane>;
  40735. /**
  40736. * Gets or sets the active clipplane 3
  40737. */
  40738. clipPlane3: Nullable<Plane>;
  40739. /**
  40740. * Gets or sets the active clipplane 4
  40741. */
  40742. clipPlane4: Nullable<Plane>;
  40743. /**
  40744. * Gets or sets the active clipplane 5
  40745. */
  40746. clipPlane5: Nullable<Plane>;
  40747. /**
  40748. * Gets or sets the active clipplane 6
  40749. */
  40750. clipPlane6: Nullable<Plane>;
  40751. /**
  40752. * Gets or sets a boolean indicating if animations are enabled
  40753. */
  40754. animationsEnabled: boolean;
  40755. private _animationPropertiesOverride;
  40756. /**
  40757. * Gets or sets the animation properties override
  40758. */
  40759. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40760. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40761. /**
  40762. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40763. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40764. */
  40765. useConstantAnimationDeltaTime: boolean;
  40766. /**
  40767. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40768. * Please note that it requires to run a ray cast through the scene on every frame
  40769. */
  40770. constantlyUpdateMeshUnderPointer: boolean;
  40771. /**
  40772. * Defines the HTML cursor to use when hovering over interactive elements
  40773. */
  40774. hoverCursor: string;
  40775. /**
  40776. * Defines the HTML default cursor to use (empty by default)
  40777. */
  40778. defaultCursor: string;
  40779. /**
  40780. * Defines whether cursors are handled by the scene.
  40781. */
  40782. doNotHandleCursors: boolean;
  40783. /**
  40784. * This is used to call preventDefault() on pointer down
  40785. * in order to block unwanted artifacts like system double clicks
  40786. */
  40787. preventDefaultOnPointerDown: boolean;
  40788. /**
  40789. * This is used to call preventDefault() on pointer up
  40790. * in order to block unwanted artifacts like system double clicks
  40791. */
  40792. preventDefaultOnPointerUp: boolean;
  40793. /**
  40794. * Gets or sets user defined metadata
  40795. */
  40796. metadata: any;
  40797. /**
  40798. * For internal use only. Please do not use.
  40799. */
  40800. reservedDataStore: any;
  40801. /**
  40802. * Gets the name of the plugin used to load this scene (null by default)
  40803. */
  40804. loadingPluginName: string;
  40805. /**
  40806. * Use this array to add regular expressions used to disable offline support for specific urls
  40807. */
  40808. disableOfflineSupportExceptionRules: RegExp[];
  40809. /**
  40810. * An event triggered when the scene is disposed.
  40811. */
  40812. onDisposeObservable: Observable<Scene>;
  40813. private _onDisposeObserver;
  40814. /** Sets a function to be executed when this scene is disposed. */
  40815. set onDispose(callback: () => void);
  40816. /**
  40817. * An event triggered before rendering the scene (right after animations and physics)
  40818. */
  40819. onBeforeRenderObservable: Observable<Scene>;
  40820. private _onBeforeRenderObserver;
  40821. /** Sets a function to be executed before rendering this scene */
  40822. set beforeRender(callback: Nullable<() => void>);
  40823. /**
  40824. * An event triggered after rendering the scene
  40825. */
  40826. onAfterRenderObservable: Observable<Scene>;
  40827. /**
  40828. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40829. */
  40830. onAfterRenderCameraObservable: Observable<Camera>;
  40831. private _onAfterRenderObserver;
  40832. /** Sets a function to be executed after rendering this scene */
  40833. set afterRender(callback: Nullable<() => void>);
  40834. /**
  40835. * An event triggered before animating the scene
  40836. */
  40837. onBeforeAnimationsObservable: Observable<Scene>;
  40838. /**
  40839. * An event triggered after animations processing
  40840. */
  40841. onAfterAnimationsObservable: Observable<Scene>;
  40842. /**
  40843. * An event triggered before draw calls are ready to be sent
  40844. */
  40845. onBeforeDrawPhaseObservable: Observable<Scene>;
  40846. /**
  40847. * An event triggered after draw calls have been sent
  40848. */
  40849. onAfterDrawPhaseObservable: Observable<Scene>;
  40850. /**
  40851. * An event triggered when the scene is ready
  40852. */
  40853. onReadyObservable: Observable<Scene>;
  40854. /**
  40855. * An event triggered before rendering a camera
  40856. */
  40857. onBeforeCameraRenderObservable: Observable<Camera>;
  40858. private _onBeforeCameraRenderObserver;
  40859. /** Sets a function to be executed before rendering a camera*/
  40860. set beforeCameraRender(callback: () => void);
  40861. /**
  40862. * An event triggered after rendering a camera
  40863. */
  40864. onAfterCameraRenderObservable: Observable<Camera>;
  40865. private _onAfterCameraRenderObserver;
  40866. /** Sets a function to be executed after rendering a camera*/
  40867. set afterCameraRender(callback: () => void);
  40868. /**
  40869. * An event triggered when active meshes evaluation is about to start
  40870. */
  40871. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40872. /**
  40873. * An event triggered when active meshes evaluation is done
  40874. */
  40875. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40876. /**
  40877. * An event triggered when particles rendering is about to start
  40878. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40879. */
  40880. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40881. /**
  40882. * An event triggered when particles rendering is done
  40883. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40884. */
  40885. onAfterParticlesRenderingObservable: Observable<Scene>;
  40886. /**
  40887. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40888. */
  40889. onDataLoadedObservable: Observable<Scene>;
  40890. /**
  40891. * An event triggered when a camera is created
  40892. */
  40893. onNewCameraAddedObservable: Observable<Camera>;
  40894. /**
  40895. * An event triggered when a camera is removed
  40896. */
  40897. onCameraRemovedObservable: Observable<Camera>;
  40898. /**
  40899. * An event triggered when a light is created
  40900. */
  40901. onNewLightAddedObservable: Observable<Light>;
  40902. /**
  40903. * An event triggered when a light is removed
  40904. */
  40905. onLightRemovedObservable: Observable<Light>;
  40906. /**
  40907. * An event triggered when a geometry is created
  40908. */
  40909. onNewGeometryAddedObservable: Observable<Geometry>;
  40910. /**
  40911. * An event triggered when a geometry is removed
  40912. */
  40913. onGeometryRemovedObservable: Observable<Geometry>;
  40914. /**
  40915. * An event triggered when a transform node is created
  40916. */
  40917. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40918. /**
  40919. * An event triggered when a transform node is removed
  40920. */
  40921. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40922. /**
  40923. * An event triggered when a mesh is created
  40924. */
  40925. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40926. /**
  40927. * An event triggered when a mesh is removed
  40928. */
  40929. onMeshRemovedObservable: Observable<AbstractMesh>;
  40930. /**
  40931. * An event triggered when a skeleton is created
  40932. */
  40933. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40934. /**
  40935. * An event triggered when a skeleton is removed
  40936. */
  40937. onSkeletonRemovedObservable: Observable<Skeleton>;
  40938. /**
  40939. * An event triggered when a material is created
  40940. */
  40941. onNewMaterialAddedObservable: Observable<Material>;
  40942. /**
  40943. * An event triggered when a material is removed
  40944. */
  40945. onMaterialRemovedObservable: Observable<Material>;
  40946. /**
  40947. * An event triggered when a texture is created
  40948. */
  40949. onNewTextureAddedObservable: Observable<BaseTexture>;
  40950. /**
  40951. * An event triggered when a texture is removed
  40952. */
  40953. onTextureRemovedObservable: Observable<BaseTexture>;
  40954. /**
  40955. * An event triggered when render targets are about to be rendered
  40956. * Can happen multiple times per frame.
  40957. */
  40958. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40959. /**
  40960. * An event triggered when render targets were rendered.
  40961. * Can happen multiple times per frame.
  40962. */
  40963. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40964. /**
  40965. * An event triggered before calculating deterministic simulation step
  40966. */
  40967. onBeforeStepObservable: Observable<Scene>;
  40968. /**
  40969. * An event triggered after calculating deterministic simulation step
  40970. */
  40971. onAfterStepObservable: Observable<Scene>;
  40972. /**
  40973. * An event triggered when the activeCamera property is updated
  40974. */
  40975. onActiveCameraChanged: Observable<Scene>;
  40976. /**
  40977. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40979. * 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)
  40980. */
  40981. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40982. /**
  40983. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40984. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40985. * 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)
  40986. */
  40987. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40988. /**
  40989. * This Observable will when a mesh has been imported into the scene.
  40990. */
  40991. onMeshImportedObservable: Observable<AbstractMesh>;
  40992. /**
  40993. * This Observable will when an animation file has been imported into the scene.
  40994. */
  40995. onAnimationFileImportedObservable: Observable<Scene>;
  40996. /**
  40997. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40998. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40999. */
  41000. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41001. /** @hidden */
  41002. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41003. /**
  41004. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41005. */
  41006. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41007. /**
  41008. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41009. */
  41010. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41011. /**
  41012. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41013. */
  41014. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41015. /** Callback called when a pointer move is detected */
  41016. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41017. /** Callback called when a pointer down is detected */
  41018. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41019. /** Callback called when a pointer up is detected */
  41020. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41021. /** Callback called when a pointer pick is detected */
  41022. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41023. /**
  41024. * 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).
  41025. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41026. */
  41027. onPrePointerObservable: Observable<PointerInfoPre>;
  41028. /**
  41029. * Observable event triggered each time an input event is received from the rendering canvas
  41030. */
  41031. onPointerObservable: Observable<PointerInfo>;
  41032. /**
  41033. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41034. */
  41035. get unTranslatedPointer(): Vector2;
  41036. /**
  41037. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41038. */
  41039. static get DragMovementThreshold(): number;
  41040. static set DragMovementThreshold(value: number);
  41041. /**
  41042. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41043. */
  41044. static get LongPressDelay(): number;
  41045. static set LongPressDelay(value: number);
  41046. /**
  41047. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41048. */
  41049. static get DoubleClickDelay(): number;
  41050. static set DoubleClickDelay(value: number);
  41051. /** If you need to check double click without raising a single click at first click, enable this flag */
  41052. static get ExclusiveDoubleClickMode(): boolean;
  41053. static set ExclusiveDoubleClickMode(value: boolean);
  41054. /** @hidden */
  41055. _mirroredCameraPosition: Nullable<Vector3>;
  41056. /**
  41057. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41058. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41059. */
  41060. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41061. /**
  41062. * Observable event triggered each time an keyboard event is received from the hosting window
  41063. */
  41064. onKeyboardObservable: Observable<KeyboardInfo>;
  41065. private _useRightHandedSystem;
  41066. /**
  41067. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41068. */
  41069. set useRightHandedSystem(value: boolean);
  41070. get useRightHandedSystem(): boolean;
  41071. private _timeAccumulator;
  41072. private _currentStepId;
  41073. private _currentInternalStep;
  41074. /**
  41075. * Sets the step Id used by deterministic lock step
  41076. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41077. * @param newStepId defines the step Id
  41078. */
  41079. setStepId(newStepId: number): void;
  41080. /**
  41081. * Gets the step Id used by deterministic lock step
  41082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41083. * @returns the step Id
  41084. */
  41085. getStepId(): number;
  41086. /**
  41087. * Gets the internal step used by deterministic lock step
  41088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41089. * @returns the internal step
  41090. */
  41091. getInternalStep(): number;
  41092. private _fogEnabled;
  41093. /**
  41094. * Gets or sets a boolean indicating if fog is enabled on this scene
  41095. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41096. * (Default is true)
  41097. */
  41098. set fogEnabled(value: boolean);
  41099. get fogEnabled(): boolean;
  41100. private _fogMode;
  41101. /**
  41102. * Gets or sets the fog mode to use
  41103. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41104. * | mode | value |
  41105. * | --- | --- |
  41106. * | FOGMODE_NONE | 0 |
  41107. * | FOGMODE_EXP | 1 |
  41108. * | FOGMODE_EXP2 | 2 |
  41109. * | FOGMODE_LINEAR | 3 |
  41110. */
  41111. set fogMode(value: number);
  41112. get fogMode(): number;
  41113. /**
  41114. * Gets or sets the fog color to use
  41115. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41116. * (Default is Color3(0.2, 0.2, 0.3))
  41117. */
  41118. fogColor: Color3;
  41119. /**
  41120. * Gets or sets the fog density to use
  41121. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41122. * (Default is 0.1)
  41123. */
  41124. fogDensity: number;
  41125. /**
  41126. * Gets or sets the fog start distance to use
  41127. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41128. * (Default is 0)
  41129. */
  41130. fogStart: number;
  41131. /**
  41132. * Gets or sets the fog end distance to use
  41133. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41134. * (Default is 1000)
  41135. */
  41136. fogEnd: number;
  41137. /**
  41138. * Flag indicating that the frame buffer binding is handled by another component
  41139. */
  41140. prePass: boolean;
  41141. private _shadowsEnabled;
  41142. /**
  41143. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41144. */
  41145. set shadowsEnabled(value: boolean);
  41146. get shadowsEnabled(): boolean;
  41147. private _lightsEnabled;
  41148. /**
  41149. * Gets or sets a boolean indicating if lights are enabled on this scene
  41150. */
  41151. set lightsEnabled(value: boolean);
  41152. get lightsEnabled(): boolean;
  41153. /** All of the active cameras added to this scene. */
  41154. activeCameras: Camera[];
  41155. /** @hidden */
  41156. _activeCamera: Nullable<Camera>;
  41157. /** Gets or sets the current active camera */
  41158. get activeCamera(): Nullable<Camera>;
  41159. set activeCamera(value: Nullable<Camera>);
  41160. private _defaultMaterial;
  41161. /** The default material used on meshes when no material is affected */
  41162. get defaultMaterial(): Material;
  41163. /** The default material used on meshes when no material is affected */
  41164. set defaultMaterial(value: Material);
  41165. private _texturesEnabled;
  41166. /**
  41167. * Gets or sets a boolean indicating if textures are enabled on this scene
  41168. */
  41169. set texturesEnabled(value: boolean);
  41170. get texturesEnabled(): boolean;
  41171. /**
  41172. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41173. */
  41174. physicsEnabled: boolean;
  41175. /**
  41176. * Gets or sets a boolean indicating if particles are enabled on this scene
  41177. */
  41178. particlesEnabled: boolean;
  41179. /**
  41180. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41181. */
  41182. spritesEnabled: boolean;
  41183. private _skeletonsEnabled;
  41184. /**
  41185. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41186. */
  41187. set skeletonsEnabled(value: boolean);
  41188. get skeletonsEnabled(): boolean;
  41189. /**
  41190. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41191. */
  41192. lensFlaresEnabled: boolean;
  41193. /**
  41194. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41195. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41196. */
  41197. collisionsEnabled: boolean;
  41198. private _collisionCoordinator;
  41199. /** @hidden */
  41200. get collisionCoordinator(): ICollisionCoordinator;
  41201. /**
  41202. * Defines the gravity applied to this scene (used only for collisions)
  41203. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41204. */
  41205. gravity: Vector3;
  41206. /**
  41207. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41208. */
  41209. postProcessesEnabled: boolean;
  41210. /**
  41211. * The list of postprocesses added to the scene
  41212. */
  41213. postProcesses: PostProcess[];
  41214. /**
  41215. * Gets the current postprocess manager
  41216. */
  41217. postProcessManager: PostProcessManager;
  41218. /**
  41219. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41220. */
  41221. renderTargetsEnabled: boolean;
  41222. /**
  41223. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41224. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41225. */
  41226. dumpNextRenderTargets: boolean;
  41227. /**
  41228. * The list of user defined render targets added to the scene
  41229. */
  41230. customRenderTargets: RenderTargetTexture[];
  41231. /**
  41232. * Defines if texture loading must be delayed
  41233. * If true, textures will only be loaded when they need to be rendered
  41234. */
  41235. useDelayedTextureLoading: boolean;
  41236. /**
  41237. * Gets the list of meshes imported to the scene through SceneLoader
  41238. */
  41239. importedMeshesFiles: String[];
  41240. /**
  41241. * Gets or sets a boolean indicating if probes are enabled on this scene
  41242. */
  41243. probesEnabled: boolean;
  41244. /**
  41245. * Gets or sets the current offline provider to use to store scene data
  41246. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41247. */
  41248. offlineProvider: IOfflineProvider;
  41249. /**
  41250. * Gets or sets the action manager associated with the scene
  41251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41252. */
  41253. actionManager: AbstractActionManager;
  41254. private _meshesForIntersections;
  41255. /**
  41256. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41257. */
  41258. proceduralTexturesEnabled: boolean;
  41259. private _engine;
  41260. private _totalVertices;
  41261. /** @hidden */
  41262. _activeIndices: PerfCounter;
  41263. /** @hidden */
  41264. _activeParticles: PerfCounter;
  41265. /** @hidden */
  41266. _activeBones: PerfCounter;
  41267. private _animationRatio;
  41268. /** @hidden */
  41269. _animationTimeLast: number;
  41270. /** @hidden */
  41271. _animationTime: number;
  41272. /**
  41273. * Gets or sets a general scale for animation speed
  41274. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41275. */
  41276. animationTimeScale: number;
  41277. /** @hidden */
  41278. _cachedMaterial: Nullable<Material>;
  41279. /** @hidden */
  41280. _cachedEffect: Nullable<Effect>;
  41281. /** @hidden */
  41282. _cachedVisibility: Nullable<number>;
  41283. private _renderId;
  41284. private _frameId;
  41285. private _executeWhenReadyTimeoutId;
  41286. private _intermediateRendering;
  41287. private _viewUpdateFlag;
  41288. private _projectionUpdateFlag;
  41289. /** @hidden */
  41290. _toBeDisposed: Nullable<IDisposable>[];
  41291. private _activeRequests;
  41292. /** @hidden */
  41293. _pendingData: any[];
  41294. private _isDisposed;
  41295. /**
  41296. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41297. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41298. */
  41299. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41300. private _activeMeshes;
  41301. private _processedMaterials;
  41302. private _renderTargets;
  41303. /** @hidden */
  41304. _activeParticleSystems: SmartArray<IParticleSystem>;
  41305. private _activeSkeletons;
  41306. private _softwareSkinnedMeshes;
  41307. private _renderingManager;
  41308. /** @hidden */
  41309. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41310. private _transformMatrix;
  41311. private _sceneUbo;
  41312. /** @hidden */
  41313. _viewMatrix: Matrix;
  41314. private _projectionMatrix;
  41315. /** @hidden */
  41316. _forcedViewPosition: Nullable<Vector3>;
  41317. /** @hidden */
  41318. _frustumPlanes: Plane[];
  41319. /**
  41320. * Gets the list of frustum planes (built from the active camera)
  41321. */
  41322. get frustumPlanes(): Plane[];
  41323. /**
  41324. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41325. * This is useful if there are more lights that the maximum simulteanous authorized
  41326. */
  41327. requireLightSorting: boolean;
  41328. /** @hidden */
  41329. readonly useMaterialMeshMap: boolean;
  41330. /** @hidden */
  41331. readonly useClonedMeshMap: boolean;
  41332. private _externalData;
  41333. private _uid;
  41334. /**
  41335. * @hidden
  41336. * Backing store of defined scene components.
  41337. */
  41338. _components: ISceneComponent[];
  41339. /**
  41340. * @hidden
  41341. * Backing store of defined scene components.
  41342. */
  41343. _serializableComponents: ISceneSerializableComponent[];
  41344. /**
  41345. * List of components to register on the next registration step.
  41346. */
  41347. private _transientComponents;
  41348. /**
  41349. * Registers the transient components if needed.
  41350. */
  41351. private _registerTransientComponents;
  41352. /**
  41353. * @hidden
  41354. * Add a component to the scene.
  41355. * Note that the ccomponent could be registered on th next frame if this is called after
  41356. * the register component stage.
  41357. * @param component Defines the component to add to the scene
  41358. */
  41359. _addComponent(component: ISceneComponent): void;
  41360. /**
  41361. * @hidden
  41362. * Gets a component from the scene.
  41363. * @param name defines the name of the component to retrieve
  41364. * @returns the component or null if not present
  41365. */
  41366. _getComponent(name: string): Nullable<ISceneComponent>;
  41367. /**
  41368. * @hidden
  41369. * Defines the actions happening before camera updates.
  41370. */
  41371. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41372. /**
  41373. * @hidden
  41374. * Defines the actions happening before clear the canvas.
  41375. */
  41376. _beforeClearStage: Stage<SimpleStageAction>;
  41377. /**
  41378. * @hidden
  41379. * Defines the actions when collecting render targets for the frame.
  41380. */
  41381. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41382. /**
  41383. * @hidden
  41384. * Defines the actions happening for one camera in the frame.
  41385. */
  41386. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41387. /**
  41388. * @hidden
  41389. * Defines the actions happening during the per mesh ready checks.
  41390. */
  41391. _isReadyForMeshStage: Stage<MeshStageAction>;
  41392. /**
  41393. * @hidden
  41394. * Defines the actions happening before evaluate active mesh checks.
  41395. */
  41396. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41397. /**
  41398. * @hidden
  41399. * Defines the actions happening during the evaluate sub mesh checks.
  41400. */
  41401. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41402. /**
  41403. * @hidden
  41404. * Defines the actions happening during the active mesh stage.
  41405. */
  41406. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41407. /**
  41408. * @hidden
  41409. * Defines the actions happening during the per camera render target step.
  41410. */
  41411. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41412. /**
  41413. * @hidden
  41414. * Defines the actions happening just before the active camera is drawing.
  41415. */
  41416. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41417. /**
  41418. * @hidden
  41419. * Defines the actions happening just before a render target is drawing.
  41420. */
  41421. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41422. /**
  41423. * @hidden
  41424. * Defines the actions happening just before a rendering group is drawing.
  41425. */
  41426. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41427. /**
  41428. * @hidden
  41429. * Defines the actions happening just before a mesh is drawing.
  41430. */
  41431. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41432. /**
  41433. * @hidden
  41434. * Defines the actions happening just after a mesh has been drawn.
  41435. */
  41436. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41437. /**
  41438. * @hidden
  41439. * Defines the actions happening just after a rendering group has been drawn.
  41440. */
  41441. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41442. /**
  41443. * @hidden
  41444. * Defines the actions happening just after the active camera has been drawn.
  41445. */
  41446. _afterCameraDrawStage: Stage<CameraStageAction>;
  41447. /**
  41448. * @hidden
  41449. * Defines the actions happening just after a render target has been drawn.
  41450. */
  41451. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41452. /**
  41453. * @hidden
  41454. * Defines the actions happening just after rendering all cameras and computing intersections.
  41455. */
  41456. _afterRenderStage: Stage<SimpleStageAction>;
  41457. /**
  41458. * @hidden
  41459. * Defines the actions happening when a pointer move event happens.
  41460. */
  41461. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41462. /**
  41463. * @hidden
  41464. * Defines the actions happening when a pointer down event happens.
  41465. */
  41466. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41467. /**
  41468. * @hidden
  41469. * Defines the actions happening when a pointer up event happens.
  41470. */
  41471. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41472. /**
  41473. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41474. */
  41475. private geometriesByUniqueId;
  41476. /**
  41477. * Creates a new Scene
  41478. * @param engine defines the engine to use to render this scene
  41479. * @param options defines the scene options
  41480. */
  41481. constructor(engine: Engine, options?: SceneOptions);
  41482. /**
  41483. * Gets a string idenfifying the name of the class
  41484. * @returns "Scene" string
  41485. */
  41486. getClassName(): string;
  41487. private _defaultMeshCandidates;
  41488. /**
  41489. * @hidden
  41490. */
  41491. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41492. private _defaultSubMeshCandidates;
  41493. /**
  41494. * @hidden
  41495. */
  41496. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41497. /**
  41498. * Sets the default candidate providers for the scene.
  41499. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41500. * and getCollidingSubMeshCandidates to their default function
  41501. */
  41502. setDefaultCandidateProviders(): void;
  41503. /**
  41504. * Gets the mesh that is currently under the pointer
  41505. */
  41506. get meshUnderPointer(): Nullable<AbstractMesh>;
  41507. /**
  41508. * Gets or sets the current on-screen X position of the pointer
  41509. */
  41510. get pointerX(): number;
  41511. set pointerX(value: number);
  41512. /**
  41513. * Gets or sets the current on-screen Y position of the pointer
  41514. */
  41515. get pointerY(): number;
  41516. set pointerY(value: number);
  41517. /**
  41518. * Gets the cached material (ie. the latest rendered one)
  41519. * @returns the cached material
  41520. */
  41521. getCachedMaterial(): Nullable<Material>;
  41522. /**
  41523. * Gets the cached effect (ie. the latest rendered one)
  41524. * @returns the cached effect
  41525. */
  41526. getCachedEffect(): Nullable<Effect>;
  41527. /**
  41528. * Gets the cached visibility state (ie. the latest rendered one)
  41529. * @returns the cached visibility state
  41530. */
  41531. getCachedVisibility(): Nullable<number>;
  41532. /**
  41533. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41534. * @param material defines the current material
  41535. * @param effect defines the current effect
  41536. * @param visibility defines the current visibility state
  41537. * @returns true if one parameter is not cached
  41538. */
  41539. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41540. /**
  41541. * Gets the engine associated with the scene
  41542. * @returns an Engine
  41543. */
  41544. getEngine(): Engine;
  41545. /**
  41546. * Gets the total number of vertices rendered per frame
  41547. * @returns the total number of vertices rendered per frame
  41548. */
  41549. getTotalVertices(): number;
  41550. /**
  41551. * Gets the performance counter for total vertices
  41552. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41553. */
  41554. get totalVerticesPerfCounter(): PerfCounter;
  41555. /**
  41556. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41557. * @returns the total number of active indices rendered per frame
  41558. */
  41559. getActiveIndices(): number;
  41560. /**
  41561. * Gets the performance counter for active indices
  41562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41563. */
  41564. get totalActiveIndicesPerfCounter(): PerfCounter;
  41565. /**
  41566. * Gets the total number of active particles rendered per frame
  41567. * @returns the total number of active particles rendered per frame
  41568. */
  41569. getActiveParticles(): number;
  41570. /**
  41571. * Gets the performance counter for active particles
  41572. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41573. */
  41574. get activeParticlesPerfCounter(): PerfCounter;
  41575. /**
  41576. * Gets the total number of active bones rendered per frame
  41577. * @returns the total number of active bones rendered per frame
  41578. */
  41579. getActiveBones(): number;
  41580. /**
  41581. * Gets the performance counter for active bones
  41582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41583. */
  41584. get activeBonesPerfCounter(): PerfCounter;
  41585. /**
  41586. * Gets the array of active meshes
  41587. * @returns an array of AbstractMesh
  41588. */
  41589. getActiveMeshes(): SmartArray<AbstractMesh>;
  41590. /**
  41591. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41592. * @returns a number
  41593. */
  41594. getAnimationRatio(): number;
  41595. /**
  41596. * Gets an unique Id for the current render phase
  41597. * @returns a number
  41598. */
  41599. getRenderId(): number;
  41600. /**
  41601. * Gets an unique Id for the current frame
  41602. * @returns a number
  41603. */
  41604. getFrameId(): number;
  41605. /** Call this function if you want to manually increment the render Id*/
  41606. incrementRenderId(): void;
  41607. private _createUbo;
  41608. /**
  41609. * Use this method to simulate a pointer move on a mesh
  41610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41613. * @returns the current scene
  41614. */
  41615. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41616. /**
  41617. * Use this method to simulate a pointer down on a mesh
  41618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41621. * @returns the current scene
  41622. */
  41623. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41624. /**
  41625. * Use this method to simulate a pointer up on a mesh
  41626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41629. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41630. * @returns the current scene
  41631. */
  41632. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41633. /**
  41634. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41635. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41636. * @returns true if the pointer was captured
  41637. */
  41638. isPointerCaptured(pointerId?: number): boolean;
  41639. /**
  41640. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41641. * @param attachUp defines if you want to attach events to pointerup
  41642. * @param attachDown defines if you want to attach events to pointerdown
  41643. * @param attachMove defines if you want to attach events to pointermove
  41644. */
  41645. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41646. /** Detaches all event handlers*/
  41647. detachControl(): void;
  41648. /**
  41649. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41650. * Delay loaded resources are not taking in account
  41651. * @return true if all required resources are ready
  41652. */
  41653. isReady(): boolean;
  41654. /** Resets all cached information relative to material (including effect and visibility) */
  41655. resetCachedMaterial(): void;
  41656. /**
  41657. * Registers a function to be called before every frame render
  41658. * @param func defines the function to register
  41659. */
  41660. registerBeforeRender(func: () => void): void;
  41661. /**
  41662. * Unregisters a function called before every frame render
  41663. * @param func defines the function to unregister
  41664. */
  41665. unregisterBeforeRender(func: () => void): void;
  41666. /**
  41667. * Registers a function to be called after every frame render
  41668. * @param func defines the function to register
  41669. */
  41670. registerAfterRender(func: () => void): void;
  41671. /**
  41672. * Unregisters a function called after every frame render
  41673. * @param func defines the function to unregister
  41674. */
  41675. unregisterAfterRender(func: () => void): void;
  41676. private _executeOnceBeforeRender;
  41677. /**
  41678. * The provided function will run before render once and will be disposed afterwards.
  41679. * A timeout delay can be provided so that the function will be executed in N ms.
  41680. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41681. * @param func The function to be executed.
  41682. * @param timeout optional delay in ms
  41683. */
  41684. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41685. /** @hidden */
  41686. _addPendingData(data: any): void;
  41687. /** @hidden */
  41688. _removePendingData(data: any): void;
  41689. /**
  41690. * Returns the number of items waiting to be loaded
  41691. * @returns the number of items waiting to be loaded
  41692. */
  41693. getWaitingItemsCount(): number;
  41694. /**
  41695. * Returns a boolean indicating if the scene is still loading data
  41696. */
  41697. get isLoading(): boolean;
  41698. /**
  41699. * Registers a function to be executed when the scene is ready
  41700. * @param {Function} func - the function to be executed
  41701. */
  41702. executeWhenReady(func: () => void): void;
  41703. /**
  41704. * Returns a promise that resolves when the scene is ready
  41705. * @returns A promise that resolves when the scene is ready
  41706. */
  41707. whenReadyAsync(): Promise<void>;
  41708. /** @hidden */
  41709. _checkIsReady(): void;
  41710. /**
  41711. * Gets all animatable attached to the scene
  41712. */
  41713. get animatables(): Animatable[];
  41714. /**
  41715. * Resets the last animation time frame.
  41716. * Useful to override when animations start running when loading a scene for the first time.
  41717. */
  41718. resetLastAnimationTimeFrame(): void;
  41719. /**
  41720. * Gets the current view matrix
  41721. * @returns a Matrix
  41722. */
  41723. getViewMatrix(): Matrix;
  41724. /**
  41725. * Gets the current projection matrix
  41726. * @returns a Matrix
  41727. */
  41728. getProjectionMatrix(): Matrix;
  41729. /**
  41730. * Gets the current transform matrix
  41731. * @returns a Matrix made of View * Projection
  41732. */
  41733. getTransformMatrix(): Matrix;
  41734. /**
  41735. * Sets the current transform matrix
  41736. * @param viewL defines the View matrix to use
  41737. * @param projectionL defines the Projection matrix to use
  41738. * @param viewR defines the right View matrix to use (if provided)
  41739. * @param projectionR defines the right Projection matrix to use (if provided)
  41740. */
  41741. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41742. /**
  41743. * Gets the uniform buffer used to store scene data
  41744. * @returns a UniformBuffer
  41745. */
  41746. getSceneUniformBuffer(): UniformBuffer;
  41747. /**
  41748. * Gets an unique (relatively to the current scene) Id
  41749. * @returns an unique number for the scene
  41750. */
  41751. getUniqueId(): number;
  41752. /**
  41753. * Add a mesh to the list of scene's meshes
  41754. * @param newMesh defines the mesh to add
  41755. * @param recursive if all child meshes should also be added to the scene
  41756. */
  41757. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41758. /**
  41759. * Remove a mesh for the list of scene's meshes
  41760. * @param toRemove defines the mesh to remove
  41761. * @param recursive if all child meshes should also be removed from the scene
  41762. * @returns the index where the mesh was in the mesh list
  41763. */
  41764. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41765. /**
  41766. * Add a transform node to the list of scene's transform nodes
  41767. * @param newTransformNode defines the transform node to add
  41768. */
  41769. addTransformNode(newTransformNode: TransformNode): void;
  41770. /**
  41771. * Remove a transform node for the list of scene's transform nodes
  41772. * @param toRemove defines the transform node to remove
  41773. * @returns the index where the transform node was in the transform node list
  41774. */
  41775. removeTransformNode(toRemove: TransformNode): number;
  41776. /**
  41777. * Remove a skeleton for the list of scene's skeletons
  41778. * @param toRemove defines the skeleton to remove
  41779. * @returns the index where the skeleton was in the skeleton list
  41780. */
  41781. removeSkeleton(toRemove: Skeleton): number;
  41782. /**
  41783. * Remove a morph target for the list of scene's morph targets
  41784. * @param toRemove defines the morph target to remove
  41785. * @returns the index where the morph target was in the morph target list
  41786. */
  41787. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41788. /**
  41789. * Remove a light for the list of scene's lights
  41790. * @param toRemove defines the light to remove
  41791. * @returns the index where the light was in the light list
  41792. */
  41793. removeLight(toRemove: Light): number;
  41794. /**
  41795. * Remove a camera for the list of scene's cameras
  41796. * @param toRemove defines the camera to remove
  41797. * @returns the index where the camera was in the camera list
  41798. */
  41799. removeCamera(toRemove: Camera): number;
  41800. /**
  41801. * Remove a particle system for the list of scene's particle systems
  41802. * @param toRemove defines the particle system to remove
  41803. * @returns the index where the particle system was in the particle system list
  41804. */
  41805. removeParticleSystem(toRemove: IParticleSystem): number;
  41806. /**
  41807. * Remove a animation for the list of scene's animations
  41808. * @param toRemove defines the animation to remove
  41809. * @returns the index where the animation was in the animation list
  41810. */
  41811. removeAnimation(toRemove: Animation): number;
  41812. /**
  41813. * Will stop the animation of the given target
  41814. * @param target - the target
  41815. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41816. * @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)
  41817. */
  41818. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41819. /**
  41820. * Removes the given animation group from this scene.
  41821. * @param toRemove The animation group to remove
  41822. * @returns The index of the removed animation group
  41823. */
  41824. removeAnimationGroup(toRemove: AnimationGroup): number;
  41825. /**
  41826. * Removes the given multi-material from this scene.
  41827. * @param toRemove The multi-material to remove
  41828. * @returns The index of the removed multi-material
  41829. */
  41830. removeMultiMaterial(toRemove: MultiMaterial): number;
  41831. /**
  41832. * Removes the given material from this scene.
  41833. * @param toRemove The material to remove
  41834. * @returns The index of the removed material
  41835. */
  41836. removeMaterial(toRemove: Material): number;
  41837. /**
  41838. * Removes the given action manager from this scene.
  41839. * @param toRemove The action manager to remove
  41840. * @returns The index of the removed action manager
  41841. */
  41842. removeActionManager(toRemove: AbstractActionManager): number;
  41843. /**
  41844. * Removes the given texture from this scene.
  41845. * @param toRemove The texture to remove
  41846. * @returns The index of the removed texture
  41847. */
  41848. removeTexture(toRemove: BaseTexture): number;
  41849. /**
  41850. * Adds the given light to this scene
  41851. * @param newLight The light to add
  41852. */
  41853. addLight(newLight: Light): void;
  41854. /**
  41855. * Sorts the list list based on light priorities
  41856. */
  41857. sortLightsByPriority(): void;
  41858. /**
  41859. * Adds the given camera to this scene
  41860. * @param newCamera The camera to add
  41861. */
  41862. addCamera(newCamera: Camera): void;
  41863. /**
  41864. * Adds the given skeleton to this scene
  41865. * @param newSkeleton The skeleton to add
  41866. */
  41867. addSkeleton(newSkeleton: Skeleton): void;
  41868. /**
  41869. * Adds the given particle system to this scene
  41870. * @param newParticleSystem The particle system to add
  41871. */
  41872. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41873. /**
  41874. * Adds the given animation to this scene
  41875. * @param newAnimation The animation to add
  41876. */
  41877. addAnimation(newAnimation: Animation): void;
  41878. /**
  41879. * Adds the given animation group to this scene.
  41880. * @param newAnimationGroup The animation group to add
  41881. */
  41882. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41883. /**
  41884. * Adds the given multi-material to this scene
  41885. * @param newMultiMaterial The multi-material to add
  41886. */
  41887. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41888. /**
  41889. * Adds the given material to this scene
  41890. * @param newMaterial The material to add
  41891. */
  41892. addMaterial(newMaterial: Material): void;
  41893. /**
  41894. * Adds the given morph target to this scene
  41895. * @param newMorphTargetManager The morph target to add
  41896. */
  41897. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41898. /**
  41899. * Adds the given geometry to this scene
  41900. * @param newGeometry The geometry to add
  41901. */
  41902. addGeometry(newGeometry: Geometry): void;
  41903. /**
  41904. * Adds the given action manager to this scene
  41905. * @param newActionManager The action manager to add
  41906. */
  41907. addActionManager(newActionManager: AbstractActionManager): void;
  41908. /**
  41909. * Adds the given texture to this scene.
  41910. * @param newTexture The texture to add
  41911. */
  41912. addTexture(newTexture: BaseTexture): void;
  41913. /**
  41914. * Switch active camera
  41915. * @param newCamera defines the new active camera
  41916. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41917. */
  41918. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41919. /**
  41920. * sets the active camera of the scene using its ID
  41921. * @param id defines the camera's ID
  41922. * @return the new active camera or null if none found.
  41923. */
  41924. setActiveCameraByID(id: string): Nullable<Camera>;
  41925. /**
  41926. * sets the active camera of the scene using its name
  41927. * @param name defines the camera's name
  41928. * @returns the new active camera or null if none found.
  41929. */
  41930. setActiveCameraByName(name: string): Nullable<Camera>;
  41931. /**
  41932. * get an animation group using its name
  41933. * @param name defines the material's name
  41934. * @return the animation group or null if none found.
  41935. */
  41936. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41937. /**
  41938. * Get a material using its unique id
  41939. * @param uniqueId defines the material's unique id
  41940. * @return the material or null if none found.
  41941. */
  41942. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41943. /**
  41944. * get a material using its id
  41945. * @param id defines the material's ID
  41946. * @return the material or null if none found.
  41947. */
  41948. getMaterialByID(id: string): Nullable<Material>;
  41949. /**
  41950. * Gets a the last added material using a given id
  41951. * @param id defines the material's ID
  41952. * @return the last material with the given id or null if none found.
  41953. */
  41954. getLastMaterialByID(id: string): Nullable<Material>;
  41955. /**
  41956. * Gets a material using its name
  41957. * @param name defines the material's name
  41958. * @return the material or null if none found.
  41959. */
  41960. getMaterialByName(name: string): Nullable<Material>;
  41961. /**
  41962. * Get a texture using its unique id
  41963. * @param uniqueId defines the texture's unique id
  41964. * @return the texture or null if none found.
  41965. */
  41966. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41967. /**
  41968. * Gets a camera using its id
  41969. * @param id defines the id to look for
  41970. * @returns the camera or null if not found
  41971. */
  41972. getCameraByID(id: string): Nullable<Camera>;
  41973. /**
  41974. * Gets a camera using its unique id
  41975. * @param uniqueId defines the unique id to look for
  41976. * @returns the camera or null if not found
  41977. */
  41978. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41979. /**
  41980. * Gets a camera using its name
  41981. * @param name defines the camera's name
  41982. * @return the camera or null if none found.
  41983. */
  41984. getCameraByName(name: string): Nullable<Camera>;
  41985. /**
  41986. * Gets a bone using its id
  41987. * @param id defines the bone's id
  41988. * @return the bone or null if not found
  41989. */
  41990. getBoneByID(id: string): Nullable<Bone>;
  41991. /**
  41992. * Gets a bone using its id
  41993. * @param name defines the bone's name
  41994. * @return the bone or null if not found
  41995. */
  41996. getBoneByName(name: string): Nullable<Bone>;
  41997. /**
  41998. * Gets a light node using its name
  41999. * @param name defines the the light's name
  42000. * @return the light or null if none found.
  42001. */
  42002. getLightByName(name: string): Nullable<Light>;
  42003. /**
  42004. * Gets a light node using its id
  42005. * @param id defines the light's id
  42006. * @return the light or null if none found.
  42007. */
  42008. getLightByID(id: string): Nullable<Light>;
  42009. /**
  42010. * Gets a light node using its scene-generated unique ID
  42011. * @param uniqueId defines the light's unique id
  42012. * @return the light or null if none found.
  42013. */
  42014. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42015. /**
  42016. * Gets a particle system by id
  42017. * @param id defines the particle system id
  42018. * @return the corresponding system or null if none found
  42019. */
  42020. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42021. /**
  42022. * Gets a geometry using its ID
  42023. * @param id defines the geometry's id
  42024. * @return the geometry or null if none found.
  42025. */
  42026. getGeometryByID(id: string): Nullable<Geometry>;
  42027. private _getGeometryByUniqueID;
  42028. /**
  42029. * Add a new geometry to this scene
  42030. * @param geometry defines the geometry to be added to the scene.
  42031. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42032. * @return a boolean defining if the geometry was added or not
  42033. */
  42034. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42035. /**
  42036. * Removes an existing geometry
  42037. * @param geometry defines the geometry to be removed from the scene
  42038. * @return a boolean defining if the geometry was removed or not
  42039. */
  42040. removeGeometry(geometry: Geometry): boolean;
  42041. /**
  42042. * Gets the list of geometries attached to the scene
  42043. * @returns an array of Geometry
  42044. */
  42045. getGeometries(): Geometry[];
  42046. /**
  42047. * Gets the first added mesh found of a given ID
  42048. * @param id defines the id to search for
  42049. * @return the mesh found or null if not found at all
  42050. */
  42051. getMeshByID(id: string): Nullable<AbstractMesh>;
  42052. /**
  42053. * Gets a list of meshes using their id
  42054. * @param id defines the id to search for
  42055. * @returns a list of meshes
  42056. */
  42057. getMeshesByID(id: string): Array<AbstractMesh>;
  42058. /**
  42059. * Gets the first added transform node found of a given ID
  42060. * @param id defines the id to search for
  42061. * @return the found transform node or null if not found at all.
  42062. */
  42063. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42064. /**
  42065. * Gets a transform node with its auto-generated unique id
  42066. * @param uniqueId efines the unique id to search for
  42067. * @return the found transform node or null if not found at all.
  42068. */
  42069. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42070. /**
  42071. * Gets a list of transform nodes using their id
  42072. * @param id defines the id to search for
  42073. * @returns a list of transform nodes
  42074. */
  42075. getTransformNodesByID(id: string): Array<TransformNode>;
  42076. /**
  42077. * Gets a mesh with its auto-generated unique id
  42078. * @param uniqueId defines the unique id to search for
  42079. * @return the found mesh or null if not found at all.
  42080. */
  42081. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42082. /**
  42083. * Gets a the last added mesh using a given id
  42084. * @param id defines the id to search for
  42085. * @return the found mesh or null if not found at all.
  42086. */
  42087. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42088. /**
  42089. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42090. * @param id defines the id to search for
  42091. * @return the found node or null if not found at all
  42092. */
  42093. getLastEntryByID(id: string): Nullable<Node>;
  42094. /**
  42095. * Gets a node (Mesh, Camera, Light) using a given id
  42096. * @param id defines the id to search for
  42097. * @return the found node or null if not found at all
  42098. */
  42099. getNodeByID(id: string): Nullable<Node>;
  42100. /**
  42101. * Gets a node (Mesh, Camera, Light) using a given name
  42102. * @param name defines the name to search for
  42103. * @return the found node or null if not found at all.
  42104. */
  42105. getNodeByName(name: string): Nullable<Node>;
  42106. /**
  42107. * Gets a mesh using a given name
  42108. * @param name defines the name to search for
  42109. * @return the found mesh or null if not found at all.
  42110. */
  42111. getMeshByName(name: string): Nullable<AbstractMesh>;
  42112. /**
  42113. * Gets a transform node using a given name
  42114. * @param name defines the name to search for
  42115. * @return the found transform node or null if not found at all.
  42116. */
  42117. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42118. /**
  42119. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42120. * @param id defines the id to search for
  42121. * @return the found skeleton or null if not found at all.
  42122. */
  42123. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42124. /**
  42125. * Gets a skeleton using a given auto generated unique id
  42126. * @param uniqueId defines the unique id to search for
  42127. * @return the found skeleton or null if not found at all.
  42128. */
  42129. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42130. /**
  42131. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42132. * @param id defines the id to search for
  42133. * @return the found skeleton or null if not found at all.
  42134. */
  42135. getSkeletonById(id: string): Nullable<Skeleton>;
  42136. /**
  42137. * Gets a skeleton using a given name
  42138. * @param name defines the name to search for
  42139. * @return the found skeleton or null if not found at all.
  42140. */
  42141. getSkeletonByName(name: string): Nullable<Skeleton>;
  42142. /**
  42143. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42144. * @param id defines the id to search for
  42145. * @return the found morph target manager or null if not found at all.
  42146. */
  42147. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42148. /**
  42149. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42150. * @param id defines the id to search for
  42151. * @return the found morph target or null if not found at all.
  42152. */
  42153. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42154. /**
  42155. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42156. * @param name defines the name to search for
  42157. * @return the found morph target or null if not found at all.
  42158. */
  42159. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42160. /**
  42161. * Gets a boolean indicating if the given mesh is active
  42162. * @param mesh defines the mesh to look for
  42163. * @returns true if the mesh is in the active list
  42164. */
  42165. isActiveMesh(mesh: AbstractMesh): boolean;
  42166. /**
  42167. * Return a unique id as a string which can serve as an identifier for the scene
  42168. */
  42169. get uid(): string;
  42170. /**
  42171. * Add an externaly attached data from its key.
  42172. * This method call will fail and return false, if such key already exists.
  42173. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42174. * @param key the unique key that identifies the data
  42175. * @param data the data object to associate to the key for this Engine instance
  42176. * @return true if no such key were already present and the data was added successfully, false otherwise
  42177. */
  42178. addExternalData<T>(key: string, data: T): boolean;
  42179. /**
  42180. * Get an externaly attached data from its key
  42181. * @param key the unique key that identifies the data
  42182. * @return the associated data, if present (can be null), or undefined if not present
  42183. */
  42184. getExternalData<T>(key: string): Nullable<T>;
  42185. /**
  42186. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42187. * @param key the unique key that identifies the data
  42188. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42189. * @return the associated data, can be null if the factory returned null.
  42190. */
  42191. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42192. /**
  42193. * Remove an externaly attached data from the Engine instance
  42194. * @param key the unique key that identifies the data
  42195. * @return true if the data was successfully removed, false if it doesn't exist
  42196. */
  42197. removeExternalData(key: string): boolean;
  42198. private _evaluateSubMesh;
  42199. /**
  42200. * Clear the processed materials smart array preventing retention point in material dispose.
  42201. */
  42202. freeProcessedMaterials(): void;
  42203. private _preventFreeActiveMeshesAndRenderingGroups;
  42204. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42205. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42206. * when disposing several meshes in a row or a hierarchy of meshes.
  42207. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42208. */
  42209. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42210. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42211. /**
  42212. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42213. */
  42214. freeActiveMeshes(): void;
  42215. /**
  42216. * Clear the info related to rendering groups preventing retention points during dispose.
  42217. */
  42218. freeRenderingGroups(): void;
  42219. /** @hidden */
  42220. _isInIntermediateRendering(): boolean;
  42221. /**
  42222. * Lambda returning the list of potentially active meshes.
  42223. */
  42224. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42225. /**
  42226. * Lambda returning the list of potentially active sub meshes.
  42227. */
  42228. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42229. /**
  42230. * Lambda returning the list of potentially intersecting sub meshes.
  42231. */
  42232. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42233. /**
  42234. * Lambda returning the list of potentially colliding sub meshes.
  42235. */
  42236. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42237. private _activeMeshesFrozen;
  42238. private _skipEvaluateActiveMeshesCompletely;
  42239. /**
  42240. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42241. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42242. * @returns the current scene
  42243. */
  42244. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42245. /**
  42246. * Use this function to restart evaluating active meshes on every frame
  42247. * @returns the current scene
  42248. */
  42249. unfreezeActiveMeshes(): Scene;
  42250. private _evaluateActiveMeshes;
  42251. private _activeMesh;
  42252. /**
  42253. * Update the transform matrix to update from the current active camera
  42254. * @param force defines a boolean used to force the update even if cache is up to date
  42255. */
  42256. updateTransformMatrix(force?: boolean): void;
  42257. private _bindFrameBuffer;
  42258. /** @hidden */
  42259. _allowPostProcessClearColor: boolean;
  42260. /** @hidden */
  42261. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42262. private _processSubCameras;
  42263. private _checkIntersections;
  42264. /** @hidden */
  42265. _advancePhysicsEngineStep(step: number): void;
  42266. /**
  42267. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42268. */
  42269. getDeterministicFrameTime: () => number;
  42270. /** @hidden */
  42271. _animate(): void;
  42272. /** Execute all animations (for a frame) */
  42273. animate(): void;
  42274. /**
  42275. * Render the scene
  42276. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42277. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42278. */
  42279. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42280. /**
  42281. * Freeze all materials
  42282. * A frozen material will not be updatable but should be faster to render
  42283. */
  42284. freezeMaterials(): void;
  42285. /**
  42286. * Unfreeze all materials
  42287. * A frozen material will not be updatable but should be faster to render
  42288. */
  42289. unfreezeMaterials(): void;
  42290. /**
  42291. * Releases all held ressources
  42292. */
  42293. dispose(): void;
  42294. /**
  42295. * Gets if the scene is already disposed
  42296. */
  42297. get isDisposed(): boolean;
  42298. /**
  42299. * Call this function to reduce memory footprint of the scene.
  42300. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42301. */
  42302. clearCachedVertexData(): void;
  42303. /**
  42304. * This function will remove the local cached buffer data from texture.
  42305. * It will save memory but will prevent the texture from being rebuilt
  42306. */
  42307. cleanCachedTextureBuffer(): void;
  42308. /**
  42309. * Get the world extend vectors with an optional filter
  42310. *
  42311. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42312. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42313. */
  42314. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42315. min: Vector3;
  42316. max: Vector3;
  42317. };
  42318. /**
  42319. * Creates a ray that can be used to pick in the scene
  42320. * @param x defines the x coordinate of the origin (on-screen)
  42321. * @param y defines the y coordinate of the origin (on-screen)
  42322. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42323. * @param camera defines the camera to use for the picking
  42324. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42325. * @returns a Ray
  42326. */
  42327. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42328. /**
  42329. * Creates a ray that can be used to pick in the scene
  42330. * @param x defines the x coordinate of the origin (on-screen)
  42331. * @param y defines the y coordinate of the origin (on-screen)
  42332. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42333. * @param result defines the ray where to store the picking ray
  42334. * @param camera defines the camera to use for the picking
  42335. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42336. * @returns the current scene
  42337. */
  42338. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42339. /**
  42340. * Creates a ray that can be used to pick in the scene
  42341. * @param x defines the x coordinate of the origin (on-screen)
  42342. * @param y defines the y coordinate of the origin (on-screen)
  42343. * @param camera defines the camera to use for the picking
  42344. * @returns a Ray
  42345. */
  42346. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42347. /**
  42348. * Creates a ray that can be used to pick in the scene
  42349. * @param x defines the x coordinate of the origin (on-screen)
  42350. * @param y defines the y coordinate of the origin (on-screen)
  42351. * @param result defines the ray where to store the picking ray
  42352. * @param camera defines the camera to use for the picking
  42353. * @returns the current scene
  42354. */
  42355. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42356. /** Launch a ray to try to pick a mesh in the scene
  42357. * @param x position on screen
  42358. * @param y position on screen
  42359. * @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
  42360. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42361. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42362. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42363. * @returns a PickingInfo
  42364. */
  42365. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42366. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42367. * @param x position on screen
  42368. * @param y position on screen
  42369. * @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
  42370. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42371. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42372. * @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)
  42373. */
  42374. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42375. /** Use the given ray to pick a mesh in the scene
  42376. * @param ray The ray to use to pick meshes
  42377. * @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
  42378. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42380. * @returns a PickingInfo
  42381. */
  42382. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42383. /**
  42384. * Launch a ray to try to pick a mesh in the scene
  42385. * @param x X position on screen
  42386. * @param y Y position on screen
  42387. * @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
  42388. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42389. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42390. * @returns an array of PickingInfo
  42391. */
  42392. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42393. /**
  42394. * Launch a ray to try to pick a mesh in the scene
  42395. * @param ray Ray to use
  42396. * @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
  42397. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42398. * @returns an array of PickingInfo
  42399. */
  42400. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42401. /**
  42402. * Force the value of meshUnderPointer
  42403. * @param mesh defines the mesh to use
  42404. */
  42405. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42406. /**
  42407. * Gets the mesh under the pointer
  42408. * @returns a Mesh or null if no mesh is under the pointer
  42409. */
  42410. getPointerOverMesh(): Nullable<AbstractMesh>;
  42411. /** @hidden */
  42412. _rebuildGeometries(): void;
  42413. /** @hidden */
  42414. _rebuildTextures(): void;
  42415. private _getByTags;
  42416. /**
  42417. * Get a list of meshes by tags
  42418. * @param tagsQuery defines the tags query to use
  42419. * @param forEach defines a predicate used to filter results
  42420. * @returns an array of Mesh
  42421. */
  42422. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42423. /**
  42424. * Get a list of cameras by tags
  42425. * @param tagsQuery defines the tags query to use
  42426. * @param forEach defines a predicate used to filter results
  42427. * @returns an array of Camera
  42428. */
  42429. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42430. /**
  42431. * Get a list of lights by tags
  42432. * @param tagsQuery defines the tags query to use
  42433. * @param forEach defines a predicate used to filter results
  42434. * @returns an array of Light
  42435. */
  42436. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42437. /**
  42438. * Get a list of materials by tags
  42439. * @param tagsQuery defines the tags query to use
  42440. * @param forEach defines a predicate used to filter results
  42441. * @returns an array of Material
  42442. */
  42443. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42444. /**
  42445. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42446. * This allowed control for front to back rendering or reversly depending of the special needs.
  42447. *
  42448. * @param renderingGroupId The rendering group id corresponding to its index
  42449. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42450. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42451. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42452. */
  42453. 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;
  42454. /**
  42455. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42456. *
  42457. * @param renderingGroupId The rendering group id corresponding to its index
  42458. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42459. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42460. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42461. */
  42462. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42463. /**
  42464. * Gets the current auto clear configuration for one rendering group of the rendering
  42465. * manager.
  42466. * @param index the rendering group index to get the information for
  42467. * @returns The auto clear setup for the requested rendering group
  42468. */
  42469. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42470. private _blockMaterialDirtyMechanism;
  42471. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42472. get blockMaterialDirtyMechanism(): boolean;
  42473. set blockMaterialDirtyMechanism(value: boolean);
  42474. /**
  42475. * Will flag all materials as dirty to trigger new shader compilation
  42476. * @param flag defines the flag used to specify which material part must be marked as dirty
  42477. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42478. */
  42479. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42480. /** @hidden */
  42481. _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;
  42482. /** @hidden */
  42483. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42484. /** @hidden */
  42485. _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;
  42486. /** @hidden */
  42487. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42488. /** @hidden */
  42489. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42490. /** @hidden */
  42491. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42492. }
  42493. }
  42494. declare module "babylonjs/assetContainer" {
  42495. import { AbstractScene } from "babylonjs/abstractScene";
  42496. import { Scene } from "babylonjs/scene";
  42497. import { Mesh } from "babylonjs/Meshes/mesh";
  42498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42499. import { Skeleton } from "babylonjs/Bones/skeleton";
  42500. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42501. import { Animatable } from "babylonjs/Animations/animatable";
  42502. import { Nullable } from "babylonjs/types";
  42503. import { Node } from "babylonjs/node";
  42504. /**
  42505. * Set of assets to keep when moving a scene into an asset container.
  42506. */
  42507. export class KeepAssets extends AbstractScene {
  42508. }
  42509. /**
  42510. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42511. */
  42512. export class InstantiatedEntries {
  42513. /**
  42514. * List of new root nodes (eg. nodes with no parent)
  42515. */
  42516. rootNodes: TransformNode[];
  42517. /**
  42518. * List of new skeletons
  42519. */
  42520. skeletons: Skeleton[];
  42521. /**
  42522. * List of new animation groups
  42523. */
  42524. animationGroups: AnimationGroup[];
  42525. }
  42526. /**
  42527. * Container with a set of assets that can be added or removed from a scene.
  42528. */
  42529. export class AssetContainer extends AbstractScene {
  42530. private _wasAddedToScene;
  42531. /**
  42532. * The scene the AssetContainer belongs to.
  42533. */
  42534. scene: Scene;
  42535. /**
  42536. * Instantiates an AssetContainer.
  42537. * @param scene The scene the AssetContainer belongs to.
  42538. */
  42539. constructor(scene: Scene);
  42540. /**
  42541. * Instantiate or clone all meshes and add the new ones to the scene.
  42542. * Skeletons and animation groups will all be cloned
  42543. * @param nameFunction defines an optional function used to get new names for clones
  42544. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42545. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42546. */
  42547. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42548. /**
  42549. * Adds all the assets from the container to the scene.
  42550. */
  42551. addAllToScene(): void;
  42552. /**
  42553. * Removes all the assets in the container from the scene
  42554. */
  42555. removeAllFromScene(): void;
  42556. /**
  42557. * Disposes all the assets in the container
  42558. */
  42559. dispose(): void;
  42560. private _moveAssets;
  42561. /**
  42562. * Removes all the assets contained in the scene and adds them to the container.
  42563. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42564. */
  42565. moveAllFromScene(keepAssets?: KeepAssets): void;
  42566. /**
  42567. * 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.
  42568. * @returns the root mesh
  42569. */
  42570. createRootMesh(): Mesh;
  42571. /**
  42572. * Merge animations (direct and animation groups) from this asset container into a scene
  42573. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42574. * @param animatables set of animatables to retarget to a node from the scene
  42575. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42576. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42577. */
  42578. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42579. }
  42580. }
  42581. declare module "babylonjs/abstractScene" {
  42582. import { Scene } from "babylonjs/scene";
  42583. import { Nullable } from "babylonjs/types";
  42584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42585. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42586. import { Geometry } from "babylonjs/Meshes/geometry";
  42587. import { Skeleton } from "babylonjs/Bones/skeleton";
  42588. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42589. import { AssetContainer } from "babylonjs/assetContainer";
  42590. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42591. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42593. import { Material } from "babylonjs/Materials/material";
  42594. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42595. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42596. import { Camera } from "babylonjs/Cameras/camera";
  42597. import { Light } from "babylonjs/Lights/light";
  42598. import { Node } from "babylonjs/node";
  42599. import { Animation } from "babylonjs/Animations/animation";
  42600. /**
  42601. * Defines how the parser contract is defined.
  42602. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42603. */
  42604. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42605. /**
  42606. * Defines how the individual parser contract is defined.
  42607. * These parser can parse an individual asset
  42608. */
  42609. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42610. /**
  42611. * Base class of the scene acting as a container for the different elements composing a scene.
  42612. * This class is dynamically extended by the different components of the scene increasing
  42613. * flexibility and reducing coupling
  42614. */
  42615. export abstract class AbstractScene {
  42616. /**
  42617. * Stores the list of available parsers in the application.
  42618. */
  42619. private static _BabylonFileParsers;
  42620. /**
  42621. * Stores the list of available individual parsers in the application.
  42622. */
  42623. private static _IndividualBabylonFileParsers;
  42624. /**
  42625. * Adds a parser in the list of available ones
  42626. * @param name Defines the name of the parser
  42627. * @param parser Defines the parser to add
  42628. */
  42629. static AddParser(name: string, parser: BabylonFileParser): void;
  42630. /**
  42631. * Gets a general parser from the list of avaialble ones
  42632. * @param name Defines the name of the parser
  42633. * @returns the requested parser or null
  42634. */
  42635. static GetParser(name: string): Nullable<BabylonFileParser>;
  42636. /**
  42637. * Adds n individual parser in the list of available ones
  42638. * @param name Defines the name of the parser
  42639. * @param parser Defines the parser to add
  42640. */
  42641. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42642. /**
  42643. * Gets an individual parser from the list of avaialble ones
  42644. * @param name Defines the name of the parser
  42645. * @returns the requested parser or null
  42646. */
  42647. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42648. /**
  42649. * Parser json data and populate both a scene and its associated container object
  42650. * @param jsonData Defines the data to parse
  42651. * @param scene Defines the scene to parse the data for
  42652. * @param container Defines the container attached to the parsing sequence
  42653. * @param rootUrl Defines the root url of the data
  42654. */
  42655. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42656. /**
  42657. * Gets the list of root nodes (ie. nodes with no parent)
  42658. */
  42659. rootNodes: Node[];
  42660. /** All of the cameras added to this scene
  42661. * @see https://doc.babylonjs.com/babylon101/cameras
  42662. */
  42663. cameras: Camera[];
  42664. /**
  42665. * All of the lights added to this scene
  42666. * @see https://doc.babylonjs.com/babylon101/lights
  42667. */
  42668. lights: Light[];
  42669. /**
  42670. * All of the (abstract) meshes added to this scene
  42671. */
  42672. meshes: AbstractMesh[];
  42673. /**
  42674. * The list of skeletons added to the scene
  42675. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42676. */
  42677. skeletons: Skeleton[];
  42678. /**
  42679. * All of the particle systems added to this scene
  42680. * @see https://doc.babylonjs.com/babylon101/particles
  42681. */
  42682. particleSystems: IParticleSystem[];
  42683. /**
  42684. * Gets a list of Animations associated with the scene
  42685. */
  42686. animations: Animation[];
  42687. /**
  42688. * All of the animation groups added to this scene
  42689. * @see https://doc.babylonjs.com/how_to/group
  42690. */
  42691. animationGroups: AnimationGroup[];
  42692. /**
  42693. * All of the multi-materials added to this scene
  42694. * @see https://doc.babylonjs.com/how_to/multi_materials
  42695. */
  42696. multiMaterials: MultiMaterial[];
  42697. /**
  42698. * All of the materials added to this scene
  42699. * In the context of a Scene, it is not supposed to be modified manually.
  42700. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42701. * Note also that the order of the Material within the array is not significant and might change.
  42702. * @see https://doc.babylonjs.com/babylon101/materials
  42703. */
  42704. materials: Material[];
  42705. /**
  42706. * The list of morph target managers added to the scene
  42707. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42708. */
  42709. morphTargetManagers: MorphTargetManager[];
  42710. /**
  42711. * The list of geometries used in the scene.
  42712. */
  42713. geometries: Geometry[];
  42714. /**
  42715. * All of the tranform nodes added to this scene
  42716. * In the context of a Scene, it is not supposed to be modified manually.
  42717. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42718. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42719. * @see https://doc.babylonjs.com/how_to/transformnode
  42720. */
  42721. transformNodes: TransformNode[];
  42722. /**
  42723. * ActionManagers available on the scene.
  42724. */
  42725. actionManagers: AbstractActionManager[];
  42726. /**
  42727. * Textures to keep.
  42728. */
  42729. textures: BaseTexture[];
  42730. /**
  42731. * Environment texture for the scene
  42732. */
  42733. environmentTexture: Nullable<BaseTexture>;
  42734. /**
  42735. * @returns all meshes, lights, cameras, transformNodes and bones
  42736. */
  42737. getNodes(): Array<Node>;
  42738. }
  42739. }
  42740. declare module "babylonjs/Audio/sound" {
  42741. import { Observable } from "babylonjs/Misc/observable";
  42742. import { Vector3 } from "babylonjs/Maths/math.vector";
  42743. import { Nullable } from "babylonjs/types";
  42744. import { Scene } from "babylonjs/scene";
  42745. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42746. /**
  42747. * Interface used to define options for Sound class
  42748. */
  42749. export interface ISoundOptions {
  42750. /**
  42751. * Does the sound autoplay once loaded.
  42752. */
  42753. autoplay?: boolean;
  42754. /**
  42755. * Does the sound loop after it finishes playing once.
  42756. */
  42757. loop?: boolean;
  42758. /**
  42759. * Sound's volume
  42760. */
  42761. volume?: number;
  42762. /**
  42763. * Is it a spatial sound?
  42764. */
  42765. spatialSound?: boolean;
  42766. /**
  42767. * Maximum distance to hear that sound
  42768. */
  42769. maxDistance?: number;
  42770. /**
  42771. * Uses user defined attenuation function
  42772. */
  42773. useCustomAttenuation?: boolean;
  42774. /**
  42775. * Define the roll off factor of spatial sounds.
  42776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42777. */
  42778. rolloffFactor?: number;
  42779. /**
  42780. * Define the reference distance the sound should be heard perfectly.
  42781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42782. */
  42783. refDistance?: number;
  42784. /**
  42785. * Define the distance attenuation model the sound will follow.
  42786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42787. */
  42788. distanceModel?: string;
  42789. /**
  42790. * Defines the playback speed (1 by default)
  42791. */
  42792. playbackRate?: number;
  42793. /**
  42794. * Defines if the sound is from a streaming source
  42795. */
  42796. streaming?: boolean;
  42797. /**
  42798. * Defines an optional length (in seconds) inside the sound file
  42799. */
  42800. length?: number;
  42801. /**
  42802. * Defines an optional offset (in seconds) inside the sound file
  42803. */
  42804. offset?: number;
  42805. /**
  42806. * If true, URLs will not be required to state the audio file codec to use.
  42807. */
  42808. skipCodecCheck?: boolean;
  42809. }
  42810. /**
  42811. * Defines a sound that can be played in the application.
  42812. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42813. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42814. */
  42815. export class Sound {
  42816. /**
  42817. * The name of the sound in the scene.
  42818. */
  42819. name: string;
  42820. /**
  42821. * Does the sound autoplay once loaded.
  42822. */
  42823. autoplay: boolean;
  42824. /**
  42825. * Does the sound loop after it finishes playing once.
  42826. */
  42827. loop: boolean;
  42828. /**
  42829. * Does the sound use a custom attenuation curve to simulate the falloff
  42830. * happening when the source gets further away from the camera.
  42831. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42832. */
  42833. useCustomAttenuation: boolean;
  42834. /**
  42835. * The sound track id this sound belongs to.
  42836. */
  42837. soundTrackId: number;
  42838. /**
  42839. * Is this sound currently played.
  42840. */
  42841. isPlaying: boolean;
  42842. /**
  42843. * Is this sound currently paused.
  42844. */
  42845. isPaused: boolean;
  42846. /**
  42847. * Does this sound enables spatial sound.
  42848. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42849. */
  42850. spatialSound: boolean;
  42851. /**
  42852. * Define the reference distance the sound should be heard perfectly.
  42853. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42854. */
  42855. refDistance: number;
  42856. /**
  42857. * Define the roll off factor of spatial sounds.
  42858. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42859. */
  42860. rolloffFactor: number;
  42861. /**
  42862. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42864. */
  42865. maxDistance: number;
  42866. /**
  42867. * Define the distance attenuation model the sound will follow.
  42868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42869. */
  42870. distanceModel: string;
  42871. /**
  42872. * @hidden
  42873. * Back Compat
  42874. **/
  42875. onended: () => any;
  42876. /**
  42877. * Gets or sets an object used to store user defined information for the sound.
  42878. */
  42879. metadata: any;
  42880. /**
  42881. * Observable event when the current playing sound finishes.
  42882. */
  42883. onEndedObservable: Observable<Sound>;
  42884. private _panningModel;
  42885. private _playbackRate;
  42886. private _streaming;
  42887. private _startTime;
  42888. private _startOffset;
  42889. private _position;
  42890. /** @hidden */
  42891. _positionInEmitterSpace: boolean;
  42892. private _localDirection;
  42893. private _volume;
  42894. private _isReadyToPlay;
  42895. private _isDirectional;
  42896. private _readyToPlayCallback;
  42897. private _audioBuffer;
  42898. private _soundSource;
  42899. private _streamingSource;
  42900. private _soundPanner;
  42901. private _soundGain;
  42902. private _inputAudioNode;
  42903. private _outputAudioNode;
  42904. private _coneInnerAngle;
  42905. private _coneOuterAngle;
  42906. private _coneOuterGain;
  42907. private _scene;
  42908. private _connectedTransformNode;
  42909. private _customAttenuationFunction;
  42910. private _registerFunc;
  42911. private _isOutputConnected;
  42912. private _htmlAudioElement;
  42913. private _urlType;
  42914. private _length?;
  42915. private _offset?;
  42916. /** @hidden */
  42917. static _SceneComponentInitialization: (scene: Scene) => void;
  42918. /**
  42919. * Create a sound and attach it to a scene
  42920. * @param name Name of your sound
  42921. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42922. * @param scene defines the scene the sound belongs to
  42923. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42924. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42925. */
  42926. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42927. /**
  42928. * Release the sound and its associated resources
  42929. */
  42930. dispose(): void;
  42931. /**
  42932. * Gets if the sounds is ready to be played or not.
  42933. * @returns true if ready, otherwise false
  42934. */
  42935. isReady(): boolean;
  42936. private _soundLoaded;
  42937. /**
  42938. * Sets the data of the sound from an audiobuffer
  42939. * @param audioBuffer The audioBuffer containing the data
  42940. */
  42941. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42942. /**
  42943. * Updates the current sounds options such as maxdistance, loop...
  42944. * @param options A JSON object containing values named as the object properties
  42945. */
  42946. updateOptions(options: ISoundOptions): void;
  42947. private _createSpatialParameters;
  42948. private _updateSpatialParameters;
  42949. /**
  42950. * Switch the panning model to HRTF:
  42951. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42953. */
  42954. switchPanningModelToHRTF(): void;
  42955. /**
  42956. * Switch the panning model to Equal Power:
  42957. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42959. */
  42960. switchPanningModelToEqualPower(): void;
  42961. private _switchPanningModel;
  42962. /**
  42963. * Connect this sound to a sound track audio node like gain...
  42964. * @param soundTrackAudioNode the sound track audio node to connect to
  42965. */
  42966. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42967. /**
  42968. * Transform this sound into a directional source
  42969. * @param coneInnerAngle Size of the inner cone in degree
  42970. * @param coneOuterAngle Size of the outer cone in degree
  42971. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42972. */
  42973. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42974. /**
  42975. * Gets or sets the inner angle for the directional cone.
  42976. */
  42977. get directionalConeInnerAngle(): number;
  42978. /**
  42979. * Gets or sets the inner angle for the directional cone.
  42980. */
  42981. set directionalConeInnerAngle(value: number);
  42982. /**
  42983. * Gets or sets the outer angle for the directional cone.
  42984. */
  42985. get directionalConeOuterAngle(): number;
  42986. /**
  42987. * Gets or sets the outer angle for the directional cone.
  42988. */
  42989. set directionalConeOuterAngle(value: number);
  42990. /**
  42991. * Sets the position of the emitter if spatial sound is enabled
  42992. * @param newPosition Defines the new posisiton
  42993. */
  42994. setPosition(newPosition: Vector3): void;
  42995. /**
  42996. * Sets the local direction of the emitter if spatial sound is enabled
  42997. * @param newLocalDirection Defines the new local direction
  42998. */
  42999. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43000. private _updateDirection;
  43001. /** @hidden */
  43002. updateDistanceFromListener(): void;
  43003. /**
  43004. * Sets a new custom attenuation function for the sound.
  43005. * @param callback Defines the function used for the attenuation
  43006. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43007. */
  43008. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43009. /**
  43010. * Play the sound
  43011. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43012. * @param offset (optional) Start the sound at a specific time in seconds
  43013. * @param length (optional) Sound duration (in seconds)
  43014. */
  43015. play(time?: number, offset?: number, length?: number): void;
  43016. private _onended;
  43017. /**
  43018. * Stop the sound
  43019. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43020. */
  43021. stop(time?: number): void;
  43022. /**
  43023. * Put the sound in pause
  43024. */
  43025. pause(): void;
  43026. /**
  43027. * Sets a dedicated volume for this sounds
  43028. * @param newVolume Define the new volume of the sound
  43029. * @param time Define time for gradual change to new volume
  43030. */
  43031. setVolume(newVolume: number, time?: number): void;
  43032. /**
  43033. * Set the sound play back rate
  43034. * @param newPlaybackRate Define the playback rate the sound should be played at
  43035. */
  43036. setPlaybackRate(newPlaybackRate: number): void;
  43037. /**
  43038. * Gets the volume of the sound.
  43039. * @returns the volume of the sound
  43040. */
  43041. getVolume(): number;
  43042. /**
  43043. * Attach the sound to a dedicated mesh
  43044. * @param transformNode The transform node to connect the sound with
  43045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43046. */
  43047. attachToMesh(transformNode: TransformNode): void;
  43048. /**
  43049. * Detach the sound from the previously attached mesh
  43050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43051. */
  43052. detachFromMesh(): void;
  43053. private _onRegisterAfterWorldMatrixUpdate;
  43054. /**
  43055. * Clone the current sound in the scene.
  43056. * @returns the new sound clone
  43057. */
  43058. clone(): Nullable<Sound>;
  43059. /**
  43060. * Gets the current underlying audio buffer containing the data
  43061. * @returns the audio buffer
  43062. */
  43063. getAudioBuffer(): Nullable<AudioBuffer>;
  43064. /**
  43065. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43066. * @returns the source node
  43067. */
  43068. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43069. /**
  43070. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43071. * @returns the gain node
  43072. */
  43073. getSoundGain(): Nullable<GainNode>;
  43074. /**
  43075. * Serializes the Sound in a JSON representation
  43076. * @returns the JSON representation of the sound
  43077. */
  43078. serialize(): any;
  43079. /**
  43080. * Parse a JSON representation of a sound to innstantiate in a given scene
  43081. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43082. * @param scene Define the scene the new parsed sound should be created in
  43083. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43084. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43085. * @returns the newly parsed sound
  43086. */
  43087. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43088. }
  43089. }
  43090. declare module "babylonjs/Actions/directAudioActions" {
  43091. import { Action } from "babylonjs/Actions/action";
  43092. import { Condition } from "babylonjs/Actions/condition";
  43093. import { Sound } from "babylonjs/Audio/sound";
  43094. /**
  43095. * This defines an action helpful to play a defined sound on a triggered action.
  43096. */
  43097. export class PlaySoundAction extends Action {
  43098. private _sound;
  43099. /**
  43100. * Instantiate the action
  43101. * @param triggerOptions defines the trigger options
  43102. * @param sound defines the sound to play
  43103. * @param condition defines the trigger related conditions
  43104. */
  43105. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43106. /** @hidden */
  43107. _prepare(): void;
  43108. /**
  43109. * Execute the action and play the sound.
  43110. */
  43111. execute(): void;
  43112. /**
  43113. * Serializes the actions and its related information.
  43114. * @param parent defines the object to serialize in
  43115. * @returns the serialized object
  43116. */
  43117. serialize(parent: any): any;
  43118. }
  43119. /**
  43120. * This defines an action helpful to stop a defined sound on a triggered action.
  43121. */
  43122. export class StopSoundAction extends Action {
  43123. private _sound;
  43124. /**
  43125. * Instantiate the action
  43126. * @param triggerOptions defines the trigger options
  43127. * @param sound defines the sound to stop
  43128. * @param condition defines the trigger related conditions
  43129. */
  43130. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43131. /** @hidden */
  43132. _prepare(): void;
  43133. /**
  43134. * Execute the action and stop the sound.
  43135. */
  43136. execute(): void;
  43137. /**
  43138. * Serializes the actions and its related information.
  43139. * @param parent defines the object to serialize in
  43140. * @returns the serialized object
  43141. */
  43142. serialize(parent: any): any;
  43143. }
  43144. }
  43145. declare module "babylonjs/Actions/interpolateValueAction" {
  43146. import { Action } from "babylonjs/Actions/action";
  43147. import { Condition } from "babylonjs/Actions/condition";
  43148. import { Observable } from "babylonjs/Misc/observable";
  43149. /**
  43150. * This defines an action responsible to change the value of a property
  43151. * by interpolating between its current value and the newly set one once triggered.
  43152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43153. */
  43154. export class InterpolateValueAction extends Action {
  43155. /**
  43156. * Defines the path of the property where the value should be interpolated
  43157. */
  43158. propertyPath: string;
  43159. /**
  43160. * Defines the target value at the end of the interpolation.
  43161. */
  43162. value: any;
  43163. /**
  43164. * Defines the time it will take for the property to interpolate to the value.
  43165. */
  43166. duration: number;
  43167. /**
  43168. * Defines if the other scene animations should be stopped when the action has been triggered
  43169. */
  43170. stopOtherAnimations?: boolean;
  43171. /**
  43172. * Defines a callback raised once the interpolation animation has been done.
  43173. */
  43174. onInterpolationDone?: () => void;
  43175. /**
  43176. * Observable triggered once the interpolation animation has been done.
  43177. */
  43178. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43179. private _target;
  43180. private _effectiveTarget;
  43181. private _property;
  43182. /**
  43183. * Instantiate the action
  43184. * @param triggerOptions defines the trigger options
  43185. * @param target defines the object containing the value to interpolate
  43186. * @param propertyPath defines the path to the property in the target object
  43187. * @param value defines the target value at the end of the interpolation
  43188. * @param duration deines the time it will take for the property to interpolate to the value.
  43189. * @param condition defines the trigger related conditions
  43190. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43191. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43192. */
  43193. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43194. /** @hidden */
  43195. _prepare(): void;
  43196. /**
  43197. * Execute the action starts the value interpolation.
  43198. */
  43199. execute(): void;
  43200. /**
  43201. * Serializes the actions and its related information.
  43202. * @param parent defines the object to serialize in
  43203. * @returns the serialized object
  43204. */
  43205. serialize(parent: any): any;
  43206. }
  43207. }
  43208. declare module "babylonjs/Actions/index" {
  43209. export * from "babylonjs/Actions/abstractActionManager";
  43210. export * from "babylonjs/Actions/action";
  43211. export * from "babylonjs/Actions/actionEvent";
  43212. export * from "babylonjs/Actions/actionManager";
  43213. export * from "babylonjs/Actions/condition";
  43214. export * from "babylonjs/Actions/directActions";
  43215. export * from "babylonjs/Actions/directAudioActions";
  43216. export * from "babylonjs/Actions/interpolateValueAction";
  43217. }
  43218. declare module "babylonjs/Animations/index" {
  43219. export * from "babylonjs/Animations/animatable";
  43220. export * from "babylonjs/Animations/animation";
  43221. export * from "babylonjs/Animations/animationGroup";
  43222. export * from "babylonjs/Animations/animationPropertiesOverride";
  43223. export * from "babylonjs/Animations/easing";
  43224. export * from "babylonjs/Animations/runtimeAnimation";
  43225. export * from "babylonjs/Animations/animationEvent";
  43226. export * from "babylonjs/Animations/animationGroup";
  43227. export * from "babylonjs/Animations/animationKey";
  43228. export * from "babylonjs/Animations/animationRange";
  43229. export * from "babylonjs/Animations/animatable.interface";
  43230. }
  43231. declare module "babylonjs/Audio/soundTrack" {
  43232. import { Sound } from "babylonjs/Audio/sound";
  43233. import { Analyser } from "babylonjs/Audio/analyser";
  43234. import { Scene } from "babylonjs/scene";
  43235. /**
  43236. * Options allowed during the creation of a sound track.
  43237. */
  43238. export interface ISoundTrackOptions {
  43239. /**
  43240. * The volume the sound track should take during creation
  43241. */
  43242. volume?: number;
  43243. /**
  43244. * Define if the sound track is the main sound track of the scene
  43245. */
  43246. mainTrack?: boolean;
  43247. }
  43248. /**
  43249. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43250. * It will be also used in a future release to apply effects on a specific track.
  43251. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43252. */
  43253. export class SoundTrack {
  43254. /**
  43255. * The unique identifier of the sound track in the scene.
  43256. */
  43257. id: number;
  43258. /**
  43259. * The list of sounds included in the sound track.
  43260. */
  43261. soundCollection: Array<Sound>;
  43262. private _outputAudioNode;
  43263. private _scene;
  43264. private _connectedAnalyser;
  43265. private _options;
  43266. private _isInitialized;
  43267. /**
  43268. * Creates a new sound track.
  43269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43270. * @param scene Define the scene the sound track belongs to
  43271. * @param options
  43272. */
  43273. constructor(scene: Scene, options?: ISoundTrackOptions);
  43274. private _initializeSoundTrackAudioGraph;
  43275. /**
  43276. * Release the sound track and its associated resources
  43277. */
  43278. dispose(): void;
  43279. /**
  43280. * Adds a sound to this sound track
  43281. * @param sound define the cound to add
  43282. * @ignoreNaming
  43283. */
  43284. AddSound(sound: Sound): void;
  43285. /**
  43286. * Removes a sound to this sound track
  43287. * @param sound define the cound to remove
  43288. * @ignoreNaming
  43289. */
  43290. RemoveSound(sound: Sound): void;
  43291. /**
  43292. * Set a global volume for the full sound track.
  43293. * @param newVolume Define the new volume of the sound track
  43294. */
  43295. setVolume(newVolume: number): void;
  43296. /**
  43297. * Switch the panning model to HRTF:
  43298. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43299. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43300. */
  43301. switchPanningModelToHRTF(): void;
  43302. /**
  43303. * Switch the panning model to Equal Power:
  43304. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43306. */
  43307. switchPanningModelToEqualPower(): void;
  43308. /**
  43309. * Connect the sound track to an audio analyser allowing some amazing
  43310. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43312. * @param analyser The analyser to connect to the engine
  43313. */
  43314. connectToAnalyser(analyser: Analyser): void;
  43315. }
  43316. }
  43317. declare module "babylonjs/Audio/audioSceneComponent" {
  43318. import { Sound } from "babylonjs/Audio/sound";
  43319. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43320. import { Nullable } from "babylonjs/types";
  43321. import { Vector3 } from "babylonjs/Maths/math.vector";
  43322. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43323. import { Scene } from "babylonjs/scene";
  43324. import { AbstractScene } from "babylonjs/abstractScene";
  43325. import "babylonjs/Audio/audioEngine";
  43326. module "babylonjs/abstractScene" {
  43327. interface AbstractScene {
  43328. /**
  43329. * The list of sounds used in the scene.
  43330. */
  43331. sounds: Nullable<Array<Sound>>;
  43332. }
  43333. }
  43334. module "babylonjs/scene" {
  43335. interface Scene {
  43336. /**
  43337. * @hidden
  43338. * Backing field
  43339. */
  43340. _mainSoundTrack: SoundTrack;
  43341. /**
  43342. * The main sound track played by the scene.
  43343. * It cotains your primary collection of sounds.
  43344. */
  43345. mainSoundTrack: SoundTrack;
  43346. /**
  43347. * The list of sound tracks added to the scene
  43348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43349. */
  43350. soundTracks: Nullable<Array<SoundTrack>>;
  43351. /**
  43352. * Gets a sound using a given name
  43353. * @param name defines the name to search for
  43354. * @return the found sound or null if not found at all.
  43355. */
  43356. getSoundByName(name: string): Nullable<Sound>;
  43357. /**
  43358. * Gets or sets if audio support is enabled
  43359. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43360. */
  43361. audioEnabled: boolean;
  43362. /**
  43363. * Gets or sets if audio will be output to headphones
  43364. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43365. */
  43366. headphone: boolean;
  43367. /**
  43368. * Gets or sets custom audio listener position provider
  43369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43370. */
  43371. audioListenerPositionProvider: Nullable<() => Vector3>;
  43372. /**
  43373. * Gets or sets a refresh rate when using 3D audio positioning
  43374. */
  43375. audioPositioningRefreshRate: number;
  43376. }
  43377. }
  43378. /**
  43379. * Defines the sound scene component responsible to manage any sounds
  43380. * in a given scene.
  43381. */
  43382. export class AudioSceneComponent implements ISceneSerializableComponent {
  43383. /**
  43384. * The component name helpfull to identify the component in the list of scene components.
  43385. */
  43386. readonly name: string;
  43387. /**
  43388. * The scene the component belongs to.
  43389. */
  43390. scene: Scene;
  43391. private _audioEnabled;
  43392. /**
  43393. * Gets whether audio is enabled or not.
  43394. * Please use related enable/disable method to switch state.
  43395. */
  43396. get audioEnabled(): boolean;
  43397. private _headphone;
  43398. /**
  43399. * Gets whether audio is outputing to headphone or not.
  43400. * Please use the according Switch methods to change output.
  43401. */
  43402. get headphone(): boolean;
  43403. /**
  43404. * Gets or sets a refresh rate when using 3D audio positioning
  43405. */
  43406. audioPositioningRefreshRate: number;
  43407. private _audioListenerPositionProvider;
  43408. /**
  43409. * Gets the current audio listener position provider
  43410. */
  43411. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43412. /**
  43413. * Sets a custom listener position for all sounds in the scene
  43414. * By default, this is the position of the first active camera
  43415. */
  43416. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43417. /**
  43418. * Creates a new instance of the component for the given scene
  43419. * @param scene Defines the scene to register the component in
  43420. */
  43421. constructor(scene: Scene);
  43422. /**
  43423. * Registers the component in a given scene
  43424. */
  43425. register(): void;
  43426. /**
  43427. * Rebuilds the elements related to this component in case of
  43428. * context lost for instance.
  43429. */
  43430. rebuild(): void;
  43431. /**
  43432. * Serializes the component data to the specified json object
  43433. * @param serializationObject The object to serialize to
  43434. */
  43435. serialize(serializationObject: any): void;
  43436. /**
  43437. * Adds all the elements from the container to the scene
  43438. * @param container the container holding the elements
  43439. */
  43440. addFromContainer(container: AbstractScene): void;
  43441. /**
  43442. * Removes all the elements in the container from the scene
  43443. * @param container contains the elements to remove
  43444. * @param dispose if the removed element should be disposed (default: false)
  43445. */
  43446. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43447. /**
  43448. * Disposes the component and the associated ressources.
  43449. */
  43450. dispose(): void;
  43451. /**
  43452. * Disables audio in the associated scene.
  43453. */
  43454. disableAudio(): void;
  43455. /**
  43456. * Enables audio in the associated scene.
  43457. */
  43458. enableAudio(): void;
  43459. /**
  43460. * Switch audio to headphone output.
  43461. */
  43462. switchAudioModeForHeadphones(): void;
  43463. /**
  43464. * Switch audio to normal speakers.
  43465. */
  43466. switchAudioModeForNormalSpeakers(): void;
  43467. private _cachedCameraDirection;
  43468. private _cachedCameraPosition;
  43469. private _lastCheck;
  43470. private _afterRender;
  43471. }
  43472. }
  43473. declare module "babylonjs/Audio/weightedsound" {
  43474. import { Sound } from "babylonjs/Audio/sound";
  43475. /**
  43476. * Wraps one or more Sound objects and selects one with random weight for playback.
  43477. */
  43478. export class WeightedSound {
  43479. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43480. loop: boolean;
  43481. private _coneInnerAngle;
  43482. private _coneOuterAngle;
  43483. private _volume;
  43484. /** A Sound is currently playing. */
  43485. isPlaying: boolean;
  43486. /** A Sound is currently paused. */
  43487. isPaused: boolean;
  43488. private _sounds;
  43489. private _weights;
  43490. private _currentIndex?;
  43491. /**
  43492. * Creates a new WeightedSound from the list of sounds given.
  43493. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43494. * @param sounds Array of Sounds that will be selected from.
  43495. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43496. */
  43497. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43498. /**
  43499. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43500. */
  43501. get directionalConeInnerAngle(): number;
  43502. /**
  43503. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43504. */
  43505. set directionalConeInnerAngle(value: number);
  43506. /**
  43507. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43508. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43509. */
  43510. get directionalConeOuterAngle(): number;
  43511. /**
  43512. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43513. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43514. */
  43515. set directionalConeOuterAngle(value: number);
  43516. /**
  43517. * Playback volume.
  43518. */
  43519. get volume(): number;
  43520. /**
  43521. * Playback volume.
  43522. */
  43523. set volume(value: number);
  43524. private _onended;
  43525. /**
  43526. * Suspend playback
  43527. */
  43528. pause(): void;
  43529. /**
  43530. * Stop playback
  43531. */
  43532. stop(): void;
  43533. /**
  43534. * Start playback.
  43535. * @param startOffset Position the clip head at a specific time in seconds.
  43536. */
  43537. play(startOffset?: number): void;
  43538. }
  43539. }
  43540. declare module "babylonjs/Audio/index" {
  43541. export * from "babylonjs/Audio/analyser";
  43542. export * from "babylonjs/Audio/audioEngine";
  43543. export * from "babylonjs/Audio/audioSceneComponent";
  43544. export * from "babylonjs/Audio/sound";
  43545. export * from "babylonjs/Audio/soundTrack";
  43546. export * from "babylonjs/Audio/weightedsound";
  43547. }
  43548. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43549. import { Behavior } from "babylonjs/Behaviors/behavior";
  43550. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43551. import { BackEase } from "babylonjs/Animations/easing";
  43552. /**
  43553. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43554. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43555. */
  43556. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43557. /**
  43558. * Gets the name of the behavior.
  43559. */
  43560. get name(): string;
  43561. /**
  43562. * The easing function used by animations
  43563. */
  43564. static EasingFunction: BackEase;
  43565. /**
  43566. * The easing mode used by animations
  43567. */
  43568. static EasingMode: number;
  43569. /**
  43570. * The duration of the animation, in milliseconds
  43571. */
  43572. transitionDuration: number;
  43573. /**
  43574. * Length of the distance animated by the transition when lower radius is reached
  43575. */
  43576. lowerRadiusTransitionRange: number;
  43577. /**
  43578. * Length of the distance animated by the transition when upper radius is reached
  43579. */
  43580. upperRadiusTransitionRange: number;
  43581. private _autoTransitionRange;
  43582. /**
  43583. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43584. */
  43585. get autoTransitionRange(): boolean;
  43586. /**
  43587. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43588. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43589. */
  43590. set autoTransitionRange(value: boolean);
  43591. private _attachedCamera;
  43592. private _onAfterCheckInputsObserver;
  43593. private _onMeshTargetChangedObserver;
  43594. /**
  43595. * Initializes the behavior.
  43596. */
  43597. init(): void;
  43598. /**
  43599. * Attaches the behavior to its arc rotate camera.
  43600. * @param camera Defines the camera to attach the behavior to
  43601. */
  43602. attach(camera: ArcRotateCamera): void;
  43603. /**
  43604. * Detaches the behavior from its current arc rotate camera.
  43605. */
  43606. detach(): void;
  43607. private _radiusIsAnimating;
  43608. private _radiusBounceTransition;
  43609. private _animatables;
  43610. private _cachedWheelPrecision;
  43611. /**
  43612. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43613. * @param radiusLimit The limit to check against.
  43614. * @return Bool to indicate if at limit.
  43615. */
  43616. private _isRadiusAtLimit;
  43617. /**
  43618. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43619. * @param radiusDelta The delta by which to animate to. Can be negative.
  43620. */
  43621. private _applyBoundRadiusAnimation;
  43622. /**
  43623. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43624. */
  43625. protected _clearAnimationLocks(): void;
  43626. /**
  43627. * Stops and removes all animations that have been applied to the camera
  43628. */
  43629. stopAllAnimations(): void;
  43630. }
  43631. }
  43632. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43633. import { Behavior } from "babylonjs/Behaviors/behavior";
  43634. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43635. import { ExponentialEase } from "babylonjs/Animations/easing";
  43636. import { Nullable } from "babylonjs/types";
  43637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43638. import { Vector3 } from "babylonjs/Maths/math.vector";
  43639. /**
  43640. * 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.
  43641. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43642. */
  43643. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43644. /**
  43645. * Gets the name of the behavior.
  43646. */
  43647. get name(): string;
  43648. private _mode;
  43649. private _radiusScale;
  43650. private _positionScale;
  43651. private _defaultElevation;
  43652. private _elevationReturnTime;
  43653. private _elevationReturnWaitTime;
  43654. private _zoomStopsAnimation;
  43655. private _framingTime;
  43656. /**
  43657. * The easing function used by animations
  43658. */
  43659. static EasingFunction: ExponentialEase;
  43660. /**
  43661. * The easing mode used by animations
  43662. */
  43663. static EasingMode: number;
  43664. /**
  43665. * Sets the current mode used by the behavior
  43666. */
  43667. set mode(mode: number);
  43668. /**
  43669. * Gets current mode used by the behavior.
  43670. */
  43671. get mode(): number;
  43672. /**
  43673. * Sets the scale applied to the radius (1 by default)
  43674. */
  43675. set radiusScale(radius: number);
  43676. /**
  43677. * Gets the scale applied to the radius
  43678. */
  43679. get radiusScale(): number;
  43680. /**
  43681. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43682. */
  43683. set positionScale(scale: number);
  43684. /**
  43685. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43686. */
  43687. get positionScale(): number;
  43688. /**
  43689. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43690. * behaviour is triggered, in radians.
  43691. */
  43692. set defaultElevation(elevation: number);
  43693. /**
  43694. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43695. * behaviour is triggered, in radians.
  43696. */
  43697. get defaultElevation(): number;
  43698. /**
  43699. * Sets the time (in milliseconds) taken to return to the default beta position.
  43700. * Negative value indicates camera should not return to default.
  43701. */
  43702. set elevationReturnTime(speed: number);
  43703. /**
  43704. * Gets the time (in milliseconds) taken to return to the default beta position.
  43705. * Negative value indicates camera should not return to default.
  43706. */
  43707. get elevationReturnTime(): number;
  43708. /**
  43709. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43710. */
  43711. set elevationReturnWaitTime(time: number);
  43712. /**
  43713. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43714. */
  43715. get elevationReturnWaitTime(): number;
  43716. /**
  43717. * Sets the flag that indicates if user zooming should stop animation.
  43718. */
  43719. set zoomStopsAnimation(flag: boolean);
  43720. /**
  43721. * Gets the flag that indicates if user zooming should stop animation.
  43722. */
  43723. get zoomStopsAnimation(): boolean;
  43724. /**
  43725. * Sets the transition time when framing the mesh, in milliseconds
  43726. */
  43727. set framingTime(time: number);
  43728. /**
  43729. * Gets the transition time when framing the mesh, in milliseconds
  43730. */
  43731. get framingTime(): number;
  43732. /**
  43733. * Define if the behavior should automatically change the configured
  43734. * camera limits and sensibilities.
  43735. */
  43736. autoCorrectCameraLimitsAndSensibility: boolean;
  43737. private _onPrePointerObservableObserver;
  43738. private _onAfterCheckInputsObserver;
  43739. private _onMeshTargetChangedObserver;
  43740. private _attachedCamera;
  43741. private _isPointerDown;
  43742. private _lastInteractionTime;
  43743. /**
  43744. * Initializes the behavior.
  43745. */
  43746. init(): void;
  43747. /**
  43748. * Attaches the behavior to its arc rotate camera.
  43749. * @param camera Defines the camera to attach the behavior to
  43750. */
  43751. attach(camera: ArcRotateCamera): void;
  43752. /**
  43753. * Detaches the behavior from its current arc rotate camera.
  43754. */
  43755. detach(): void;
  43756. private _animatables;
  43757. private _betaIsAnimating;
  43758. private _betaTransition;
  43759. private _radiusTransition;
  43760. private _vectorTransition;
  43761. /**
  43762. * Targets the given mesh and updates zoom level accordingly.
  43763. * @param mesh The mesh to target.
  43764. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43765. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43766. */
  43767. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43768. /**
  43769. * Targets the given mesh with its children and updates zoom level accordingly.
  43770. * @param mesh The mesh to target.
  43771. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43772. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43773. */
  43774. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43775. /**
  43776. * Targets the given meshes with their children and updates zoom level accordingly.
  43777. * @param meshes The mesh to target.
  43778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43780. */
  43781. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43782. /**
  43783. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43784. * @param minimumWorld Determines the smaller position of the bounding box extend
  43785. * @param maximumWorld Determines the bigger position of the bounding box extend
  43786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43788. */
  43789. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43790. /**
  43791. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43792. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43793. * frustum width.
  43794. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43795. * to fully enclose the mesh in the viewing frustum.
  43796. */
  43797. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43798. /**
  43799. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43800. * is automatically returned to its default position (expected to be above ground plane).
  43801. */
  43802. private _maintainCameraAboveGround;
  43803. /**
  43804. * Returns the frustum slope based on the canvas ratio and camera FOV
  43805. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43806. */
  43807. private _getFrustumSlope;
  43808. /**
  43809. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43810. */
  43811. private _clearAnimationLocks;
  43812. /**
  43813. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43814. */
  43815. private _applyUserInteraction;
  43816. /**
  43817. * Stops and removes all animations that have been applied to the camera
  43818. */
  43819. stopAllAnimations(): void;
  43820. /**
  43821. * Gets a value indicating if the user is moving the camera
  43822. */
  43823. get isUserIsMoving(): boolean;
  43824. /**
  43825. * The camera can move all the way towards the mesh.
  43826. */
  43827. static IgnoreBoundsSizeMode: number;
  43828. /**
  43829. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43830. */
  43831. static FitFrustumSidesMode: number;
  43832. }
  43833. }
  43834. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43835. import { Nullable } from "babylonjs/types";
  43836. import { Camera } from "babylonjs/Cameras/camera";
  43837. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43838. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43839. /**
  43840. * Base class for Camera Pointer Inputs.
  43841. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43842. * for example usage.
  43843. */
  43844. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43845. /**
  43846. * Defines the camera the input is attached to.
  43847. */
  43848. abstract camera: Camera;
  43849. /**
  43850. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43851. */
  43852. protected _altKey: boolean;
  43853. protected _ctrlKey: boolean;
  43854. protected _metaKey: boolean;
  43855. protected _shiftKey: boolean;
  43856. /**
  43857. * Which mouse buttons were pressed at time of last mouse event.
  43858. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43859. */
  43860. protected _buttonsPressed: number;
  43861. /**
  43862. * Defines the buttons associated with the input to handle camera move.
  43863. */
  43864. buttons: number[];
  43865. /**
  43866. * Attach the input controls to a specific dom element to get the input from.
  43867. * @param element Defines the element the controls should be listened from
  43868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43869. */
  43870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43871. /**
  43872. * Detach the current controls from the specified dom element.
  43873. * @param element Defines the element to stop listening the inputs from
  43874. */
  43875. detachControl(element: Nullable<HTMLElement>): void;
  43876. /**
  43877. * Gets the class name of the current input.
  43878. * @returns the class name
  43879. */
  43880. getClassName(): string;
  43881. /**
  43882. * Get the friendly name associated with the input class.
  43883. * @returns the input friendly name
  43884. */
  43885. getSimpleName(): string;
  43886. /**
  43887. * Called on pointer POINTERDOUBLETAP event.
  43888. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43889. */
  43890. protected onDoubleTap(type: string): void;
  43891. /**
  43892. * Called on pointer POINTERMOVE event if only a single touch is active.
  43893. * Override this method to provide functionality.
  43894. */
  43895. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43896. /**
  43897. * Called on pointer POINTERMOVE event if multiple touches are active.
  43898. * Override this method to provide functionality.
  43899. */
  43900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43901. /**
  43902. * Called on JS contextmenu event.
  43903. * Override this method to provide functionality.
  43904. */
  43905. protected onContextMenu(evt: PointerEvent): void;
  43906. /**
  43907. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43908. * press.
  43909. * Override this method to provide functionality.
  43910. */
  43911. protected onButtonDown(evt: PointerEvent): void;
  43912. /**
  43913. * Called each time a new POINTERUP event occurs. Ie, for each button
  43914. * release.
  43915. * Override this method to provide functionality.
  43916. */
  43917. protected onButtonUp(evt: PointerEvent): void;
  43918. /**
  43919. * Called when window becomes inactive.
  43920. * Override this method to provide functionality.
  43921. */
  43922. protected onLostFocus(): void;
  43923. private _pointerInput;
  43924. private _observer;
  43925. private _onLostFocus;
  43926. private pointA;
  43927. private pointB;
  43928. }
  43929. }
  43930. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43931. import { Nullable } from "babylonjs/types";
  43932. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43933. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43934. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43935. /**
  43936. * Manage the pointers inputs to control an arc rotate camera.
  43937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43938. */
  43939. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43940. /**
  43941. * Defines the camera the input is attached to.
  43942. */
  43943. camera: ArcRotateCamera;
  43944. /**
  43945. * Gets the class name of the current input.
  43946. * @returns the class name
  43947. */
  43948. getClassName(): string;
  43949. /**
  43950. * Defines the buttons associated with the input to handle camera move.
  43951. */
  43952. buttons: number[];
  43953. /**
  43954. * Defines the pointer angular sensibility along the X axis or how fast is
  43955. * the camera rotating.
  43956. */
  43957. angularSensibilityX: number;
  43958. /**
  43959. * Defines the pointer angular sensibility along the Y axis or how fast is
  43960. * the camera rotating.
  43961. */
  43962. angularSensibilityY: number;
  43963. /**
  43964. * Defines the pointer pinch precision or how fast is the camera zooming.
  43965. */
  43966. pinchPrecision: number;
  43967. /**
  43968. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43969. * from 0.
  43970. * It defines the percentage of current camera.radius to use as delta when
  43971. * pinch zoom is used.
  43972. */
  43973. pinchDeltaPercentage: number;
  43974. /**
  43975. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43976. * that any object in the plane at the camera's target point will scale
  43977. * perfectly with finger motion.
  43978. * Overrides pinchDeltaPercentage and pinchPrecision.
  43979. */
  43980. useNaturalPinchZoom: boolean;
  43981. /**
  43982. * Defines the pointer panning sensibility or how fast is the camera moving.
  43983. */
  43984. panningSensibility: number;
  43985. /**
  43986. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43987. */
  43988. multiTouchPanning: boolean;
  43989. /**
  43990. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43991. * zoom (pinch) through multitouch.
  43992. */
  43993. multiTouchPanAndZoom: boolean;
  43994. /**
  43995. * Revers pinch action direction.
  43996. */
  43997. pinchInwards: boolean;
  43998. private _isPanClick;
  43999. private _twoFingerActivityCount;
  44000. private _isPinching;
  44001. /**
  44002. * Called on pointer POINTERMOVE event if only a single touch is active.
  44003. */
  44004. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44005. /**
  44006. * Called on pointer POINTERDOUBLETAP event.
  44007. */
  44008. protected onDoubleTap(type: string): void;
  44009. /**
  44010. * Called on pointer POINTERMOVE event if multiple touches are active.
  44011. */
  44012. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44013. /**
  44014. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44015. * press.
  44016. */
  44017. protected onButtonDown(evt: PointerEvent): void;
  44018. /**
  44019. * Called each time a new POINTERUP event occurs. Ie, for each button
  44020. * release.
  44021. */
  44022. protected onButtonUp(evt: PointerEvent): void;
  44023. /**
  44024. * Called when window becomes inactive.
  44025. */
  44026. protected onLostFocus(): void;
  44027. }
  44028. }
  44029. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44030. import { Nullable } from "babylonjs/types";
  44031. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44032. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44033. /**
  44034. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44035. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44036. */
  44037. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44038. /**
  44039. * Defines the camera the input is attached to.
  44040. */
  44041. camera: ArcRotateCamera;
  44042. /**
  44043. * Defines the list of key codes associated with the up action (increase alpha)
  44044. */
  44045. keysUp: number[];
  44046. /**
  44047. * Defines the list of key codes associated with the down action (decrease alpha)
  44048. */
  44049. keysDown: number[];
  44050. /**
  44051. * Defines the list of key codes associated with the left action (increase beta)
  44052. */
  44053. keysLeft: number[];
  44054. /**
  44055. * Defines the list of key codes associated with the right action (decrease beta)
  44056. */
  44057. keysRight: number[];
  44058. /**
  44059. * Defines the list of key codes associated with the reset action.
  44060. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44061. */
  44062. keysReset: number[];
  44063. /**
  44064. * Defines the panning sensibility of the inputs.
  44065. * (How fast is the camera panning)
  44066. */
  44067. panningSensibility: number;
  44068. /**
  44069. * Defines the zooming sensibility of the inputs.
  44070. * (How fast is the camera zooming)
  44071. */
  44072. zoomingSensibility: number;
  44073. /**
  44074. * Defines whether maintaining the alt key down switch the movement mode from
  44075. * orientation to zoom.
  44076. */
  44077. useAltToZoom: boolean;
  44078. /**
  44079. * Rotation speed of the camera
  44080. */
  44081. angularSpeed: number;
  44082. private _keys;
  44083. private _ctrlPressed;
  44084. private _altPressed;
  44085. private _onCanvasBlurObserver;
  44086. private _onKeyboardObserver;
  44087. private _engine;
  44088. private _scene;
  44089. /**
  44090. * Attach the input controls to a specific dom element to get the input from.
  44091. * @param element Defines the element the controls should be listened from
  44092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44093. */
  44094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44095. /**
  44096. * Detach the current controls from the specified dom element.
  44097. * @param element Defines the element to stop listening the inputs from
  44098. */
  44099. detachControl(element: Nullable<HTMLElement>): void;
  44100. /**
  44101. * Update the current camera state depending on the inputs that have been used this frame.
  44102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44103. */
  44104. checkInputs(): void;
  44105. /**
  44106. * Gets the class name of the current intput.
  44107. * @returns the class name
  44108. */
  44109. getClassName(): string;
  44110. /**
  44111. * Get the friendly name associated with the input class.
  44112. * @returns the input friendly name
  44113. */
  44114. getSimpleName(): string;
  44115. }
  44116. }
  44117. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44118. import { Nullable } from "babylonjs/types";
  44119. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44121. /**
  44122. * Manage the mouse wheel inputs to control an arc rotate camera.
  44123. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44124. */
  44125. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44126. /**
  44127. * Defines the camera the input is attached to.
  44128. */
  44129. camera: ArcRotateCamera;
  44130. /**
  44131. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44132. */
  44133. wheelPrecision: number;
  44134. /**
  44135. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44136. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44137. */
  44138. wheelDeltaPercentage: number;
  44139. private _wheel;
  44140. private _observer;
  44141. private computeDeltaFromMouseWheelLegacyEvent;
  44142. /**
  44143. * Attach the input controls to a specific dom element to get the input from.
  44144. * @param element Defines the element the controls should be listened from
  44145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44146. */
  44147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44148. /**
  44149. * Detach the current controls from the specified dom element.
  44150. * @param element Defines the element to stop listening the inputs from
  44151. */
  44152. detachControl(element: Nullable<HTMLElement>): void;
  44153. /**
  44154. * Gets the class name of the current intput.
  44155. * @returns the class name
  44156. */
  44157. getClassName(): string;
  44158. /**
  44159. * Get the friendly name associated with the input class.
  44160. * @returns the input friendly name
  44161. */
  44162. getSimpleName(): string;
  44163. }
  44164. }
  44165. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44166. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44167. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44168. /**
  44169. * Default Inputs manager for the ArcRotateCamera.
  44170. * It groups all the default supported inputs for ease of use.
  44171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44172. */
  44173. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44174. /**
  44175. * Instantiates a new ArcRotateCameraInputsManager.
  44176. * @param camera Defines the camera the inputs belong to
  44177. */
  44178. constructor(camera: ArcRotateCamera);
  44179. /**
  44180. * Add mouse wheel input support to the input manager.
  44181. * @returns the current input manager
  44182. */
  44183. addMouseWheel(): ArcRotateCameraInputsManager;
  44184. /**
  44185. * Add pointers input support to the input manager.
  44186. * @returns the current input manager
  44187. */
  44188. addPointers(): ArcRotateCameraInputsManager;
  44189. /**
  44190. * Add keyboard input support to the input manager.
  44191. * @returns the current input manager
  44192. */
  44193. addKeyboard(): ArcRotateCameraInputsManager;
  44194. }
  44195. }
  44196. declare module "babylonjs/Cameras/arcRotateCamera" {
  44197. import { Observable } from "babylonjs/Misc/observable";
  44198. import { Nullable } from "babylonjs/types";
  44199. import { Scene } from "babylonjs/scene";
  44200. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44202. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44203. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44204. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44205. import { Camera } from "babylonjs/Cameras/camera";
  44206. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44207. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44208. import { Collider } from "babylonjs/Collisions/collider";
  44209. /**
  44210. * This represents an orbital type of camera.
  44211. *
  44212. * 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.
  44213. * 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.
  44214. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44215. */
  44216. export class ArcRotateCamera extends TargetCamera {
  44217. /**
  44218. * Defines the rotation angle of the camera along the longitudinal axis.
  44219. */
  44220. alpha: number;
  44221. /**
  44222. * Defines the rotation angle of the camera along the latitudinal axis.
  44223. */
  44224. beta: number;
  44225. /**
  44226. * Defines the radius of the camera from it s target point.
  44227. */
  44228. radius: number;
  44229. protected _target: Vector3;
  44230. protected _targetHost: Nullable<AbstractMesh>;
  44231. /**
  44232. * Defines the target point of the camera.
  44233. * The camera looks towards it form the radius distance.
  44234. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44235. */
  44236. get target(): Vector3;
  44237. set target(value: Vector3);
  44238. /**
  44239. * Define the current local position of the camera in the scene
  44240. */
  44241. get position(): Vector3;
  44242. set position(newPosition: Vector3);
  44243. protected _upVector: Vector3;
  44244. protected _upToYMatrix: Matrix;
  44245. protected _YToUpMatrix: Matrix;
  44246. /**
  44247. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44248. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44249. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44250. */
  44251. set upVector(vec: Vector3);
  44252. get upVector(): Vector3;
  44253. /**
  44254. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44255. */
  44256. setMatUp(): void;
  44257. /**
  44258. * Current inertia value on the longitudinal axis.
  44259. * The bigger this number the longer it will take for the camera to stop.
  44260. */
  44261. inertialAlphaOffset: number;
  44262. /**
  44263. * Current inertia value on the latitudinal axis.
  44264. * The bigger this number the longer it will take for the camera to stop.
  44265. */
  44266. inertialBetaOffset: number;
  44267. /**
  44268. * Current inertia value on the radius axis.
  44269. * The bigger this number the longer it will take for the camera to stop.
  44270. */
  44271. inertialRadiusOffset: number;
  44272. /**
  44273. * Minimum allowed angle on the longitudinal axis.
  44274. * This can help limiting how the Camera is able to move in the scene.
  44275. */
  44276. lowerAlphaLimit: Nullable<number>;
  44277. /**
  44278. * Maximum allowed angle on the longitudinal axis.
  44279. * This can help limiting how the Camera is able to move in the scene.
  44280. */
  44281. upperAlphaLimit: Nullable<number>;
  44282. /**
  44283. * Minimum allowed angle on the latitudinal axis.
  44284. * This can help limiting how the Camera is able to move in the scene.
  44285. */
  44286. lowerBetaLimit: number;
  44287. /**
  44288. * Maximum allowed angle on the latitudinal axis.
  44289. * This can help limiting how the Camera is able to move in the scene.
  44290. */
  44291. upperBetaLimit: number;
  44292. /**
  44293. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44294. * This can help limiting how the Camera is able to move in the scene.
  44295. */
  44296. lowerRadiusLimit: Nullable<number>;
  44297. /**
  44298. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44299. * This can help limiting how the Camera is able to move in the scene.
  44300. */
  44301. upperRadiusLimit: Nullable<number>;
  44302. /**
  44303. * Defines the current inertia value used during panning of the camera along the X axis.
  44304. */
  44305. inertialPanningX: number;
  44306. /**
  44307. * Defines the current inertia value used during panning of the camera along the Y axis.
  44308. */
  44309. inertialPanningY: number;
  44310. /**
  44311. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44312. * Basically if your fingers moves away from more than this distance you will be considered
  44313. * in pinch mode.
  44314. */
  44315. pinchToPanMaxDistance: number;
  44316. /**
  44317. * Defines the maximum distance the camera can pan.
  44318. * This could help keeping the cammera always in your scene.
  44319. */
  44320. panningDistanceLimit: Nullable<number>;
  44321. /**
  44322. * Defines the target of the camera before paning.
  44323. */
  44324. panningOriginTarget: Vector3;
  44325. /**
  44326. * Defines the value of the inertia used during panning.
  44327. * 0 would mean stop inertia and one would mean no decelleration at all.
  44328. */
  44329. panningInertia: number;
  44330. /**
  44331. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44332. */
  44333. get angularSensibilityX(): number;
  44334. set angularSensibilityX(value: number);
  44335. /**
  44336. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44337. */
  44338. get angularSensibilityY(): number;
  44339. set angularSensibilityY(value: number);
  44340. /**
  44341. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44342. */
  44343. get pinchPrecision(): number;
  44344. set pinchPrecision(value: number);
  44345. /**
  44346. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44347. * It will be used instead of pinchDeltaPrecision if different from 0.
  44348. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44349. */
  44350. get pinchDeltaPercentage(): number;
  44351. set pinchDeltaPercentage(value: number);
  44352. /**
  44353. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44354. * and pinch delta percentage.
  44355. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44356. * that any object in the plane at the camera's target point will scale
  44357. * perfectly with finger motion.
  44358. */
  44359. get useNaturalPinchZoom(): boolean;
  44360. set useNaturalPinchZoom(value: boolean);
  44361. /**
  44362. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44363. */
  44364. get panningSensibility(): number;
  44365. set panningSensibility(value: number);
  44366. /**
  44367. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44368. */
  44369. get keysUp(): number[];
  44370. set keysUp(value: number[]);
  44371. /**
  44372. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44373. */
  44374. get keysDown(): number[];
  44375. set keysDown(value: number[]);
  44376. /**
  44377. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44378. */
  44379. get keysLeft(): number[];
  44380. set keysLeft(value: number[]);
  44381. /**
  44382. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44383. */
  44384. get keysRight(): number[];
  44385. set keysRight(value: number[]);
  44386. /**
  44387. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44388. */
  44389. get wheelPrecision(): number;
  44390. set wheelPrecision(value: number);
  44391. /**
  44392. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44393. * It will be used instead of pinchDeltaPrecision if different from 0.
  44394. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44395. */
  44396. get wheelDeltaPercentage(): number;
  44397. set wheelDeltaPercentage(value: number);
  44398. /**
  44399. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44400. */
  44401. zoomOnFactor: number;
  44402. /**
  44403. * Defines a screen offset for the camera position.
  44404. */
  44405. targetScreenOffset: Vector2;
  44406. /**
  44407. * Allows the camera to be completely reversed.
  44408. * If false the camera can not arrive upside down.
  44409. */
  44410. allowUpsideDown: boolean;
  44411. /**
  44412. * Define if double tap/click is used to restore the previously saved state of the camera.
  44413. */
  44414. useInputToRestoreState: boolean;
  44415. /** @hidden */
  44416. _viewMatrix: Matrix;
  44417. /** @hidden */
  44418. _useCtrlForPanning: boolean;
  44419. /** @hidden */
  44420. _panningMouseButton: number;
  44421. /**
  44422. * Defines the input associated to the camera.
  44423. */
  44424. inputs: ArcRotateCameraInputsManager;
  44425. /** @hidden */
  44426. _reset: () => void;
  44427. /**
  44428. * Defines the allowed panning axis.
  44429. */
  44430. panningAxis: Vector3;
  44431. protected _localDirection: Vector3;
  44432. protected _transformedDirection: Vector3;
  44433. private _bouncingBehavior;
  44434. /**
  44435. * Gets the bouncing behavior of the camera if it has been enabled.
  44436. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44437. */
  44438. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44439. /**
  44440. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44441. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44442. */
  44443. get useBouncingBehavior(): boolean;
  44444. set useBouncingBehavior(value: boolean);
  44445. private _framingBehavior;
  44446. /**
  44447. * Gets the framing behavior of the camera if it has been enabled.
  44448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44449. */
  44450. get framingBehavior(): Nullable<FramingBehavior>;
  44451. /**
  44452. * Defines if the framing behavior of the camera is enabled on the camera.
  44453. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44454. */
  44455. get useFramingBehavior(): boolean;
  44456. set useFramingBehavior(value: boolean);
  44457. private _autoRotationBehavior;
  44458. /**
  44459. * Gets the auto rotation behavior of the camera if it has been enabled.
  44460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44461. */
  44462. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44463. /**
  44464. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44465. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44466. */
  44467. get useAutoRotationBehavior(): boolean;
  44468. set useAutoRotationBehavior(value: boolean);
  44469. /**
  44470. * Observable triggered when the mesh target has been changed on the camera.
  44471. */
  44472. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44473. /**
  44474. * Event raised when the camera is colliding with a mesh.
  44475. */
  44476. onCollide: (collidedMesh: AbstractMesh) => void;
  44477. /**
  44478. * Defines whether the camera should check collision with the objects oh the scene.
  44479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44480. */
  44481. checkCollisions: boolean;
  44482. /**
  44483. * Defines the collision radius of the camera.
  44484. * This simulates a sphere around the camera.
  44485. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44486. */
  44487. collisionRadius: Vector3;
  44488. protected _collider: Collider;
  44489. protected _previousPosition: Vector3;
  44490. protected _collisionVelocity: Vector3;
  44491. protected _newPosition: Vector3;
  44492. protected _previousAlpha: number;
  44493. protected _previousBeta: number;
  44494. protected _previousRadius: number;
  44495. protected _collisionTriggered: boolean;
  44496. protected _targetBoundingCenter: Nullable<Vector3>;
  44497. private _computationVector;
  44498. /**
  44499. * Instantiates a new ArcRotateCamera in a given scene
  44500. * @param name Defines the name of the camera
  44501. * @param alpha Defines the camera rotation along the logitudinal axis
  44502. * @param beta Defines the camera rotation along the latitudinal axis
  44503. * @param radius Defines the camera distance from its target
  44504. * @param target Defines the camera target
  44505. * @param scene Defines the scene the camera belongs to
  44506. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44507. */
  44508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44509. /** @hidden */
  44510. _initCache(): void;
  44511. /** @hidden */
  44512. _updateCache(ignoreParentClass?: boolean): void;
  44513. protected _getTargetPosition(): Vector3;
  44514. private _storedAlpha;
  44515. private _storedBeta;
  44516. private _storedRadius;
  44517. private _storedTarget;
  44518. private _storedTargetScreenOffset;
  44519. /**
  44520. * Stores the current state of the camera (alpha, beta, radius and target)
  44521. * @returns the camera itself
  44522. */
  44523. storeState(): Camera;
  44524. /**
  44525. * @hidden
  44526. * Restored camera state. You must call storeState() first
  44527. */
  44528. _restoreStateValues(): boolean;
  44529. /** @hidden */
  44530. _isSynchronizedViewMatrix(): boolean;
  44531. /**
  44532. * Attached controls to the current camera.
  44533. * @param element Defines the element the controls should be listened from
  44534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44535. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44536. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44537. */
  44538. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44539. /**
  44540. * Detach the current controls from the camera.
  44541. * The camera will stop reacting to inputs.
  44542. * @param element Defines the element to stop listening the inputs from
  44543. */
  44544. detachControl(element: HTMLElement): void;
  44545. /** @hidden */
  44546. _checkInputs(): void;
  44547. protected _checkLimits(): void;
  44548. /**
  44549. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44550. */
  44551. rebuildAnglesAndRadius(): void;
  44552. /**
  44553. * Use a position to define the current camera related information like alpha, beta and radius
  44554. * @param position Defines the position to set the camera at
  44555. */
  44556. setPosition(position: Vector3): void;
  44557. /**
  44558. * Defines the target the camera should look at.
  44559. * This will automatically adapt alpha beta and radius to fit within the new target.
  44560. * @param target Defines the new target as a Vector or a mesh
  44561. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44562. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44563. */
  44564. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44565. /** @hidden */
  44566. _getViewMatrix(): Matrix;
  44567. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44568. /**
  44569. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44570. * @param meshes Defines the mesh to zoom on
  44571. * @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)
  44572. */
  44573. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44574. /**
  44575. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44576. * The target will be changed but the radius
  44577. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44578. * @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)
  44579. */
  44580. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44581. min: Vector3;
  44582. max: Vector3;
  44583. distance: number;
  44584. }, doNotUpdateMaxZ?: boolean): void;
  44585. /**
  44586. * @override
  44587. * Override Camera.createRigCamera
  44588. */
  44589. createRigCamera(name: string, cameraIndex: number): Camera;
  44590. /**
  44591. * @hidden
  44592. * @override
  44593. * Override Camera._updateRigCameras
  44594. */
  44595. _updateRigCameras(): void;
  44596. /**
  44597. * Destroy the camera and release the current resources hold by it.
  44598. */
  44599. dispose(): void;
  44600. /**
  44601. * Gets the current object class name.
  44602. * @return the class name
  44603. */
  44604. getClassName(): string;
  44605. }
  44606. }
  44607. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44608. import { Behavior } from "babylonjs/Behaviors/behavior";
  44609. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44610. /**
  44611. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44612. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44613. */
  44614. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44615. /**
  44616. * Gets the name of the behavior.
  44617. */
  44618. get name(): string;
  44619. private _zoomStopsAnimation;
  44620. private _idleRotationSpeed;
  44621. private _idleRotationWaitTime;
  44622. private _idleRotationSpinupTime;
  44623. /**
  44624. * Sets the flag that indicates if user zooming should stop animation.
  44625. */
  44626. set zoomStopsAnimation(flag: boolean);
  44627. /**
  44628. * Gets the flag that indicates if user zooming should stop animation.
  44629. */
  44630. get zoomStopsAnimation(): boolean;
  44631. /**
  44632. * Sets the default speed at which the camera rotates around the model.
  44633. */
  44634. set idleRotationSpeed(speed: number);
  44635. /**
  44636. * Gets the default speed at which the camera rotates around the model.
  44637. */
  44638. get idleRotationSpeed(): number;
  44639. /**
  44640. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44641. */
  44642. set idleRotationWaitTime(time: number);
  44643. /**
  44644. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44645. */
  44646. get idleRotationWaitTime(): number;
  44647. /**
  44648. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44649. */
  44650. set idleRotationSpinupTime(time: number);
  44651. /**
  44652. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44653. */
  44654. get idleRotationSpinupTime(): number;
  44655. /**
  44656. * Gets a value indicating if the camera is currently rotating because of this behavior
  44657. */
  44658. get rotationInProgress(): boolean;
  44659. private _onPrePointerObservableObserver;
  44660. private _onAfterCheckInputsObserver;
  44661. private _attachedCamera;
  44662. private _isPointerDown;
  44663. private _lastFrameTime;
  44664. private _lastInteractionTime;
  44665. private _cameraRotationSpeed;
  44666. /**
  44667. * Initializes the behavior.
  44668. */
  44669. init(): void;
  44670. /**
  44671. * Attaches the behavior to its arc rotate camera.
  44672. * @param camera Defines the camera to attach the behavior to
  44673. */
  44674. attach(camera: ArcRotateCamera): void;
  44675. /**
  44676. * Detaches the behavior from its current arc rotate camera.
  44677. */
  44678. detach(): void;
  44679. /**
  44680. * Returns true if user is scrolling.
  44681. * @return true if user is scrolling.
  44682. */
  44683. private _userIsZooming;
  44684. private _lastFrameRadius;
  44685. private _shouldAnimationStopForInteraction;
  44686. /**
  44687. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44688. */
  44689. private _applyUserInteraction;
  44690. private _userIsMoving;
  44691. }
  44692. }
  44693. declare module "babylonjs/Behaviors/Cameras/index" {
  44694. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44695. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44696. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44697. }
  44698. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44699. import { Mesh } from "babylonjs/Meshes/mesh";
  44700. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44701. import { Behavior } from "babylonjs/Behaviors/behavior";
  44702. /**
  44703. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44704. */
  44705. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44706. private ui;
  44707. /**
  44708. * The name of the behavior
  44709. */
  44710. name: string;
  44711. /**
  44712. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44713. */
  44714. distanceAwayFromFace: number;
  44715. /**
  44716. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44717. */
  44718. distanceAwayFromBottomOfFace: number;
  44719. private _faceVectors;
  44720. private _target;
  44721. private _scene;
  44722. private _onRenderObserver;
  44723. private _tmpMatrix;
  44724. private _tmpVector;
  44725. /**
  44726. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44727. * @param ui The transform node that should be attched to the mesh
  44728. */
  44729. constructor(ui: TransformNode);
  44730. /**
  44731. * Initializes the behavior
  44732. */
  44733. init(): void;
  44734. private _closestFace;
  44735. private _zeroVector;
  44736. private _lookAtTmpMatrix;
  44737. private _lookAtToRef;
  44738. /**
  44739. * Attaches the AttachToBoxBehavior to the passed in mesh
  44740. * @param target The mesh that the specified node will be attached to
  44741. */
  44742. attach(target: Mesh): void;
  44743. /**
  44744. * Detaches the behavior from the mesh
  44745. */
  44746. detach(): void;
  44747. }
  44748. }
  44749. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44750. import { Behavior } from "babylonjs/Behaviors/behavior";
  44751. import { Mesh } from "babylonjs/Meshes/mesh";
  44752. /**
  44753. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44754. */
  44755. export class FadeInOutBehavior implements Behavior<Mesh> {
  44756. /**
  44757. * Time in milliseconds to delay before fading in (Default: 0)
  44758. */
  44759. delay: number;
  44760. /**
  44761. * Time in milliseconds for the mesh to fade in (Default: 300)
  44762. */
  44763. fadeInTime: number;
  44764. private _millisecondsPerFrame;
  44765. private _hovered;
  44766. private _hoverValue;
  44767. private _ownerNode;
  44768. /**
  44769. * Instatiates the FadeInOutBehavior
  44770. */
  44771. constructor();
  44772. /**
  44773. * The name of the behavior
  44774. */
  44775. get name(): string;
  44776. /**
  44777. * Initializes the behavior
  44778. */
  44779. init(): void;
  44780. /**
  44781. * Attaches the fade behavior on the passed in mesh
  44782. * @param ownerNode The mesh that will be faded in/out once attached
  44783. */
  44784. attach(ownerNode: Mesh): void;
  44785. /**
  44786. * Detaches the behavior from the mesh
  44787. */
  44788. detach(): void;
  44789. /**
  44790. * Triggers the mesh to begin fading in or out
  44791. * @param value if the object should fade in or out (true to fade in)
  44792. */
  44793. fadeIn(value: boolean): void;
  44794. private _update;
  44795. private _setAllVisibility;
  44796. }
  44797. }
  44798. declare module "babylonjs/Misc/pivotTools" {
  44799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44800. /**
  44801. * Class containing a set of static utilities functions for managing Pivots
  44802. * @hidden
  44803. */
  44804. export class PivotTools {
  44805. private static _PivotCached;
  44806. private static _OldPivotPoint;
  44807. private static _PivotTranslation;
  44808. private static _PivotTmpVector;
  44809. /** @hidden */
  44810. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44811. /** @hidden */
  44812. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44813. }
  44814. }
  44815. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44816. import { Scene } from "babylonjs/scene";
  44817. import { Vector4 } from "babylonjs/Maths/math.vector";
  44818. import { Mesh } from "babylonjs/Meshes/mesh";
  44819. import { Nullable } from "babylonjs/types";
  44820. import { Plane } from "babylonjs/Maths/math.plane";
  44821. /**
  44822. * Class containing static functions to help procedurally build meshes
  44823. */
  44824. export class PlaneBuilder {
  44825. /**
  44826. * Creates a plane mesh
  44827. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44828. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44829. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44833. * @param name defines the name of the mesh
  44834. * @param options defines the options used to create the mesh
  44835. * @param scene defines the hosting scene
  44836. * @returns the plane mesh
  44837. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44838. */
  44839. static CreatePlane(name: string, options: {
  44840. size?: number;
  44841. width?: number;
  44842. height?: number;
  44843. sideOrientation?: number;
  44844. frontUVs?: Vector4;
  44845. backUVs?: Vector4;
  44846. updatable?: boolean;
  44847. sourcePlane?: Plane;
  44848. }, scene?: Nullable<Scene>): Mesh;
  44849. }
  44850. }
  44851. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44852. import { Behavior } from "babylonjs/Behaviors/behavior";
  44853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44854. import { Observable } from "babylonjs/Misc/observable";
  44855. import { Vector3 } from "babylonjs/Maths/math.vector";
  44856. import { Ray } from "babylonjs/Culling/ray";
  44857. import "babylonjs/Meshes/Builders/planeBuilder";
  44858. /**
  44859. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44860. */
  44861. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44862. private static _AnyMouseID;
  44863. /**
  44864. * Abstract mesh the behavior is set on
  44865. */
  44866. attachedNode: AbstractMesh;
  44867. private _dragPlane;
  44868. private _scene;
  44869. private _pointerObserver;
  44870. private _beforeRenderObserver;
  44871. private static _planeScene;
  44872. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44873. /**
  44874. * 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)
  44875. */
  44876. maxDragAngle: number;
  44877. /**
  44878. * @hidden
  44879. */
  44880. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44881. /**
  44882. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44883. */
  44884. currentDraggingPointerID: number;
  44885. /**
  44886. * The last position where the pointer hit the drag plane in world space
  44887. */
  44888. lastDragPosition: Vector3;
  44889. /**
  44890. * If the behavior is currently in a dragging state
  44891. */
  44892. dragging: boolean;
  44893. /**
  44894. * 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)
  44895. */
  44896. dragDeltaRatio: number;
  44897. /**
  44898. * If the drag plane orientation should be updated during the dragging (Default: true)
  44899. */
  44900. updateDragPlane: boolean;
  44901. private _debugMode;
  44902. private _moving;
  44903. /**
  44904. * Fires each time the attached mesh is dragged with the pointer
  44905. * * delta between last drag position and current drag position in world space
  44906. * * dragDistance along the drag axis
  44907. * * dragPlaneNormal normal of the current drag plane used during the drag
  44908. * * dragPlanePoint in world space where the drag intersects the drag plane
  44909. */
  44910. onDragObservable: Observable<{
  44911. delta: Vector3;
  44912. dragPlanePoint: Vector3;
  44913. dragPlaneNormal: Vector3;
  44914. dragDistance: number;
  44915. pointerId: number;
  44916. }>;
  44917. /**
  44918. * Fires each time a drag begins (eg. mouse down on mesh)
  44919. */
  44920. onDragStartObservable: Observable<{
  44921. dragPlanePoint: Vector3;
  44922. pointerId: number;
  44923. }>;
  44924. /**
  44925. * Fires each time a drag ends (eg. mouse release after drag)
  44926. */
  44927. onDragEndObservable: Observable<{
  44928. dragPlanePoint: Vector3;
  44929. pointerId: number;
  44930. }>;
  44931. /**
  44932. * If the attached mesh should be moved when dragged
  44933. */
  44934. moveAttached: boolean;
  44935. /**
  44936. * If the drag behavior will react to drag events (Default: true)
  44937. */
  44938. enabled: boolean;
  44939. /**
  44940. * If pointer events should start and release the drag (Default: true)
  44941. */
  44942. startAndReleaseDragOnPointerEvents: boolean;
  44943. /**
  44944. * If camera controls should be detached during the drag
  44945. */
  44946. detachCameraControls: boolean;
  44947. /**
  44948. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44949. */
  44950. useObjectOrientationForDragging: boolean;
  44951. private _options;
  44952. /**
  44953. * Gets the options used by the behavior
  44954. */
  44955. get options(): {
  44956. dragAxis?: Vector3;
  44957. dragPlaneNormal?: Vector3;
  44958. };
  44959. /**
  44960. * Sets the options used by the behavior
  44961. */
  44962. set options(options: {
  44963. dragAxis?: Vector3;
  44964. dragPlaneNormal?: Vector3;
  44965. });
  44966. /**
  44967. * Creates a pointer drag behavior that can be attached to a mesh
  44968. * @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)
  44969. */
  44970. constructor(options?: {
  44971. dragAxis?: Vector3;
  44972. dragPlaneNormal?: Vector3;
  44973. });
  44974. /**
  44975. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44976. */
  44977. validateDrag: (targetPosition: Vector3) => boolean;
  44978. /**
  44979. * The name of the behavior
  44980. */
  44981. get name(): string;
  44982. /**
  44983. * Initializes the behavior
  44984. */
  44985. init(): void;
  44986. private _tmpVector;
  44987. private _alternatePickedPoint;
  44988. private _worldDragAxis;
  44989. private _targetPosition;
  44990. private _attachedElement;
  44991. /**
  44992. * Attaches the drag behavior the passed in mesh
  44993. * @param ownerNode The mesh that will be dragged around once attached
  44994. * @param predicate Predicate to use for pick filtering
  44995. */
  44996. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44997. /**
  44998. * Force relase the drag action by code.
  44999. */
  45000. releaseDrag(): void;
  45001. private _startDragRay;
  45002. private _lastPointerRay;
  45003. /**
  45004. * Simulates the start of a pointer drag event on the behavior
  45005. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45006. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45007. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45008. */
  45009. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45010. private _startDrag;
  45011. private _dragDelta;
  45012. private _moveDrag;
  45013. private _pickWithRayOnDragPlane;
  45014. private _pointA;
  45015. private _pointC;
  45016. private _localAxis;
  45017. private _lookAt;
  45018. private _updateDragPlanePosition;
  45019. /**
  45020. * Detaches the behavior from the mesh
  45021. */
  45022. detach(): void;
  45023. }
  45024. }
  45025. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45026. import { Mesh } from "babylonjs/Meshes/mesh";
  45027. import { Behavior } from "babylonjs/Behaviors/behavior";
  45028. /**
  45029. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45030. */
  45031. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45032. private _dragBehaviorA;
  45033. private _dragBehaviorB;
  45034. private _startDistance;
  45035. private _initialScale;
  45036. private _targetScale;
  45037. private _ownerNode;
  45038. private _sceneRenderObserver;
  45039. /**
  45040. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45041. */
  45042. constructor();
  45043. /**
  45044. * The name of the behavior
  45045. */
  45046. get name(): string;
  45047. /**
  45048. * Initializes the behavior
  45049. */
  45050. init(): void;
  45051. private _getCurrentDistance;
  45052. /**
  45053. * Attaches the scale behavior the passed in mesh
  45054. * @param ownerNode The mesh that will be scaled around once attached
  45055. */
  45056. attach(ownerNode: Mesh): void;
  45057. /**
  45058. * Detaches the behavior from the mesh
  45059. */
  45060. detach(): void;
  45061. }
  45062. }
  45063. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45064. import { Behavior } from "babylonjs/Behaviors/behavior";
  45065. import { Mesh } from "babylonjs/Meshes/mesh";
  45066. import { Observable } from "babylonjs/Misc/observable";
  45067. /**
  45068. * 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
  45069. */
  45070. export class SixDofDragBehavior implements Behavior<Mesh> {
  45071. private static _virtualScene;
  45072. private _ownerNode;
  45073. private _sceneRenderObserver;
  45074. private _scene;
  45075. private _targetPosition;
  45076. private _virtualOriginMesh;
  45077. private _virtualDragMesh;
  45078. private _pointerObserver;
  45079. private _moving;
  45080. private _startingOrientation;
  45081. private _attachedElement;
  45082. /**
  45083. * 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)
  45084. */
  45085. private zDragFactor;
  45086. /**
  45087. * If the object should rotate to face the drag origin
  45088. */
  45089. rotateDraggedObject: boolean;
  45090. /**
  45091. * If the behavior is currently in a dragging state
  45092. */
  45093. dragging: boolean;
  45094. /**
  45095. * 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)
  45096. */
  45097. dragDeltaRatio: number;
  45098. /**
  45099. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45100. */
  45101. currentDraggingPointerID: number;
  45102. /**
  45103. * If camera controls should be detached during the drag
  45104. */
  45105. detachCameraControls: boolean;
  45106. /**
  45107. * Fires each time a drag starts
  45108. */
  45109. onDragStartObservable: Observable<{}>;
  45110. /**
  45111. * Fires each time a drag ends (eg. mouse release after drag)
  45112. */
  45113. onDragEndObservable: Observable<{}>;
  45114. /**
  45115. * 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
  45116. */
  45117. constructor();
  45118. /**
  45119. * The name of the behavior
  45120. */
  45121. get name(): string;
  45122. /**
  45123. * Initializes the behavior
  45124. */
  45125. init(): void;
  45126. /**
  45127. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45128. */
  45129. private get _pointerCamera();
  45130. /**
  45131. * Attaches the scale behavior the passed in mesh
  45132. * @param ownerNode The mesh that will be scaled around once attached
  45133. */
  45134. attach(ownerNode: Mesh): void;
  45135. /**
  45136. * Detaches the behavior from the mesh
  45137. */
  45138. detach(): void;
  45139. }
  45140. }
  45141. declare module "babylonjs/Behaviors/Meshes/index" {
  45142. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45143. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45144. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45145. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45146. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45147. }
  45148. declare module "babylonjs/Behaviors/index" {
  45149. export * from "babylonjs/Behaviors/behavior";
  45150. export * from "babylonjs/Behaviors/Cameras/index";
  45151. export * from "babylonjs/Behaviors/Meshes/index";
  45152. }
  45153. declare module "babylonjs/Bones/boneIKController" {
  45154. import { Bone } from "babylonjs/Bones/bone";
  45155. import { Vector3 } from "babylonjs/Maths/math.vector";
  45156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45157. import { Nullable } from "babylonjs/types";
  45158. /**
  45159. * Class used to apply inverse kinematics to bones
  45160. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45161. */
  45162. export class BoneIKController {
  45163. private static _tmpVecs;
  45164. private static _tmpQuat;
  45165. private static _tmpMats;
  45166. /**
  45167. * Gets or sets the target mesh
  45168. */
  45169. targetMesh: AbstractMesh;
  45170. /** Gets or sets the mesh used as pole */
  45171. poleTargetMesh: AbstractMesh;
  45172. /**
  45173. * Gets or sets the bone used as pole
  45174. */
  45175. poleTargetBone: Nullable<Bone>;
  45176. /**
  45177. * Gets or sets the target position
  45178. */
  45179. targetPosition: Vector3;
  45180. /**
  45181. * Gets or sets the pole target position
  45182. */
  45183. poleTargetPosition: Vector3;
  45184. /**
  45185. * Gets or sets the pole target local offset
  45186. */
  45187. poleTargetLocalOffset: Vector3;
  45188. /**
  45189. * Gets or sets the pole angle
  45190. */
  45191. poleAngle: number;
  45192. /**
  45193. * Gets or sets the mesh associated with the controller
  45194. */
  45195. mesh: AbstractMesh;
  45196. /**
  45197. * 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)
  45198. */
  45199. slerpAmount: number;
  45200. private _bone1Quat;
  45201. private _bone1Mat;
  45202. private _bone2Ang;
  45203. private _bone1;
  45204. private _bone2;
  45205. private _bone1Length;
  45206. private _bone2Length;
  45207. private _maxAngle;
  45208. private _maxReach;
  45209. private _rightHandedSystem;
  45210. private _bendAxis;
  45211. private _slerping;
  45212. private _adjustRoll;
  45213. /**
  45214. * Gets or sets maximum allowed angle
  45215. */
  45216. get maxAngle(): number;
  45217. set maxAngle(value: number);
  45218. /**
  45219. * Creates a new BoneIKController
  45220. * @param mesh defines the mesh to control
  45221. * @param bone defines the bone to control
  45222. * @param options defines options to set up the controller
  45223. */
  45224. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45225. targetMesh?: AbstractMesh;
  45226. poleTargetMesh?: AbstractMesh;
  45227. poleTargetBone?: Bone;
  45228. poleTargetLocalOffset?: Vector3;
  45229. poleAngle?: number;
  45230. bendAxis?: Vector3;
  45231. maxAngle?: number;
  45232. slerpAmount?: number;
  45233. });
  45234. private _setMaxAngle;
  45235. /**
  45236. * Force the controller to update the bones
  45237. */
  45238. update(): void;
  45239. }
  45240. }
  45241. declare module "babylonjs/Bones/boneLookController" {
  45242. import { Vector3 } from "babylonjs/Maths/math.vector";
  45243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45244. import { Bone } from "babylonjs/Bones/bone";
  45245. import { Space } from "babylonjs/Maths/math.axis";
  45246. /**
  45247. * Class used to make a bone look toward a point in space
  45248. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45249. */
  45250. export class BoneLookController {
  45251. private static _tmpVecs;
  45252. private static _tmpQuat;
  45253. private static _tmpMats;
  45254. /**
  45255. * The target Vector3 that the bone will look at
  45256. */
  45257. target: Vector3;
  45258. /**
  45259. * The mesh that the bone is attached to
  45260. */
  45261. mesh: AbstractMesh;
  45262. /**
  45263. * The bone that will be looking to the target
  45264. */
  45265. bone: Bone;
  45266. /**
  45267. * The up axis of the coordinate system that is used when the bone is rotated
  45268. */
  45269. upAxis: Vector3;
  45270. /**
  45271. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45272. */
  45273. upAxisSpace: Space;
  45274. /**
  45275. * Used to make an adjustment to the yaw of the bone
  45276. */
  45277. adjustYaw: number;
  45278. /**
  45279. * Used to make an adjustment to the pitch of the bone
  45280. */
  45281. adjustPitch: number;
  45282. /**
  45283. * Used to make an adjustment to the roll of the bone
  45284. */
  45285. adjustRoll: number;
  45286. /**
  45287. * 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)
  45288. */
  45289. slerpAmount: number;
  45290. private _minYaw;
  45291. private _maxYaw;
  45292. private _minPitch;
  45293. private _maxPitch;
  45294. private _minYawSin;
  45295. private _minYawCos;
  45296. private _maxYawSin;
  45297. private _maxYawCos;
  45298. private _midYawConstraint;
  45299. private _minPitchTan;
  45300. private _maxPitchTan;
  45301. private _boneQuat;
  45302. private _slerping;
  45303. private _transformYawPitch;
  45304. private _transformYawPitchInv;
  45305. private _firstFrameSkipped;
  45306. private _yawRange;
  45307. private _fowardAxis;
  45308. /**
  45309. * Gets or sets the minimum yaw angle that the bone can look to
  45310. */
  45311. get minYaw(): number;
  45312. set minYaw(value: number);
  45313. /**
  45314. * Gets or sets the maximum yaw angle that the bone can look to
  45315. */
  45316. get maxYaw(): number;
  45317. set maxYaw(value: number);
  45318. /**
  45319. * Gets or sets the minimum pitch angle that the bone can look to
  45320. */
  45321. get minPitch(): number;
  45322. set minPitch(value: number);
  45323. /**
  45324. * Gets or sets the maximum pitch angle that the bone can look to
  45325. */
  45326. get maxPitch(): number;
  45327. set maxPitch(value: number);
  45328. /**
  45329. * Create a BoneLookController
  45330. * @param mesh the mesh that the bone belongs to
  45331. * @param bone the bone that will be looking to the target
  45332. * @param target the target Vector3 to look at
  45333. * @param options optional settings:
  45334. * * maxYaw: the maximum angle the bone will yaw to
  45335. * * minYaw: the minimum angle the bone will yaw to
  45336. * * maxPitch: the maximum angle the bone will pitch to
  45337. * * minPitch: the minimum angle the bone will yaw to
  45338. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45339. * * upAxis: the up axis of the coordinate system
  45340. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45341. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45342. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45343. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45344. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45345. * * adjustRoll: used to make an adjustment to the roll of the bone
  45346. **/
  45347. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45348. maxYaw?: number;
  45349. minYaw?: number;
  45350. maxPitch?: number;
  45351. minPitch?: number;
  45352. slerpAmount?: number;
  45353. upAxis?: Vector3;
  45354. upAxisSpace?: Space;
  45355. yawAxis?: Vector3;
  45356. pitchAxis?: Vector3;
  45357. adjustYaw?: number;
  45358. adjustPitch?: number;
  45359. adjustRoll?: number;
  45360. });
  45361. /**
  45362. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45363. */
  45364. update(): void;
  45365. private _getAngleDiff;
  45366. private _getAngleBetween;
  45367. private _isAngleBetween;
  45368. }
  45369. }
  45370. declare module "babylonjs/Bones/index" {
  45371. export * from "babylonjs/Bones/bone";
  45372. export * from "babylonjs/Bones/boneIKController";
  45373. export * from "babylonjs/Bones/boneLookController";
  45374. export * from "babylonjs/Bones/skeleton";
  45375. }
  45376. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45377. import { Nullable } from "babylonjs/types";
  45378. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45379. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45380. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45381. /**
  45382. * Manage the gamepad inputs to control an arc rotate camera.
  45383. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45384. */
  45385. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45386. /**
  45387. * Defines the camera the input is attached to.
  45388. */
  45389. camera: ArcRotateCamera;
  45390. /**
  45391. * Defines the gamepad the input is gathering event from.
  45392. */
  45393. gamepad: Nullable<Gamepad>;
  45394. /**
  45395. * Defines the gamepad rotation sensiblity.
  45396. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45397. */
  45398. gamepadRotationSensibility: number;
  45399. /**
  45400. * Defines the gamepad move sensiblity.
  45401. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45402. */
  45403. gamepadMoveSensibility: number;
  45404. private _yAxisScale;
  45405. /**
  45406. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45407. */
  45408. get invertYAxis(): boolean;
  45409. set invertYAxis(value: boolean);
  45410. private _onGamepadConnectedObserver;
  45411. private _onGamepadDisconnectedObserver;
  45412. /**
  45413. * Attach the input controls to a specific dom element to get the input from.
  45414. * @param element Defines the element the controls should be listened from
  45415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45416. */
  45417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45418. /**
  45419. * Detach the current controls from the specified dom element.
  45420. * @param element Defines the element to stop listening the inputs from
  45421. */
  45422. detachControl(element: Nullable<HTMLElement>): void;
  45423. /**
  45424. * Update the current camera state depending on the inputs that have been used this frame.
  45425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45426. */
  45427. checkInputs(): void;
  45428. /**
  45429. * Gets the class name of the current intput.
  45430. * @returns the class name
  45431. */
  45432. getClassName(): string;
  45433. /**
  45434. * Get the friendly name associated with the input class.
  45435. * @returns the input friendly name
  45436. */
  45437. getSimpleName(): string;
  45438. }
  45439. }
  45440. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45441. import { Nullable } from "babylonjs/types";
  45442. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45443. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45444. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45445. interface ArcRotateCameraInputsManager {
  45446. /**
  45447. * Add orientation input support to the input manager.
  45448. * @returns the current input manager
  45449. */
  45450. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45451. }
  45452. }
  45453. /**
  45454. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45456. */
  45457. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45458. /**
  45459. * Defines the camera the input is attached to.
  45460. */
  45461. camera: ArcRotateCamera;
  45462. /**
  45463. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45464. */
  45465. alphaCorrection: number;
  45466. /**
  45467. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45468. */
  45469. gammaCorrection: number;
  45470. private _alpha;
  45471. private _gamma;
  45472. private _dirty;
  45473. private _deviceOrientationHandler;
  45474. /**
  45475. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45476. */
  45477. constructor();
  45478. /**
  45479. * Attach the input controls to a specific dom element to get the input from.
  45480. * @param element Defines the element the controls should be listened from
  45481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45482. */
  45483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45484. /** @hidden */
  45485. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45486. /**
  45487. * Update the current camera state depending on the inputs that have been used this frame.
  45488. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45489. */
  45490. checkInputs(): void;
  45491. /**
  45492. * Detach the current controls from the specified dom element.
  45493. * @param element Defines the element to stop listening the inputs from
  45494. */
  45495. detachControl(element: Nullable<HTMLElement>): void;
  45496. /**
  45497. * Gets the class name of the current intput.
  45498. * @returns the class name
  45499. */
  45500. getClassName(): string;
  45501. /**
  45502. * Get the friendly name associated with the input class.
  45503. * @returns the input friendly name
  45504. */
  45505. getSimpleName(): string;
  45506. }
  45507. }
  45508. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45509. import { Nullable } from "babylonjs/types";
  45510. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45511. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45512. /**
  45513. * Listen to mouse events to control the camera.
  45514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45515. */
  45516. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45517. /**
  45518. * Defines the camera the input is attached to.
  45519. */
  45520. camera: FlyCamera;
  45521. /**
  45522. * Defines if touch is enabled. (Default is true.)
  45523. */
  45524. touchEnabled: boolean;
  45525. /**
  45526. * Defines the buttons associated with the input to handle camera rotation.
  45527. */
  45528. buttons: number[];
  45529. /**
  45530. * Assign buttons for Yaw control.
  45531. */
  45532. buttonsYaw: number[];
  45533. /**
  45534. * Assign buttons for Pitch control.
  45535. */
  45536. buttonsPitch: number[];
  45537. /**
  45538. * Assign buttons for Roll control.
  45539. */
  45540. buttonsRoll: number[];
  45541. /**
  45542. * Detect if any button is being pressed while mouse is moved.
  45543. * -1 = Mouse locked.
  45544. * 0 = Left button.
  45545. * 1 = Middle Button.
  45546. * 2 = Right Button.
  45547. */
  45548. activeButton: number;
  45549. /**
  45550. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45551. * Higher values reduce its sensitivity.
  45552. */
  45553. angularSensibility: number;
  45554. private _mousemoveCallback;
  45555. private _observer;
  45556. private _rollObserver;
  45557. private previousPosition;
  45558. private noPreventDefault;
  45559. private element;
  45560. /**
  45561. * Listen to mouse events to control the camera.
  45562. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45563. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45564. */
  45565. constructor(touchEnabled?: boolean);
  45566. /**
  45567. * Attach the mouse control to the HTML DOM element.
  45568. * @param element Defines the element that listens to the input events.
  45569. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45570. */
  45571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45572. /**
  45573. * Detach the current controls from the specified dom element.
  45574. * @param element Defines the element to stop listening the inputs from
  45575. */
  45576. detachControl(element: Nullable<HTMLElement>): void;
  45577. /**
  45578. * Gets the class name of the current input.
  45579. * @returns the class name.
  45580. */
  45581. getClassName(): string;
  45582. /**
  45583. * Get the friendly name associated with the input class.
  45584. * @returns the input's friendly name.
  45585. */
  45586. getSimpleName(): string;
  45587. private _pointerInput;
  45588. private _onMouseMove;
  45589. /**
  45590. * Rotate camera by mouse offset.
  45591. */
  45592. private rotateCamera;
  45593. }
  45594. }
  45595. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45596. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45597. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45598. /**
  45599. * Default Inputs manager for the FlyCamera.
  45600. * It groups all the default supported inputs for ease of use.
  45601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45602. */
  45603. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45604. /**
  45605. * Instantiates a new FlyCameraInputsManager.
  45606. * @param camera Defines the camera the inputs belong to.
  45607. */
  45608. constructor(camera: FlyCamera);
  45609. /**
  45610. * Add keyboard input support to the input manager.
  45611. * @returns the new FlyCameraKeyboardMoveInput().
  45612. */
  45613. addKeyboard(): FlyCameraInputsManager;
  45614. /**
  45615. * Add mouse input support to the input manager.
  45616. * @param touchEnabled Enable touch screen support.
  45617. * @returns the new FlyCameraMouseInput().
  45618. */
  45619. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45620. }
  45621. }
  45622. declare module "babylonjs/Cameras/flyCamera" {
  45623. import { Scene } from "babylonjs/scene";
  45624. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45626. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45627. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45628. /**
  45629. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45630. * such as in a 3D Space Shooter or a Flight Simulator.
  45631. */
  45632. export class FlyCamera extends TargetCamera {
  45633. /**
  45634. * Define the collision ellipsoid of the camera.
  45635. * This is helpful for simulating a camera body, like a player's body.
  45636. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45637. */
  45638. ellipsoid: Vector3;
  45639. /**
  45640. * Define an offset for the position of the ellipsoid around the camera.
  45641. * This can be helpful if the camera is attached away from the player's body center,
  45642. * such as at its head.
  45643. */
  45644. ellipsoidOffset: Vector3;
  45645. /**
  45646. * Enable or disable collisions of the camera with the rest of the scene objects.
  45647. */
  45648. checkCollisions: boolean;
  45649. /**
  45650. * Enable or disable gravity on the camera.
  45651. */
  45652. applyGravity: boolean;
  45653. /**
  45654. * Define the current direction the camera is moving to.
  45655. */
  45656. cameraDirection: Vector3;
  45657. /**
  45658. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45659. * This overrides and empties cameraRotation.
  45660. */
  45661. rotationQuaternion: Quaternion;
  45662. /**
  45663. * Track Roll to maintain the wanted Rolling when looking around.
  45664. */
  45665. _trackRoll: number;
  45666. /**
  45667. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45668. */
  45669. rollCorrect: number;
  45670. /**
  45671. * Mimic a banked turn, Rolling the camera when Yawing.
  45672. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45673. */
  45674. bankedTurn: boolean;
  45675. /**
  45676. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45677. */
  45678. bankedTurnLimit: number;
  45679. /**
  45680. * Value of 0 disables the banked Roll.
  45681. * Value of 1 is equal to the Yaw angle in radians.
  45682. */
  45683. bankedTurnMultiplier: number;
  45684. /**
  45685. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45686. */
  45687. inputs: FlyCameraInputsManager;
  45688. /**
  45689. * Gets the input sensibility for mouse input.
  45690. * Higher values reduce sensitivity.
  45691. */
  45692. get angularSensibility(): number;
  45693. /**
  45694. * Sets the input sensibility for a mouse input.
  45695. * Higher values reduce sensitivity.
  45696. */
  45697. set angularSensibility(value: number);
  45698. /**
  45699. * Get the keys for camera movement forward.
  45700. */
  45701. get keysForward(): number[];
  45702. /**
  45703. * Set the keys for camera movement forward.
  45704. */
  45705. set keysForward(value: number[]);
  45706. /**
  45707. * Get the keys for camera movement backward.
  45708. */
  45709. get keysBackward(): number[];
  45710. set keysBackward(value: number[]);
  45711. /**
  45712. * Get the keys for camera movement up.
  45713. */
  45714. get keysUp(): number[];
  45715. /**
  45716. * Set the keys for camera movement up.
  45717. */
  45718. set keysUp(value: number[]);
  45719. /**
  45720. * Get the keys for camera movement down.
  45721. */
  45722. get keysDown(): number[];
  45723. /**
  45724. * Set the keys for camera movement down.
  45725. */
  45726. set keysDown(value: number[]);
  45727. /**
  45728. * Get the keys for camera movement left.
  45729. */
  45730. get keysLeft(): number[];
  45731. /**
  45732. * Set the keys for camera movement left.
  45733. */
  45734. set keysLeft(value: number[]);
  45735. /**
  45736. * Set the keys for camera movement right.
  45737. */
  45738. get keysRight(): number[];
  45739. /**
  45740. * Set the keys for camera movement right.
  45741. */
  45742. set keysRight(value: number[]);
  45743. /**
  45744. * Event raised when the camera collides with a mesh in the scene.
  45745. */
  45746. onCollide: (collidedMesh: AbstractMesh) => void;
  45747. private _collider;
  45748. private _needMoveForGravity;
  45749. private _oldPosition;
  45750. private _diffPosition;
  45751. private _newPosition;
  45752. /** @hidden */
  45753. _localDirection: Vector3;
  45754. /** @hidden */
  45755. _transformedDirection: Vector3;
  45756. /**
  45757. * Instantiates a FlyCamera.
  45758. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45759. * such as in a 3D Space Shooter or a Flight Simulator.
  45760. * @param name Define the name of the camera in the scene.
  45761. * @param position Define the starting position of the camera in the scene.
  45762. * @param scene Define the scene the camera belongs to.
  45763. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45764. */
  45765. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45766. /**
  45767. * Attach a control to the HTML DOM element.
  45768. * @param element Defines the element that listens to the input events.
  45769. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45770. */
  45771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45772. /**
  45773. * Detach a control from the HTML DOM element.
  45774. * The camera will stop reacting to that input.
  45775. * @param element Defines the element that listens to the input events.
  45776. */
  45777. detachControl(element: HTMLElement): void;
  45778. private _collisionMask;
  45779. /**
  45780. * Get the mask that the camera ignores in collision events.
  45781. */
  45782. get collisionMask(): number;
  45783. /**
  45784. * Set the mask that the camera ignores in collision events.
  45785. */
  45786. set collisionMask(mask: number);
  45787. /** @hidden */
  45788. _collideWithWorld(displacement: Vector3): void;
  45789. /** @hidden */
  45790. private _onCollisionPositionChange;
  45791. /** @hidden */
  45792. _checkInputs(): void;
  45793. /** @hidden */
  45794. _decideIfNeedsToMove(): boolean;
  45795. /** @hidden */
  45796. _updatePosition(): void;
  45797. /**
  45798. * Restore the Roll to its target value at the rate specified.
  45799. * @param rate - Higher means slower restoring.
  45800. * @hidden
  45801. */
  45802. restoreRoll(rate: number): void;
  45803. /**
  45804. * Destroy the camera and release the current resources held by it.
  45805. */
  45806. dispose(): void;
  45807. /**
  45808. * Get the current object class name.
  45809. * @returns the class name.
  45810. */
  45811. getClassName(): string;
  45812. }
  45813. }
  45814. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45815. import { Nullable } from "babylonjs/types";
  45816. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45817. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45818. /**
  45819. * Listen to keyboard events to control the camera.
  45820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45821. */
  45822. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45823. /**
  45824. * Defines the camera the input is attached to.
  45825. */
  45826. camera: FlyCamera;
  45827. /**
  45828. * The list of keyboard keys used to control the forward move of the camera.
  45829. */
  45830. keysForward: number[];
  45831. /**
  45832. * The list of keyboard keys used to control the backward move of the camera.
  45833. */
  45834. keysBackward: number[];
  45835. /**
  45836. * The list of keyboard keys used to control the forward move of the camera.
  45837. */
  45838. keysUp: number[];
  45839. /**
  45840. * The list of keyboard keys used to control the backward move of the camera.
  45841. */
  45842. keysDown: number[];
  45843. /**
  45844. * The list of keyboard keys used to control the right strafe move of the camera.
  45845. */
  45846. keysRight: number[];
  45847. /**
  45848. * The list of keyboard keys used to control the left strafe move of the camera.
  45849. */
  45850. keysLeft: number[];
  45851. private _keys;
  45852. private _onCanvasBlurObserver;
  45853. private _onKeyboardObserver;
  45854. private _engine;
  45855. private _scene;
  45856. /**
  45857. * Attach the input controls to a specific dom element to get the input from.
  45858. * @param element Defines the element the controls should be listened from
  45859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45860. */
  45861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45862. /**
  45863. * Detach the current controls from the specified dom element.
  45864. * @param element Defines the element to stop listening the inputs from
  45865. */
  45866. detachControl(element: Nullable<HTMLElement>): void;
  45867. /**
  45868. * Gets the class name of the current intput.
  45869. * @returns the class name
  45870. */
  45871. getClassName(): string;
  45872. /** @hidden */
  45873. _onLostFocus(e: FocusEvent): void;
  45874. /**
  45875. * Get the friendly name associated with the input class.
  45876. * @returns the input friendly name
  45877. */
  45878. getSimpleName(): string;
  45879. /**
  45880. * Update the current camera state depending on the inputs that have been used this frame.
  45881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45882. */
  45883. checkInputs(): void;
  45884. }
  45885. }
  45886. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45887. import { Nullable } from "babylonjs/types";
  45888. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45889. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45890. /**
  45891. * Manage the mouse wheel inputs to control a follow camera.
  45892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45893. */
  45894. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45895. /**
  45896. * Defines the camera the input is attached to.
  45897. */
  45898. camera: FollowCamera;
  45899. /**
  45900. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45901. */
  45902. axisControlRadius: boolean;
  45903. /**
  45904. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45905. */
  45906. axisControlHeight: boolean;
  45907. /**
  45908. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45909. */
  45910. axisControlRotation: boolean;
  45911. /**
  45912. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45913. * relation to mouseWheel events.
  45914. */
  45915. wheelPrecision: number;
  45916. /**
  45917. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45918. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45919. */
  45920. wheelDeltaPercentage: number;
  45921. private _wheel;
  45922. private _observer;
  45923. /**
  45924. * Attach the input controls to a specific dom element to get the input from.
  45925. * @param element Defines the element the controls should be listened from
  45926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45927. */
  45928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45929. /**
  45930. * Detach the current controls from the specified dom element.
  45931. * @param element Defines the element to stop listening the inputs from
  45932. */
  45933. detachControl(element: Nullable<HTMLElement>): void;
  45934. /**
  45935. * Gets the class name of the current intput.
  45936. * @returns the class name
  45937. */
  45938. getClassName(): string;
  45939. /**
  45940. * Get the friendly name associated with the input class.
  45941. * @returns the input friendly name
  45942. */
  45943. getSimpleName(): string;
  45944. }
  45945. }
  45946. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45947. import { Nullable } from "babylonjs/types";
  45948. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45949. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45950. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45951. /**
  45952. * Manage the pointers inputs to control an follow camera.
  45953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45954. */
  45955. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45956. /**
  45957. * Defines the camera the input is attached to.
  45958. */
  45959. camera: FollowCamera;
  45960. /**
  45961. * Gets the class name of the current input.
  45962. * @returns the class name
  45963. */
  45964. getClassName(): string;
  45965. /**
  45966. * Defines the pointer angular sensibility along the X axis or how fast is
  45967. * the camera rotating.
  45968. * A negative number will reverse the axis direction.
  45969. */
  45970. angularSensibilityX: number;
  45971. /**
  45972. * Defines the pointer angular sensibility along the Y axis or how fast is
  45973. * the camera rotating.
  45974. * A negative number will reverse the axis direction.
  45975. */
  45976. angularSensibilityY: number;
  45977. /**
  45978. * Defines the pointer pinch precision or how fast is the camera zooming.
  45979. * A negative number will reverse the axis direction.
  45980. */
  45981. pinchPrecision: number;
  45982. /**
  45983. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45984. * from 0.
  45985. * It defines the percentage of current camera.radius to use as delta when
  45986. * pinch zoom is used.
  45987. */
  45988. pinchDeltaPercentage: number;
  45989. /**
  45990. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45991. */
  45992. axisXControlRadius: boolean;
  45993. /**
  45994. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45995. */
  45996. axisXControlHeight: boolean;
  45997. /**
  45998. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45999. */
  46000. axisXControlRotation: boolean;
  46001. /**
  46002. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46003. */
  46004. axisYControlRadius: boolean;
  46005. /**
  46006. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46007. */
  46008. axisYControlHeight: boolean;
  46009. /**
  46010. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46011. */
  46012. axisYControlRotation: boolean;
  46013. /**
  46014. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46015. */
  46016. axisPinchControlRadius: boolean;
  46017. /**
  46018. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46019. */
  46020. axisPinchControlHeight: boolean;
  46021. /**
  46022. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46023. */
  46024. axisPinchControlRotation: boolean;
  46025. /**
  46026. * Log error messages if basic misconfiguration has occurred.
  46027. */
  46028. warningEnable: boolean;
  46029. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46030. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46031. private _warningCounter;
  46032. private _warning;
  46033. }
  46034. }
  46035. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46036. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46037. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46038. /**
  46039. * Default Inputs manager for the FollowCamera.
  46040. * It groups all the default supported inputs for ease of use.
  46041. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46042. */
  46043. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46044. /**
  46045. * Instantiates a new FollowCameraInputsManager.
  46046. * @param camera Defines the camera the inputs belong to
  46047. */
  46048. constructor(camera: FollowCamera);
  46049. /**
  46050. * Add keyboard input support to the input manager.
  46051. * @returns the current input manager
  46052. */
  46053. addKeyboard(): FollowCameraInputsManager;
  46054. /**
  46055. * Add mouse wheel input support to the input manager.
  46056. * @returns the current input manager
  46057. */
  46058. addMouseWheel(): FollowCameraInputsManager;
  46059. /**
  46060. * Add pointers input support to the input manager.
  46061. * @returns the current input manager
  46062. */
  46063. addPointers(): FollowCameraInputsManager;
  46064. /**
  46065. * Add orientation input support to the input manager.
  46066. * @returns the current input manager
  46067. */
  46068. addVRDeviceOrientation(): FollowCameraInputsManager;
  46069. }
  46070. }
  46071. declare module "babylonjs/Cameras/followCamera" {
  46072. import { Nullable } from "babylonjs/types";
  46073. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46074. import { Scene } from "babylonjs/scene";
  46075. import { Vector3 } from "babylonjs/Maths/math.vector";
  46076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46077. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46078. /**
  46079. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46080. * an arc rotate version arcFollowCamera are available.
  46081. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46082. */
  46083. export class FollowCamera extends TargetCamera {
  46084. /**
  46085. * Distance the follow camera should follow an object at
  46086. */
  46087. radius: number;
  46088. /**
  46089. * Minimum allowed distance of the camera to the axis of rotation
  46090. * (The camera can not get closer).
  46091. * This can help limiting how the Camera is able to move in the scene.
  46092. */
  46093. lowerRadiusLimit: Nullable<number>;
  46094. /**
  46095. * Maximum allowed distance of the camera to the axis of rotation
  46096. * (The camera can not get further).
  46097. * This can help limiting how the Camera is able to move in the scene.
  46098. */
  46099. upperRadiusLimit: Nullable<number>;
  46100. /**
  46101. * Define a rotation offset between the camera and the object it follows
  46102. */
  46103. rotationOffset: number;
  46104. /**
  46105. * Minimum allowed angle to camera position relative to target object.
  46106. * This can help limiting how the Camera is able to move in the scene.
  46107. */
  46108. lowerRotationOffsetLimit: Nullable<number>;
  46109. /**
  46110. * Maximum allowed angle to camera position relative to target object.
  46111. * This can help limiting how the Camera is able to move in the scene.
  46112. */
  46113. upperRotationOffsetLimit: Nullable<number>;
  46114. /**
  46115. * Define a height offset between the camera and the object it follows.
  46116. * It can help following an object from the top (like a car chaing a plane)
  46117. */
  46118. heightOffset: number;
  46119. /**
  46120. * Minimum allowed height of camera position relative to target object.
  46121. * This can help limiting how the Camera is able to move in the scene.
  46122. */
  46123. lowerHeightOffsetLimit: Nullable<number>;
  46124. /**
  46125. * Maximum allowed height of camera position relative to target object.
  46126. * This can help limiting how the Camera is able to move in the scene.
  46127. */
  46128. upperHeightOffsetLimit: Nullable<number>;
  46129. /**
  46130. * Define how fast the camera can accelerate to follow it s target.
  46131. */
  46132. cameraAcceleration: number;
  46133. /**
  46134. * Define the speed limit of the camera following an object.
  46135. */
  46136. maxCameraSpeed: number;
  46137. /**
  46138. * Define the target of the camera.
  46139. */
  46140. lockedTarget: Nullable<AbstractMesh>;
  46141. /**
  46142. * Defines the input associated with the camera.
  46143. */
  46144. inputs: FollowCameraInputsManager;
  46145. /**
  46146. * Instantiates the follow camera.
  46147. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46148. * @param name Define the name of the camera in the scene
  46149. * @param position Define the position of the camera
  46150. * @param scene Define the scene the camera belong to
  46151. * @param lockedTarget Define the target of the camera
  46152. */
  46153. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46154. private _follow;
  46155. /**
  46156. * Attached controls to the current camera.
  46157. * @param element Defines the element the controls should be listened from
  46158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46159. */
  46160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46161. /**
  46162. * Detach the current controls from the camera.
  46163. * The camera will stop reacting to inputs.
  46164. * @param element Defines the element to stop listening the inputs from
  46165. */
  46166. detachControl(element: HTMLElement): void;
  46167. /** @hidden */
  46168. _checkInputs(): void;
  46169. private _checkLimits;
  46170. /**
  46171. * Gets the camera class name.
  46172. * @returns the class name
  46173. */
  46174. getClassName(): string;
  46175. }
  46176. /**
  46177. * Arc Rotate version of the follow camera.
  46178. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46179. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46180. */
  46181. export class ArcFollowCamera extends TargetCamera {
  46182. /** The longitudinal angle of the camera */
  46183. alpha: number;
  46184. /** The latitudinal angle of the camera */
  46185. beta: number;
  46186. /** The radius of the camera from its target */
  46187. radius: number;
  46188. private _cartesianCoordinates;
  46189. /** Define the camera target (the mesh it should follow) */
  46190. private _meshTarget;
  46191. /**
  46192. * Instantiates a new ArcFollowCamera
  46193. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46194. * @param name Define the name of the camera
  46195. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46196. * @param beta Define the rotation angle of the camera around the elevation axis
  46197. * @param radius Define the radius of the camera from its target point
  46198. * @param target Define the target of the camera
  46199. * @param scene Define the scene the camera belongs to
  46200. */
  46201. constructor(name: string,
  46202. /** The longitudinal angle of the camera */
  46203. alpha: number,
  46204. /** The latitudinal angle of the camera */
  46205. beta: number,
  46206. /** The radius of the camera from its target */
  46207. radius: number,
  46208. /** Define the camera target (the mesh it should follow) */
  46209. target: Nullable<AbstractMesh>, scene: Scene);
  46210. private _follow;
  46211. /** @hidden */
  46212. _checkInputs(): void;
  46213. /**
  46214. * Returns the class name of the object.
  46215. * It is mostly used internally for serialization purposes.
  46216. */
  46217. getClassName(): string;
  46218. }
  46219. }
  46220. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46222. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46223. import { Nullable } from "babylonjs/types";
  46224. /**
  46225. * Manage the keyboard inputs to control the movement of a follow camera.
  46226. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46227. */
  46228. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46229. /**
  46230. * Defines the camera the input is attached to.
  46231. */
  46232. camera: FollowCamera;
  46233. /**
  46234. * Defines the list of key codes associated with the up action (increase heightOffset)
  46235. */
  46236. keysHeightOffsetIncr: number[];
  46237. /**
  46238. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46239. */
  46240. keysHeightOffsetDecr: number[];
  46241. /**
  46242. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46243. */
  46244. keysHeightOffsetModifierAlt: boolean;
  46245. /**
  46246. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46247. */
  46248. keysHeightOffsetModifierCtrl: boolean;
  46249. /**
  46250. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46251. */
  46252. keysHeightOffsetModifierShift: boolean;
  46253. /**
  46254. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46255. */
  46256. keysRotationOffsetIncr: number[];
  46257. /**
  46258. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46259. */
  46260. keysRotationOffsetDecr: number[];
  46261. /**
  46262. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46263. */
  46264. keysRotationOffsetModifierAlt: boolean;
  46265. /**
  46266. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46267. */
  46268. keysRotationOffsetModifierCtrl: boolean;
  46269. /**
  46270. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46271. */
  46272. keysRotationOffsetModifierShift: boolean;
  46273. /**
  46274. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46275. */
  46276. keysRadiusIncr: number[];
  46277. /**
  46278. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46279. */
  46280. keysRadiusDecr: number[];
  46281. /**
  46282. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46283. */
  46284. keysRadiusModifierAlt: boolean;
  46285. /**
  46286. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46287. */
  46288. keysRadiusModifierCtrl: boolean;
  46289. /**
  46290. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46291. */
  46292. keysRadiusModifierShift: boolean;
  46293. /**
  46294. * Defines the rate of change of heightOffset.
  46295. */
  46296. heightSensibility: number;
  46297. /**
  46298. * Defines the rate of change of rotationOffset.
  46299. */
  46300. rotationSensibility: number;
  46301. /**
  46302. * Defines the rate of change of radius.
  46303. */
  46304. radiusSensibility: number;
  46305. private _keys;
  46306. private _ctrlPressed;
  46307. private _altPressed;
  46308. private _shiftPressed;
  46309. private _onCanvasBlurObserver;
  46310. private _onKeyboardObserver;
  46311. private _engine;
  46312. private _scene;
  46313. /**
  46314. * Attach the input controls to a specific dom element to get the input from.
  46315. * @param element Defines the element the controls should be listened from
  46316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46317. */
  46318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46319. /**
  46320. * Detach the current controls from the specified dom element.
  46321. * @param element Defines the element to stop listening the inputs from
  46322. */
  46323. detachControl(element: Nullable<HTMLElement>): void;
  46324. /**
  46325. * Update the current camera state depending on the inputs that have been used this frame.
  46326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46327. */
  46328. checkInputs(): void;
  46329. /**
  46330. * Gets the class name of the current input.
  46331. * @returns the class name
  46332. */
  46333. getClassName(): string;
  46334. /**
  46335. * Get the friendly name associated with the input class.
  46336. * @returns the input friendly name
  46337. */
  46338. getSimpleName(): string;
  46339. /**
  46340. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46341. * allow modification of the heightOffset value.
  46342. */
  46343. private _modifierHeightOffset;
  46344. /**
  46345. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46346. * allow modification of the rotationOffset value.
  46347. */
  46348. private _modifierRotationOffset;
  46349. /**
  46350. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46351. * allow modification of the radius value.
  46352. */
  46353. private _modifierRadius;
  46354. }
  46355. }
  46356. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46357. import { Nullable } from "babylonjs/types";
  46358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46360. import { Observable } from "babylonjs/Misc/observable";
  46361. module "babylonjs/Cameras/freeCameraInputsManager" {
  46362. interface FreeCameraInputsManager {
  46363. /**
  46364. * @hidden
  46365. */
  46366. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46367. /**
  46368. * Add orientation input support to the input manager.
  46369. * @returns the current input manager
  46370. */
  46371. addDeviceOrientation(): FreeCameraInputsManager;
  46372. }
  46373. }
  46374. /**
  46375. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46376. * Screen rotation is taken into account.
  46377. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46378. */
  46379. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46380. private _camera;
  46381. private _screenOrientationAngle;
  46382. private _constantTranform;
  46383. private _screenQuaternion;
  46384. private _alpha;
  46385. private _beta;
  46386. private _gamma;
  46387. /**
  46388. * Can be used to detect if a device orientation sensor is available on a device
  46389. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46390. * @returns a promise that will resolve on orientation change
  46391. */
  46392. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46393. /**
  46394. * @hidden
  46395. */
  46396. _onDeviceOrientationChangedObservable: Observable<void>;
  46397. /**
  46398. * Instantiates a new input
  46399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46400. */
  46401. constructor();
  46402. /**
  46403. * Define the camera controlled by the input.
  46404. */
  46405. get camera(): FreeCamera;
  46406. set camera(camera: FreeCamera);
  46407. /**
  46408. * Attach the input controls to a specific dom element to get the input from.
  46409. * @param element Defines the element the controls should be listened from
  46410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46411. */
  46412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46413. private _orientationChanged;
  46414. private _deviceOrientation;
  46415. /**
  46416. * Detach the current controls from the specified dom element.
  46417. * @param element Defines the element to stop listening the inputs from
  46418. */
  46419. detachControl(element: Nullable<HTMLElement>): void;
  46420. /**
  46421. * Update the current camera state depending on the inputs that have been used this frame.
  46422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46423. */
  46424. checkInputs(): void;
  46425. /**
  46426. * Gets the class name of the current intput.
  46427. * @returns the class name
  46428. */
  46429. getClassName(): string;
  46430. /**
  46431. * Get the friendly name associated with the input class.
  46432. * @returns the input friendly name
  46433. */
  46434. getSimpleName(): string;
  46435. }
  46436. }
  46437. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46438. import { Nullable } from "babylonjs/types";
  46439. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46440. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46441. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46442. /**
  46443. * Manage the gamepad inputs to control a free camera.
  46444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46445. */
  46446. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46447. /**
  46448. * Define the camera the input is attached to.
  46449. */
  46450. camera: FreeCamera;
  46451. /**
  46452. * Define the Gamepad controlling the input
  46453. */
  46454. gamepad: Nullable<Gamepad>;
  46455. /**
  46456. * Defines the gamepad rotation sensiblity.
  46457. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46458. */
  46459. gamepadAngularSensibility: number;
  46460. /**
  46461. * Defines the gamepad move sensiblity.
  46462. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46463. */
  46464. gamepadMoveSensibility: number;
  46465. private _yAxisScale;
  46466. /**
  46467. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46468. */
  46469. get invertYAxis(): boolean;
  46470. set invertYAxis(value: boolean);
  46471. private _onGamepadConnectedObserver;
  46472. private _onGamepadDisconnectedObserver;
  46473. private _cameraTransform;
  46474. private _deltaTransform;
  46475. private _vector3;
  46476. private _vector2;
  46477. /**
  46478. * Attach the input controls to a specific dom element to get the input from.
  46479. * @param element Defines the element the controls should be listened from
  46480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46481. */
  46482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46483. /**
  46484. * Detach the current controls from the specified dom element.
  46485. * @param element Defines the element to stop listening the inputs from
  46486. */
  46487. detachControl(element: Nullable<HTMLElement>): void;
  46488. /**
  46489. * Update the current camera state depending on the inputs that have been used this frame.
  46490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46491. */
  46492. checkInputs(): void;
  46493. /**
  46494. * Gets the class name of the current intput.
  46495. * @returns the class name
  46496. */
  46497. getClassName(): string;
  46498. /**
  46499. * Get the friendly name associated with the input class.
  46500. * @returns the input friendly name
  46501. */
  46502. getSimpleName(): string;
  46503. }
  46504. }
  46505. declare module "babylonjs/Misc/virtualJoystick" {
  46506. import { Nullable } from "babylonjs/types";
  46507. import { Vector3 } from "babylonjs/Maths/math.vector";
  46508. /**
  46509. * Defines the potential axis of a Joystick
  46510. */
  46511. export enum JoystickAxis {
  46512. /** X axis */
  46513. X = 0,
  46514. /** Y axis */
  46515. Y = 1,
  46516. /** Z axis */
  46517. Z = 2
  46518. }
  46519. /**
  46520. * Represents the different customization options available
  46521. * for VirtualJoystick
  46522. */
  46523. interface VirtualJoystickCustomizations {
  46524. /**
  46525. * Size of the joystick's puck
  46526. */
  46527. puckSize: number;
  46528. /**
  46529. * Size of the joystick's container
  46530. */
  46531. containerSize: number;
  46532. /**
  46533. * Color of the joystick && puck
  46534. */
  46535. color: string;
  46536. /**
  46537. * Image URL for the joystick's puck
  46538. */
  46539. puckImage?: string;
  46540. /**
  46541. * Image URL for the joystick's container
  46542. */
  46543. containerImage?: string;
  46544. /**
  46545. * Defines the unmoving position of the joystick container
  46546. */
  46547. position?: {
  46548. x: number;
  46549. y: number;
  46550. };
  46551. /**
  46552. * Defines whether or not the joystick container is always visible
  46553. */
  46554. alwaysVisible: boolean;
  46555. /**
  46556. * Defines whether or not to limit the movement of the puck to the joystick's container
  46557. */
  46558. limitToContainer: boolean;
  46559. }
  46560. /**
  46561. * Class used to define virtual joystick (used in touch mode)
  46562. */
  46563. export class VirtualJoystick {
  46564. /**
  46565. * Gets or sets a boolean indicating that left and right values must be inverted
  46566. */
  46567. reverseLeftRight: boolean;
  46568. /**
  46569. * Gets or sets a boolean indicating that up and down values must be inverted
  46570. */
  46571. reverseUpDown: boolean;
  46572. /**
  46573. * Gets the offset value for the position (ie. the change of the position value)
  46574. */
  46575. deltaPosition: Vector3;
  46576. /**
  46577. * Gets a boolean indicating if the virtual joystick was pressed
  46578. */
  46579. pressed: boolean;
  46580. /**
  46581. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46582. */
  46583. static Canvas: Nullable<HTMLCanvasElement>;
  46584. /**
  46585. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46586. */
  46587. limitToContainer: boolean;
  46588. private static _globalJoystickIndex;
  46589. private static _alwaysVisibleSticks;
  46590. private static vjCanvasContext;
  46591. private static vjCanvasWidth;
  46592. private static vjCanvasHeight;
  46593. private static halfWidth;
  46594. private static _GetDefaultOptions;
  46595. private _action;
  46596. private _axisTargetedByLeftAndRight;
  46597. private _axisTargetedByUpAndDown;
  46598. private _joystickSensibility;
  46599. private _inversedSensibility;
  46600. private _joystickPointerID;
  46601. private _joystickColor;
  46602. private _joystickPointerPos;
  46603. private _joystickPreviousPointerPos;
  46604. private _joystickPointerStartPos;
  46605. private _deltaJoystickVector;
  46606. private _leftJoystick;
  46607. private _touches;
  46608. private _joystickPosition;
  46609. private _alwaysVisible;
  46610. private _puckImage;
  46611. private _containerImage;
  46612. private _joystickPuckSize;
  46613. private _joystickContainerSize;
  46614. private _clearPuckSize;
  46615. private _clearContainerSize;
  46616. private _clearPuckSizeOffset;
  46617. private _clearContainerSizeOffset;
  46618. private _onPointerDownHandlerRef;
  46619. private _onPointerMoveHandlerRef;
  46620. private _onPointerUpHandlerRef;
  46621. private _onResize;
  46622. /**
  46623. * Creates a new virtual joystick
  46624. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46625. * @param customizations Defines the options we want to customize the VirtualJoystick
  46626. */
  46627. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46628. /**
  46629. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46630. * @param newJoystickSensibility defines the new sensibility
  46631. */
  46632. setJoystickSensibility(newJoystickSensibility: number): void;
  46633. private _onPointerDown;
  46634. private _onPointerMove;
  46635. private _onPointerUp;
  46636. /**
  46637. * Change the color of the virtual joystick
  46638. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46639. */
  46640. setJoystickColor(newColor: string): void;
  46641. /**
  46642. * Size of the joystick's container
  46643. */
  46644. set containerSize(newSize: number);
  46645. get containerSize(): number;
  46646. /**
  46647. * Size of the joystick's puck
  46648. */
  46649. set puckSize(newSize: number);
  46650. get puckSize(): number;
  46651. /**
  46652. * Clears the set position of the joystick
  46653. */
  46654. clearPosition(): void;
  46655. /**
  46656. * Defines whether or not the joystick container is always visible
  46657. */
  46658. set alwaysVisible(value: boolean);
  46659. get alwaysVisible(): boolean;
  46660. /**
  46661. * Sets the constant position of the Joystick container
  46662. * @param x X axis coordinate
  46663. * @param y Y axis coordinate
  46664. */
  46665. setPosition(x: number, y: number): void;
  46666. /**
  46667. * Defines a callback to call when the joystick is touched
  46668. * @param action defines the callback
  46669. */
  46670. setActionOnTouch(action: () => any): void;
  46671. /**
  46672. * Defines which axis you'd like to control for left & right
  46673. * @param axis defines the axis to use
  46674. */
  46675. setAxisForLeftRight(axis: JoystickAxis): void;
  46676. /**
  46677. * Defines which axis you'd like to control for up & down
  46678. * @param axis defines the axis to use
  46679. */
  46680. setAxisForUpDown(axis: JoystickAxis): void;
  46681. /**
  46682. * Clears the canvas from the previous puck / container draw
  46683. */
  46684. private _clearPreviousDraw;
  46685. /**
  46686. * Loads `urlPath` to be used for the container's image
  46687. * @param urlPath defines the urlPath of an image to use
  46688. */
  46689. setContainerImage(urlPath: string): void;
  46690. /**
  46691. * Loads `urlPath` to be used for the puck's image
  46692. * @param urlPath defines the urlPath of an image to use
  46693. */
  46694. setPuckImage(urlPath: string): void;
  46695. /**
  46696. * Draws the Virtual Joystick's container
  46697. */
  46698. private _drawContainer;
  46699. /**
  46700. * Draws the Virtual Joystick's puck
  46701. */
  46702. private _drawPuck;
  46703. private _drawVirtualJoystick;
  46704. /**
  46705. * Release internal HTML canvas
  46706. */
  46707. releaseCanvas(): void;
  46708. }
  46709. }
  46710. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46711. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46712. import { Nullable } from "babylonjs/types";
  46713. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46714. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46715. module "babylonjs/Cameras/freeCameraInputsManager" {
  46716. interface FreeCameraInputsManager {
  46717. /**
  46718. * Add virtual joystick input support to the input manager.
  46719. * @returns the current input manager
  46720. */
  46721. addVirtualJoystick(): FreeCameraInputsManager;
  46722. }
  46723. }
  46724. /**
  46725. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46727. */
  46728. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46729. /**
  46730. * Defines the camera the input is attached to.
  46731. */
  46732. camera: FreeCamera;
  46733. private _leftjoystick;
  46734. private _rightjoystick;
  46735. /**
  46736. * Gets the left stick of the virtual joystick.
  46737. * @returns The virtual Joystick
  46738. */
  46739. getLeftJoystick(): VirtualJoystick;
  46740. /**
  46741. * Gets the right stick of the virtual joystick.
  46742. * @returns The virtual Joystick
  46743. */
  46744. getRightJoystick(): VirtualJoystick;
  46745. /**
  46746. * Update the current camera state depending on the inputs that have been used this frame.
  46747. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46748. */
  46749. checkInputs(): void;
  46750. /**
  46751. * Attach the input controls to a specific dom element to get the input from.
  46752. * @param element Defines the element the controls should be listened from
  46753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46754. */
  46755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46756. /**
  46757. * Detach the current controls from the specified dom element.
  46758. * @param element Defines the element to stop listening the inputs from
  46759. */
  46760. detachControl(element: Nullable<HTMLElement>): void;
  46761. /**
  46762. * Gets the class name of the current intput.
  46763. * @returns the class name
  46764. */
  46765. getClassName(): string;
  46766. /**
  46767. * Get the friendly name associated with the input class.
  46768. * @returns the input friendly name
  46769. */
  46770. getSimpleName(): string;
  46771. }
  46772. }
  46773. declare module "babylonjs/Cameras/Inputs/index" {
  46774. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46775. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46776. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46777. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46778. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46779. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46780. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46781. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46782. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46783. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46784. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46785. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46786. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46787. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46788. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46789. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46790. }
  46791. declare module "babylonjs/Cameras/touchCamera" {
  46792. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46793. import { Scene } from "babylonjs/scene";
  46794. import { Vector3 } from "babylonjs/Maths/math.vector";
  46795. /**
  46796. * This represents a FPS type of camera controlled by touch.
  46797. * This is like a universal camera minus the Gamepad controls.
  46798. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46799. */
  46800. export class TouchCamera extends FreeCamera {
  46801. /**
  46802. * Defines the touch sensibility for rotation.
  46803. * The higher the faster.
  46804. */
  46805. get touchAngularSensibility(): number;
  46806. set touchAngularSensibility(value: number);
  46807. /**
  46808. * Defines the touch sensibility for move.
  46809. * The higher the faster.
  46810. */
  46811. get touchMoveSensibility(): number;
  46812. set touchMoveSensibility(value: number);
  46813. /**
  46814. * Instantiates a new touch camera.
  46815. * This represents a FPS type of camera controlled by touch.
  46816. * This is like a universal camera minus the Gamepad controls.
  46817. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46818. * @param name Define the name of the camera in the scene
  46819. * @param position Define the start position of the camera in the scene
  46820. * @param scene Define the scene the camera belongs to
  46821. */
  46822. constructor(name: string, position: Vector3, scene: Scene);
  46823. /**
  46824. * Gets the current object class name.
  46825. * @return the class name
  46826. */
  46827. getClassName(): string;
  46828. /** @hidden */
  46829. _setupInputs(): void;
  46830. }
  46831. }
  46832. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46834. import { Scene } from "babylonjs/scene";
  46835. import { Vector3 } from "babylonjs/Maths/math.vector";
  46836. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46837. import { Axis } from "babylonjs/Maths/math.axis";
  46838. /**
  46839. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46840. * being tilted forward or back and left or right.
  46841. */
  46842. export class DeviceOrientationCamera extends FreeCamera {
  46843. private _initialQuaternion;
  46844. private _quaternionCache;
  46845. private _tmpDragQuaternion;
  46846. private _disablePointerInputWhenUsingDeviceOrientation;
  46847. /**
  46848. * Creates a new device orientation camera
  46849. * @param name The name of the camera
  46850. * @param position The start position camera
  46851. * @param scene The scene the camera belongs to
  46852. */
  46853. constructor(name: string, position: Vector3, scene: Scene);
  46854. /**
  46855. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46856. */
  46857. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46858. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46859. private _dragFactor;
  46860. /**
  46861. * Enabled turning on the y axis when the orientation sensor is active
  46862. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46863. */
  46864. enableHorizontalDragging(dragFactor?: number): void;
  46865. /**
  46866. * Gets the current instance class name ("DeviceOrientationCamera").
  46867. * This helps avoiding instanceof at run time.
  46868. * @returns the class name
  46869. */
  46870. getClassName(): string;
  46871. /**
  46872. * @hidden
  46873. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46874. */
  46875. _checkInputs(): void;
  46876. /**
  46877. * Reset the camera to its default orientation on the specified axis only.
  46878. * @param axis The axis to reset
  46879. */
  46880. resetToCurrentRotation(axis?: Axis): void;
  46881. }
  46882. }
  46883. declare module "babylonjs/Gamepads/xboxGamepad" {
  46884. import { Observable } from "babylonjs/Misc/observable";
  46885. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46886. /**
  46887. * Defines supported buttons for XBox360 compatible gamepads
  46888. */
  46889. export enum Xbox360Button {
  46890. /** A */
  46891. A = 0,
  46892. /** B */
  46893. B = 1,
  46894. /** X */
  46895. X = 2,
  46896. /** Y */
  46897. Y = 3,
  46898. /** Left button */
  46899. LB = 4,
  46900. /** Right button */
  46901. RB = 5,
  46902. /** Back */
  46903. Back = 8,
  46904. /** Start */
  46905. Start = 9,
  46906. /** Left stick */
  46907. LeftStick = 10,
  46908. /** Right stick */
  46909. RightStick = 11
  46910. }
  46911. /** Defines values for XBox360 DPad */
  46912. export enum Xbox360Dpad {
  46913. /** Up */
  46914. Up = 12,
  46915. /** Down */
  46916. Down = 13,
  46917. /** Left */
  46918. Left = 14,
  46919. /** Right */
  46920. Right = 15
  46921. }
  46922. /**
  46923. * Defines a XBox360 gamepad
  46924. */
  46925. export class Xbox360Pad extends Gamepad {
  46926. private _leftTrigger;
  46927. private _rightTrigger;
  46928. private _onlefttriggerchanged;
  46929. private _onrighttriggerchanged;
  46930. private _onbuttondown;
  46931. private _onbuttonup;
  46932. private _ondpaddown;
  46933. private _ondpadup;
  46934. /** Observable raised when a button is pressed */
  46935. onButtonDownObservable: Observable<Xbox360Button>;
  46936. /** Observable raised when a button is released */
  46937. onButtonUpObservable: Observable<Xbox360Button>;
  46938. /** Observable raised when a pad is pressed */
  46939. onPadDownObservable: Observable<Xbox360Dpad>;
  46940. /** Observable raised when a pad is released */
  46941. onPadUpObservable: Observable<Xbox360Dpad>;
  46942. private _buttonA;
  46943. private _buttonB;
  46944. private _buttonX;
  46945. private _buttonY;
  46946. private _buttonBack;
  46947. private _buttonStart;
  46948. private _buttonLB;
  46949. private _buttonRB;
  46950. private _buttonLeftStick;
  46951. private _buttonRightStick;
  46952. private _dPadUp;
  46953. private _dPadDown;
  46954. private _dPadLeft;
  46955. private _dPadRight;
  46956. private _isXboxOnePad;
  46957. /**
  46958. * Creates a new XBox360 gamepad object
  46959. * @param id defines the id of this gamepad
  46960. * @param index defines its index
  46961. * @param gamepad defines the internal HTML gamepad object
  46962. * @param xboxOne defines if it is a XBox One gamepad
  46963. */
  46964. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46965. /**
  46966. * Defines the callback to call when left trigger is pressed
  46967. * @param callback defines the callback to use
  46968. */
  46969. onlefttriggerchanged(callback: (value: number) => void): void;
  46970. /**
  46971. * Defines the callback to call when right trigger is pressed
  46972. * @param callback defines the callback to use
  46973. */
  46974. onrighttriggerchanged(callback: (value: number) => void): void;
  46975. /**
  46976. * Gets the left trigger value
  46977. */
  46978. get leftTrigger(): number;
  46979. /**
  46980. * Sets the left trigger value
  46981. */
  46982. set leftTrigger(newValue: number);
  46983. /**
  46984. * Gets the right trigger value
  46985. */
  46986. get rightTrigger(): number;
  46987. /**
  46988. * Sets the right trigger value
  46989. */
  46990. set rightTrigger(newValue: number);
  46991. /**
  46992. * Defines the callback to call when a button is pressed
  46993. * @param callback defines the callback to use
  46994. */
  46995. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46996. /**
  46997. * Defines the callback to call when a button is released
  46998. * @param callback defines the callback to use
  46999. */
  47000. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47001. /**
  47002. * Defines the callback to call when a pad is pressed
  47003. * @param callback defines the callback to use
  47004. */
  47005. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47006. /**
  47007. * Defines the callback to call when a pad is released
  47008. * @param callback defines the callback to use
  47009. */
  47010. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47011. private _setButtonValue;
  47012. private _setDPadValue;
  47013. /**
  47014. * Gets the value of the `A` button
  47015. */
  47016. get buttonA(): number;
  47017. /**
  47018. * Sets the value of the `A` button
  47019. */
  47020. set buttonA(value: number);
  47021. /**
  47022. * Gets the value of the `B` button
  47023. */
  47024. get buttonB(): number;
  47025. /**
  47026. * Sets the value of the `B` button
  47027. */
  47028. set buttonB(value: number);
  47029. /**
  47030. * Gets the value of the `X` button
  47031. */
  47032. get buttonX(): number;
  47033. /**
  47034. * Sets the value of the `X` button
  47035. */
  47036. set buttonX(value: number);
  47037. /**
  47038. * Gets the value of the `Y` button
  47039. */
  47040. get buttonY(): number;
  47041. /**
  47042. * Sets the value of the `Y` button
  47043. */
  47044. set buttonY(value: number);
  47045. /**
  47046. * Gets the value of the `Start` button
  47047. */
  47048. get buttonStart(): number;
  47049. /**
  47050. * Sets the value of the `Start` button
  47051. */
  47052. set buttonStart(value: number);
  47053. /**
  47054. * Gets the value of the `Back` button
  47055. */
  47056. get buttonBack(): number;
  47057. /**
  47058. * Sets the value of the `Back` button
  47059. */
  47060. set buttonBack(value: number);
  47061. /**
  47062. * Gets the value of the `Left` button
  47063. */
  47064. get buttonLB(): number;
  47065. /**
  47066. * Sets the value of the `Left` button
  47067. */
  47068. set buttonLB(value: number);
  47069. /**
  47070. * Gets the value of the `Right` button
  47071. */
  47072. get buttonRB(): number;
  47073. /**
  47074. * Sets the value of the `Right` button
  47075. */
  47076. set buttonRB(value: number);
  47077. /**
  47078. * Gets the value of the Left joystick
  47079. */
  47080. get buttonLeftStick(): number;
  47081. /**
  47082. * Sets the value of the Left joystick
  47083. */
  47084. set buttonLeftStick(value: number);
  47085. /**
  47086. * Gets the value of the Right joystick
  47087. */
  47088. get buttonRightStick(): number;
  47089. /**
  47090. * Sets the value of the Right joystick
  47091. */
  47092. set buttonRightStick(value: number);
  47093. /**
  47094. * Gets the value of D-pad up
  47095. */
  47096. get dPadUp(): number;
  47097. /**
  47098. * Sets the value of D-pad up
  47099. */
  47100. set dPadUp(value: number);
  47101. /**
  47102. * Gets the value of D-pad down
  47103. */
  47104. get dPadDown(): number;
  47105. /**
  47106. * Sets the value of D-pad down
  47107. */
  47108. set dPadDown(value: number);
  47109. /**
  47110. * Gets the value of D-pad left
  47111. */
  47112. get dPadLeft(): number;
  47113. /**
  47114. * Sets the value of D-pad left
  47115. */
  47116. set dPadLeft(value: number);
  47117. /**
  47118. * Gets the value of D-pad right
  47119. */
  47120. get dPadRight(): number;
  47121. /**
  47122. * Sets the value of D-pad right
  47123. */
  47124. set dPadRight(value: number);
  47125. /**
  47126. * Force the gamepad to synchronize with device values
  47127. */
  47128. update(): void;
  47129. /**
  47130. * Disposes the gamepad
  47131. */
  47132. dispose(): void;
  47133. }
  47134. }
  47135. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47136. import { Observable } from "babylonjs/Misc/observable";
  47137. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47138. /**
  47139. * Defines supported buttons for DualShock compatible gamepads
  47140. */
  47141. export enum DualShockButton {
  47142. /** Cross */
  47143. Cross = 0,
  47144. /** Circle */
  47145. Circle = 1,
  47146. /** Square */
  47147. Square = 2,
  47148. /** Triangle */
  47149. Triangle = 3,
  47150. /** L1 */
  47151. L1 = 4,
  47152. /** R1 */
  47153. R1 = 5,
  47154. /** Share */
  47155. Share = 8,
  47156. /** Options */
  47157. Options = 9,
  47158. /** Left stick */
  47159. LeftStick = 10,
  47160. /** Right stick */
  47161. RightStick = 11
  47162. }
  47163. /** Defines values for DualShock DPad */
  47164. export enum DualShockDpad {
  47165. /** Up */
  47166. Up = 12,
  47167. /** Down */
  47168. Down = 13,
  47169. /** Left */
  47170. Left = 14,
  47171. /** Right */
  47172. Right = 15
  47173. }
  47174. /**
  47175. * Defines a DualShock gamepad
  47176. */
  47177. export class DualShockPad extends Gamepad {
  47178. private _leftTrigger;
  47179. private _rightTrigger;
  47180. private _onlefttriggerchanged;
  47181. private _onrighttriggerchanged;
  47182. private _onbuttondown;
  47183. private _onbuttonup;
  47184. private _ondpaddown;
  47185. private _ondpadup;
  47186. /** Observable raised when a button is pressed */
  47187. onButtonDownObservable: Observable<DualShockButton>;
  47188. /** Observable raised when a button is released */
  47189. onButtonUpObservable: Observable<DualShockButton>;
  47190. /** Observable raised when a pad is pressed */
  47191. onPadDownObservable: Observable<DualShockDpad>;
  47192. /** Observable raised when a pad is released */
  47193. onPadUpObservable: Observable<DualShockDpad>;
  47194. private _buttonCross;
  47195. private _buttonCircle;
  47196. private _buttonSquare;
  47197. private _buttonTriangle;
  47198. private _buttonShare;
  47199. private _buttonOptions;
  47200. private _buttonL1;
  47201. private _buttonR1;
  47202. private _buttonLeftStick;
  47203. private _buttonRightStick;
  47204. private _dPadUp;
  47205. private _dPadDown;
  47206. private _dPadLeft;
  47207. private _dPadRight;
  47208. /**
  47209. * Creates a new DualShock gamepad object
  47210. * @param id defines the id of this gamepad
  47211. * @param index defines its index
  47212. * @param gamepad defines the internal HTML gamepad object
  47213. */
  47214. constructor(id: string, index: number, gamepad: any);
  47215. /**
  47216. * Defines the callback to call when left trigger is pressed
  47217. * @param callback defines the callback to use
  47218. */
  47219. onlefttriggerchanged(callback: (value: number) => void): void;
  47220. /**
  47221. * Defines the callback to call when right trigger is pressed
  47222. * @param callback defines the callback to use
  47223. */
  47224. onrighttriggerchanged(callback: (value: number) => void): void;
  47225. /**
  47226. * Gets the left trigger value
  47227. */
  47228. get leftTrigger(): number;
  47229. /**
  47230. * Sets the left trigger value
  47231. */
  47232. set leftTrigger(newValue: number);
  47233. /**
  47234. * Gets the right trigger value
  47235. */
  47236. get rightTrigger(): number;
  47237. /**
  47238. * Sets the right trigger value
  47239. */
  47240. set rightTrigger(newValue: number);
  47241. /**
  47242. * Defines the callback to call when a button is pressed
  47243. * @param callback defines the callback to use
  47244. */
  47245. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47246. /**
  47247. * Defines the callback to call when a button is released
  47248. * @param callback defines the callback to use
  47249. */
  47250. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47251. /**
  47252. * Defines the callback to call when a pad is pressed
  47253. * @param callback defines the callback to use
  47254. */
  47255. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47256. /**
  47257. * Defines the callback to call when a pad is released
  47258. * @param callback defines the callback to use
  47259. */
  47260. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47261. private _setButtonValue;
  47262. private _setDPadValue;
  47263. /**
  47264. * Gets the value of the `Cross` button
  47265. */
  47266. get buttonCross(): number;
  47267. /**
  47268. * Sets the value of the `Cross` button
  47269. */
  47270. set buttonCross(value: number);
  47271. /**
  47272. * Gets the value of the `Circle` button
  47273. */
  47274. get buttonCircle(): number;
  47275. /**
  47276. * Sets the value of the `Circle` button
  47277. */
  47278. set buttonCircle(value: number);
  47279. /**
  47280. * Gets the value of the `Square` button
  47281. */
  47282. get buttonSquare(): number;
  47283. /**
  47284. * Sets the value of the `Square` button
  47285. */
  47286. set buttonSquare(value: number);
  47287. /**
  47288. * Gets the value of the `Triangle` button
  47289. */
  47290. get buttonTriangle(): number;
  47291. /**
  47292. * Sets the value of the `Triangle` button
  47293. */
  47294. set buttonTriangle(value: number);
  47295. /**
  47296. * Gets the value of the `Options` button
  47297. */
  47298. get buttonOptions(): number;
  47299. /**
  47300. * Sets the value of the `Options` button
  47301. */
  47302. set buttonOptions(value: number);
  47303. /**
  47304. * Gets the value of the `Share` button
  47305. */
  47306. get buttonShare(): number;
  47307. /**
  47308. * Sets the value of the `Share` button
  47309. */
  47310. set buttonShare(value: number);
  47311. /**
  47312. * Gets the value of the `L1` button
  47313. */
  47314. get buttonL1(): number;
  47315. /**
  47316. * Sets the value of the `L1` button
  47317. */
  47318. set buttonL1(value: number);
  47319. /**
  47320. * Gets the value of the `R1` button
  47321. */
  47322. get buttonR1(): number;
  47323. /**
  47324. * Sets the value of the `R1` button
  47325. */
  47326. set buttonR1(value: number);
  47327. /**
  47328. * Gets the value of the Left joystick
  47329. */
  47330. get buttonLeftStick(): number;
  47331. /**
  47332. * Sets the value of the Left joystick
  47333. */
  47334. set buttonLeftStick(value: number);
  47335. /**
  47336. * Gets the value of the Right joystick
  47337. */
  47338. get buttonRightStick(): number;
  47339. /**
  47340. * Sets the value of the Right joystick
  47341. */
  47342. set buttonRightStick(value: number);
  47343. /**
  47344. * Gets the value of D-pad up
  47345. */
  47346. get dPadUp(): number;
  47347. /**
  47348. * Sets the value of D-pad up
  47349. */
  47350. set dPadUp(value: number);
  47351. /**
  47352. * Gets the value of D-pad down
  47353. */
  47354. get dPadDown(): number;
  47355. /**
  47356. * Sets the value of D-pad down
  47357. */
  47358. set dPadDown(value: number);
  47359. /**
  47360. * Gets the value of D-pad left
  47361. */
  47362. get dPadLeft(): number;
  47363. /**
  47364. * Sets the value of D-pad left
  47365. */
  47366. set dPadLeft(value: number);
  47367. /**
  47368. * Gets the value of D-pad right
  47369. */
  47370. get dPadRight(): number;
  47371. /**
  47372. * Sets the value of D-pad right
  47373. */
  47374. set dPadRight(value: number);
  47375. /**
  47376. * Force the gamepad to synchronize with device values
  47377. */
  47378. update(): void;
  47379. /**
  47380. * Disposes the gamepad
  47381. */
  47382. dispose(): void;
  47383. }
  47384. }
  47385. declare module "babylonjs/Gamepads/gamepadManager" {
  47386. import { Observable } from "babylonjs/Misc/observable";
  47387. import { Nullable } from "babylonjs/types";
  47388. import { Scene } from "babylonjs/scene";
  47389. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47390. /**
  47391. * Manager for handling gamepads
  47392. */
  47393. export class GamepadManager {
  47394. private _scene?;
  47395. private _babylonGamepads;
  47396. private _oneGamepadConnected;
  47397. /** @hidden */
  47398. _isMonitoring: boolean;
  47399. private _gamepadEventSupported;
  47400. private _gamepadSupport?;
  47401. /**
  47402. * observable to be triggered when the gamepad controller has been connected
  47403. */
  47404. onGamepadConnectedObservable: Observable<Gamepad>;
  47405. /**
  47406. * observable to be triggered when the gamepad controller has been disconnected
  47407. */
  47408. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47409. private _onGamepadConnectedEvent;
  47410. private _onGamepadDisconnectedEvent;
  47411. /**
  47412. * Initializes the gamepad manager
  47413. * @param _scene BabylonJS scene
  47414. */
  47415. constructor(_scene?: Scene | undefined);
  47416. /**
  47417. * The gamepads in the game pad manager
  47418. */
  47419. get gamepads(): Gamepad[];
  47420. /**
  47421. * Get the gamepad controllers based on type
  47422. * @param type The type of gamepad controller
  47423. * @returns Nullable gamepad
  47424. */
  47425. getGamepadByType(type?: number): Nullable<Gamepad>;
  47426. /**
  47427. * Disposes the gamepad manager
  47428. */
  47429. dispose(): void;
  47430. private _addNewGamepad;
  47431. private _startMonitoringGamepads;
  47432. private _stopMonitoringGamepads;
  47433. /** @hidden */
  47434. _checkGamepadsStatus(): void;
  47435. private _updateGamepadObjects;
  47436. }
  47437. }
  47438. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47439. import { Nullable } from "babylonjs/types";
  47440. import { Scene } from "babylonjs/scene";
  47441. import { ISceneComponent } from "babylonjs/sceneComponent";
  47442. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47443. module "babylonjs/scene" {
  47444. interface Scene {
  47445. /** @hidden */
  47446. _gamepadManager: Nullable<GamepadManager>;
  47447. /**
  47448. * Gets the gamepad manager associated with the scene
  47449. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47450. */
  47451. gamepadManager: GamepadManager;
  47452. }
  47453. }
  47454. module "babylonjs/Cameras/freeCameraInputsManager" {
  47455. /**
  47456. * Interface representing a free camera inputs manager
  47457. */
  47458. interface FreeCameraInputsManager {
  47459. /**
  47460. * Adds gamepad input support to the FreeCameraInputsManager.
  47461. * @returns the FreeCameraInputsManager
  47462. */
  47463. addGamepad(): FreeCameraInputsManager;
  47464. }
  47465. }
  47466. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47467. /**
  47468. * Interface representing an arc rotate camera inputs manager
  47469. */
  47470. interface ArcRotateCameraInputsManager {
  47471. /**
  47472. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47473. * @returns the camera inputs manager
  47474. */
  47475. addGamepad(): ArcRotateCameraInputsManager;
  47476. }
  47477. }
  47478. /**
  47479. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47480. */
  47481. export class GamepadSystemSceneComponent implements ISceneComponent {
  47482. /**
  47483. * The component name helpfull to identify the component in the list of scene components.
  47484. */
  47485. readonly name: string;
  47486. /**
  47487. * The scene the component belongs to.
  47488. */
  47489. scene: Scene;
  47490. /**
  47491. * Creates a new instance of the component for the given scene
  47492. * @param scene Defines the scene to register the component in
  47493. */
  47494. constructor(scene: Scene);
  47495. /**
  47496. * Registers the component in a given scene
  47497. */
  47498. register(): void;
  47499. /**
  47500. * Rebuilds the elements related to this component in case of
  47501. * context lost for instance.
  47502. */
  47503. rebuild(): void;
  47504. /**
  47505. * Disposes the component and the associated ressources
  47506. */
  47507. dispose(): void;
  47508. private _beforeCameraUpdate;
  47509. }
  47510. }
  47511. declare module "babylonjs/Cameras/universalCamera" {
  47512. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47513. import { Scene } from "babylonjs/scene";
  47514. import { Vector3 } from "babylonjs/Maths/math.vector";
  47515. import "babylonjs/Gamepads/gamepadSceneComponent";
  47516. /**
  47517. * 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,
  47518. * which still works and will still be found in many Playgrounds.
  47519. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47520. */
  47521. export class UniversalCamera extends TouchCamera {
  47522. /**
  47523. * Defines the gamepad rotation sensiblity.
  47524. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47525. */
  47526. get gamepadAngularSensibility(): number;
  47527. set gamepadAngularSensibility(value: number);
  47528. /**
  47529. * Defines the gamepad move sensiblity.
  47530. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47531. */
  47532. get gamepadMoveSensibility(): number;
  47533. set gamepadMoveSensibility(value: number);
  47534. /**
  47535. * 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,
  47536. * which still works and will still be found in many Playgrounds.
  47537. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47538. * @param name Define the name of the camera in the scene
  47539. * @param position Define the start position of the camera in the scene
  47540. * @param scene Define the scene the camera belongs to
  47541. */
  47542. constructor(name: string, position: Vector3, scene: Scene);
  47543. /**
  47544. * Gets the current object class name.
  47545. * @return the class name
  47546. */
  47547. getClassName(): string;
  47548. }
  47549. }
  47550. declare module "babylonjs/Cameras/gamepadCamera" {
  47551. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47552. import { Scene } from "babylonjs/scene";
  47553. import { Vector3 } from "babylonjs/Maths/math.vector";
  47554. /**
  47555. * This represents a FPS type of camera. This is only here for back compat purpose.
  47556. * Please use the UniversalCamera instead as both are identical.
  47557. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47558. */
  47559. export class GamepadCamera extends UniversalCamera {
  47560. /**
  47561. * Instantiates a new Gamepad Camera
  47562. * This represents a FPS type of camera. This is only here for back compat purpose.
  47563. * Please use the UniversalCamera instead as both are identical.
  47564. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47565. * @param name Define the name of the camera in the scene
  47566. * @param position Define the start position of the camera in the scene
  47567. * @param scene Define the scene the camera belongs to
  47568. */
  47569. constructor(name: string, position: Vector3, scene: Scene);
  47570. /**
  47571. * Gets the current object class name.
  47572. * @return the class name
  47573. */
  47574. getClassName(): string;
  47575. }
  47576. }
  47577. declare module "babylonjs/Shaders/pass.fragment" {
  47578. /** @hidden */
  47579. export var passPixelShader: {
  47580. name: string;
  47581. shader: string;
  47582. };
  47583. }
  47584. declare module "babylonjs/Shaders/passCube.fragment" {
  47585. /** @hidden */
  47586. export var passCubePixelShader: {
  47587. name: string;
  47588. shader: string;
  47589. };
  47590. }
  47591. declare module "babylonjs/PostProcesses/passPostProcess" {
  47592. import { Nullable } from "babylonjs/types";
  47593. import { Camera } from "babylonjs/Cameras/camera";
  47594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47595. import { Engine } from "babylonjs/Engines/engine";
  47596. import "babylonjs/Shaders/pass.fragment";
  47597. import "babylonjs/Shaders/passCube.fragment";
  47598. /**
  47599. * PassPostProcess which produces an output the same as it's input
  47600. */
  47601. export class PassPostProcess extends PostProcess {
  47602. /**
  47603. * Creates the PassPostProcess
  47604. * @param name The name of the effect.
  47605. * @param options The required width/height ratio to downsize to before computing the render pass.
  47606. * @param camera The camera to apply the render pass to.
  47607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47608. * @param engine The engine which the post process will be applied. (default: current engine)
  47609. * @param reusable If the post process can be reused on the same frame. (default: false)
  47610. * @param textureType The type of texture to be used when performing the post processing.
  47611. * @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)
  47612. */
  47613. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47614. }
  47615. /**
  47616. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47617. */
  47618. export class PassCubePostProcess extends PostProcess {
  47619. private _face;
  47620. /**
  47621. * Gets or sets the cube face to display.
  47622. * * 0 is +X
  47623. * * 1 is -X
  47624. * * 2 is +Y
  47625. * * 3 is -Y
  47626. * * 4 is +Z
  47627. * * 5 is -Z
  47628. */
  47629. get face(): number;
  47630. set face(value: number);
  47631. /**
  47632. * Creates the PassCubePostProcess
  47633. * @param name The name of the effect.
  47634. * @param options The required width/height ratio to downsize to before computing the render pass.
  47635. * @param camera The camera to apply the render pass to.
  47636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47637. * @param engine The engine which the post process will be applied. (default: current engine)
  47638. * @param reusable If the post process can be reused on the same frame. (default: false)
  47639. * @param textureType The type of texture to be used when performing the post processing.
  47640. * @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)
  47641. */
  47642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47643. }
  47644. }
  47645. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47646. /** @hidden */
  47647. export var anaglyphPixelShader: {
  47648. name: string;
  47649. shader: string;
  47650. };
  47651. }
  47652. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47653. import { Engine } from "babylonjs/Engines/engine";
  47654. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47655. import { Camera } from "babylonjs/Cameras/camera";
  47656. import "babylonjs/Shaders/anaglyph.fragment";
  47657. /**
  47658. * Postprocess used to generate anaglyphic rendering
  47659. */
  47660. export class AnaglyphPostProcess extends PostProcess {
  47661. private _passedProcess;
  47662. /**
  47663. * Creates a new AnaglyphPostProcess
  47664. * @param name defines postprocess name
  47665. * @param options defines creation options or target ratio scale
  47666. * @param rigCameras defines cameras using this postprocess
  47667. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47668. * @param engine defines hosting engine
  47669. * @param reusable defines if the postprocess will be reused multiple times per frame
  47670. */
  47671. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47672. }
  47673. }
  47674. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47675. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47676. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47677. import { Scene } from "babylonjs/scene";
  47678. import { Vector3 } from "babylonjs/Maths/math.vector";
  47679. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47680. /**
  47681. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47682. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47683. */
  47684. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47685. /**
  47686. * Creates a new AnaglyphArcRotateCamera
  47687. * @param name defines camera name
  47688. * @param alpha defines alpha angle (in radians)
  47689. * @param beta defines beta angle (in radians)
  47690. * @param radius defines radius
  47691. * @param target defines camera target
  47692. * @param interaxialDistance defines distance between each color axis
  47693. * @param scene defines the hosting scene
  47694. */
  47695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47696. /**
  47697. * Gets camera class name
  47698. * @returns AnaglyphArcRotateCamera
  47699. */
  47700. getClassName(): string;
  47701. }
  47702. }
  47703. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47704. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47705. import { Scene } from "babylonjs/scene";
  47706. import { Vector3 } from "babylonjs/Maths/math.vector";
  47707. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47708. /**
  47709. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47710. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47711. */
  47712. export class AnaglyphFreeCamera extends FreeCamera {
  47713. /**
  47714. * Creates a new AnaglyphFreeCamera
  47715. * @param name defines camera name
  47716. * @param position defines initial position
  47717. * @param interaxialDistance defines distance between each color axis
  47718. * @param scene defines the hosting scene
  47719. */
  47720. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47721. /**
  47722. * Gets camera class name
  47723. * @returns AnaglyphFreeCamera
  47724. */
  47725. getClassName(): string;
  47726. }
  47727. }
  47728. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47729. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47730. import { Scene } from "babylonjs/scene";
  47731. import { Vector3 } from "babylonjs/Maths/math.vector";
  47732. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47733. /**
  47734. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47735. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47736. */
  47737. export class AnaglyphGamepadCamera extends GamepadCamera {
  47738. /**
  47739. * Creates a new AnaglyphGamepadCamera
  47740. * @param name defines camera name
  47741. * @param position defines initial position
  47742. * @param interaxialDistance defines distance between each color axis
  47743. * @param scene defines the hosting scene
  47744. */
  47745. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47746. /**
  47747. * Gets camera class name
  47748. * @returns AnaglyphGamepadCamera
  47749. */
  47750. getClassName(): string;
  47751. }
  47752. }
  47753. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47754. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47755. import { Scene } from "babylonjs/scene";
  47756. import { Vector3 } from "babylonjs/Maths/math.vector";
  47757. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47758. /**
  47759. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47760. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47761. */
  47762. export class AnaglyphUniversalCamera extends UniversalCamera {
  47763. /**
  47764. * Creates a new AnaglyphUniversalCamera
  47765. * @param name defines camera name
  47766. * @param position defines initial position
  47767. * @param interaxialDistance defines distance between each color axis
  47768. * @param scene defines the hosting scene
  47769. */
  47770. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47771. /**
  47772. * Gets camera class name
  47773. * @returns AnaglyphUniversalCamera
  47774. */
  47775. getClassName(): string;
  47776. }
  47777. }
  47778. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47779. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47781. import { Scene } from "babylonjs/scene";
  47782. import { Vector3 } from "babylonjs/Maths/math.vector";
  47783. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47784. /**
  47785. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47786. * @see https://doc.babylonjs.com/features/cameras
  47787. */
  47788. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47789. /**
  47790. * Creates a new StereoscopicArcRotateCamera
  47791. * @param name defines camera name
  47792. * @param alpha defines alpha angle (in radians)
  47793. * @param beta defines beta angle (in radians)
  47794. * @param radius defines radius
  47795. * @param target defines camera target
  47796. * @param interaxialDistance defines distance between each color axis
  47797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47798. * @param scene defines the hosting scene
  47799. */
  47800. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47801. /**
  47802. * Gets camera class name
  47803. * @returns StereoscopicArcRotateCamera
  47804. */
  47805. getClassName(): string;
  47806. }
  47807. }
  47808. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47809. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47810. import { Scene } from "babylonjs/scene";
  47811. import { Vector3 } from "babylonjs/Maths/math.vector";
  47812. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47813. /**
  47814. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47815. * @see https://doc.babylonjs.com/features/cameras
  47816. */
  47817. export class StereoscopicFreeCamera extends FreeCamera {
  47818. /**
  47819. * Creates a new StereoscopicFreeCamera
  47820. * @param name defines camera name
  47821. * @param position defines initial position
  47822. * @param interaxialDistance defines distance between each color axis
  47823. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47824. * @param scene defines the hosting scene
  47825. */
  47826. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47827. /**
  47828. * Gets camera class name
  47829. * @returns StereoscopicFreeCamera
  47830. */
  47831. getClassName(): string;
  47832. }
  47833. }
  47834. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47835. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47836. import { Scene } from "babylonjs/scene";
  47837. import { Vector3 } from "babylonjs/Maths/math.vector";
  47838. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47839. /**
  47840. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47841. * @see https://doc.babylonjs.com/features/cameras
  47842. */
  47843. export class StereoscopicGamepadCamera extends GamepadCamera {
  47844. /**
  47845. * Creates a new StereoscopicGamepadCamera
  47846. * @param name defines camera name
  47847. * @param position defines initial position
  47848. * @param interaxialDistance defines distance between each color axis
  47849. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47850. * @param scene defines the hosting scene
  47851. */
  47852. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47853. /**
  47854. * Gets camera class name
  47855. * @returns StereoscopicGamepadCamera
  47856. */
  47857. getClassName(): string;
  47858. }
  47859. }
  47860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47861. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47862. import { Scene } from "babylonjs/scene";
  47863. import { Vector3 } from "babylonjs/Maths/math.vector";
  47864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47865. /**
  47866. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47867. * @see https://doc.babylonjs.com/features/cameras
  47868. */
  47869. export class StereoscopicUniversalCamera extends UniversalCamera {
  47870. /**
  47871. * Creates a new StereoscopicUniversalCamera
  47872. * @param name defines camera name
  47873. * @param position defines initial position
  47874. * @param interaxialDistance defines distance between each color axis
  47875. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47876. * @param scene defines the hosting scene
  47877. */
  47878. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47879. /**
  47880. * Gets camera class name
  47881. * @returns StereoscopicUniversalCamera
  47882. */
  47883. getClassName(): string;
  47884. }
  47885. }
  47886. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47887. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47888. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47889. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47890. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47891. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47892. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47893. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47894. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47895. }
  47896. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47897. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47898. import { Scene } from "babylonjs/scene";
  47899. import { Vector3 } from "babylonjs/Maths/math.vector";
  47900. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47901. /**
  47902. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47903. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47904. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47905. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47906. */
  47907. export class VirtualJoysticksCamera extends FreeCamera {
  47908. /**
  47909. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47910. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47911. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47912. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47913. * @param name Define the name of the camera in the scene
  47914. * @param position Define the start position of the camera in the scene
  47915. * @param scene Define the scene the camera belongs to
  47916. */
  47917. constructor(name: string, position: Vector3, scene: Scene);
  47918. /**
  47919. * Gets the current object class name.
  47920. * @return the class name
  47921. */
  47922. getClassName(): string;
  47923. }
  47924. }
  47925. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47926. import { Matrix } from "babylonjs/Maths/math.vector";
  47927. /**
  47928. * This represents all the required metrics to create a VR camera.
  47929. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47930. */
  47931. export class VRCameraMetrics {
  47932. /**
  47933. * Define the horizontal resolution off the screen.
  47934. */
  47935. hResolution: number;
  47936. /**
  47937. * Define the vertical resolution off the screen.
  47938. */
  47939. vResolution: number;
  47940. /**
  47941. * Define the horizontal screen size.
  47942. */
  47943. hScreenSize: number;
  47944. /**
  47945. * Define the vertical screen size.
  47946. */
  47947. vScreenSize: number;
  47948. /**
  47949. * Define the vertical screen center position.
  47950. */
  47951. vScreenCenter: number;
  47952. /**
  47953. * Define the distance of the eyes to the screen.
  47954. */
  47955. eyeToScreenDistance: number;
  47956. /**
  47957. * Define the distance between both lenses
  47958. */
  47959. lensSeparationDistance: number;
  47960. /**
  47961. * Define the distance between both viewer's eyes.
  47962. */
  47963. interpupillaryDistance: number;
  47964. /**
  47965. * Define the distortion factor of the VR postprocess.
  47966. * Please, touch with care.
  47967. */
  47968. distortionK: number[];
  47969. /**
  47970. * Define the chromatic aberration correction factors for the VR post process.
  47971. */
  47972. chromaAbCorrection: number[];
  47973. /**
  47974. * Define the scale factor of the post process.
  47975. * The smaller the better but the slower.
  47976. */
  47977. postProcessScaleFactor: number;
  47978. /**
  47979. * Define an offset for the lens center.
  47980. */
  47981. lensCenterOffset: number;
  47982. /**
  47983. * Define if the current vr camera should compensate the distortion of the lense or not.
  47984. */
  47985. compensateDistortion: boolean;
  47986. /**
  47987. * Defines if multiview should be enabled when rendering (Default: false)
  47988. */
  47989. multiviewEnabled: boolean;
  47990. /**
  47991. * Gets the rendering aspect ratio based on the provided resolutions.
  47992. */
  47993. get aspectRatio(): number;
  47994. /**
  47995. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47996. */
  47997. get aspectRatioFov(): number;
  47998. /**
  47999. * @hidden
  48000. */
  48001. get leftHMatrix(): Matrix;
  48002. /**
  48003. * @hidden
  48004. */
  48005. get rightHMatrix(): Matrix;
  48006. /**
  48007. * @hidden
  48008. */
  48009. get leftPreViewMatrix(): Matrix;
  48010. /**
  48011. * @hidden
  48012. */
  48013. get rightPreViewMatrix(): Matrix;
  48014. /**
  48015. * Get the default VRMetrics based on the most generic setup.
  48016. * @returns the default vr metrics
  48017. */
  48018. static GetDefault(): VRCameraMetrics;
  48019. }
  48020. }
  48021. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48022. /** @hidden */
  48023. export var vrDistortionCorrectionPixelShader: {
  48024. name: string;
  48025. shader: string;
  48026. };
  48027. }
  48028. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48029. import { Camera } from "babylonjs/Cameras/camera";
  48030. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48031. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48032. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48033. /**
  48034. * VRDistortionCorrectionPostProcess used for mobile VR
  48035. */
  48036. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48037. private _isRightEye;
  48038. private _distortionFactors;
  48039. private _postProcessScaleFactor;
  48040. private _lensCenterOffset;
  48041. private _scaleIn;
  48042. private _scaleFactor;
  48043. private _lensCenter;
  48044. /**
  48045. * Initializes the VRDistortionCorrectionPostProcess
  48046. * @param name The name of the effect.
  48047. * @param camera The camera to apply the render pass to.
  48048. * @param isRightEye If this is for the right eye distortion
  48049. * @param vrMetrics All the required metrics for the VR camera
  48050. */
  48051. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48052. }
  48053. }
  48054. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48055. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48056. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48057. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48058. import { Scene } from "babylonjs/scene";
  48059. import { Vector3 } from "babylonjs/Maths/math.vector";
  48060. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48061. import "babylonjs/Cameras/RigModes/vrRigMode";
  48062. /**
  48063. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48064. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48065. */
  48066. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48067. /**
  48068. * Creates a new VRDeviceOrientationArcRotateCamera
  48069. * @param name defines camera name
  48070. * @param alpha defines the camera rotation along the logitudinal axis
  48071. * @param beta defines the camera rotation along the latitudinal axis
  48072. * @param radius defines the camera distance from its target
  48073. * @param target defines the camera target
  48074. * @param scene defines the scene the camera belongs to
  48075. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48076. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48077. */
  48078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48079. /**
  48080. * Gets camera class name
  48081. * @returns VRDeviceOrientationArcRotateCamera
  48082. */
  48083. getClassName(): string;
  48084. }
  48085. }
  48086. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48087. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48088. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48089. import { Scene } from "babylonjs/scene";
  48090. import { Vector3 } from "babylonjs/Maths/math.vector";
  48091. import "babylonjs/Cameras/RigModes/vrRigMode";
  48092. /**
  48093. * Camera used to simulate VR rendering (based on FreeCamera)
  48094. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48095. */
  48096. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48097. /**
  48098. * Creates a new VRDeviceOrientationFreeCamera
  48099. * @param name defines camera name
  48100. * @param position defines the start position of the camera
  48101. * @param scene defines the scene the camera belongs to
  48102. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48103. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48104. */
  48105. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48106. /**
  48107. * Gets camera class name
  48108. * @returns VRDeviceOrientationFreeCamera
  48109. */
  48110. getClassName(): string;
  48111. }
  48112. }
  48113. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48114. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48115. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48116. import { Scene } from "babylonjs/scene";
  48117. import { Vector3 } from "babylonjs/Maths/math.vector";
  48118. import "babylonjs/Gamepads/gamepadSceneComponent";
  48119. /**
  48120. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48121. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48122. */
  48123. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48124. /**
  48125. * Creates a new VRDeviceOrientationGamepadCamera
  48126. * @param name defines camera name
  48127. * @param position defines the start position of the camera
  48128. * @param scene defines the scene the camera belongs to
  48129. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48130. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48131. */
  48132. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48133. /**
  48134. * Gets camera class name
  48135. * @returns VRDeviceOrientationGamepadCamera
  48136. */
  48137. getClassName(): string;
  48138. }
  48139. }
  48140. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48141. import { Scene } from "babylonjs/scene";
  48142. import { Texture } from "babylonjs/Materials/Textures/texture";
  48143. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48144. /**
  48145. * A class extending Texture allowing drawing on a texture
  48146. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48147. */
  48148. export class DynamicTexture extends Texture {
  48149. private _generateMipMaps;
  48150. private _canvas;
  48151. private _context;
  48152. /**
  48153. * Creates a DynamicTexture
  48154. * @param name defines the name of the texture
  48155. * @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
  48156. * @param scene defines the scene where you want the texture
  48157. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48158. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48159. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48160. */
  48161. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48162. /**
  48163. * Get the current class name of the texture useful for serialization or dynamic coding.
  48164. * @returns "DynamicTexture"
  48165. */
  48166. getClassName(): string;
  48167. /**
  48168. * Gets the current state of canRescale
  48169. */
  48170. get canRescale(): boolean;
  48171. private _recreate;
  48172. /**
  48173. * Scales the texture
  48174. * @param ratio the scale factor to apply to both width and height
  48175. */
  48176. scale(ratio: number): void;
  48177. /**
  48178. * Resizes the texture
  48179. * @param width the new width
  48180. * @param height the new height
  48181. */
  48182. scaleTo(width: number, height: number): void;
  48183. /**
  48184. * Gets the context of the canvas used by the texture
  48185. * @returns the canvas context of the dynamic texture
  48186. */
  48187. getContext(): CanvasRenderingContext2D;
  48188. /**
  48189. * Clears the texture
  48190. */
  48191. clear(): void;
  48192. /**
  48193. * Updates the texture
  48194. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48195. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48196. */
  48197. update(invertY?: boolean, premulAlpha?: boolean): void;
  48198. /**
  48199. * Draws text onto the texture
  48200. * @param text defines the text to be drawn
  48201. * @param x defines the placement of the text from the left
  48202. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48203. * @param font defines the font to be used with font-style, font-size, font-name
  48204. * @param color defines the color used for the text
  48205. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48206. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48207. * @param update defines whether texture is immediately update (default is true)
  48208. */
  48209. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48210. /**
  48211. * Clones the texture
  48212. * @returns the clone of the texture.
  48213. */
  48214. clone(): DynamicTexture;
  48215. /**
  48216. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48217. * @returns a serialized dynamic texture object
  48218. */
  48219. serialize(): any;
  48220. private _IsCanvasElement;
  48221. /** @hidden */
  48222. _rebuild(): void;
  48223. }
  48224. }
  48225. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48226. import { Scene } from "babylonjs/scene";
  48227. import { Color3 } from "babylonjs/Maths/math.color";
  48228. import { Mesh } from "babylonjs/Meshes/mesh";
  48229. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48230. import { Nullable } from "babylonjs/types";
  48231. /**
  48232. * Class containing static functions to help procedurally build meshes
  48233. */
  48234. export class GroundBuilder {
  48235. /**
  48236. * Creates a ground mesh
  48237. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48238. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48240. * @param name defines the name of the mesh
  48241. * @param options defines the options used to create the mesh
  48242. * @param scene defines the hosting scene
  48243. * @returns the ground mesh
  48244. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48245. */
  48246. static CreateGround(name: string, options: {
  48247. width?: number;
  48248. height?: number;
  48249. subdivisions?: number;
  48250. subdivisionsX?: number;
  48251. subdivisionsY?: number;
  48252. updatable?: boolean;
  48253. }, scene: any): Mesh;
  48254. /**
  48255. * Creates a tiled ground mesh
  48256. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48257. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48258. * * 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
  48259. * * 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
  48260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48261. * @param name defines the name of the mesh
  48262. * @param options defines the options used to create the mesh
  48263. * @param scene defines the hosting scene
  48264. * @returns the tiled ground mesh
  48265. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48266. */
  48267. static CreateTiledGround(name: string, options: {
  48268. xmin: number;
  48269. zmin: number;
  48270. xmax: number;
  48271. zmax: number;
  48272. subdivisions?: {
  48273. w: number;
  48274. h: number;
  48275. };
  48276. precision?: {
  48277. w: number;
  48278. h: number;
  48279. };
  48280. updatable?: boolean;
  48281. }, scene?: Nullable<Scene>): Mesh;
  48282. /**
  48283. * Creates a ground mesh from a height map
  48284. * * The parameter `url` sets the URL of the height map image resource.
  48285. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48286. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48287. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48288. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48289. * * 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.
  48290. * * 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).
  48291. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48293. * @param name defines the name of the mesh
  48294. * @param url defines the url to the height map
  48295. * @param options defines the options used to create the mesh
  48296. * @param scene defines the hosting scene
  48297. * @returns the ground mesh
  48298. * @see https://doc.babylonjs.com/babylon101/height_map
  48299. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48300. */
  48301. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48302. width?: number;
  48303. height?: number;
  48304. subdivisions?: number;
  48305. minHeight?: number;
  48306. maxHeight?: number;
  48307. colorFilter?: Color3;
  48308. alphaFilter?: number;
  48309. updatable?: boolean;
  48310. onReady?: (mesh: GroundMesh) => void;
  48311. }, scene?: Nullable<Scene>): GroundMesh;
  48312. }
  48313. }
  48314. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48315. import { Vector4 } from "babylonjs/Maths/math.vector";
  48316. import { Mesh } from "babylonjs/Meshes/mesh";
  48317. /**
  48318. * Class containing static functions to help procedurally build meshes
  48319. */
  48320. export class TorusBuilder {
  48321. /**
  48322. * Creates a torus mesh
  48323. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48324. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48325. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48329. * @param name defines the name of the mesh
  48330. * @param options defines the options used to create the mesh
  48331. * @param scene defines the hosting scene
  48332. * @returns the torus mesh
  48333. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48334. */
  48335. static CreateTorus(name: string, options: {
  48336. diameter?: number;
  48337. thickness?: number;
  48338. tessellation?: number;
  48339. updatable?: boolean;
  48340. sideOrientation?: number;
  48341. frontUVs?: Vector4;
  48342. backUVs?: Vector4;
  48343. }, scene: any): Mesh;
  48344. }
  48345. }
  48346. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48347. import { Vector4 } from "babylonjs/Maths/math.vector";
  48348. import { Color4 } from "babylonjs/Maths/math.color";
  48349. import { Mesh } from "babylonjs/Meshes/mesh";
  48350. /**
  48351. * Class containing static functions to help procedurally build meshes
  48352. */
  48353. export class CylinderBuilder {
  48354. /**
  48355. * Creates a cylinder or a cone mesh
  48356. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48357. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48358. * * 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.
  48359. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48360. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48361. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48362. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48363. * * 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).
  48364. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48365. * * 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).
  48366. * * 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
  48367. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48368. * * 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
  48369. * * 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.
  48370. * * If `enclose` is false, a ring surface is one element.
  48371. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48372. * * 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
  48373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48376. * @param name defines the name of the mesh
  48377. * @param options defines the options used to create the mesh
  48378. * @param scene defines the hosting scene
  48379. * @returns the cylinder mesh
  48380. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48381. */
  48382. static CreateCylinder(name: string, options: {
  48383. height?: number;
  48384. diameterTop?: number;
  48385. diameterBottom?: number;
  48386. diameter?: number;
  48387. tessellation?: number;
  48388. subdivisions?: number;
  48389. arc?: number;
  48390. faceColors?: Color4[];
  48391. faceUV?: Vector4[];
  48392. updatable?: boolean;
  48393. hasRings?: boolean;
  48394. enclose?: boolean;
  48395. cap?: number;
  48396. sideOrientation?: number;
  48397. frontUVs?: Vector4;
  48398. backUVs?: Vector4;
  48399. }, scene: any): Mesh;
  48400. }
  48401. }
  48402. declare module "babylonjs/XR/webXRTypes" {
  48403. import { Nullable } from "babylonjs/types";
  48404. import { IDisposable } from "babylonjs/scene";
  48405. /**
  48406. * States of the webXR experience
  48407. */
  48408. export enum WebXRState {
  48409. /**
  48410. * Transitioning to being in XR mode
  48411. */
  48412. ENTERING_XR = 0,
  48413. /**
  48414. * Transitioning to non XR mode
  48415. */
  48416. EXITING_XR = 1,
  48417. /**
  48418. * In XR mode and presenting
  48419. */
  48420. IN_XR = 2,
  48421. /**
  48422. * Not entered XR mode
  48423. */
  48424. NOT_IN_XR = 3
  48425. }
  48426. /**
  48427. * Abstraction of the XR render target
  48428. */
  48429. export interface WebXRRenderTarget extends IDisposable {
  48430. /**
  48431. * xrpresent context of the canvas which can be used to display/mirror xr content
  48432. */
  48433. canvasContext: WebGLRenderingContext;
  48434. /**
  48435. * xr layer for the canvas
  48436. */
  48437. xrLayer: Nullable<XRWebGLLayer>;
  48438. /**
  48439. * Initializes the xr layer for the session
  48440. * @param xrSession xr session
  48441. * @returns a promise that will resolve once the XR Layer has been created
  48442. */
  48443. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48444. }
  48445. }
  48446. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48449. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48450. import { Observable } from "babylonjs/Misc/observable";
  48451. /**
  48452. * COnfiguration object for WebXR output canvas
  48453. */
  48454. export class WebXRManagedOutputCanvasOptions {
  48455. /**
  48456. * An optional canvas in case you wish to create it yourself and provide it here.
  48457. * If not provided, a new canvas will be created
  48458. */
  48459. canvasElement?: HTMLCanvasElement;
  48460. /**
  48461. * Options for this XR Layer output
  48462. */
  48463. canvasOptions?: XRWebGLLayerOptions;
  48464. /**
  48465. * CSS styling for a newly created canvas (if not provided)
  48466. */
  48467. newCanvasCssStyle?: string;
  48468. /**
  48469. * Get the default values of the configuration object
  48470. * @returns default values of this configuration object
  48471. */
  48472. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48473. }
  48474. /**
  48475. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48476. */
  48477. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48478. private _options;
  48479. private _canvas;
  48480. private _engine;
  48481. private _originalCanvasSize;
  48482. /**
  48483. * Rendering context of the canvas which can be used to display/mirror xr content
  48484. */
  48485. canvasContext: WebGLRenderingContext;
  48486. /**
  48487. * xr layer for the canvas
  48488. */
  48489. xrLayer: Nullable<XRWebGLLayer>;
  48490. /**
  48491. * Obseervers registered here will be triggered when the xr layer was initialized
  48492. */
  48493. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48494. /**
  48495. * Initializes the canvas to be added/removed upon entering/exiting xr
  48496. * @param _xrSessionManager The XR Session manager
  48497. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48498. */
  48499. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48500. /**
  48501. * Disposes of the object
  48502. */
  48503. dispose(): void;
  48504. /**
  48505. * Initializes the xr layer for the session
  48506. * @param xrSession xr session
  48507. * @returns a promise that will resolve once the XR Layer has been created
  48508. */
  48509. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48510. private _addCanvas;
  48511. private _removeCanvas;
  48512. private _setCanvasSize;
  48513. private _setManagedOutputCanvas;
  48514. }
  48515. }
  48516. declare module "babylonjs/XR/webXRSessionManager" {
  48517. import { Observable } from "babylonjs/Misc/observable";
  48518. import { Nullable } from "babylonjs/types";
  48519. import { IDisposable, Scene } from "babylonjs/scene";
  48520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48521. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48522. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48523. /**
  48524. * Manages an XRSession to work with Babylon's engine
  48525. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48526. */
  48527. export class WebXRSessionManager implements IDisposable {
  48528. /** The scene which the session should be created for */
  48529. scene: Scene;
  48530. private _referenceSpace;
  48531. private _rttProvider;
  48532. private _sessionEnded;
  48533. private _xrNavigator;
  48534. private baseLayer;
  48535. /**
  48536. * The base reference space from which the session started. good if you want to reset your
  48537. * reference space
  48538. */
  48539. baseReferenceSpace: XRReferenceSpace;
  48540. /**
  48541. * Current XR frame
  48542. */
  48543. currentFrame: Nullable<XRFrame>;
  48544. /** WebXR timestamp updated every frame */
  48545. currentTimestamp: number;
  48546. /**
  48547. * Used just in case of a failure to initialize an immersive session.
  48548. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48549. */
  48550. defaultHeightCompensation: number;
  48551. /**
  48552. * Fires every time a new xrFrame arrives which can be used to update the camera
  48553. */
  48554. onXRFrameObservable: Observable<XRFrame>;
  48555. /**
  48556. * Fires when the reference space changed
  48557. */
  48558. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48559. /**
  48560. * Fires when the xr session is ended either by the device or manually done
  48561. */
  48562. onXRSessionEnded: Observable<any>;
  48563. /**
  48564. * Fires when the xr session is ended either by the device or manually done
  48565. */
  48566. onXRSessionInit: Observable<XRSession>;
  48567. /**
  48568. * Underlying xr session
  48569. */
  48570. session: XRSession;
  48571. /**
  48572. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48573. * or get the offset the player is currently at.
  48574. */
  48575. viewerReferenceSpace: XRReferenceSpace;
  48576. /**
  48577. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48578. * @param scene The scene which the session should be created for
  48579. */
  48580. constructor(
  48581. /** The scene which the session should be created for */
  48582. scene: Scene);
  48583. /**
  48584. * The current reference space used in this session. This reference space can constantly change!
  48585. * It is mainly used to offset the camera's position.
  48586. */
  48587. get referenceSpace(): XRReferenceSpace;
  48588. /**
  48589. * Set a new reference space and triggers the observable
  48590. */
  48591. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48592. /**
  48593. * Disposes of the session manager
  48594. */
  48595. dispose(): void;
  48596. /**
  48597. * Stops the xrSession and restores the render loop
  48598. * @returns Promise which resolves after it exits XR
  48599. */
  48600. exitXRAsync(): Promise<void>;
  48601. /**
  48602. * Gets the correct render target texture to be rendered this frame for this eye
  48603. * @param eye the eye for which to get the render target
  48604. * @returns the render target for the specified eye
  48605. */
  48606. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48607. /**
  48608. * Creates a WebXRRenderTarget object for the XR session
  48609. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48610. * @param options optional options to provide when creating a new render target
  48611. * @returns a WebXR render target to which the session can render
  48612. */
  48613. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48614. /**
  48615. * Initializes the manager
  48616. * After initialization enterXR can be called to start an XR session
  48617. * @returns Promise which resolves after it is initialized
  48618. */
  48619. initializeAsync(): Promise<void>;
  48620. /**
  48621. * Initializes an xr session
  48622. * @param xrSessionMode mode to initialize
  48623. * @param xrSessionInit defines optional and required values to pass to the session builder
  48624. * @returns a promise which will resolve once the session has been initialized
  48625. */
  48626. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48627. /**
  48628. * Checks if a session would be supported for the creation options specified
  48629. * @param sessionMode session mode to check if supported eg. immersive-vr
  48630. * @returns A Promise that resolves to true if supported and false if not
  48631. */
  48632. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48633. /**
  48634. * Resets the reference space to the one started the session
  48635. */
  48636. resetReferenceSpace(): void;
  48637. /**
  48638. * Starts rendering to the xr layer
  48639. */
  48640. runXRRenderLoop(): void;
  48641. /**
  48642. * Sets the reference space on the xr session
  48643. * @param referenceSpaceType space to set
  48644. * @returns a promise that will resolve once the reference space has been set
  48645. */
  48646. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48647. /**
  48648. * Updates the render state of the session
  48649. * @param state state to set
  48650. * @returns a promise that resolves once the render state has been updated
  48651. */
  48652. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48653. /**
  48654. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48655. * @param sessionMode defines the session to test
  48656. * @returns a promise with boolean as final value
  48657. */
  48658. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48659. private _createRenderTargetTexture;
  48660. }
  48661. }
  48662. declare module "babylonjs/XR/webXRCamera" {
  48663. import { Vector3 } from "babylonjs/Maths/math.vector";
  48664. import { Scene } from "babylonjs/scene";
  48665. import { Camera } from "babylonjs/Cameras/camera";
  48666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48667. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48668. import { Observable } from "babylonjs/Misc/observable";
  48669. /**
  48670. * WebXR Camera which holds the views for the xrSession
  48671. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48672. */
  48673. export class WebXRCamera extends FreeCamera {
  48674. private _xrSessionManager;
  48675. private _firstFrame;
  48676. private _referenceQuaternion;
  48677. private _referencedPosition;
  48678. private _xrInvPositionCache;
  48679. private _xrInvQuaternionCache;
  48680. /**
  48681. * Observable raised before camera teleportation
  48682. */
  48683. onBeforeCameraTeleport: Observable<Vector3>;
  48684. /**
  48685. * Observable raised after camera teleportation
  48686. */
  48687. onAfterCameraTeleport: Observable<Vector3>;
  48688. /**
  48689. * Should position compensation execute on first frame.
  48690. * This is used when copying the position from a native (non XR) camera
  48691. */
  48692. compensateOnFirstFrame: boolean;
  48693. /**
  48694. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48695. * @param name the name of the camera
  48696. * @param scene the scene to add the camera to
  48697. * @param _xrSessionManager a constructed xr session manager
  48698. */
  48699. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48700. /**
  48701. * Return the user's height, unrelated to the current ground.
  48702. * This will be the y position of this camera, when ground level is 0.
  48703. */
  48704. get realWorldHeight(): number;
  48705. /** @hidden */
  48706. _updateForDualEyeDebugging(): void;
  48707. /**
  48708. * Sets this camera's transformation based on a non-vr camera
  48709. * @param otherCamera the non-vr camera to copy the transformation from
  48710. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48711. */
  48712. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48713. /**
  48714. * Gets the current instance class name ("WebXRCamera").
  48715. * @returns the class name
  48716. */
  48717. getClassName(): string;
  48718. private _rotate180;
  48719. private _updateFromXRSession;
  48720. private _updateNumberOfRigCameras;
  48721. private _updateReferenceSpace;
  48722. private _updateReferenceSpaceOffset;
  48723. }
  48724. }
  48725. declare module "babylonjs/XR/webXRFeaturesManager" {
  48726. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48727. import { IDisposable } from "babylonjs/scene";
  48728. /**
  48729. * Defining the interface required for a (webxr) feature
  48730. */
  48731. export interface IWebXRFeature extends IDisposable {
  48732. /**
  48733. * Is this feature attached
  48734. */
  48735. attached: boolean;
  48736. /**
  48737. * Should auto-attach be disabled?
  48738. */
  48739. disableAutoAttach: boolean;
  48740. /**
  48741. * Attach the feature to the session
  48742. * Will usually be called by the features manager
  48743. *
  48744. * @param force should attachment be forced (even when already attached)
  48745. * @returns true if successful.
  48746. */
  48747. attach(force?: boolean): boolean;
  48748. /**
  48749. * Detach the feature from the session
  48750. * Will usually be called by the features manager
  48751. *
  48752. * @returns true if successful.
  48753. */
  48754. detach(): boolean;
  48755. /**
  48756. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48757. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48758. *
  48759. * @returns whether or not the feature is compatible in this environment
  48760. */
  48761. isCompatible(): boolean;
  48762. /**
  48763. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48764. */
  48765. xrNativeFeatureName?: string;
  48766. }
  48767. /**
  48768. * A list of the currently available features without referencing them
  48769. */
  48770. export class WebXRFeatureName {
  48771. /**
  48772. * The name of the anchor system feature
  48773. */
  48774. static ANCHOR_SYSTEM: string;
  48775. /**
  48776. * The name of the background remover feature
  48777. */
  48778. static BACKGROUND_REMOVER: string;
  48779. /**
  48780. * The name of the hit test feature
  48781. */
  48782. static HIT_TEST: string;
  48783. /**
  48784. * physics impostors for xr controllers feature
  48785. */
  48786. static PHYSICS_CONTROLLERS: string;
  48787. /**
  48788. * The name of the plane detection feature
  48789. */
  48790. static PLANE_DETECTION: string;
  48791. /**
  48792. * The name of the pointer selection feature
  48793. */
  48794. static POINTER_SELECTION: string;
  48795. /**
  48796. * The name of the teleportation feature
  48797. */
  48798. static TELEPORTATION: string;
  48799. }
  48800. /**
  48801. * Defining the constructor of a feature. Used to register the modules.
  48802. */
  48803. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48804. /**
  48805. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48806. * It is mainly used in AR sessions.
  48807. *
  48808. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48809. */
  48810. export class WebXRFeaturesManager implements IDisposable {
  48811. private _xrSessionManager;
  48812. private static readonly _AvailableFeatures;
  48813. private _features;
  48814. /**
  48815. * constructs a new features manages.
  48816. *
  48817. * @param _xrSessionManager an instance of WebXRSessionManager
  48818. */
  48819. constructor(_xrSessionManager: WebXRSessionManager);
  48820. /**
  48821. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48822. * Mainly used internally.
  48823. *
  48824. * @param featureName the name of the feature to register
  48825. * @param constructorFunction the function used to construct the module
  48826. * @param version the (babylon) version of the module
  48827. * @param stable is that a stable version of this module
  48828. */
  48829. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48830. /**
  48831. * Returns a constructor of a specific feature.
  48832. *
  48833. * @param featureName the name of the feature to construct
  48834. * @param version the version of the feature to load
  48835. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48836. * @param options optional options provided to the module.
  48837. * @returns a function that, when called, will return a new instance of this feature
  48838. */
  48839. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48840. /**
  48841. * Can be used to return the list of features currently registered
  48842. *
  48843. * @returns an Array of available features
  48844. */
  48845. static GetAvailableFeatures(): string[];
  48846. /**
  48847. * Gets the versions available for a specific feature
  48848. * @param featureName the name of the feature
  48849. * @returns an array with the available versions
  48850. */
  48851. static GetAvailableVersions(featureName: string): string[];
  48852. /**
  48853. * Return the latest unstable version of this feature
  48854. * @param featureName the name of the feature to search
  48855. * @returns the version number. if not found will return -1
  48856. */
  48857. static GetLatestVersionOfFeature(featureName: string): number;
  48858. /**
  48859. * Return the latest stable version of this feature
  48860. * @param featureName the name of the feature to search
  48861. * @returns the version number. if not found will return -1
  48862. */
  48863. static GetStableVersionOfFeature(featureName: string): number;
  48864. /**
  48865. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48866. * Can be used during a session to start a feature
  48867. * @param featureName the name of feature to attach
  48868. */
  48869. attachFeature(featureName: string): void;
  48870. /**
  48871. * Can be used inside a session or when the session ends to detach a specific feature
  48872. * @param featureName the name of the feature to detach
  48873. */
  48874. detachFeature(featureName: string): void;
  48875. /**
  48876. * Used to disable an already-enabled feature
  48877. * The feature will be disposed and will be recreated once enabled.
  48878. * @param featureName the feature to disable
  48879. * @returns true if disable was successful
  48880. */
  48881. disableFeature(featureName: string | {
  48882. Name: string;
  48883. }): boolean;
  48884. /**
  48885. * dispose this features manager
  48886. */
  48887. dispose(): void;
  48888. /**
  48889. * 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.
  48890. * 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.
  48891. *
  48892. * @param featureName the name of the feature to load or the class of the feature
  48893. * @param version optional version to load. if not provided the latest version will be enabled
  48894. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48895. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48896. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48897. * @returns a new constructed feature or throws an error if feature not found.
  48898. */
  48899. enableFeature(featureName: string | {
  48900. Name: string;
  48901. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48902. /**
  48903. * get the implementation of an enabled feature.
  48904. * @param featureName the name of the feature to load
  48905. * @returns the feature class, if found
  48906. */
  48907. getEnabledFeature(featureName: string): IWebXRFeature;
  48908. /**
  48909. * Get the list of enabled features
  48910. * @returns an array of enabled features
  48911. */
  48912. getEnabledFeatures(): string[];
  48913. /**
  48914. * This function will exten the session creation configuration object with enabled features.
  48915. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48916. * according to the defined "required" variable, provided during enableFeature call
  48917. * @param xrSessionInit the xr Session init object to extend
  48918. *
  48919. * @returns an extended XRSessionInit object
  48920. */
  48921. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48922. }
  48923. }
  48924. declare module "babylonjs/XR/webXRExperienceHelper" {
  48925. import { Observable } from "babylonjs/Misc/observable";
  48926. import { IDisposable, Scene } from "babylonjs/scene";
  48927. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48928. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48929. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48930. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48931. /**
  48932. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48933. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48934. */
  48935. export class WebXRExperienceHelper implements IDisposable {
  48936. private scene;
  48937. private _nonVRCamera;
  48938. private _originalSceneAutoClear;
  48939. private _supported;
  48940. /**
  48941. * Camera used to render xr content
  48942. */
  48943. camera: WebXRCamera;
  48944. /** A features manager for this xr session */
  48945. featuresManager: WebXRFeaturesManager;
  48946. /**
  48947. * Observers registered here will be triggered after the camera's initial transformation is set
  48948. * This can be used to set a different ground level or an extra rotation.
  48949. *
  48950. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48951. * to the position set after this observable is done executing.
  48952. */
  48953. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48954. /**
  48955. * Fires when the state of the experience helper has changed
  48956. */
  48957. onStateChangedObservable: Observable<WebXRState>;
  48958. /** Session manager used to keep track of xr session */
  48959. sessionManager: WebXRSessionManager;
  48960. /**
  48961. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48962. */
  48963. state: WebXRState;
  48964. /**
  48965. * Creates a WebXRExperienceHelper
  48966. * @param scene The scene the helper should be created in
  48967. */
  48968. private constructor();
  48969. /**
  48970. * Creates the experience helper
  48971. * @param scene the scene to attach the experience helper to
  48972. * @returns a promise for the experience helper
  48973. */
  48974. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48975. /**
  48976. * Disposes of the experience helper
  48977. */
  48978. dispose(): void;
  48979. /**
  48980. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48981. * @param sessionMode options for the XR session
  48982. * @param referenceSpaceType frame of reference of the XR session
  48983. * @param renderTarget the output canvas that will be used to enter XR mode
  48984. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48985. * @returns promise that resolves after xr mode has entered
  48986. */
  48987. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48988. /**
  48989. * Exits XR mode and returns the scene to its original state
  48990. * @returns promise that resolves after xr mode has exited
  48991. */
  48992. exitXRAsync(): Promise<void>;
  48993. private _nonXRToXRCamera;
  48994. private _setState;
  48995. }
  48996. }
  48997. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48998. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48999. import { Observable } from "babylonjs/Misc/observable";
  49000. import { IDisposable } from "babylonjs/scene";
  49001. /**
  49002. * X-Y values for axes in WebXR
  49003. */
  49004. export interface IWebXRMotionControllerAxesValue {
  49005. /**
  49006. * The value of the x axis
  49007. */
  49008. x: number;
  49009. /**
  49010. * The value of the y-axis
  49011. */
  49012. y: number;
  49013. }
  49014. /**
  49015. * changed / previous values for the values of this component
  49016. */
  49017. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49018. /**
  49019. * current (this frame) value
  49020. */
  49021. current: T;
  49022. /**
  49023. * previous (last change) value
  49024. */
  49025. previous: T;
  49026. }
  49027. /**
  49028. * Represents changes in the component between current frame and last values recorded
  49029. */
  49030. export interface IWebXRMotionControllerComponentChanges {
  49031. /**
  49032. * will be populated with previous and current values if axes changed
  49033. */
  49034. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49035. /**
  49036. * will be populated with previous and current values if pressed changed
  49037. */
  49038. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49039. /**
  49040. * will be populated with previous and current values if touched changed
  49041. */
  49042. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49043. /**
  49044. * will be populated with previous and current values if value changed
  49045. */
  49046. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49047. }
  49048. /**
  49049. * This class represents a single component (for example button or thumbstick) of a motion controller
  49050. */
  49051. export class WebXRControllerComponent implements IDisposable {
  49052. /**
  49053. * the id of this component
  49054. */
  49055. id: string;
  49056. /**
  49057. * the type of the component
  49058. */
  49059. type: MotionControllerComponentType;
  49060. private _buttonIndex;
  49061. private _axesIndices;
  49062. private _axes;
  49063. private _changes;
  49064. private _currentValue;
  49065. private _hasChanges;
  49066. private _pressed;
  49067. private _touched;
  49068. /**
  49069. * button component type
  49070. */
  49071. static BUTTON_TYPE: MotionControllerComponentType;
  49072. /**
  49073. * squeeze component type
  49074. */
  49075. static SQUEEZE_TYPE: MotionControllerComponentType;
  49076. /**
  49077. * Thumbstick component type
  49078. */
  49079. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49080. /**
  49081. * Touchpad component type
  49082. */
  49083. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49084. /**
  49085. * trigger component type
  49086. */
  49087. static TRIGGER_TYPE: MotionControllerComponentType;
  49088. /**
  49089. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49090. * the axes data changes
  49091. */
  49092. onAxisValueChangedObservable: Observable<{
  49093. x: number;
  49094. y: number;
  49095. }>;
  49096. /**
  49097. * Observers registered here will be triggered when the state of a button changes
  49098. * State change is either pressed / touched / value
  49099. */
  49100. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49101. /**
  49102. * Creates a new component for a motion controller.
  49103. * It is created by the motion controller itself
  49104. *
  49105. * @param id the id of this component
  49106. * @param type the type of the component
  49107. * @param _buttonIndex index in the buttons array of the gamepad
  49108. * @param _axesIndices indices of the values in the axes array of the gamepad
  49109. */
  49110. constructor(
  49111. /**
  49112. * the id of this component
  49113. */
  49114. id: string,
  49115. /**
  49116. * the type of the component
  49117. */
  49118. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49119. /**
  49120. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49121. */
  49122. get axes(): IWebXRMotionControllerAxesValue;
  49123. /**
  49124. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49125. */
  49126. get changes(): IWebXRMotionControllerComponentChanges;
  49127. /**
  49128. * Return whether or not the component changed the last frame
  49129. */
  49130. get hasChanges(): boolean;
  49131. /**
  49132. * is the button currently pressed
  49133. */
  49134. get pressed(): boolean;
  49135. /**
  49136. * is the button currently touched
  49137. */
  49138. get touched(): boolean;
  49139. /**
  49140. * Get the current value of this component
  49141. */
  49142. get value(): number;
  49143. /**
  49144. * Dispose this component
  49145. */
  49146. dispose(): void;
  49147. /**
  49148. * Are there axes correlating to this component
  49149. * @return true is axes data is available
  49150. */
  49151. isAxes(): boolean;
  49152. /**
  49153. * Is this component a button (hence - pressable)
  49154. * @returns true if can be pressed
  49155. */
  49156. isButton(): boolean;
  49157. /**
  49158. * update this component using the gamepad object it is in. Called on every frame
  49159. * @param nativeController the native gamepad controller object
  49160. */
  49161. update(nativeController: IMinimalMotionControllerObject): void;
  49162. }
  49163. }
  49164. declare module "babylonjs/Loading/sceneLoader" {
  49165. import { Observable } from "babylonjs/Misc/observable";
  49166. import { Nullable } from "babylonjs/types";
  49167. import { Scene } from "babylonjs/scene";
  49168. import { Engine } from "babylonjs/Engines/engine";
  49169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49170. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49171. import { AssetContainer } from "babylonjs/assetContainer";
  49172. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49173. import { Skeleton } from "babylonjs/Bones/skeleton";
  49174. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49175. import { WebRequest } from "babylonjs/Misc/webRequest";
  49176. /**
  49177. * Interface used to represent data loading progression
  49178. */
  49179. export interface ISceneLoaderProgressEvent {
  49180. /**
  49181. * Defines if data length to load can be evaluated
  49182. */
  49183. readonly lengthComputable: boolean;
  49184. /**
  49185. * Defines the loaded data length
  49186. */
  49187. readonly loaded: number;
  49188. /**
  49189. * Defines the data length to load
  49190. */
  49191. readonly total: number;
  49192. }
  49193. /**
  49194. * Interface used by SceneLoader plugins to define supported file extensions
  49195. */
  49196. export interface ISceneLoaderPluginExtensions {
  49197. /**
  49198. * Defines the list of supported extensions
  49199. */
  49200. [extension: string]: {
  49201. isBinary: boolean;
  49202. };
  49203. }
  49204. /**
  49205. * Interface used by SceneLoader plugin factory
  49206. */
  49207. export interface ISceneLoaderPluginFactory {
  49208. /**
  49209. * Defines the name of the factory
  49210. */
  49211. name: string;
  49212. /**
  49213. * Function called to create a new plugin
  49214. * @return the new plugin
  49215. */
  49216. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49217. /**
  49218. * The callback that returns true if the data can be directly loaded.
  49219. * @param data string containing the file data
  49220. * @returns if the data can be loaded directly
  49221. */
  49222. canDirectLoad?(data: string): boolean;
  49223. }
  49224. /**
  49225. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49226. */
  49227. export interface ISceneLoaderPluginBase {
  49228. /**
  49229. * The friendly name of this plugin.
  49230. */
  49231. name: string;
  49232. /**
  49233. * The file extensions supported by this plugin.
  49234. */
  49235. extensions: string | ISceneLoaderPluginExtensions;
  49236. /**
  49237. * The callback called when loading from a url.
  49238. * @param scene scene loading this url
  49239. * @param url url to load
  49240. * @param onSuccess callback called when the file successfully loads
  49241. * @param onProgress callback called while file is loading (if the server supports this mode)
  49242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49243. * @param onError callback called when the file fails to load
  49244. * @returns a file request object
  49245. */
  49246. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49247. /**
  49248. * The callback called when loading from a file object.
  49249. * @param scene scene loading this file
  49250. * @param file defines the file to load
  49251. * @param onSuccess defines the callback to call when data is loaded
  49252. * @param onProgress defines the callback to call during loading process
  49253. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49254. * @param onError defines the callback to call when an error occurs
  49255. * @returns a file request object
  49256. */
  49257. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49258. /**
  49259. * The callback that returns true if the data can be directly loaded.
  49260. * @param data string containing the file data
  49261. * @returns if the data can be loaded directly
  49262. */
  49263. canDirectLoad?(data: string): boolean;
  49264. /**
  49265. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49266. * @param scene scene loading this data
  49267. * @param data string containing the data
  49268. * @returns data to pass to the plugin
  49269. */
  49270. directLoad?(scene: Scene, data: string): any;
  49271. /**
  49272. * The callback that allows custom handling of the root url based on the response url.
  49273. * @param rootUrl the original root url
  49274. * @param responseURL the response url if available
  49275. * @returns the new root url
  49276. */
  49277. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49278. }
  49279. /**
  49280. * Interface used to define a SceneLoader plugin
  49281. */
  49282. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49283. /**
  49284. * Import meshes into a scene.
  49285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49286. * @param scene The scene to import into
  49287. * @param data The data to import
  49288. * @param rootUrl The root url for scene and resources
  49289. * @param meshes The meshes array to import into
  49290. * @param particleSystems The particle systems array to import into
  49291. * @param skeletons The skeletons array to import into
  49292. * @param onError The callback when import fails
  49293. * @returns True if successful or false otherwise
  49294. */
  49295. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49296. /**
  49297. * Load into a scene.
  49298. * @param scene The scene to load into
  49299. * @param data The data to import
  49300. * @param rootUrl The root url for scene and resources
  49301. * @param onError The callback when import fails
  49302. * @returns True if successful or false otherwise
  49303. */
  49304. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49305. /**
  49306. * Load into an asset container.
  49307. * @param scene The scene to load into
  49308. * @param data The data to import
  49309. * @param rootUrl The root url for scene and resources
  49310. * @param onError The callback when import fails
  49311. * @returns The loaded asset container
  49312. */
  49313. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49314. }
  49315. /**
  49316. * Interface used to define an async SceneLoader plugin
  49317. */
  49318. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49319. /**
  49320. * Import meshes into a scene.
  49321. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49322. * @param scene The scene to import into
  49323. * @param data The data to import
  49324. * @param rootUrl The root url for scene and resources
  49325. * @param onProgress The callback when the load progresses
  49326. * @param fileName Defines the name of the file to load
  49327. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49328. */
  49329. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49330. meshes: AbstractMesh[];
  49331. particleSystems: IParticleSystem[];
  49332. skeletons: Skeleton[];
  49333. animationGroups: AnimationGroup[];
  49334. }>;
  49335. /**
  49336. * Load into a scene.
  49337. * @param scene The scene to load into
  49338. * @param data The data to import
  49339. * @param rootUrl The root url for scene and resources
  49340. * @param onProgress The callback when the load progresses
  49341. * @param fileName Defines the name of the file to load
  49342. * @returns Nothing
  49343. */
  49344. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49345. /**
  49346. * Load into an asset container.
  49347. * @param scene The scene to load into
  49348. * @param data The data to import
  49349. * @param rootUrl The root url for scene and resources
  49350. * @param onProgress The callback when the load progresses
  49351. * @param fileName Defines the name of the file to load
  49352. * @returns The loaded asset container
  49353. */
  49354. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49355. }
  49356. /**
  49357. * Mode that determines how to handle old animation groups before loading new ones.
  49358. */
  49359. export enum SceneLoaderAnimationGroupLoadingMode {
  49360. /**
  49361. * Reset all old animations to initial state then dispose them.
  49362. */
  49363. Clean = 0,
  49364. /**
  49365. * Stop all old animations.
  49366. */
  49367. Stop = 1,
  49368. /**
  49369. * Restart old animations from first frame.
  49370. */
  49371. Sync = 2,
  49372. /**
  49373. * Old animations remains untouched.
  49374. */
  49375. NoSync = 3
  49376. }
  49377. /**
  49378. * Defines a plugin registered by the SceneLoader
  49379. */
  49380. interface IRegisteredPlugin {
  49381. /**
  49382. * Defines the plugin to use
  49383. */
  49384. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49385. /**
  49386. * Defines if the plugin supports binary data
  49387. */
  49388. isBinary: boolean;
  49389. }
  49390. /**
  49391. * Class used to load scene from various file formats using registered plugins
  49392. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49393. */
  49394. export class SceneLoader {
  49395. /**
  49396. * No logging while loading
  49397. */
  49398. static readonly NO_LOGGING: number;
  49399. /**
  49400. * Minimal logging while loading
  49401. */
  49402. static readonly MINIMAL_LOGGING: number;
  49403. /**
  49404. * Summary logging while loading
  49405. */
  49406. static readonly SUMMARY_LOGGING: number;
  49407. /**
  49408. * Detailled logging while loading
  49409. */
  49410. static readonly DETAILED_LOGGING: number;
  49411. /**
  49412. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49413. */
  49414. static get ForceFullSceneLoadingForIncremental(): boolean;
  49415. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49416. /**
  49417. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49418. */
  49419. static get ShowLoadingScreen(): boolean;
  49420. static set ShowLoadingScreen(value: boolean);
  49421. /**
  49422. * Defines the current logging level (while loading the scene)
  49423. * @ignorenaming
  49424. */
  49425. static get loggingLevel(): number;
  49426. static set loggingLevel(value: number);
  49427. /**
  49428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49429. */
  49430. static get CleanBoneMatrixWeights(): boolean;
  49431. static set CleanBoneMatrixWeights(value: boolean);
  49432. /**
  49433. * Event raised when a plugin is used to load a scene
  49434. */
  49435. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49436. private static _registeredPlugins;
  49437. private static _showingLoadingScreen;
  49438. /**
  49439. * Gets the default plugin (used to load Babylon files)
  49440. * @returns the .babylon plugin
  49441. */
  49442. static GetDefaultPlugin(): IRegisteredPlugin;
  49443. private static _GetPluginForExtension;
  49444. private static _GetPluginForDirectLoad;
  49445. private static _GetPluginForFilename;
  49446. private static _GetDirectLoad;
  49447. private static _LoadData;
  49448. private static _GetFileInfo;
  49449. /**
  49450. * Gets a plugin that can load the given extension
  49451. * @param extension defines the extension to load
  49452. * @returns a plugin or null if none works
  49453. */
  49454. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49455. /**
  49456. * Gets a boolean indicating that the given extension can be loaded
  49457. * @param extension defines the extension to load
  49458. * @returns true if the extension is supported
  49459. */
  49460. static IsPluginForExtensionAvailable(extension: string): boolean;
  49461. /**
  49462. * Adds a new plugin to the list of registered plugins
  49463. * @param plugin defines the plugin to add
  49464. */
  49465. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49466. /**
  49467. * Import meshes into a scene
  49468. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49469. * @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)
  49470. * @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)
  49471. * @param scene the instance of BABYLON.Scene to append to
  49472. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49473. * @param onProgress a callback with a progress event for each file being loaded
  49474. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49475. * @param pluginExtension the extension used to determine the plugin
  49476. * @returns The loaded plugin
  49477. */
  49478. 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>;
  49479. /**
  49480. * Import meshes into a scene
  49481. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49482. * @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)
  49483. * @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)
  49484. * @param scene the instance of BABYLON.Scene to append to
  49485. * @param onProgress a callback with a progress event for each file being loaded
  49486. * @param pluginExtension the extension used to determine the plugin
  49487. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49488. */
  49489. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49490. meshes: AbstractMesh[];
  49491. particleSystems: IParticleSystem[];
  49492. skeletons: Skeleton[];
  49493. animationGroups: AnimationGroup[];
  49494. }>;
  49495. /**
  49496. * Load a scene
  49497. * @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)
  49498. * @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)
  49499. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49500. * @param onSuccess a callback with the scene when import succeeds
  49501. * @param onProgress a callback with a progress event for each file being loaded
  49502. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49503. * @param pluginExtension the extension used to determine the plugin
  49504. * @returns The loaded plugin
  49505. */
  49506. 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>;
  49507. /**
  49508. * Load a scene
  49509. * @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)
  49510. * @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)
  49511. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49512. * @param onProgress a callback with a progress event for each file being loaded
  49513. * @param pluginExtension the extension used to determine the plugin
  49514. * @returns The loaded scene
  49515. */
  49516. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49517. /**
  49518. * Append a scene
  49519. * @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)
  49520. * @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)
  49521. * @param scene is the instance of BABYLON.Scene to append to
  49522. * @param onSuccess a callback with the scene when import succeeds
  49523. * @param onProgress a callback with a progress event for each file being loaded
  49524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49525. * @param pluginExtension the extension used to determine the plugin
  49526. * @returns The loaded plugin
  49527. */
  49528. 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>;
  49529. /**
  49530. * Append a scene
  49531. * @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)
  49532. * @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)
  49533. * @param scene is the instance of BABYLON.Scene to append to
  49534. * @param onProgress a callback with a progress event for each file being loaded
  49535. * @param pluginExtension the extension used to determine the plugin
  49536. * @returns The given scene
  49537. */
  49538. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49539. /**
  49540. * Load a scene into an asset container
  49541. * @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)
  49542. * @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)
  49543. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49544. * @param onSuccess a callback with the scene when import succeeds
  49545. * @param onProgress a callback with a progress event for each file being loaded
  49546. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49547. * @param pluginExtension the extension used to determine the plugin
  49548. * @returns The loaded plugin
  49549. */
  49550. 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>;
  49551. /**
  49552. * Load a scene into an asset container
  49553. * @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)
  49554. * @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)
  49555. * @param scene is the instance of Scene to append to
  49556. * @param onProgress a callback with a progress event for each file being loaded
  49557. * @param pluginExtension the extension used to determine the plugin
  49558. * @returns The loaded asset container
  49559. */
  49560. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49561. /**
  49562. * Import animations from a file into a scene
  49563. * @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)
  49564. * @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)
  49565. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49566. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49567. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49568. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49569. * @param onSuccess a callback with the scene when import succeeds
  49570. * @param onProgress a callback with a progress event for each file being loaded
  49571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49572. * @param pluginExtension the extension used to determine the plugin
  49573. */
  49574. 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;
  49575. /**
  49576. * Import animations from a file into a scene
  49577. * @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)
  49578. * @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)
  49579. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49580. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49581. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49582. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49583. * @param onSuccess a callback with the scene when import succeeds
  49584. * @param onProgress a callback with a progress event for each file being loaded
  49585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49586. * @param pluginExtension the extension used to determine the plugin
  49587. * @returns the updated scene with imported animations
  49588. */
  49589. 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>;
  49590. }
  49591. }
  49592. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49593. import { IDisposable, Scene } from "babylonjs/scene";
  49594. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49595. import { Observable } from "babylonjs/Misc/observable";
  49596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49597. import { Nullable } from "babylonjs/types";
  49598. /**
  49599. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49600. */
  49601. export type MotionControllerHandedness = "none" | "left" | "right";
  49602. /**
  49603. * The type of components available in motion controllers.
  49604. * This is not the name of the component.
  49605. */
  49606. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49607. /**
  49608. * The state of a controller component
  49609. */
  49610. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49611. /**
  49612. * The schema of motion controller layout.
  49613. * No object will be initialized using this interface
  49614. * This is used just to define the profile.
  49615. */
  49616. export interface IMotionControllerLayout {
  49617. /**
  49618. * Path to load the assets. Usually relative to the base path
  49619. */
  49620. assetPath: string;
  49621. /**
  49622. * Available components (unsorted)
  49623. */
  49624. components: {
  49625. /**
  49626. * A map of component Ids
  49627. */
  49628. [componentId: string]: {
  49629. /**
  49630. * The type of input the component outputs
  49631. */
  49632. type: MotionControllerComponentType;
  49633. /**
  49634. * The indices of this component in the gamepad object
  49635. */
  49636. gamepadIndices: {
  49637. /**
  49638. * Index of button
  49639. */
  49640. button?: number;
  49641. /**
  49642. * If available, index of x-axis
  49643. */
  49644. xAxis?: number;
  49645. /**
  49646. * If available, index of y-axis
  49647. */
  49648. yAxis?: number;
  49649. };
  49650. /**
  49651. * The mesh's root node name
  49652. */
  49653. rootNodeName: string;
  49654. /**
  49655. * Animation definitions for this model
  49656. */
  49657. visualResponses: {
  49658. [stateKey: string]: {
  49659. /**
  49660. * What property will be animated
  49661. */
  49662. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49663. /**
  49664. * What states influence this visual response
  49665. */
  49666. states: MotionControllerComponentStateType[];
  49667. /**
  49668. * Type of animation - movement or visibility
  49669. */
  49670. valueNodeProperty: "transform" | "visibility";
  49671. /**
  49672. * Base node name to move. Its position will be calculated according to the min and max nodes
  49673. */
  49674. valueNodeName?: string;
  49675. /**
  49676. * Minimum movement node
  49677. */
  49678. minNodeName?: string;
  49679. /**
  49680. * Max movement node
  49681. */
  49682. maxNodeName?: string;
  49683. };
  49684. };
  49685. /**
  49686. * If touch enabled, what is the name of node to display user feedback
  49687. */
  49688. touchPointNodeName?: string;
  49689. };
  49690. };
  49691. /**
  49692. * Is it xr standard mapping or not
  49693. */
  49694. gamepadMapping: "" | "xr-standard";
  49695. /**
  49696. * Base root node of this entire model
  49697. */
  49698. rootNodeName: string;
  49699. /**
  49700. * Defines the main button component id
  49701. */
  49702. selectComponentId: string;
  49703. }
  49704. /**
  49705. * A definition for the layout map in the input profile
  49706. */
  49707. export interface IMotionControllerLayoutMap {
  49708. /**
  49709. * Layouts with handedness type as a key
  49710. */
  49711. [handedness: string]: IMotionControllerLayout;
  49712. }
  49713. /**
  49714. * The XR Input profile schema
  49715. * Profiles can be found here:
  49716. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49717. */
  49718. export interface IMotionControllerProfile {
  49719. /**
  49720. * fallback profiles for this profileId
  49721. */
  49722. fallbackProfileIds: string[];
  49723. /**
  49724. * The layout map, with handedness as key
  49725. */
  49726. layouts: IMotionControllerLayoutMap;
  49727. /**
  49728. * The id of this profile
  49729. * correlates to the profile(s) in the xrInput.profiles array
  49730. */
  49731. profileId: string;
  49732. }
  49733. /**
  49734. * A helper-interface for the 3 meshes needed for controller button animation
  49735. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49736. */
  49737. export interface IMotionControllerButtonMeshMap {
  49738. /**
  49739. * the mesh that defines the pressed value mesh position.
  49740. * This is used to find the max-position of this button
  49741. */
  49742. pressedMesh: AbstractMesh;
  49743. /**
  49744. * the mesh that defines the unpressed value mesh position.
  49745. * This is used to find the min (or initial) position of this button
  49746. */
  49747. unpressedMesh: AbstractMesh;
  49748. /**
  49749. * The mesh that will be changed when value changes
  49750. */
  49751. valueMesh: AbstractMesh;
  49752. }
  49753. /**
  49754. * A helper-interface for the 3 meshes needed for controller axis animation.
  49755. * This will be expanded when touchpad animations are fully supported
  49756. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49757. */
  49758. export interface IMotionControllerMeshMap {
  49759. /**
  49760. * the mesh that defines the maximum value mesh position.
  49761. */
  49762. maxMesh?: AbstractMesh;
  49763. /**
  49764. * the mesh that defines the minimum value mesh position.
  49765. */
  49766. minMesh?: AbstractMesh;
  49767. /**
  49768. * The mesh that will be changed when axis value changes
  49769. */
  49770. valueMesh: AbstractMesh;
  49771. }
  49772. /**
  49773. * The elements needed for change-detection of the gamepad objects in motion controllers
  49774. */
  49775. export interface IMinimalMotionControllerObject {
  49776. /**
  49777. * Available axes of this controller
  49778. */
  49779. axes: number[];
  49780. /**
  49781. * An array of available buttons
  49782. */
  49783. buttons: Array<{
  49784. /**
  49785. * Value of the button/trigger
  49786. */
  49787. value: number;
  49788. /**
  49789. * If the button/trigger is currently touched
  49790. */
  49791. touched: boolean;
  49792. /**
  49793. * If the button/trigger is currently pressed
  49794. */
  49795. pressed: boolean;
  49796. }>;
  49797. /**
  49798. * EXPERIMENTAL haptic support.
  49799. */
  49800. hapticActuators?: Array<{
  49801. pulse: (value: number, duration: number) => Promise<boolean>;
  49802. }>;
  49803. }
  49804. /**
  49805. * An Abstract Motion controller
  49806. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49807. * Each component has an observable to check for changes in value and state
  49808. */
  49809. export abstract class WebXRAbstractMotionController implements IDisposable {
  49810. protected scene: Scene;
  49811. protected layout: IMotionControllerLayout;
  49812. /**
  49813. * The gamepad object correlating to this controller
  49814. */
  49815. gamepadObject: IMinimalMotionControllerObject;
  49816. /**
  49817. * handedness (left/right/none) of this controller
  49818. */
  49819. handedness: MotionControllerHandedness;
  49820. private _initComponent;
  49821. private _modelReady;
  49822. /**
  49823. * A map of components (WebXRControllerComponent) in this motion controller
  49824. * Components have a ComponentType and can also have both button and axis definitions
  49825. */
  49826. readonly components: {
  49827. [id: string]: WebXRControllerComponent;
  49828. };
  49829. /**
  49830. * Disable the model's animation. Can be set at any time.
  49831. */
  49832. disableAnimation: boolean;
  49833. /**
  49834. * Observers registered here will be triggered when the model of this controller is done loading
  49835. */
  49836. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49837. /**
  49838. * The profile id of this motion controller
  49839. */
  49840. abstract profileId: string;
  49841. /**
  49842. * The root mesh of the model. It is null if the model was not yet initialized
  49843. */
  49844. rootMesh: Nullable<AbstractMesh>;
  49845. /**
  49846. * constructs a new abstract motion controller
  49847. * @param scene the scene to which the model of the controller will be added
  49848. * @param layout The profile layout to load
  49849. * @param gamepadObject The gamepad object correlating to this controller
  49850. * @param handedness handedness (left/right/none) of this controller
  49851. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49852. */
  49853. constructor(scene: Scene, layout: IMotionControllerLayout,
  49854. /**
  49855. * The gamepad object correlating to this controller
  49856. */
  49857. gamepadObject: IMinimalMotionControllerObject,
  49858. /**
  49859. * handedness (left/right/none) of this controller
  49860. */
  49861. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49862. /**
  49863. * Dispose this controller, the model mesh and all its components
  49864. */
  49865. dispose(): void;
  49866. /**
  49867. * Returns all components of specific type
  49868. * @param type the type to search for
  49869. * @return an array of components with this type
  49870. */
  49871. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49872. /**
  49873. * get a component based an its component id as defined in layout.components
  49874. * @param id the id of the component
  49875. * @returns the component correlates to the id or undefined if not found
  49876. */
  49877. getComponent(id: string): WebXRControllerComponent;
  49878. /**
  49879. * Get the list of components available in this motion controller
  49880. * @returns an array of strings correlating to available components
  49881. */
  49882. getComponentIds(): string[];
  49883. /**
  49884. * Get the first component of specific type
  49885. * @param type type of component to find
  49886. * @return a controller component or null if not found
  49887. */
  49888. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49889. /**
  49890. * Get the main (Select) component of this controller as defined in the layout
  49891. * @returns the main component of this controller
  49892. */
  49893. getMainComponent(): WebXRControllerComponent;
  49894. /**
  49895. * Loads the model correlating to this controller
  49896. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49897. * @returns A promise fulfilled with the result of the model loading
  49898. */
  49899. loadModel(): Promise<boolean>;
  49900. /**
  49901. * Update this model using the current XRFrame
  49902. * @param xrFrame the current xr frame to use and update the model
  49903. */
  49904. updateFromXRFrame(xrFrame: XRFrame): void;
  49905. /**
  49906. * Backwards compatibility due to a deeply-integrated typo
  49907. */
  49908. get handness(): XREye;
  49909. /**
  49910. * Pulse (vibrate) this controller
  49911. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49912. * Consecutive calls to this function will cancel the last pulse call
  49913. *
  49914. * @param value the strength of the pulse in 0.0...1.0 range
  49915. * @param duration Duration of the pulse in milliseconds
  49916. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49917. * @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
  49918. */
  49919. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49920. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49921. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49922. /**
  49923. * Moves the axis on the controller mesh based on its current state
  49924. * @param axis the index of the axis
  49925. * @param axisValue the value of the axis which determines the meshes new position
  49926. * @hidden
  49927. */
  49928. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49929. /**
  49930. * Update the model itself with the current frame data
  49931. * @param xrFrame the frame to use for updating the model mesh
  49932. */
  49933. protected updateModel(xrFrame: XRFrame): void;
  49934. /**
  49935. * Get the filename and path for this controller's model
  49936. * @returns a map of filename and path
  49937. */
  49938. protected abstract _getFilenameAndPath(): {
  49939. filename: string;
  49940. path: string;
  49941. };
  49942. /**
  49943. * This function is called before the mesh is loaded. It checks for loading constraints.
  49944. * For example, this function can check if the GLB loader is available
  49945. * If this function returns false, the generic controller will be loaded instead
  49946. * @returns Is the client ready to load the mesh
  49947. */
  49948. protected abstract _getModelLoadingConstraints(): boolean;
  49949. /**
  49950. * This function will be called after the model was successfully loaded and can be used
  49951. * for mesh transformations before it is available for the user
  49952. * @param meshes the loaded meshes
  49953. */
  49954. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49955. /**
  49956. * Set the root mesh for this controller. Important for the WebXR controller class
  49957. * @param meshes the loaded meshes
  49958. */
  49959. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49960. /**
  49961. * A function executed each frame that updates the mesh (if needed)
  49962. * @param xrFrame the current xrFrame
  49963. */
  49964. protected abstract _updateModel(xrFrame: XRFrame): void;
  49965. private _getGenericFilenameAndPath;
  49966. private _getGenericParentMesh;
  49967. }
  49968. }
  49969. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49970. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49972. import { Scene } from "babylonjs/scene";
  49973. /**
  49974. * A generic trigger-only motion controller for WebXR
  49975. */
  49976. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49977. /**
  49978. * Static version of the profile id of this controller
  49979. */
  49980. static ProfileId: string;
  49981. profileId: string;
  49982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49983. protected _getFilenameAndPath(): {
  49984. filename: string;
  49985. path: string;
  49986. };
  49987. protected _getModelLoadingConstraints(): boolean;
  49988. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49989. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49990. protected _updateModel(): void;
  49991. }
  49992. }
  49993. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49994. import { Vector4 } from "babylonjs/Maths/math.vector";
  49995. import { Mesh } from "babylonjs/Meshes/mesh";
  49996. import { Scene } from "babylonjs/scene";
  49997. import { Nullable } from "babylonjs/types";
  49998. /**
  49999. * Class containing static functions to help procedurally build meshes
  50000. */
  50001. export class SphereBuilder {
  50002. /**
  50003. * Creates a sphere mesh
  50004. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50005. * * 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`)
  50006. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50007. * * 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
  50008. * * 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)
  50009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50012. * @param name defines the name of the mesh
  50013. * @param options defines the options used to create the mesh
  50014. * @param scene defines the hosting scene
  50015. * @returns the sphere mesh
  50016. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50017. */
  50018. static CreateSphere(name: string, options: {
  50019. segments?: number;
  50020. diameter?: number;
  50021. diameterX?: number;
  50022. diameterY?: number;
  50023. diameterZ?: number;
  50024. arc?: number;
  50025. slice?: number;
  50026. sideOrientation?: number;
  50027. frontUVs?: Vector4;
  50028. backUVs?: Vector4;
  50029. updatable?: boolean;
  50030. }, scene?: Nullable<Scene>): Mesh;
  50031. }
  50032. }
  50033. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50035. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50036. import { Scene } from "babylonjs/scene";
  50037. /**
  50038. * A profiled motion controller has its profile loaded from an online repository.
  50039. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50040. */
  50041. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50042. private _repositoryUrl;
  50043. private _buttonMeshMapping;
  50044. private _touchDots;
  50045. /**
  50046. * The profile ID of this controller. Will be populated when the controller initializes.
  50047. */
  50048. profileId: string;
  50049. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50050. dispose(): void;
  50051. protected _getFilenameAndPath(): {
  50052. filename: string;
  50053. path: string;
  50054. };
  50055. protected _getModelLoadingConstraints(): boolean;
  50056. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50058. protected _updateModel(_xrFrame: XRFrame): void;
  50059. }
  50060. }
  50061. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50062. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50063. import { Scene } from "babylonjs/scene";
  50064. /**
  50065. * A construction function type to create a new controller based on an xrInput object
  50066. */
  50067. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50068. /**
  50069. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50070. *
  50071. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50072. * it should be replaced with auto-loaded controllers.
  50073. *
  50074. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50075. */
  50076. export class WebXRMotionControllerManager {
  50077. private static _AvailableControllers;
  50078. private static _Fallbacks;
  50079. private static _ProfileLoadingPromises;
  50080. private static _ProfilesList;
  50081. /**
  50082. * The base URL of the online controller repository. Can be changed at any time.
  50083. */
  50084. static BaseRepositoryUrl: string;
  50085. /**
  50086. * Which repository gets priority - local or online
  50087. */
  50088. static PrioritizeOnlineRepository: boolean;
  50089. /**
  50090. * Use the online repository, or use only locally-defined controllers
  50091. */
  50092. static UseOnlineRepository: boolean;
  50093. /**
  50094. * Clear the cache used for profile loading and reload when requested again
  50095. */
  50096. static ClearProfilesCache(): void;
  50097. /**
  50098. * Register the default fallbacks.
  50099. * This function is called automatically when this file is imported.
  50100. */
  50101. static DefaultFallbacks(): void;
  50102. /**
  50103. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50104. * @param profileId the profile to which a fallback needs to be found
  50105. * @return an array with corresponding fallback profiles
  50106. */
  50107. static FindFallbackWithProfileId(profileId: string): string[];
  50108. /**
  50109. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50110. * The order of search:
  50111. *
  50112. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50113. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50114. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50115. * 4) return the generic trigger controller if none were found
  50116. *
  50117. * @param xrInput the xrInput to which a new controller is initialized
  50118. * @param scene the scene to which the model will be added
  50119. * @param forceProfile force a certain profile for this controller
  50120. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50121. */
  50122. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50123. /**
  50124. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50125. *
  50126. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50127. *
  50128. * @param type the profile type to register
  50129. * @param constructFunction the function to be called when loading this profile
  50130. */
  50131. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50132. /**
  50133. * Register a fallback to a specific profile.
  50134. * @param profileId the profileId that will receive the fallbacks
  50135. * @param fallbacks A list of fallback profiles
  50136. */
  50137. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50138. /**
  50139. * Will update the list of profiles available in the repository
  50140. * @return a promise that resolves to a map of profiles available online
  50141. */
  50142. static UpdateProfilesList(): Promise<{
  50143. [profile: string]: string;
  50144. }>;
  50145. private static _LoadProfileFromRepository;
  50146. private static _LoadProfilesFromAvailableControllers;
  50147. }
  50148. }
  50149. declare module "babylonjs/XR/webXRInputSource" {
  50150. import { Observable } from "babylonjs/Misc/observable";
  50151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50152. import { Ray } from "babylonjs/Culling/ray";
  50153. import { Scene } from "babylonjs/scene";
  50154. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50155. /**
  50156. * Configuration options for the WebXR controller creation
  50157. */
  50158. export interface IWebXRControllerOptions {
  50159. /**
  50160. * Should the controller mesh be animated when a user interacts with it
  50161. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50162. */
  50163. disableMotionControllerAnimation?: boolean;
  50164. /**
  50165. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50166. */
  50167. doNotLoadControllerMesh?: boolean;
  50168. /**
  50169. * Force a specific controller type for this controller.
  50170. * This can be used when creating your own profile or when testing different controllers
  50171. */
  50172. forceControllerProfile?: string;
  50173. /**
  50174. * Defines a rendering group ID for meshes that will be loaded.
  50175. * This is for the default controllers only.
  50176. */
  50177. renderingGroupId?: number;
  50178. }
  50179. /**
  50180. * Represents an XR controller
  50181. */
  50182. export class WebXRInputSource {
  50183. private _scene;
  50184. /** The underlying input source for the controller */
  50185. inputSource: XRInputSource;
  50186. private _options;
  50187. private _tmpVector;
  50188. private _uniqueId;
  50189. /**
  50190. * 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
  50191. */
  50192. grip?: AbstractMesh;
  50193. /**
  50194. * If available, this is the gamepad object related to this controller.
  50195. * Using this object it is possible to get click events and trackpad changes of the
  50196. * webxr controller that is currently being used.
  50197. */
  50198. motionController?: WebXRAbstractMotionController;
  50199. /**
  50200. * Event that fires when the controller is removed/disposed.
  50201. * The object provided as event data is this controller, after associated assets were disposed.
  50202. * uniqueId is still available.
  50203. */
  50204. onDisposeObservable: Observable<WebXRInputSource>;
  50205. /**
  50206. * Will be triggered when the mesh associated with the motion controller is done loading.
  50207. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50208. * A shortened version of controller -> motion controller -> on mesh loaded.
  50209. */
  50210. onMeshLoadedObservable: Observable<AbstractMesh>;
  50211. /**
  50212. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50213. */
  50214. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50215. /**
  50216. * Pointer which can be used to select objects or attach a visible laser to
  50217. */
  50218. pointer: AbstractMesh;
  50219. /**
  50220. * Creates the input source object
  50221. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50222. * @param _scene the scene which the controller should be associated to
  50223. * @param inputSource the underlying input source for the controller
  50224. * @param _options options for this controller creation
  50225. */
  50226. constructor(_scene: Scene,
  50227. /** The underlying input source for the controller */
  50228. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50229. /**
  50230. * Get this controllers unique id
  50231. */
  50232. get uniqueId(): string;
  50233. /**
  50234. * Disposes of the object
  50235. */
  50236. dispose(): void;
  50237. /**
  50238. * Gets a world space ray coming from the pointer or grip
  50239. * @param result the resulting ray
  50240. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50241. */
  50242. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50243. /**
  50244. * Updates the controller pose based on the given XRFrame
  50245. * @param xrFrame xr frame to update the pose with
  50246. * @param referenceSpace reference space to use
  50247. */
  50248. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50249. }
  50250. }
  50251. declare module "babylonjs/XR/webXRInput" {
  50252. import { Observable } from "babylonjs/Misc/observable";
  50253. import { IDisposable } from "babylonjs/scene";
  50254. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50255. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50256. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50257. /**
  50258. * The schema for initialization options of the XR Input class
  50259. */
  50260. export interface IWebXRInputOptions {
  50261. /**
  50262. * If set to true no model will be automatically loaded
  50263. */
  50264. doNotLoadControllerMeshes?: boolean;
  50265. /**
  50266. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50267. * If not found, the xr input profile data will be used.
  50268. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50269. */
  50270. forceInputProfile?: string;
  50271. /**
  50272. * Do not send a request to the controller repository to load the profile.
  50273. *
  50274. * Instead, use the controllers available in babylon itself.
  50275. */
  50276. disableOnlineControllerRepository?: boolean;
  50277. /**
  50278. * A custom URL for the controllers repository
  50279. */
  50280. customControllersRepositoryURL?: string;
  50281. /**
  50282. * Should the controller model's components not move according to the user input
  50283. */
  50284. disableControllerAnimation?: boolean;
  50285. /**
  50286. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50287. */
  50288. controllerOptions?: IWebXRControllerOptions;
  50289. }
  50290. /**
  50291. * XR input used to track XR inputs such as controllers/rays
  50292. */
  50293. export class WebXRInput implements IDisposable {
  50294. /**
  50295. * the xr session manager for this session
  50296. */
  50297. xrSessionManager: WebXRSessionManager;
  50298. /**
  50299. * the WebXR camera for this session. Mainly used for teleportation
  50300. */
  50301. xrCamera: WebXRCamera;
  50302. private readonly options;
  50303. /**
  50304. * XR controllers being tracked
  50305. */
  50306. controllers: Array<WebXRInputSource>;
  50307. private _frameObserver;
  50308. private _sessionEndedObserver;
  50309. private _sessionInitObserver;
  50310. /**
  50311. * Event when a controller has been connected/added
  50312. */
  50313. onControllerAddedObservable: Observable<WebXRInputSource>;
  50314. /**
  50315. * Event when a controller has been removed/disconnected
  50316. */
  50317. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50318. /**
  50319. * Initializes the WebXRInput
  50320. * @param xrSessionManager the xr session manager for this session
  50321. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50322. * @param options = initialization options for this xr input
  50323. */
  50324. constructor(
  50325. /**
  50326. * the xr session manager for this session
  50327. */
  50328. xrSessionManager: WebXRSessionManager,
  50329. /**
  50330. * the WebXR camera for this session. Mainly used for teleportation
  50331. */
  50332. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50333. private _onInputSourcesChange;
  50334. private _addAndRemoveControllers;
  50335. /**
  50336. * Disposes of the object
  50337. */
  50338. dispose(): void;
  50339. }
  50340. }
  50341. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50342. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50343. import { Observable, EventState } from "babylonjs/Misc/observable";
  50344. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50345. /**
  50346. * This is the base class for all WebXR features.
  50347. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50348. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50349. */
  50350. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50351. protected _xrSessionManager: WebXRSessionManager;
  50352. private _attached;
  50353. private _removeOnDetach;
  50354. /**
  50355. * Should auto-attach be disabled?
  50356. */
  50357. disableAutoAttach: boolean;
  50358. /**
  50359. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50360. */
  50361. xrNativeFeatureName: string;
  50362. /**
  50363. * Construct a new (abstract) WebXR feature
  50364. * @param _xrSessionManager the xr session manager for this feature
  50365. */
  50366. constructor(_xrSessionManager: WebXRSessionManager);
  50367. /**
  50368. * Is this feature attached
  50369. */
  50370. get attached(): boolean;
  50371. /**
  50372. * attach this feature
  50373. *
  50374. * @param force should attachment be forced (even when already attached)
  50375. * @returns true if successful, false is failed or already attached
  50376. */
  50377. attach(force?: boolean): boolean;
  50378. /**
  50379. * detach this feature.
  50380. *
  50381. * @returns true if successful, false if failed or already detached
  50382. */
  50383. detach(): boolean;
  50384. /**
  50385. * Dispose this feature and all of the resources attached
  50386. */
  50387. dispose(): void;
  50388. /**
  50389. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50390. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50391. *
  50392. * @returns whether or not the feature is compatible in this environment
  50393. */
  50394. isCompatible(): boolean;
  50395. /**
  50396. * This is used to register callbacks that will automatically be removed when detach is called.
  50397. * @param observable the observable to which the observer will be attached
  50398. * @param callback the callback to register
  50399. */
  50400. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50401. /**
  50402. * Code in this function will be executed on each xrFrame received from the browser.
  50403. * This function will not execute after the feature is detached.
  50404. * @param _xrFrame the current frame
  50405. */
  50406. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50407. }
  50408. }
  50409. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50410. import { IDisposable, Scene } from "babylonjs/scene";
  50411. import { Nullable } from "babylonjs/types";
  50412. import { Observable } from "babylonjs/Misc/observable";
  50413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50414. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50415. import { Camera } from "babylonjs/Cameras/camera";
  50416. /**
  50417. * Renders a layer on top of an existing scene
  50418. */
  50419. export class UtilityLayerRenderer implements IDisposable {
  50420. /** the original scene that will be rendered on top of */
  50421. originalScene: Scene;
  50422. private _pointerCaptures;
  50423. private _lastPointerEvents;
  50424. private static _DefaultUtilityLayer;
  50425. private static _DefaultKeepDepthUtilityLayer;
  50426. private _sharedGizmoLight;
  50427. private _renderCamera;
  50428. /**
  50429. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50430. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50431. * @returns the camera that is used when rendering the utility layer
  50432. */
  50433. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50434. /**
  50435. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50436. * @param cam the camera that should be used when rendering the utility layer
  50437. */
  50438. setRenderCamera(cam: Nullable<Camera>): void;
  50439. /**
  50440. * @hidden
  50441. * Light which used by gizmos to get light shading
  50442. */
  50443. _getSharedGizmoLight(): HemisphericLight;
  50444. /**
  50445. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50446. */
  50447. pickUtilitySceneFirst: boolean;
  50448. /**
  50449. * 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)
  50450. */
  50451. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50452. /**
  50453. * 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)
  50454. */
  50455. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50456. /**
  50457. * The scene that is rendered on top of the original scene
  50458. */
  50459. utilityLayerScene: Scene;
  50460. /**
  50461. * If the utility layer should automatically be rendered on top of existing scene
  50462. */
  50463. shouldRender: boolean;
  50464. /**
  50465. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50466. */
  50467. onlyCheckPointerDownEvents: boolean;
  50468. /**
  50469. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50470. */
  50471. processAllEvents: boolean;
  50472. /**
  50473. * Observable raised when the pointer move from the utility layer scene to the main scene
  50474. */
  50475. onPointerOutObservable: Observable<number>;
  50476. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50477. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50478. private _afterRenderObserver;
  50479. private _sceneDisposeObserver;
  50480. private _originalPointerObserver;
  50481. /**
  50482. * Instantiates a UtilityLayerRenderer
  50483. * @param originalScene the original scene that will be rendered on top of
  50484. * @param handleEvents boolean indicating if the utility layer should handle events
  50485. */
  50486. constructor(
  50487. /** the original scene that will be rendered on top of */
  50488. originalScene: Scene, handleEvents?: boolean);
  50489. private _notifyObservers;
  50490. /**
  50491. * Renders the utility layers scene on top of the original scene
  50492. */
  50493. render(): void;
  50494. /**
  50495. * Disposes of the renderer
  50496. */
  50497. dispose(): void;
  50498. private _updateCamera;
  50499. }
  50500. }
  50501. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50502. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50504. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50505. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50506. import { Scene } from "babylonjs/scene";
  50507. import { Nullable } from "babylonjs/types";
  50508. import { Color3 } from "babylonjs/Maths/math.color";
  50509. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50510. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50511. /**
  50512. * Options interface for the pointer selection module
  50513. */
  50514. export interface IWebXRControllerPointerSelectionOptions {
  50515. /**
  50516. * if provided, this scene will be used to render meshes.
  50517. */
  50518. customUtilityLayerScene?: Scene;
  50519. /**
  50520. * 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)
  50521. * If not disabled, the last picked point will be used to execute a pointer up event
  50522. * If disabled, pointer up event will be triggered right after the pointer down event.
  50523. * Used in screen and gaze target ray mode only
  50524. */
  50525. disablePointerUpOnTouchOut: boolean;
  50526. /**
  50527. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50528. */
  50529. forceGazeMode: boolean;
  50530. /**
  50531. * 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
  50532. * to start a new countdown to the pointer down event.
  50533. * Defaults to 1.
  50534. */
  50535. gazeModePointerMovedFactor?: number;
  50536. /**
  50537. * Different button type to use instead of the main component
  50538. */
  50539. overrideButtonId?: string;
  50540. /**
  50541. * use this rendering group id for the meshes (optional)
  50542. */
  50543. renderingGroupId?: number;
  50544. /**
  50545. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50546. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50547. * 3000 means 3 seconds between pointing at something and selecting it
  50548. */
  50549. timeToSelect?: number;
  50550. /**
  50551. * Should meshes created here be added to a utility layer or the main scene
  50552. */
  50553. useUtilityLayer?: boolean;
  50554. /**
  50555. * Optional WebXR camera to be used for gaze selection
  50556. */
  50557. gazeCamera?: WebXRCamera;
  50558. /**
  50559. * the xr input to use with this pointer selection
  50560. */
  50561. xrInput: WebXRInput;
  50562. }
  50563. /**
  50564. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50565. */
  50566. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50567. private readonly _options;
  50568. private static _idCounter;
  50569. private _attachController;
  50570. private _controllers;
  50571. private _scene;
  50572. private _tmpVectorForPickCompare;
  50573. /**
  50574. * The module's name
  50575. */
  50576. static readonly Name: string;
  50577. /**
  50578. * The (Babylon) version of this module.
  50579. * This is an integer representing the implementation version.
  50580. * This number does not correspond to the WebXR specs version
  50581. */
  50582. static readonly Version: number;
  50583. /**
  50584. * Disable lighting on the laser pointer (so it will always be visible)
  50585. */
  50586. disablePointerLighting: boolean;
  50587. /**
  50588. * Disable lighting on the selection mesh (so it will always be visible)
  50589. */
  50590. disableSelectionMeshLighting: boolean;
  50591. /**
  50592. * Should the laser pointer be displayed
  50593. */
  50594. displayLaserPointer: boolean;
  50595. /**
  50596. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50597. */
  50598. displaySelectionMesh: boolean;
  50599. /**
  50600. * This color will be set to the laser pointer when selection is triggered
  50601. */
  50602. laserPointerPickedColor: Color3;
  50603. /**
  50604. * Default color of the laser pointer
  50605. */
  50606. laserPointerDefaultColor: Color3;
  50607. /**
  50608. * default color of the selection ring
  50609. */
  50610. selectionMeshDefaultColor: Color3;
  50611. /**
  50612. * This color will be applied to the selection ring when selection is triggered
  50613. */
  50614. selectionMeshPickedColor: Color3;
  50615. /**
  50616. * Optional filter to be used for ray selection. This predicate shares behavior with
  50617. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50618. */
  50619. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50620. /**
  50621. * constructs a new background remover module
  50622. * @param _xrSessionManager the session manager for this module
  50623. * @param _options read-only options to be used in this module
  50624. */
  50625. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50626. /**
  50627. * attach this feature
  50628. * Will usually be called by the features manager
  50629. *
  50630. * @returns true if successful.
  50631. */
  50632. attach(): boolean;
  50633. /**
  50634. * detach this feature.
  50635. * Will usually be called by the features manager
  50636. *
  50637. * @returns true if successful.
  50638. */
  50639. detach(): boolean;
  50640. /**
  50641. * Will get the mesh under a specific pointer.
  50642. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50643. * @param controllerId the controllerId to check
  50644. * @returns The mesh under pointer or null if no mesh is under the pointer
  50645. */
  50646. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50647. /**
  50648. * Get the xr controller that correlates to the pointer id in the pointer event
  50649. *
  50650. * @param id the pointer id to search for
  50651. * @returns the controller that correlates to this id or null if not found
  50652. */
  50653. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50654. protected _onXRFrame(_xrFrame: XRFrame): void;
  50655. private _attachGazeMode;
  50656. private _attachScreenRayMode;
  50657. private _attachTrackedPointerRayMode;
  50658. private _convertNormalToDirectionOfRay;
  50659. private _detachController;
  50660. private _generateNewMeshPair;
  50661. private _pickingMoved;
  50662. private _updatePointerDistance;
  50663. /** @hidden */
  50664. get lasterPointerDefaultColor(): Color3;
  50665. }
  50666. }
  50667. declare module "babylonjs/XR/webXREnterExitUI" {
  50668. import { Nullable } from "babylonjs/types";
  50669. import { Observable } from "babylonjs/Misc/observable";
  50670. import { IDisposable, Scene } from "babylonjs/scene";
  50671. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50672. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50673. /**
  50674. * Button which can be used to enter a different mode of XR
  50675. */
  50676. export class WebXREnterExitUIButton {
  50677. /** button element */
  50678. element: HTMLElement;
  50679. /** XR initialization options for the button */
  50680. sessionMode: XRSessionMode;
  50681. /** Reference space type */
  50682. referenceSpaceType: XRReferenceSpaceType;
  50683. /**
  50684. * Creates a WebXREnterExitUIButton
  50685. * @param element button element
  50686. * @param sessionMode XR initialization session mode
  50687. * @param referenceSpaceType the type of reference space to be used
  50688. */
  50689. constructor(
  50690. /** button element */
  50691. element: HTMLElement,
  50692. /** XR initialization options for the button */
  50693. sessionMode: XRSessionMode,
  50694. /** Reference space type */
  50695. referenceSpaceType: XRReferenceSpaceType);
  50696. /**
  50697. * Extendable function which can be used to update the button's visuals when the state changes
  50698. * @param activeButton the current active button in the UI
  50699. */
  50700. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50701. }
  50702. /**
  50703. * Options to create the webXR UI
  50704. */
  50705. export class WebXREnterExitUIOptions {
  50706. /**
  50707. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50708. */
  50709. customButtons?: Array<WebXREnterExitUIButton>;
  50710. /**
  50711. * A reference space type to use when creating the default button.
  50712. * Default is local-floor
  50713. */
  50714. referenceSpaceType?: XRReferenceSpaceType;
  50715. /**
  50716. * Context to enter xr with
  50717. */
  50718. renderTarget?: Nullable<WebXRRenderTarget>;
  50719. /**
  50720. * A session mode to use when creating the default button.
  50721. * Default is immersive-vr
  50722. */
  50723. sessionMode?: XRSessionMode;
  50724. /**
  50725. * A list of optional features to init the session with
  50726. */
  50727. optionalFeatures?: string[];
  50728. /**
  50729. * A list of optional features to init the session with
  50730. */
  50731. requiredFeatures?: string[];
  50732. }
  50733. /**
  50734. * UI to allow the user to enter/exit XR mode
  50735. */
  50736. export class WebXREnterExitUI implements IDisposable {
  50737. private scene;
  50738. /** version of the options passed to this UI */
  50739. options: WebXREnterExitUIOptions;
  50740. private _activeButton;
  50741. private _buttons;
  50742. private _overlay;
  50743. /**
  50744. * Fired every time the active button is changed.
  50745. *
  50746. * When xr is entered via a button that launches xr that button will be the callback parameter
  50747. *
  50748. * When exiting xr the callback parameter will be null)
  50749. */
  50750. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50751. /**
  50752. *
  50753. * @param scene babylon scene object to use
  50754. * @param options (read-only) version of the options passed to this UI
  50755. */
  50756. private constructor();
  50757. /**
  50758. * Creates UI to allow the user to enter/exit XR mode
  50759. * @param scene the scene to add the ui to
  50760. * @param helper the xr experience helper to enter/exit xr with
  50761. * @param options options to configure the UI
  50762. * @returns the created ui
  50763. */
  50764. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50765. /**
  50766. * Disposes of the XR UI component
  50767. */
  50768. dispose(): void;
  50769. private _updateButtons;
  50770. }
  50771. }
  50772. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50773. import { Vector3 } from "babylonjs/Maths/math.vector";
  50774. import { Color4 } from "babylonjs/Maths/math.color";
  50775. import { Nullable } from "babylonjs/types";
  50776. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50777. import { Scene } from "babylonjs/scene";
  50778. /**
  50779. * Class containing static functions to help procedurally build meshes
  50780. */
  50781. export class LinesBuilder {
  50782. /**
  50783. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50784. * * 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
  50785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50786. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50787. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50788. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50789. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50790. * * 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
  50791. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50794. * @param name defines the name of the new line system
  50795. * @param options defines the options used to create the line system
  50796. * @param scene defines the hosting scene
  50797. * @returns a new line system mesh
  50798. */
  50799. static CreateLineSystem(name: string, options: {
  50800. lines: Vector3[][];
  50801. updatable?: boolean;
  50802. instance?: Nullable<LinesMesh>;
  50803. colors?: Nullable<Color4[][]>;
  50804. useVertexAlpha?: boolean;
  50805. }, scene: Nullable<Scene>): LinesMesh;
  50806. /**
  50807. * Creates a line mesh
  50808. * 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
  50809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50810. * * The parameter `points` is an array successive Vector3
  50811. * * 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
  50812. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50813. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50814. * * When updating an instance, remember that only point positions can change, not the number of points
  50815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50817. * @param name defines the name of the new line system
  50818. * @param options defines the options used to create the line system
  50819. * @param scene defines the hosting scene
  50820. * @returns a new line mesh
  50821. */
  50822. static CreateLines(name: string, options: {
  50823. points: Vector3[];
  50824. updatable?: boolean;
  50825. instance?: Nullable<LinesMesh>;
  50826. colors?: Color4[];
  50827. useVertexAlpha?: boolean;
  50828. }, scene?: Nullable<Scene>): LinesMesh;
  50829. /**
  50830. * Creates a dashed line mesh
  50831. * * 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
  50832. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50833. * * The parameter `points` is an array successive Vector3
  50834. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50835. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50836. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50837. * * 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
  50838. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50839. * * When updating an instance, remember that only point positions can change, not the number of points
  50840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50841. * @param name defines the name of the mesh
  50842. * @param options defines the options used to create the mesh
  50843. * @param scene defines the hosting scene
  50844. * @returns the dashed line mesh
  50845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50846. */
  50847. static CreateDashedLines(name: string, options: {
  50848. points: Vector3[];
  50849. dashSize?: number;
  50850. gapSize?: number;
  50851. dashNb?: number;
  50852. updatable?: boolean;
  50853. instance?: LinesMesh;
  50854. useVertexAlpha?: boolean;
  50855. }, scene?: Nullable<Scene>): LinesMesh;
  50856. }
  50857. }
  50858. declare module "babylonjs/Misc/timer" {
  50859. import { Observable, Observer } from "babylonjs/Misc/observable";
  50860. import { Nullable } from "babylonjs/types";
  50861. import { IDisposable } from "babylonjs/scene";
  50862. /**
  50863. * Construction options for a timer
  50864. */
  50865. export interface ITimerOptions<T> {
  50866. /**
  50867. * Time-to-end
  50868. */
  50869. timeout: number;
  50870. /**
  50871. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50872. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50873. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50874. */
  50875. contextObservable: Observable<T>;
  50876. /**
  50877. * Optional parameters when adding an observer to the observable
  50878. */
  50879. observableParameters?: {
  50880. mask?: number;
  50881. insertFirst?: boolean;
  50882. scope?: any;
  50883. };
  50884. /**
  50885. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50886. */
  50887. breakCondition?: (data?: ITimerData<T>) => boolean;
  50888. /**
  50889. * Will be triggered when the time condition has met
  50890. */
  50891. onEnded?: (data: ITimerData<any>) => void;
  50892. /**
  50893. * Will be triggered when the break condition has met (prematurely ended)
  50894. */
  50895. onAborted?: (data: ITimerData<any>) => void;
  50896. /**
  50897. * Optional function to execute on each tick (or count)
  50898. */
  50899. onTick?: (data: ITimerData<any>) => void;
  50900. }
  50901. /**
  50902. * An interface defining the data sent by the timer
  50903. */
  50904. export interface ITimerData<T> {
  50905. /**
  50906. * When did it start
  50907. */
  50908. startTime: number;
  50909. /**
  50910. * Time now
  50911. */
  50912. currentTime: number;
  50913. /**
  50914. * Time passed since started
  50915. */
  50916. deltaTime: number;
  50917. /**
  50918. * How much is completed, in [0.0...1.0].
  50919. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50920. */
  50921. completeRate: number;
  50922. /**
  50923. * What the registered observable sent in the last count
  50924. */
  50925. payload: T;
  50926. }
  50927. /**
  50928. * The current state of the timer
  50929. */
  50930. export enum TimerState {
  50931. /**
  50932. * Timer initialized, not yet started
  50933. */
  50934. INIT = 0,
  50935. /**
  50936. * Timer started and counting
  50937. */
  50938. STARTED = 1,
  50939. /**
  50940. * Timer ended (whether aborted or time reached)
  50941. */
  50942. ENDED = 2
  50943. }
  50944. /**
  50945. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50946. *
  50947. * @param options options with which to initialize this timer
  50948. */
  50949. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50950. /**
  50951. * An advanced implementation of a timer class
  50952. */
  50953. export class AdvancedTimer<T = any> implements IDisposable {
  50954. /**
  50955. * Will notify each time the timer calculates the remaining time
  50956. */
  50957. onEachCountObservable: Observable<ITimerData<T>>;
  50958. /**
  50959. * Will trigger when the timer was aborted due to the break condition
  50960. */
  50961. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50962. /**
  50963. * Will trigger when the timer ended successfully
  50964. */
  50965. onTimerEndedObservable: Observable<ITimerData<T>>;
  50966. /**
  50967. * Will trigger when the timer state has changed
  50968. */
  50969. onStateChangedObservable: Observable<TimerState>;
  50970. private _observer;
  50971. private _contextObservable;
  50972. private _observableParameters;
  50973. private _startTime;
  50974. private _timer;
  50975. private _state;
  50976. private _breakCondition;
  50977. private _timeToEnd;
  50978. private _breakOnNextTick;
  50979. /**
  50980. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50981. * @param options construction options for this advanced timer
  50982. */
  50983. constructor(options: ITimerOptions<T>);
  50984. /**
  50985. * set a breaking condition for this timer. Default is to never break during count
  50986. * @param predicate the new break condition. Returns true to break, false otherwise
  50987. */
  50988. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50989. /**
  50990. * Reset ALL associated observables in this advanced timer
  50991. */
  50992. clearObservables(): void;
  50993. /**
  50994. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50995. *
  50996. * @param timeToEnd how much time to measure until timer ended
  50997. */
  50998. start(timeToEnd?: number): void;
  50999. /**
  51000. * Will force a stop on the next tick.
  51001. */
  51002. stop(): void;
  51003. /**
  51004. * Dispose this timer, clearing all resources
  51005. */
  51006. dispose(): void;
  51007. private _setState;
  51008. private _tick;
  51009. private _stop;
  51010. }
  51011. }
  51012. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51013. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51014. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51015. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51017. import { Vector3 } from "babylonjs/Maths/math.vector";
  51018. import { Material } from "babylonjs/Materials/material";
  51019. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51020. import { Scene } from "babylonjs/scene";
  51021. /**
  51022. * The options container for the teleportation module
  51023. */
  51024. export interface IWebXRTeleportationOptions {
  51025. /**
  51026. * if provided, this scene will be used to render meshes.
  51027. */
  51028. customUtilityLayerScene?: Scene;
  51029. /**
  51030. * Values to configure the default target mesh
  51031. */
  51032. defaultTargetMeshOptions?: {
  51033. /**
  51034. * Fill color of the teleportation area
  51035. */
  51036. teleportationFillColor?: string;
  51037. /**
  51038. * Border color for the teleportation area
  51039. */
  51040. teleportationBorderColor?: string;
  51041. /**
  51042. * Disable the mesh's animation sequence
  51043. */
  51044. disableAnimation?: boolean;
  51045. /**
  51046. * Disable lighting on the material or the ring and arrow
  51047. */
  51048. disableLighting?: boolean;
  51049. /**
  51050. * Override the default material of the torus and arrow
  51051. */
  51052. torusArrowMaterial?: Material;
  51053. };
  51054. /**
  51055. * A list of meshes to use as floor meshes.
  51056. * Meshes can be added and removed after initializing the feature using the
  51057. * addFloorMesh and removeFloorMesh functions
  51058. * If empty, rotation will still work
  51059. */
  51060. floorMeshes?: AbstractMesh[];
  51061. /**
  51062. * use this rendering group id for the meshes (optional)
  51063. */
  51064. renderingGroupId?: number;
  51065. /**
  51066. * Should teleportation move only to snap points
  51067. */
  51068. snapPointsOnly?: boolean;
  51069. /**
  51070. * An array of points to which the teleportation will snap to.
  51071. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51072. */
  51073. snapPositions?: Vector3[];
  51074. /**
  51075. * How close should the teleportation ray be in order to snap to position.
  51076. * Default to 0.8 units (meters)
  51077. */
  51078. snapToPositionRadius?: number;
  51079. /**
  51080. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51081. * If you want to support rotation, make sure your mesh has a direction indicator.
  51082. *
  51083. * When left untouched, the default mesh will be initialized.
  51084. */
  51085. teleportationTargetMesh?: AbstractMesh;
  51086. /**
  51087. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51088. */
  51089. timeToTeleport?: number;
  51090. /**
  51091. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51092. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51093. */
  51094. useMainComponentOnly?: boolean;
  51095. /**
  51096. * Should meshes created here be added to a utility layer or the main scene
  51097. */
  51098. useUtilityLayer?: boolean;
  51099. /**
  51100. * Babylon XR Input class for controller
  51101. */
  51102. xrInput: WebXRInput;
  51103. }
  51104. /**
  51105. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51106. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51107. * the input of the attached controllers.
  51108. */
  51109. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51110. private _options;
  51111. private _controllers;
  51112. private _currentTeleportationControllerId;
  51113. private _floorMeshes;
  51114. private _quadraticBezierCurve;
  51115. private _selectionFeature;
  51116. private _snapToPositions;
  51117. private _snappedToPoint;
  51118. private _teleportationRingMaterial?;
  51119. private _tmpRay;
  51120. private _tmpVector;
  51121. /**
  51122. * The module's name
  51123. */
  51124. static readonly Name: string;
  51125. /**
  51126. * The (Babylon) version of this module.
  51127. * This is an integer representing the implementation version.
  51128. * This number does not correspond to the webxr specs version
  51129. */
  51130. static readonly Version: number;
  51131. /**
  51132. * Is movement backwards enabled
  51133. */
  51134. backwardsMovementEnabled: boolean;
  51135. /**
  51136. * Distance to travel when moving backwards
  51137. */
  51138. backwardsTeleportationDistance: number;
  51139. /**
  51140. * The distance from the user to the inspection point in the direction of the controller
  51141. * A higher number will allow the user to move further
  51142. * defaults to 5 (meters, in xr units)
  51143. */
  51144. parabolicCheckRadius: number;
  51145. /**
  51146. * Should the module support parabolic ray on top of direct ray
  51147. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51148. * Very helpful when moving between floors / different heights
  51149. */
  51150. parabolicRayEnabled: boolean;
  51151. /**
  51152. * How much rotation should be applied when rotating right and left
  51153. */
  51154. rotationAngle: number;
  51155. /**
  51156. * Is rotation enabled when moving forward?
  51157. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51158. */
  51159. rotationEnabled: boolean;
  51160. /**
  51161. * constructs a new anchor system
  51162. * @param _xrSessionManager an instance of WebXRSessionManager
  51163. * @param _options configuration object for this feature
  51164. */
  51165. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51166. /**
  51167. * Get the snapPointsOnly flag
  51168. */
  51169. get snapPointsOnly(): boolean;
  51170. /**
  51171. * Sets the snapPointsOnly flag
  51172. * @param snapToPoints should teleportation be exclusively to snap points
  51173. */
  51174. set snapPointsOnly(snapToPoints: boolean);
  51175. /**
  51176. * Add a new mesh to the floor meshes array
  51177. * @param mesh the mesh to use as floor mesh
  51178. */
  51179. addFloorMesh(mesh: AbstractMesh): void;
  51180. /**
  51181. * Add a new snap-to point to fix teleportation to this position
  51182. * @param newSnapPoint The new Snap-To point
  51183. */
  51184. addSnapPoint(newSnapPoint: Vector3): void;
  51185. attach(): boolean;
  51186. detach(): boolean;
  51187. dispose(): void;
  51188. /**
  51189. * Remove a mesh from the floor meshes array
  51190. * @param mesh the mesh to remove
  51191. */
  51192. removeFloorMesh(mesh: AbstractMesh): void;
  51193. /**
  51194. * Remove a mesh from the floor meshes array using its name
  51195. * @param name the mesh name to remove
  51196. */
  51197. removeFloorMeshByName(name: string): void;
  51198. /**
  51199. * 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
  51200. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51201. * @returns was the point found and removed or not
  51202. */
  51203. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51204. /**
  51205. * This function sets a selection feature that will be disabled when
  51206. * the forward ray is shown and will be reattached when hidden.
  51207. * This is used to remove the selection rays when moving.
  51208. * @param selectionFeature the feature to disable when forward movement is enabled
  51209. */
  51210. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51211. protected _onXRFrame(_xrFrame: XRFrame): void;
  51212. private _attachController;
  51213. private _createDefaultTargetMesh;
  51214. private _detachController;
  51215. private _findClosestSnapPointWithRadius;
  51216. private _setTargetMeshPosition;
  51217. private _setTargetMeshVisibility;
  51218. private _showParabolicPath;
  51219. private _teleportForward;
  51220. }
  51221. }
  51222. declare module "babylonjs/XR/webXRDefaultExperience" {
  51223. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51224. import { Scene } from "babylonjs/scene";
  51225. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51226. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51227. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51228. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51230. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51231. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51232. /**
  51233. * Options for the default xr helper
  51234. */
  51235. export class WebXRDefaultExperienceOptions {
  51236. /**
  51237. * Enable or disable default UI to enter XR
  51238. */
  51239. disableDefaultUI?: boolean;
  51240. /**
  51241. * Should teleportation not initialize. defaults to false.
  51242. */
  51243. disableTeleportation?: boolean;
  51244. /**
  51245. * Floor meshes that will be used for teleport
  51246. */
  51247. floorMeshes?: Array<AbstractMesh>;
  51248. /**
  51249. * If set to true, the first frame will not be used to reset position
  51250. * The first frame is mainly used when copying transformation from the old camera
  51251. * Mainly used in AR
  51252. */
  51253. ignoreNativeCameraTransformation?: boolean;
  51254. /**
  51255. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51256. */
  51257. inputOptions?: IWebXRInputOptions;
  51258. /**
  51259. * optional configuration for the output canvas
  51260. */
  51261. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51262. /**
  51263. * optional UI options. This can be used among other to change session mode and reference space type
  51264. */
  51265. uiOptions?: WebXREnterExitUIOptions;
  51266. /**
  51267. * When loading teleportation and pointer select, use stable versions instead of latest.
  51268. */
  51269. useStablePlugins?: boolean;
  51270. /**
  51271. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51272. */
  51273. renderingGroupId?: number;
  51274. /**
  51275. * A list of optional features to init the session with
  51276. * If set to true, all features we support will be added
  51277. */
  51278. optionalFeatures?: boolean | string[];
  51279. }
  51280. /**
  51281. * Default experience which provides a similar setup to the previous webVRExperience
  51282. */
  51283. export class WebXRDefaultExperience {
  51284. /**
  51285. * Base experience
  51286. */
  51287. baseExperience: WebXRExperienceHelper;
  51288. /**
  51289. * Enables ui for entering/exiting xr
  51290. */
  51291. enterExitUI: WebXREnterExitUI;
  51292. /**
  51293. * Input experience extension
  51294. */
  51295. input: WebXRInput;
  51296. /**
  51297. * Enables laser pointer and selection
  51298. */
  51299. pointerSelection: WebXRControllerPointerSelection;
  51300. /**
  51301. * Default target xr should render to
  51302. */
  51303. renderTarget: WebXRRenderTarget;
  51304. /**
  51305. * Enables teleportation
  51306. */
  51307. teleportation: WebXRMotionControllerTeleportation;
  51308. private constructor();
  51309. /**
  51310. * Creates the default xr experience
  51311. * @param scene scene
  51312. * @param options options for basic configuration
  51313. * @returns resulting WebXRDefaultExperience
  51314. */
  51315. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51316. /**
  51317. * DIsposes of the experience helper
  51318. */
  51319. dispose(): void;
  51320. }
  51321. }
  51322. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51323. import { Observable } from "babylonjs/Misc/observable";
  51324. import { Nullable } from "babylonjs/types";
  51325. import { Camera } from "babylonjs/Cameras/camera";
  51326. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51327. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51328. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51329. import { Scene } from "babylonjs/scene";
  51330. import { Vector3 } from "babylonjs/Maths/math.vector";
  51331. import { Color3 } from "babylonjs/Maths/math.color";
  51332. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51334. import { Mesh } from "babylonjs/Meshes/mesh";
  51335. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51336. import { EasingFunction } from "babylonjs/Animations/easing";
  51337. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51338. import "babylonjs/Meshes/Builders/groundBuilder";
  51339. import "babylonjs/Meshes/Builders/torusBuilder";
  51340. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51341. import "babylonjs/Gamepads/gamepadSceneComponent";
  51342. import "babylonjs/Animations/animatable";
  51343. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51344. /**
  51345. * Options to modify the vr teleportation behavior.
  51346. */
  51347. export interface VRTeleportationOptions {
  51348. /**
  51349. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51350. */
  51351. floorMeshName?: string;
  51352. /**
  51353. * A list of meshes to be used as the teleportation floor. (default: empty)
  51354. */
  51355. floorMeshes?: Mesh[];
  51356. /**
  51357. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51358. */
  51359. teleportationMode?: number;
  51360. /**
  51361. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51362. */
  51363. teleportationTime?: number;
  51364. /**
  51365. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51366. */
  51367. teleportationSpeed?: number;
  51368. /**
  51369. * The easing function used in the animation or null for Linear. (default CircleEase)
  51370. */
  51371. easingFunction?: EasingFunction;
  51372. }
  51373. /**
  51374. * Options to modify the vr experience helper's behavior.
  51375. */
  51376. export interface VRExperienceHelperOptions extends WebVROptions {
  51377. /**
  51378. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51379. */
  51380. createDeviceOrientationCamera?: boolean;
  51381. /**
  51382. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51383. */
  51384. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51385. /**
  51386. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51387. */
  51388. laserToggle?: boolean;
  51389. /**
  51390. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51391. */
  51392. floorMeshes?: Mesh[];
  51393. /**
  51394. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51395. */
  51396. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51397. /**
  51398. * Defines if WebXR should be used instead of WebVR (if available)
  51399. */
  51400. useXR?: boolean;
  51401. }
  51402. /**
  51403. * Event containing information after VR has been entered
  51404. */
  51405. export class OnAfterEnteringVRObservableEvent {
  51406. /**
  51407. * If entering vr was successful
  51408. */
  51409. success: boolean;
  51410. }
  51411. /**
  51412. * Helps to quickly add VR support to an existing scene.
  51413. * See https://doc.babylonjs.com/how_to/webvr_helper
  51414. */
  51415. export class VRExperienceHelper {
  51416. /** Options to modify the vr experience helper's behavior. */
  51417. webVROptions: VRExperienceHelperOptions;
  51418. private _scene;
  51419. private _position;
  51420. private _btnVR;
  51421. private _btnVRDisplayed;
  51422. private _webVRsupported;
  51423. private _webVRready;
  51424. private _webVRrequesting;
  51425. private _webVRpresenting;
  51426. private _hasEnteredVR;
  51427. private _fullscreenVRpresenting;
  51428. private _inputElement;
  51429. private _webVRCamera;
  51430. private _vrDeviceOrientationCamera;
  51431. private _deviceOrientationCamera;
  51432. private _existingCamera;
  51433. private _onKeyDown;
  51434. private _onVrDisplayPresentChange;
  51435. private _onVRDisplayChanged;
  51436. private _onVRRequestPresentStart;
  51437. private _onVRRequestPresentComplete;
  51438. /**
  51439. * 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)
  51440. */
  51441. enableGazeEvenWhenNoPointerLock: boolean;
  51442. /**
  51443. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51444. */
  51445. exitVROnDoubleTap: boolean;
  51446. /**
  51447. * Observable raised right before entering VR.
  51448. */
  51449. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51450. /**
  51451. * Observable raised when entering VR has completed.
  51452. */
  51453. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51454. /**
  51455. * Observable raised when exiting VR.
  51456. */
  51457. onExitingVRObservable: Observable<VRExperienceHelper>;
  51458. /**
  51459. * Observable raised when controller mesh is loaded.
  51460. */
  51461. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51462. /** Return this.onEnteringVRObservable
  51463. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51464. */
  51465. get onEnteringVR(): Observable<VRExperienceHelper>;
  51466. /** Return this.onExitingVRObservable
  51467. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51468. */
  51469. get onExitingVR(): Observable<VRExperienceHelper>;
  51470. /** Return this.onControllerMeshLoadedObservable
  51471. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51472. */
  51473. get onControllerMeshLoaded(): Observable<WebVRController>;
  51474. private _rayLength;
  51475. private _useCustomVRButton;
  51476. private _teleportationRequested;
  51477. private _teleportActive;
  51478. private _floorMeshName;
  51479. private _floorMeshesCollection;
  51480. private _teleportationMode;
  51481. private _teleportationTime;
  51482. private _teleportationSpeed;
  51483. private _teleportationEasing;
  51484. private _rotationAllowed;
  51485. private _teleportBackwardsVector;
  51486. private _teleportationTarget;
  51487. private _isDefaultTeleportationTarget;
  51488. private _postProcessMove;
  51489. private _teleportationFillColor;
  51490. private _teleportationBorderColor;
  51491. private _rotationAngle;
  51492. private _haloCenter;
  51493. private _cameraGazer;
  51494. private _padSensibilityUp;
  51495. private _padSensibilityDown;
  51496. private _leftController;
  51497. private _rightController;
  51498. private _gazeColor;
  51499. private _laserColor;
  51500. private _pickedLaserColor;
  51501. private _pickedGazeColor;
  51502. /**
  51503. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51504. */
  51505. onNewMeshSelected: Observable<AbstractMesh>;
  51506. /**
  51507. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51508. * This observable will provide the mesh and the controller used to select the mesh
  51509. */
  51510. onMeshSelectedWithController: Observable<{
  51511. mesh: AbstractMesh;
  51512. controller: WebVRController;
  51513. }>;
  51514. /**
  51515. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51516. */
  51517. onNewMeshPicked: Observable<PickingInfo>;
  51518. private _circleEase;
  51519. /**
  51520. * Observable raised before camera teleportation
  51521. */
  51522. onBeforeCameraTeleport: Observable<Vector3>;
  51523. /**
  51524. * Observable raised after camera teleportation
  51525. */
  51526. onAfterCameraTeleport: Observable<Vector3>;
  51527. /**
  51528. * Observable raised when current selected mesh gets unselected
  51529. */
  51530. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51531. private _raySelectionPredicate;
  51532. /**
  51533. * To be optionaly changed by user to define custom ray selection
  51534. */
  51535. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51536. /**
  51537. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51538. */
  51539. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51540. /**
  51541. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51542. */
  51543. teleportationEnabled: boolean;
  51544. private _defaultHeight;
  51545. private _teleportationInitialized;
  51546. private _interactionsEnabled;
  51547. private _interactionsRequested;
  51548. private _displayGaze;
  51549. private _displayLaserPointer;
  51550. /**
  51551. * The mesh used to display where the user is going to teleport.
  51552. */
  51553. get teleportationTarget(): Mesh;
  51554. /**
  51555. * Sets the mesh to be used to display where the user is going to teleport.
  51556. */
  51557. set teleportationTarget(value: Mesh);
  51558. /**
  51559. * 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
  51560. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51561. * See https://doc.babylonjs.com/resources/baking_transformations
  51562. */
  51563. get gazeTrackerMesh(): Mesh;
  51564. set gazeTrackerMesh(value: Mesh);
  51565. /**
  51566. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51567. */
  51568. updateGazeTrackerScale: boolean;
  51569. /**
  51570. * If the gaze trackers color should be updated when selecting meshes
  51571. */
  51572. updateGazeTrackerColor: boolean;
  51573. /**
  51574. * If the controller laser color should be updated when selecting meshes
  51575. */
  51576. updateControllerLaserColor: boolean;
  51577. /**
  51578. * The gaze tracking mesh corresponding to the left controller
  51579. */
  51580. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51581. /**
  51582. * The gaze tracking mesh corresponding to the right controller
  51583. */
  51584. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51585. /**
  51586. * If the ray of the gaze should be displayed.
  51587. */
  51588. get displayGaze(): boolean;
  51589. /**
  51590. * Sets if the ray of the gaze should be displayed.
  51591. */
  51592. set displayGaze(value: boolean);
  51593. /**
  51594. * If the ray of the LaserPointer should be displayed.
  51595. */
  51596. get displayLaserPointer(): boolean;
  51597. /**
  51598. * Sets if the ray of the LaserPointer should be displayed.
  51599. */
  51600. set displayLaserPointer(value: boolean);
  51601. /**
  51602. * The deviceOrientationCamera used as the camera when not in VR.
  51603. */
  51604. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51605. /**
  51606. * Based on the current WebVR support, returns the current VR camera used.
  51607. */
  51608. get currentVRCamera(): Nullable<Camera>;
  51609. /**
  51610. * The webVRCamera which is used when in VR.
  51611. */
  51612. get webVRCamera(): WebVRFreeCamera;
  51613. /**
  51614. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51615. */
  51616. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51617. /**
  51618. * The html button that is used to trigger entering into VR.
  51619. */
  51620. get vrButton(): Nullable<HTMLButtonElement>;
  51621. private get _teleportationRequestInitiated();
  51622. /**
  51623. * Defines whether or not Pointer lock should be requested when switching to
  51624. * full screen.
  51625. */
  51626. requestPointerLockOnFullScreen: boolean;
  51627. /**
  51628. * If asking to force XR, this will be populated with the default xr experience
  51629. */
  51630. xr: WebXRDefaultExperience;
  51631. /**
  51632. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51633. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51634. */
  51635. xrTestDone: boolean;
  51636. /**
  51637. * Instantiates a VRExperienceHelper.
  51638. * Helps to quickly add VR support to an existing scene.
  51639. * @param scene The scene the VRExperienceHelper belongs to.
  51640. * @param webVROptions Options to modify the vr experience helper's behavior.
  51641. */
  51642. constructor(scene: Scene,
  51643. /** Options to modify the vr experience helper's behavior. */
  51644. webVROptions?: VRExperienceHelperOptions);
  51645. private completeVRInit;
  51646. private _onDefaultMeshLoaded;
  51647. private _onResize;
  51648. private _onFullscreenChange;
  51649. /**
  51650. * Gets a value indicating if we are currently in VR mode.
  51651. */
  51652. get isInVRMode(): boolean;
  51653. private onVrDisplayPresentChange;
  51654. private onVRDisplayChanged;
  51655. private moveButtonToBottomRight;
  51656. private displayVRButton;
  51657. private updateButtonVisibility;
  51658. private _cachedAngularSensibility;
  51659. /**
  51660. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51661. * Otherwise, will use the fullscreen API.
  51662. */
  51663. enterVR(): void;
  51664. /**
  51665. * Attempt to exit VR, or fullscreen.
  51666. */
  51667. exitVR(): void;
  51668. /**
  51669. * The position of the vr experience helper.
  51670. */
  51671. get position(): Vector3;
  51672. /**
  51673. * Sets the position of the vr experience helper.
  51674. */
  51675. set position(value: Vector3);
  51676. /**
  51677. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51678. */
  51679. enableInteractions(): void;
  51680. private get _noControllerIsActive();
  51681. private beforeRender;
  51682. private _isTeleportationFloor;
  51683. /**
  51684. * Adds a floor mesh to be used for teleportation.
  51685. * @param floorMesh the mesh to be used for teleportation.
  51686. */
  51687. addFloorMesh(floorMesh: Mesh): void;
  51688. /**
  51689. * Removes a floor mesh from being used for teleportation.
  51690. * @param floorMesh the mesh to be removed.
  51691. */
  51692. removeFloorMesh(floorMesh: Mesh): void;
  51693. /**
  51694. * Enables interactions and teleportation using the VR controllers and gaze.
  51695. * @param vrTeleportationOptions options to modify teleportation behavior.
  51696. */
  51697. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51698. private _onNewGamepadConnected;
  51699. private _tryEnableInteractionOnController;
  51700. private _onNewGamepadDisconnected;
  51701. private _enableInteractionOnController;
  51702. private _checkTeleportWithRay;
  51703. private _checkRotate;
  51704. private _checkTeleportBackwards;
  51705. private _enableTeleportationOnController;
  51706. private _createTeleportationCircles;
  51707. private _displayTeleportationTarget;
  51708. private _hideTeleportationTarget;
  51709. private _rotateCamera;
  51710. private _moveTeleportationSelectorTo;
  51711. private _workingVector;
  51712. private _workingQuaternion;
  51713. private _workingMatrix;
  51714. /**
  51715. * Time Constant Teleportation Mode
  51716. */
  51717. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51718. /**
  51719. * Speed Constant Teleportation Mode
  51720. */
  51721. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51722. /**
  51723. * Teleports the users feet to the desired location
  51724. * @param location The location where the user's feet should be placed
  51725. */
  51726. teleportCamera(location: Vector3): void;
  51727. private _convertNormalToDirectionOfRay;
  51728. private _castRayAndSelectObject;
  51729. private _notifySelectedMeshUnselected;
  51730. /**
  51731. * Permanently set new colors for the laser pointer
  51732. * @param color the new laser color
  51733. * @param pickedColor the new laser color when picked mesh detected
  51734. */
  51735. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51736. /**
  51737. * Set lighting enabled / disabled on the laser pointer of both controllers
  51738. * @param enabled should the lighting be enabled on the laser pointer
  51739. */
  51740. setLaserLightingState(enabled?: boolean): void;
  51741. /**
  51742. * Permanently set new colors for the gaze pointer
  51743. * @param color the new gaze color
  51744. * @param pickedColor the new gaze color when picked mesh detected
  51745. */
  51746. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51747. /**
  51748. * Sets the color of the laser ray from the vr controllers.
  51749. * @param color new color for the ray.
  51750. */
  51751. changeLaserColor(color: Color3): void;
  51752. /**
  51753. * Sets the color of the ray from the vr headsets gaze.
  51754. * @param color new color for the ray.
  51755. */
  51756. changeGazeColor(color: Color3): void;
  51757. /**
  51758. * Exits VR and disposes of the vr experience helper
  51759. */
  51760. dispose(): void;
  51761. /**
  51762. * Gets the name of the VRExperienceHelper class
  51763. * @returns "VRExperienceHelper"
  51764. */
  51765. getClassName(): string;
  51766. }
  51767. }
  51768. declare module "babylonjs/Cameras/VR/index" {
  51769. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51770. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51771. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51772. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51773. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51774. export * from "babylonjs/Cameras/VR/webVRCamera";
  51775. }
  51776. declare module "babylonjs/Cameras/RigModes/index" {
  51777. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51778. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51779. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51780. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51781. }
  51782. declare module "babylonjs/Cameras/index" {
  51783. export * from "babylonjs/Cameras/Inputs/index";
  51784. export * from "babylonjs/Cameras/cameraInputsManager";
  51785. export * from "babylonjs/Cameras/camera";
  51786. export * from "babylonjs/Cameras/targetCamera";
  51787. export * from "babylonjs/Cameras/freeCamera";
  51788. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51789. export * from "babylonjs/Cameras/touchCamera";
  51790. export * from "babylonjs/Cameras/arcRotateCamera";
  51791. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51792. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51793. export * from "babylonjs/Cameras/flyCamera";
  51794. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51795. export * from "babylonjs/Cameras/followCamera";
  51796. export * from "babylonjs/Cameras/followCameraInputsManager";
  51797. export * from "babylonjs/Cameras/gamepadCamera";
  51798. export * from "babylonjs/Cameras/Stereoscopic/index";
  51799. export * from "babylonjs/Cameras/universalCamera";
  51800. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51801. export * from "babylonjs/Cameras/VR/index";
  51802. export * from "babylonjs/Cameras/RigModes/index";
  51803. }
  51804. declare module "babylonjs/Collisions/index" {
  51805. export * from "babylonjs/Collisions/collider";
  51806. export * from "babylonjs/Collisions/collisionCoordinator";
  51807. export * from "babylonjs/Collisions/pickingInfo";
  51808. export * from "babylonjs/Collisions/intersectionInfo";
  51809. export * from "babylonjs/Collisions/meshCollisionData";
  51810. }
  51811. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51812. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51813. import { Vector3 } from "babylonjs/Maths/math.vector";
  51814. import { Ray } from "babylonjs/Culling/ray";
  51815. import { Plane } from "babylonjs/Maths/math.plane";
  51816. /**
  51817. * Contains an array of blocks representing the octree
  51818. */
  51819. export interface IOctreeContainer<T> {
  51820. /**
  51821. * Blocks within the octree
  51822. */
  51823. blocks: Array<OctreeBlock<T>>;
  51824. }
  51825. /**
  51826. * Class used to store a cell in an octree
  51827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51828. */
  51829. export class OctreeBlock<T> {
  51830. /**
  51831. * Gets the content of the current block
  51832. */
  51833. entries: T[];
  51834. /**
  51835. * Gets the list of block children
  51836. */
  51837. blocks: Array<OctreeBlock<T>>;
  51838. private _depth;
  51839. private _maxDepth;
  51840. private _capacity;
  51841. private _minPoint;
  51842. private _maxPoint;
  51843. private _boundingVectors;
  51844. private _creationFunc;
  51845. /**
  51846. * Creates a new block
  51847. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51848. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51849. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51850. * @param depth defines the current depth of this block in the octree
  51851. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51852. * @param creationFunc defines a callback to call when an element is added to the block
  51853. */
  51854. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51855. /**
  51856. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51857. */
  51858. get capacity(): number;
  51859. /**
  51860. * Gets the minimum vector (in world space) of the block's bounding box
  51861. */
  51862. get minPoint(): Vector3;
  51863. /**
  51864. * Gets the maximum vector (in world space) of the block's bounding box
  51865. */
  51866. get maxPoint(): Vector3;
  51867. /**
  51868. * Add a new element to this block
  51869. * @param entry defines the element to add
  51870. */
  51871. addEntry(entry: T): void;
  51872. /**
  51873. * Remove an element from this block
  51874. * @param entry defines the element to remove
  51875. */
  51876. removeEntry(entry: T): void;
  51877. /**
  51878. * Add an array of elements to this block
  51879. * @param entries defines the array of elements to add
  51880. */
  51881. addEntries(entries: T[]): void;
  51882. /**
  51883. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51884. * @param frustumPlanes defines the frustum planes to test
  51885. * @param selection defines the array to store current content if selection is positive
  51886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51887. */
  51888. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51889. /**
  51890. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51891. * @param sphereCenter defines the bounding sphere center
  51892. * @param sphereRadius defines the bounding sphere radius
  51893. * @param selection defines the array to store current content if selection is positive
  51894. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51895. */
  51896. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51897. /**
  51898. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51899. * @param ray defines the ray to test with
  51900. * @param selection defines the array to store current content if selection is positive
  51901. */
  51902. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51903. /**
  51904. * Subdivide the content into child blocks (this block will then be empty)
  51905. */
  51906. createInnerBlocks(): void;
  51907. /**
  51908. * @hidden
  51909. */
  51910. 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;
  51911. }
  51912. }
  51913. declare module "babylonjs/Culling/Octrees/octree" {
  51914. import { SmartArray } from "babylonjs/Misc/smartArray";
  51915. import { Vector3 } from "babylonjs/Maths/math.vector";
  51916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51918. import { Ray } from "babylonjs/Culling/ray";
  51919. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51920. import { Plane } from "babylonjs/Maths/math.plane";
  51921. /**
  51922. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51923. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51924. */
  51925. export class Octree<T> {
  51926. /** 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.) */
  51927. maxDepth: number;
  51928. /**
  51929. * Blocks within the octree containing objects
  51930. */
  51931. blocks: Array<OctreeBlock<T>>;
  51932. /**
  51933. * Content stored in the octree
  51934. */
  51935. dynamicContent: T[];
  51936. private _maxBlockCapacity;
  51937. private _selectionContent;
  51938. private _creationFunc;
  51939. /**
  51940. * Creates a octree
  51941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51942. * @param creationFunc function to be used to instatiate the octree
  51943. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51944. * @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.)
  51945. */
  51946. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51947. /** 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.) */
  51948. maxDepth?: number);
  51949. /**
  51950. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51951. * @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);
  51952. * @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);
  51953. * @param entries meshes to be added to the octree blocks
  51954. */
  51955. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51956. /**
  51957. * Adds a mesh to the octree
  51958. * @param entry Mesh to add to the octree
  51959. */
  51960. addMesh(entry: T): void;
  51961. /**
  51962. * Remove an element from the octree
  51963. * @param entry defines the element to remove
  51964. */
  51965. removeMesh(entry: T): void;
  51966. /**
  51967. * Selects an array of meshes within the frustum
  51968. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51969. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51970. * @returns array of meshes within the frustum
  51971. */
  51972. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51973. /**
  51974. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51975. * @param sphereCenter defines the bounding sphere center
  51976. * @param sphereRadius defines the bounding sphere radius
  51977. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51978. * @returns an array of objects that intersect the sphere
  51979. */
  51980. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51981. /**
  51982. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51983. * @param ray defines the ray to test with
  51984. * @returns array of intersected objects
  51985. */
  51986. intersectsRay(ray: Ray): SmartArray<T>;
  51987. /**
  51988. * Adds a mesh into the octree block if it intersects the block
  51989. */
  51990. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51991. /**
  51992. * Adds a submesh into the octree block if it intersects the block
  51993. */
  51994. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51995. }
  51996. }
  51997. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51998. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51999. import { Scene } from "babylonjs/scene";
  52000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52002. import { Ray } from "babylonjs/Culling/ray";
  52003. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52004. import { Collider } from "babylonjs/Collisions/collider";
  52005. module "babylonjs/scene" {
  52006. interface Scene {
  52007. /**
  52008. * @hidden
  52009. * Backing Filed
  52010. */
  52011. _selectionOctree: Octree<AbstractMesh>;
  52012. /**
  52013. * Gets the octree used to boost mesh selection (picking)
  52014. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52015. */
  52016. selectionOctree: Octree<AbstractMesh>;
  52017. /**
  52018. * Creates or updates the octree used to boost selection (picking)
  52019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52020. * @param maxCapacity defines the maximum capacity per leaf
  52021. * @param maxDepth defines the maximum depth of the octree
  52022. * @returns an octree of AbstractMesh
  52023. */
  52024. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52025. }
  52026. }
  52027. module "babylonjs/Meshes/abstractMesh" {
  52028. interface AbstractMesh {
  52029. /**
  52030. * @hidden
  52031. * Backing Field
  52032. */
  52033. _submeshesOctree: Octree<SubMesh>;
  52034. /**
  52035. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52036. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52037. * @param maxCapacity defines the maximum size of each block (64 by default)
  52038. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52039. * @returns the new octree
  52040. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52041. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52042. */
  52043. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52044. }
  52045. }
  52046. /**
  52047. * Defines the octree scene component responsible to manage any octrees
  52048. * in a given scene.
  52049. */
  52050. export class OctreeSceneComponent {
  52051. /**
  52052. * The component name help to identify the component in the list of scene components.
  52053. */
  52054. readonly name: string;
  52055. /**
  52056. * The scene the component belongs to.
  52057. */
  52058. scene: Scene;
  52059. /**
  52060. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52061. */
  52062. readonly checksIsEnabled: boolean;
  52063. /**
  52064. * Creates a new instance of the component for the given scene
  52065. * @param scene Defines the scene to register the component in
  52066. */
  52067. constructor(scene: Scene);
  52068. /**
  52069. * Registers the component in a given scene
  52070. */
  52071. register(): void;
  52072. /**
  52073. * Return the list of active meshes
  52074. * @returns the list of active meshes
  52075. */
  52076. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52077. /**
  52078. * Return the list of active sub meshes
  52079. * @param mesh The mesh to get the candidates sub meshes from
  52080. * @returns the list of active sub meshes
  52081. */
  52082. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52083. private _tempRay;
  52084. /**
  52085. * Return the list of sub meshes intersecting with a given local ray
  52086. * @param mesh defines the mesh to find the submesh for
  52087. * @param localRay defines the ray in local space
  52088. * @returns the list of intersecting sub meshes
  52089. */
  52090. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52091. /**
  52092. * Return the list of sub meshes colliding with a collider
  52093. * @param mesh defines the mesh to find the submesh for
  52094. * @param collider defines the collider to evaluate the collision against
  52095. * @returns the list of colliding sub meshes
  52096. */
  52097. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52098. /**
  52099. * Rebuilds the elements related to this component in case of
  52100. * context lost for instance.
  52101. */
  52102. rebuild(): void;
  52103. /**
  52104. * Disposes the component and the associated ressources.
  52105. */
  52106. dispose(): void;
  52107. }
  52108. }
  52109. declare module "babylonjs/Culling/Octrees/index" {
  52110. export * from "babylonjs/Culling/Octrees/octree";
  52111. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52112. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52113. }
  52114. declare module "babylonjs/Culling/index" {
  52115. export * from "babylonjs/Culling/boundingBox";
  52116. export * from "babylonjs/Culling/boundingInfo";
  52117. export * from "babylonjs/Culling/boundingSphere";
  52118. export * from "babylonjs/Culling/Octrees/index";
  52119. export * from "babylonjs/Culling/ray";
  52120. }
  52121. declare module "babylonjs/Gizmos/gizmo" {
  52122. import { Nullable } from "babylonjs/types";
  52123. import { IDisposable } from "babylonjs/scene";
  52124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52125. import { Mesh } from "babylonjs/Meshes/mesh";
  52126. import { Node } from "babylonjs/node";
  52127. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52128. /**
  52129. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52130. */
  52131. export class Gizmo implements IDisposable {
  52132. /** The utility layer the gizmo will be added to */
  52133. gizmoLayer: UtilityLayerRenderer;
  52134. /**
  52135. * The root mesh of the gizmo
  52136. */
  52137. _rootMesh: Mesh;
  52138. private _attachedMesh;
  52139. private _attachedNode;
  52140. /**
  52141. * Ratio for the scale of the gizmo (Default: 1)
  52142. */
  52143. scaleRatio: number;
  52144. /**
  52145. * If a custom mesh has been set (Default: false)
  52146. */
  52147. protected _customMeshSet: boolean;
  52148. /**
  52149. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52150. * * When set, interactions will be enabled
  52151. */
  52152. get attachedMesh(): Nullable<AbstractMesh>;
  52153. set attachedMesh(value: Nullable<AbstractMesh>);
  52154. /**
  52155. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52156. * * When set, interactions will be enabled
  52157. */
  52158. get attachedNode(): Nullable<Node>;
  52159. set attachedNode(value: Nullable<Node>);
  52160. /**
  52161. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52162. * @param mesh The mesh to replace the default mesh of the gizmo
  52163. */
  52164. setCustomMesh(mesh: Mesh): void;
  52165. /**
  52166. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52167. */
  52168. updateGizmoRotationToMatchAttachedMesh: boolean;
  52169. /**
  52170. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52171. */
  52172. updateGizmoPositionToMatchAttachedMesh: boolean;
  52173. /**
  52174. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52175. */
  52176. updateScale: boolean;
  52177. protected _interactionsEnabled: boolean;
  52178. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52179. private _beforeRenderObserver;
  52180. private _tempQuaternion;
  52181. private _tempVector;
  52182. private _tempVector2;
  52183. /**
  52184. * Creates a gizmo
  52185. * @param gizmoLayer The utility layer the gizmo will be added to
  52186. */
  52187. constructor(
  52188. /** The utility layer the gizmo will be added to */
  52189. gizmoLayer?: UtilityLayerRenderer);
  52190. /**
  52191. * Updates the gizmo to match the attached mesh's position/rotation
  52192. */
  52193. protected _update(): void;
  52194. /**
  52195. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52196. * @param value Node, TransformNode or mesh
  52197. */
  52198. protected _matrixChanged(): void;
  52199. /**
  52200. * Disposes of the gizmo
  52201. */
  52202. dispose(): void;
  52203. }
  52204. }
  52205. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52206. import { Observable } from "babylonjs/Misc/observable";
  52207. import { Nullable } from "babylonjs/types";
  52208. import { Vector3 } from "babylonjs/Maths/math.vector";
  52209. import { Color3 } from "babylonjs/Maths/math.color";
  52210. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52211. import { Node } from "babylonjs/node";
  52212. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52214. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52215. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52216. import { Scene } from "babylonjs/scene";
  52217. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52218. /**
  52219. * Single plane drag gizmo
  52220. */
  52221. export class PlaneDragGizmo extends Gizmo {
  52222. /**
  52223. * Drag behavior responsible for the gizmos dragging interactions
  52224. */
  52225. dragBehavior: PointerDragBehavior;
  52226. private _pointerObserver;
  52227. /**
  52228. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52229. */
  52230. snapDistance: number;
  52231. /**
  52232. * Event that fires each time the gizmo snaps to a new location.
  52233. * * snapDistance is the the change in distance
  52234. */
  52235. onSnapObservable: Observable<{
  52236. snapDistance: number;
  52237. }>;
  52238. private _plane;
  52239. private _coloredMaterial;
  52240. private _hoverMaterial;
  52241. private _isEnabled;
  52242. private _parent;
  52243. /** @hidden */
  52244. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52245. /** @hidden */
  52246. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52247. /**
  52248. * Creates a PlaneDragGizmo
  52249. * @param gizmoLayer The utility layer the gizmo will be added to
  52250. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52251. * @param color The color of the gizmo
  52252. */
  52253. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52254. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52255. /**
  52256. * If the gizmo is enabled
  52257. */
  52258. set isEnabled(value: boolean);
  52259. get isEnabled(): boolean;
  52260. /**
  52261. * Disposes of the gizmo
  52262. */
  52263. dispose(): void;
  52264. }
  52265. }
  52266. declare module "babylonjs/Gizmos/positionGizmo" {
  52267. import { Observable } from "babylonjs/Misc/observable";
  52268. import { Nullable } from "babylonjs/types";
  52269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52270. import { Node } from "babylonjs/node";
  52271. import { Mesh } from "babylonjs/Meshes/mesh";
  52272. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52273. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52274. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52275. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52276. /**
  52277. * Gizmo that enables dragging a mesh along 3 axis
  52278. */
  52279. export class PositionGizmo extends Gizmo {
  52280. /**
  52281. * Internal gizmo used for interactions on the x axis
  52282. */
  52283. xGizmo: AxisDragGizmo;
  52284. /**
  52285. * Internal gizmo used for interactions on the y axis
  52286. */
  52287. yGizmo: AxisDragGizmo;
  52288. /**
  52289. * Internal gizmo used for interactions on the z axis
  52290. */
  52291. zGizmo: AxisDragGizmo;
  52292. /**
  52293. * Internal gizmo used for interactions on the yz plane
  52294. */
  52295. xPlaneGizmo: PlaneDragGizmo;
  52296. /**
  52297. * Internal gizmo used for interactions on the xz plane
  52298. */
  52299. yPlaneGizmo: PlaneDragGizmo;
  52300. /**
  52301. * Internal gizmo used for interactions on the xy plane
  52302. */
  52303. zPlaneGizmo: PlaneDragGizmo;
  52304. /**
  52305. * private variables
  52306. */
  52307. private _meshAttached;
  52308. private _nodeAttached;
  52309. private _updateGizmoRotationToMatchAttachedMesh;
  52310. private _snapDistance;
  52311. private _scaleRatio;
  52312. /** Fires an event when any of it's sub gizmos are dragged */
  52313. onDragStartObservable: Observable<unknown>;
  52314. /** Fires an event when any of it's sub gizmos are released from dragging */
  52315. onDragEndObservable: Observable<unknown>;
  52316. /**
  52317. * If set to true, planar drag is enabled
  52318. */
  52319. private _planarGizmoEnabled;
  52320. get attachedMesh(): Nullable<AbstractMesh>;
  52321. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52322. get attachedNode(): Nullable<Node>;
  52323. set attachedNode(node: Nullable<Node>);
  52324. /**
  52325. * Creates a PositionGizmo
  52326. * @param gizmoLayer The utility layer the gizmo will be added to
  52327. @param thickness display gizmo axis thickness
  52328. */
  52329. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52330. /**
  52331. * If the planar drag gizmo is enabled
  52332. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52333. */
  52334. set planarGizmoEnabled(value: boolean);
  52335. get planarGizmoEnabled(): boolean;
  52336. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52337. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52338. /**
  52339. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52340. */
  52341. set snapDistance(value: number);
  52342. get snapDistance(): number;
  52343. /**
  52344. * Ratio for the scale of the gizmo (Default: 1)
  52345. */
  52346. set scaleRatio(value: number);
  52347. get scaleRatio(): number;
  52348. /**
  52349. * Disposes of the gizmo
  52350. */
  52351. dispose(): void;
  52352. /**
  52353. * CustomMeshes are not supported by this gizmo
  52354. * @param mesh The mesh to replace the default mesh of the gizmo
  52355. */
  52356. setCustomMesh(mesh: Mesh): void;
  52357. }
  52358. }
  52359. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52360. import { Observable } from "babylonjs/Misc/observable";
  52361. import { Nullable } from "babylonjs/types";
  52362. import { Vector3 } from "babylonjs/Maths/math.vector";
  52363. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52364. import { Node } from "babylonjs/node";
  52365. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52366. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52367. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52368. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52369. import { Scene } from "babylonjs/scene";
  52370. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52371. import { Color3 } from "babylonjs/Maths/math.color";
  52372. /**
  52373. * Single axis drag gizmo
  52374. */
  52375. export class AxisDragGizmo extends Gizmo {
  52376. /**
  52377. * Drag behavior responsible for the gizmos dragging interactions
  52378. */
  52379. dragBehavior: PointerDragBehavior;
  52380. private _pointerObserver;
  52381. /**
  52382. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52383. */
  52384. snapDistance: number;
  52385. /**
  52386. * Event that fires each time the gizmo snaps to a new location.
  52387. * * snapDistance is the the change in distance
  52388. */
  52389. onSnapObservable: Observable<{
  52390. snapDistance: number;
  52391. }>;
  52392. private _isEnabled;
  52393. private _parent;
  52394. private _arrow;
  52395. private _coloredMaterial;
  52396. private _hoverMaterial;
  52397. /** @hidden */
  52398. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52399. /** @hidden */
  52400. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52401. /**
  52402. * Creates an AxisDragGizmo
  52403. * @param gizmoLayer The utility layer the gizmo will be added to
  52404. * @param dragAxis The axis which the gizmo will be able to drag on
  52405. * @param color The color of the gizmo
  52406. * @param thickness display gizmo axis thickness
  52407. */
  52408. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52409. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52410. /**
  52411. * If the gizmo is enabled
  52412. */
  52413. set isEnabled(value: boolean);
  52414. get isEnabled(): boolean;
  52415. /**
  52416. * Disposes of the gizmo
  52417. */
  52418. dispose(): void;
  52419. }
  52420. }
  52421. declare module "babylonjs/Debug/axesViewer" {
  52422. import { Vector3 } from "babylonjs/Maths/math.vector";
  52423. import { Nullable } from "babylonjs/types";
  52424. import { Scene } from "babylonjs/scene";
  52425. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52426. /**
  52427. * The Axes viewer will show 3 axes in a specific point in space
  52428. */
  52429. export class AxesViewer {
  52430. private _xAxis;
  52431. private _yAxis;
  52432. private _zAxis;
  52433. private _scaleLinesFactor;
  52434. private _instanced;
  52435. /**
  52436. * Gets the hosting scene
  52437. */
  52438. scene: Scene;
  52439. /**
  52440. * Gets or sets a number used to scale line length
  52441. */
  52442. scaleLines: number;
  52443. /** Gets the node hierarchy used to render x-axis */
  52444. get xAxis(): TransformNode;
  52445. /** Gets the node hierarchy used to render y-axis */
  52446. get yAxis(): TransformNode;
  52447. /** Gets the node hierarchy used to render z-axis */
  52448. get zAxis(): TransformNode;
  52449. /**
  52450. * Creates a new AxesViewer
  52451. * @param scene defines the hosting scene
  52452. * @param scaleLines defines a number used to scale line length (1 by default)
  52453. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52454. * @param xAxis defines the node hierarchy used to render the x-axis
  52455. * @param yAxis defines the node hierarchy used to render the y-axis
  52456. * @param zAxis defines the node hierarchy used to render the z-axis
  52457. */
  52458. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52459. /**
  52460. * Force the viewer to update
  52461. * @param position defines the position of the viewer
  52462. * @param xaxis defines the x axis of the viewer
  52463. * @param yaxis defines the y axis of the viewer
  52464. * @param zaxis defines the z axis of the viewer
  52465. */
  52466. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52467. /**
  52468. * Creates an instance of this axes viewer.
  52469. * @returns a new axes viewer with instanced meshes
  52470. */
  52471. createInstance(): AxesViewer;
  52472. /** Releases resources */
  52473. dispose(): void;
  52474. private static _SetRenderingGroupId;
  52475. }
  52476. }
  52477. declare module "babylonjs/Debug/boneAxesViewer" {
  52478. import { Nullable } from "babylonjs/types";
  52479. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52480. import { Vector3 } from "babylonjs/Maths/math.vector";
  52481. import { Mesh } from "babylonjs/Meshes/mesh";
  52482. import { Bone } from "babylonjs/Bones/bone";
  52483. import { Scene } from "babylonjs/scene";
  52484. /**
  52485. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52486. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52487. */
  52488. export class BoneAxesViewer extends AxesViewer {
  52489. /**
  52490. * Gets or sets the target mesh where to display the axes viewer
  52491. */
  52492. mesh: Nullable<Mesh>;
  52493. /**
  52494. * Gets or sets the target bone where to display the axes viewer
  52495. */
  52496. bone: Nullable<Bone>;
  52497. /** Gets current position */
  52498. pos: Vector3;
  52499. /** Gets direction of X axis */
  52500. xaxis: Vector3;
  52501. /** Gets direction of Y axis */
  52502. yaxis: Vector3;
  52503. /** Gets direction of Z axis */
  52504. zaxis: Vector3;
  52505. /**
  52506. * Creates a new BoneAxesViewer
  52507. * @param scene defines the hosting scene
  52508. * @param bone defines the target bone
  52509. * @param mesh defines the target mesh
  52510. * @param scaleLines defines a scaling factor for line length (1 by default)
  52511. */
  52512. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52513. /**
  52514. * Force the viewer to update
  52515. */
  52516. update(): void;
  52517. /** Releases resources */
  52518. dispose(): void;
  52519. }
  52520. }
  52521. declare module "babylonjs/Debug/debugLayer" {
  52522. import { Scene } from "babylonjs/scene";
  52523. /**
  52524. * Interface used to define scene explorer extensibility option
  52525. */
  52526. export interface IExplorerExtensibilityOption {
  52527. /**
  52528. * Define the option label
  52529. */
  52530. label: string;
  52531. /**
  52532. * Defines the action to execute on click
  52533. */
  52534. action: (entity: any) => void;
  52535. }
  52536. /**
  52537. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52538. */
  52539. export interface IExplorerExtensibilityGroup {
  52540. /**
  52541. * Defines a predicate to test if a given type mut be extended
  52542. */
  52543. predicate: (entity: any) => boolean;
  52544. /**
  52545. * Gets the list of options added to a type
  52546. */
  52547. entries: IExplorerExtensibilityOption[];
  52548. }
  52549. /**
  52550. * Interface used to define the options to use to create the Inspector
  52551. */
  52552. export interface IInspectorOptions {
  52553. /**
  52554. * Display in overlay mode (default: false)
  52555. */
  52556. overlay?: boolean;
  52557. /**
  52558. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52559. */
  52560. globalRoot?: HTMLElement;
  52561. /**
  52562. * Display the Scene explorer
  52563. */
  52564. showExplorer?: boolean;
  52565. /**
  52566. * Display the property inspector
  52567. */
  52568. showInspector?: boolean;
  52569. /**
  52570. * Display in embed mode (both panes on the right)
  52571. */
  52572. embedMode?: boolean;
  52573. /**
  52574. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52575. */
  52576. handleResize?: boolean;
  52577. /**
  52578. * Allow the panes to popup (default: true)
  52579. */
  52580. enablePopup?: boolean;
  52581. /**
  52582. * Allow the panes to be closed by users (default: true)
  52583. */
  52584. enableClose?: boolean;
  52585. /**
  52586. * Optional list of extensibility entries
  52587. */
  52588. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52589. /**
  52590. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52591. */
  52592. inspectorURL?: string;
  52593. /**
  52594. * Optional initial tab (default to DebugLayerTab.Properties)
  52595. */
  52596. initialTab?: DebugLayerTab;
  52597. }
  52598. module "babylonjs/scene" {
  52599. interface Scene {
  52600. /**
  52601. * @hidden
  52602. * Backing field
  52603. */
  52604. _debugLayer: DebugLayer;
  52605. /**
  52606. * Gets the debug layer (aka Inspector) associated with the scene
  52607. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52608. */
  52609. debugLayer: DebugLayer;
  52610. }
  52611. }
  52612. /**
  52613. * Enum of inspector action tab
  52614. */
  52615. export enum DebugLayerTab {
  52616. /**
  52617. * Properties tag (default)
  52618. */
  52619. Properties = 0,
  52620. /**
  52621. * Debug tab
  52622. */
  52623. Debug = 1,
  52624. /**
  52625. * Statistics tab
  52626. */
  52627. Statistics = 2,
  52628. /**
  52629. * Tools tab
  52630. */
  52631. Tools = 3,
  52632. /**
  52633. * Settings tab
  52634. */
  52635. Settings = 4
  52636. }
  52637. /**
  52638. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52639. * what is happening in your scene
  52640. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52641. */
  52642. export class DebugLayer {
  52643. /**
  52644. * Define the url to get the inspector script from.
  52645. * By default it uses the babylonjs CDN.
  52646. * @ignoreNaming
  52647. */
  52648. static InspectorURL: string;
  52649. private _scene;
  52650. private BJSINSPECTOR;
  52651. private _onPropertyChangedObservable?;
  52652. /**
  52653. * Observable triggered when a property is changed through the inspector.
  52654. */
  52655. get onPropertyChangedObservable(): any;
  52656. /**
  52657. * Instantiates a new debug layer.
  52658. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52659. * what is happening in your scene
  52660. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52661. * @param scene Defines the scene to inspect
  52662. */
  52663. constructor(scene: Scene);
  52664. /** Creates the inspector window. */
  52665. private _createInspector;
  52666. /**
  52667. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52668. * @param entity defines the entity to select
  52669. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52670. */
  52671. select(entity: any, lineContainerTitles?: string | string[]): void;
  52672. /** Get the inspector from bundle or global */
  52673. private _getGlobalInspector;
  52674. /**
  52675. * Get if the inspector is visible or not.
  52676. * @returns true if visible otherwise, false
  52677. */
  52678. isVisible(): boolean;
  52679. /**
  52680. * Hide the inspector and close its window.
  52681. */
  52682. hide(): void;
  52683. /**
  52684. * Update the scene in the inspector
  52685. */
  52686. setAsActiveScene(): void;
  52687. /**
  52688. * Launch the debugLayer.
  52689. * @param config Define the configuration of the inspector
  52690. * @return a promise fulfilled when the debug layer is visible
  52691. */
  52692. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52693. }
  52694. }
  52695. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52696. import { Nullable } from "babylonjs/types";
  52697. import { Scene } from "babylonjs/scene";
  52698. import { Vector4 } from "babylonjs/Maths/math.vector";
  52699. import { Color4 } from "babylonjs/Maths/math.color";
  52700. import { Mesh } from "babylonjs/Meshes/mesh";
  52701. /**
  52702. * Class containing static functions to help procedurally build meshes
  52703. */
  52704. export class BoxBuilder {
  52705. /**
  52706. * Creates a box mesh
  52707. * * The parameter `size` sets the size (float) of each box side (default 1)
  52708. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52709. * * 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)
  52710. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52714. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52715. * @param name defines the name of the mesh
  52716. * @param options defines the options used to create the mesh
  52717. * @param scene defines the hosting scene
  52718. * @returns the box mesh
  52719. */
  52720. static CreateBox(name: string, options: {
  52721. size?: number;
  52722. width?: number;
  52723. height?: number;
  52724. depth?: number;
  52725. faceUV?: Vector4[];
  52726. faceColors?: Color4[];
  52727. sideOrientation?: number;
  52728. frontUVs?: Vector4;
  52729. backUVs?: Vector4;
  52730. wrap?: boolean;
  52731. topBaseAt?: number;
  52732. bottomBaseAt?: number;
  52733. updatable?: boolean;
  52734. }, scene?: Nullable<Scene>): Mesh;
  52735. }
  52736. }
  52737. declare module "babylonjs/Debug/physicsViewer" {
  52738. import { Nullable } from "babylonjs/types";
  52739. import { Scene } from "babylonjs/scene";
  52740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52741. import { Mesh } from "babylonjs/Meshes/mesh";
  52742. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52743. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52744. /**
  52745. * Used to show the physics impostor around the specific mesh
  52746. */
  52747. export class PhysicsViewer {
  52748. /** @hidden */
  52749. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52750. /** @hidden */
  52751. protected _meshes: Array<Nullable<AbstractMesh>>;
  52752. /** @hidden */
  52753. protected _scene: Nullable<Scene>;
  52754. /** @hidden */
  52755. protected _numMeshes: number;
  52756. /** @hidden */
  52757. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52758. private _renderFunction;
  52759. private _utilityLayer;
  52760. private _debugBoxMesh;
  52761. private _debugSphereMesh;
  52762. private _debugCylinderMesh;
  52763. private _debugMaterial;
  52764. private _debugMeshMeshes;
  52765. /**
  52766. * Creates a new PhysicsViewer
  52767. * @param scene defines the hosting scene
  52768. */
  52769. constructor(scene: Scene);
  52770. /** @hidden */
  52771. protected _updateDebugMeshes(): void;
  52772. /**
  52773. * Renders a specified physic impostor
  52774. * @param impostor defines the impostor to render
  52775. * @param targetMesh defines the mesh represented by the impostor
  52776. * @returns the new debug mesh used to render the impostor
  52777. */
  52778. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52779. /**
  52780. * Hides a specified physic impostor
  52781. * @param impostor defines the impostor to hide
  52782. */
  52783. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52784. private _getDebugMaterial;
  52785. private _getDebugBoxMesh;
  52786. private _getDebugSphereMesh;
  52787. private _getDebugCylinderMesh;
  52788. private _getDebugMeshMesh;
  52789. private _getDebugMesh;
  52790. /** Releases all resources */
  52791. dispose(): void;
  52792. }
  52793. }
  52794. declare module "babylonjs/Debug/rayHelper" {
  52795. import { Nullable } from "babylonjs/types";
  52796. import { Ray } from "babylonjs/Culling/ray";
  52797. import { Vector3 } from "babylonjs/Maths/math.vector";
  52798. import { Color3 } from "babylonjs/Maths/math.color";
  52799. import { Scene } from "babylonjs/scene";
  52800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52801. import "babylonjs/Meshes/Builders/linesBuilder";
  52802. /**
  52803. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52804. * in order to better appreciate the issue one might have.
  52805. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52806. */
  52807. export class RayHelper {
  52808. /**
  52809. * Defines the ray we are currently tryin to visualize.
  52810. */
  52811. ray: Nullable<Ray>;
  52812. private _renderPoints;
  52813. private _renderLine;
  52814. private _renderFunction;
  52815. private _scene;
  52816. private _updateToMeshFunction;
  52817. private _onAfterStepObserver;
  52818. private _attachedToMesh;
  52819. private _meshSpaceDirection;
  52820. private _meshSpaceOrigin;
  52821. /**
  52822. * Helper function to create a colored helper in a scene in one line.
  52823. * @param ray Defines the ray we are currently tryin to visualize
  52824. * @param scene Defines the scene the ray is used in
  52825. * @param color Defines the color we want to see the ray in
  52826. * @returns The newly created ray helper.
  52827. */
  52828. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52829. /**
  52830. * Instantiate a new ray helper.
  52831. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52832. * in order to better appreciate the issue one might have.
  52833. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52834. * @param ray Defines the ray we are currently tryin to visualize
  52835. */
  52836. constructor(ray: Ray);
  52837. /**
  52838. * Shows the ray we are willing to debug.
  52839. * @param scene Defines the scene the ray needs to be rendered in
  52840. * @param color Defines the color the ray needs to be rendered in
  52841. */
  52842. show(scene: Scene, color?: Color3): void;
  52843. /**
  52844. * Hides the ray we are debugging.
  52845. */
  52846. hide(): void;
  52847. private _render;
  52848. /**
  52849. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52850. * @param mesh Defines the mesh we want the helper attached to
  52851. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52852. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52853. * @param length Defines the length of the ray
  52854. */
  52855. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52856. /**
  52857. * Detach the ray helper from the mesh it has previously been attached to.
  52858. */
  52859. detachFromMesh(): void;
  52860. private _updateToMesh;
  52861. /**
  52862. * Dispose the helper and release its associated resources.
  52863. */
  52864. dispose(): void;
  52865. }
  52866. }
  52867. declare module "babylonjs/Debug/ISkeletonViewer" {
  52868. /**
  52869. * Defines the options associated with the creation of a SkeletonViewer.
  52870. */
  52871. export interface ISkeletonViewerOptions {
  52872. /** Should the system pause animations before building the Viewer? */
  52873. pauseAnimations: boolean;
  52874. /** Should the system return the skeleton to rest before building? */
  52875. returnToRest: boolean;
  52876. /** public Display Mode of the Viewer */
  52877. displayMode: number;
  52878. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52879. displayOptions: ISkeletonViewerDisplayOptions;
  52880. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52881. computeBonesUsingShaders: boolean;
  52882. }
  52883. /**
  52884. * Defines how to display the various bone meshes for the viewer.
  52885. */
  52886. export interface ISkeletonViewerDisplayOptions {
  52887. /** How far down to start tapering the bone spurs */
  52888. midStep?: number;
  52889. /** How big is the midStep? */
  52890. midStepFactor?: number;
  52891. /** Base for the Sphere Size */
  52892. sphereBaseSize?: number;
  52893. /** The ratio of the sphere to the longest bone in units */
  52894. sphereScaleUnit?: number;
  52895. /** Ratio for the Sphere Size */
  52896. sphereFactor?: number;
  52897. }
  52898. }
  52899. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52900. import { Nullable } from "babylonjs/types";
  52901. import { Scene } from "babylonjs/scene";
  52902. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52903. import { Color4 } from "babylonjs/Maths/math.color";
  52904. import { Mesh } from "babylonjs/Meshes/mesh";
  52905. /**
  52906. * Class containing static functions to help procedurally build meshes
  52907. */
  52908. export class RibbonBuilder {
  52909. /**
  52910. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52911. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52912. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52913. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52914. * * 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
  52915. * * 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
  52916. * * 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
  52917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52920. * * 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
  52921. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52922. * * 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
  52923. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52925. * @param name defines the name of the mesh
  52926. * @param options defines the options used to create the mesh
  52927. * @param scene defines the hosting scene
  52928. * @returns the ribbon mesh
  52929. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52930. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52931. */
  52932. static CreateRibbon(name: string, options: {
  52933. pathArray: Vector3[][];
  52934. closeArray?: boolean;
  52935. closePath?: boolean;
  52936. offset?: number;
  52937. updatable?: boolean;
  52938. sideOrientation?: number;
  52939. frontUVs?: Vector4;
  52940. backUVs?: Vector4;
  52941. instance?: Mesh;
  52942. invertUV?: boolean;
  52943. uvs?: Vector2[];
  52944. colors?: Color4[];
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. }
  52947. }
  52948. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52949. import { Nullable } from "babylonjs/types";
  52950. import { Scene } from "babylonjs/scene";
  52951. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52952. import { Mesh } from "babylonjs/Meshes/mesh";
  52953. /**
  52954. * Class containing static functions to help procedurally build meshes
  52955. */
  52956. export class ShapeBuilder {
  52957. /**
  52958. * 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.
  52959. * * 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.
  52960. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52961. * * 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.
  52962. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52963. * * 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
  52964. * * 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
  52965. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52970. * @param name defines the name of the mesh
  52971. * @param options defines the options used to create the mesh
  52972. * @param scene defines the hosting scene
  52973. * @returns the extruded shape mesh
  52974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52976. */
  52977. static ExtrudeShape(name: string, options: {
  52978. shape: Vector3[];
  52979. path: Vector3[];
  52980. scale?: number;
  52981. rotation?: number;
  52982. cap?: number;
  52983. updatable?: boolean;
  52984. sideOrientation?: number;
  52985. frontUVs?: Vector4;
  52986. backUVs?: Vector4;
  52987. instance?: Mesh;
  52988. invertUV?: boolean;
  52989. }, scene?: Nullable<Scene>): Mesh;
  52990. /**
  52991. * Creates an custom extruded shape mesh.
  52992. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52993. * * 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.
  52994. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52995. * * 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
  52996. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52997. * * 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
  52998. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52999. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53000. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53001. * * 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
  53002. * * 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
  53003. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53008. * @param name defines the name of the mesh
  53009. * @param options defines the options used to create the mesh
  53010. * @param scene defines the hosting scene
  53011. * @returns the custom extruded shape mesh
  53012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53013. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53015. */
  53016. static ExtrudeShapeCustom(name: string, options: {
  53017. shape: Vector3[];
  53018. path: Vector3[];
  53019. scaleFunction?: any;
  53020. rotationFunction?: any;
  53021. ribbonCloseArray?: boolean;
  53022. ribbonClosePath?: boolean;
  53023. cap?: number;
  53024. updatable?: boolean;
  53025. sideOrientation?: number;
  53026. frontUVs?: Vector4;
  53027. backUVs?: Vector4;
  53028. instance?: Mesh;
  53029. invertUV?: boolean;
  53030. }, scene?: Nullable<Scene>): Mesh;
  53031. private static _ExtrudeShapeGeneric;
  53032. }
  53033. }
  53034. declare module "babylonjs/Debug/skeletonViewer" {
  53035. import { Color3 } from "babylonjs/Maths/math.color";
  53036. import { Scene } from "babylonjs/scene";
  53037. import { Nullable } from "babylonjs/types";
  53038. import { Skeleton } from "babylonjs/Bones/skeleton";
  53039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53040. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53041. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53042. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53043. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53044. /**
  53045. * Class used to render a debug view of a given skeleton
  53046. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53047. */
  53048. export class SkeletonViewer {
  53049. /** defines the skeleton to render */
  53050. skeleton: Skeleton;
  53051. /** defines the mesh attached to the skeleton */
  53052. mesh: AbstractMesh;
  53053. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53054. autoUpdateBonesMatrices: boolean;
  53055. /** defines the rendering group id to use with the viewer */
  53056. renderingGroupId: number;
  53057. /** is the options for the viewer */
  53058. options: Partial<ISkeletonViewerOptions>;
  53059. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53060. static readonly DISPLAY_LINES: number;
  53061. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53062. static readonly DISPLAY_SPHERES: number;
  53063. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53064. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53065. /** If SkeletonViewer scene scope. */
  53066. private _scene;
  53067. /** Gets or sets the color used to render the skeleton */
  53068. color: Color3;
  53069. /** Array of the points of the skeleton fo the line view. */
  53070. private _debugLines;
  53071. /** The SkeletonViewers Mesh. */
  53072. private _debugMesh;
  53073. /** If SkeletonViewer is enabled. */
  53074. private _isEnabled;
  53075. /** If SkeletonViewer is ready. */
  53076. private _ready;
  53077. /** SkeletonViewer render observable. */
  53078. private _obs;
  53079. /** The Utility Layer to render the gizmos in. */
  53080. private _utilityLayer;
  53081. private _boneIndices;
  53082. /** Gets the Scene. */
  53083. get scene(): Scene;
  53084. /** Gets the utilityLayer. */
  53085. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53086. /** Checks Ready Status. */
  53087. get isReady(): Boolean;
  53088. /** Sets Ready Status. */
  53089. set ready(value: boolean);
  53090. /** Gets the debugMesh */
  53091. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53092. /** Sets the debugMesh */
  53093. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53094. /** Gets the material */
  53095. get material(): StandardMaterial;
  53096. /** Sets the material */
  53097. set material(value: StandardMaterial);
  53098. /** Gets the material */
  53099. get displayMode(): number;
  53100. /** Sets the material */
  53101. set displayMode(value: number);
  53102. /**
  53103. * Creates a new SkeletonViewer
  53104. * @param skeleton defines the skeleton to render
  53105. * @param mesh defines the mesh attached to the skeleton
  53106. * @param scene defines the hosting scene
  53107. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53108. * @param renderingGroupId defines the rendering group id to use with the viewer
  53109. * @param options All of the extra constructor options for the SkeletonViewer
  53110. */
  53111. constructor(
  53112. /** defines the skeleton to render */
  53113. skeleton: Skeleton,
  53114. /** defines the mesh attached to the skeleton */
  53115. mesh: AbstractMesh,
  53116. /** The Scene scope*/
  53117. scene: Scene,
  53118. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53119. autoUpdateBonesMatrices?: boolean,
  53120. /** defines the rendering group id to use with the viewer */
  53121. renderingGroupId?: number,
  53122. /** is the options for the viewer */
  53123. options?: Partial<ISkeletonViewerOptions>);
  53124. /** The Dynamic bindings for the update functions */
  53125. private _bindObs;
  53126. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53127. update(): void;
  53128. /** Gets or sets a boolean indicating if the viewer is enabled */
  53129. set isEnabled(value: boolean);
  53130. get isEnabled(): boolean;
  53131. private _getBonePosition;
  53132. private _getLinesForBonesWithLength;
  53133. private _getLinesForBonesNoLength;
  53134. /** function to revert the mesh and scene back to the initial state. */
  53135. private _revert;
  53136. /** function to build and bind sphere joint points and spur bone representations. */
  53137. private _buildSpheresAndSpurs;
  53138. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53139. private _displayLinesUpdate;
  53140. /** Changes the displayMode of the skeleton viewer
  53141. * @param mode The displayMode numerical value
  53142. */
  53143. changeDisplayMode(mode: number): void;
  53144. /** Changes the displayMode of the skeleton viewer
  53145. * @param option String of the option name
  53146. * @param value The numerical option value
  53147. */
  53148. changeDisplayOptions(option: string, value: number): void;
  53149. /** Release associated resources */
  53150. dispose(): void;
  53151. }
  53152. }
  53153. declare module "babylonjs/Debug/index" {
  53154. export * from "babylonjs/Debug/axesViewer";
  53155. export * from "babylonjs/Debug/boneAxesViewer";
  53156. export * from "babylonjs/Debug/debugLayer";
  53157. export * from "babylonjs/Debug/physicsViewer";
  53158. export * from "babylonjs/Debug/rayHelper";
  53159. export * from "babylonjs/Debug/skeletonViewer";
  53160. export * from "babylonjs/Debug/ISkeletonViewer";
  53161. }
  53162. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53163. /**
  53164. * Enum for Device Types
  53165. */
  53166. export enum DeviceType {
  53167. /** Generic */
  53168. Generic = 0,
  53169. /** Keyboard */
  53170. Keyboard = 1,
  53171. /** Mouse */
  53172. Mouse = 2,
  53173. /** Touch Pointers */
  53174. Touch = 3,
  53175. /** PS4 Dual Shock */
  53176. DualShock = 4,
  53177. /** Xbox */
  53178. Xbox = 5,
  53179. /** Switch Controller */
  53180. Switch = 6
  53181. }
  53182. /**
  53183. * Enum for All Pointers (Touch/Mouse)
  53184. */
  53185. export enum PointerInput {
  53186. /** Horizontal Axis */
  53187. Horizontal = 0,
  53188. /** Vertical Axis */
  53189. Vertical = 1,
  53190. /** Left Click or Touch */
  53191. LeftClick = 2,
  53192. /** Middle Click */
  53193. MiddleClick = 3,
  53194. /** Right Click */
  53195. RightClick = 4,
  53196. /** Browser Back */
  53197. BrowserBack = 5,
  53198. /** Browser Forward */
  53199. BrowserForward = 6
  53200. }
  53201. /**
  53202. * Enum for Dual Shock Gamepad
  53203. */
  53204. export enum DualShockInput {
  53205. /** Cross */
  53206. Cross = 0,
  53207. /** Circle */
  53208. Circle = 1,
  53209. /** Square */
  53210. Square = 2,
  53211. /** Triangle */
  53212. Triangle = 3,
  53213. /** L1 */
  53214. L1 = 4,
  53215. /** R1 */
  53216. R1 = 5,
  53217. /** L2 */
  53218. L2 = 6,
  53219. /** R2 */
  53220. R2 = 7,
  53221. /** Share */
  53222. Share = 8,
  53223. /** Options */
  53224. Options = 9,
  53225. /** L3 */
  53226. L3 = 10,
  53227. /** R3 */
  53228. R3 = 11,
  53229. /** DPadUp */
  53230. DPadUp = 12,
  53231. /** DPadDown */
  53232. DPadDown = 13,
  53233. /** DPadLeft */
  53234. DPadLeft = 14,
  53235. /** DRight */
  53236. DPadRight = 15,
  53237. /** Home */
  53238. Home = 16,
  53239. /** TouchPad */
  53240. TouchPad = 17,
  53241. /** LStickXAxis */
  53242. LStickXAxis = 18,
  53243. /** LStickYAxis */
  53244. LStickYAxis = 19,
  53245. /** RStickXAxis */
  53246. RStickXAxis = 20,
  53247. /** RStickYAxis */
  53248. RStickYAxis = 21
  53249. }
  53250. /**
  53251. * Enum for Xbox Gamepad
  53252. */
  53253. export enum XboxInput {
  53254. /** A */
  53255. A = 0,
  53256. /** B */
  53257. B = 1,
  53258. /** X */
  53259. X = 2,
  53260. /** Y */
  53261. Y = 3,
  53262. /** LB */
  53263. LB = 4,
  53264. /** RB */
  53265. RB = 5,
  53266. /** LT */
  53267. LT = 6,
  53268. /** RT */
  53269. RT = 7,
  53270. /** Back */
  53271. Back = 8,
  53272. /** Start */
  53273. Start = 9,
  53274. /** LS */
  53275. LS = 10,
  53276. /** RS */
  53277. RS = 11,
  53278. /** DPadUp */
  53279. DPadUp = 12,
  53280. /** DPadDown */
  53281. DPadDown = 13,
  53282. /** DPadLeft */
  53283. DPadLeft = 14,
  53284. /** DRight */
  53285. DPadRight = 15,
  53286. /** Home */
  53287. Home = 16,
  53288. /** LStickXAxis */
  53289. LStickXAxis = 17,
  53290. /** LStickYAxis */
  53291. LStickYAxis = 18,
  53292. /** RStickXAxis */
  53293. RStickXAxis = 19,
  53294. /** RStickYAxis */
  53295. RStickYAxis = 20
  53296. }
  53297. /**
  53298. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53299. */
  53300. export enum SwitchInput {
  53301. /** B */
  53302. B = 0,
  53303. /** A */
  53304. A = 1,
  53305. /** Y */
  53306. Y = 2,
  53307. /** X */
  53308. X = 3,
  53309. /** L */
  53310. L = 4,
  53311. /** R */
  53312. R = 5,
  53313. /** ZL */
  53314. ZL = 6,
  53315. /** ZR */
  53316. ZR = 7,
  53317. /** Minus */
  53318. Minus = 8,
  53319. /** Plus */
  53320. Plus = 9,
  53321. /** LS */
  53322. LS = 10,
  53323. /** RS */
  53324. RS = 11,
  53325. /** DPadUp */
  53326. DPadUp = 12,
  53327. /** DPadDown */
  53328. DPadDown = 13,
  53329. /** DPadLeft */
  53330. DPadLeft = 14,
  53331. /** DRight */
  53332. DPadRight = 15,
  53333. /** Home */
  53334. Home = 16,
  53335. /** Capture */
  53336. Capture = 17,
  53337. /** LStickXAxis */
  53338. LStickXAxis = 18,
  53339. /** LStickYAxis */
  53340. LStickYAxis = 19,
  53341. /** RStickXAxis */
  53342. RStickXAxis = 20,
  53343. /** RStickYAxis */
  53344. RStickYAxis = 21
  53345. }
  53346. }
  53347. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53348. import { Engine } from "babylonjs/Engines/engine";
  53349. import { IDisposable } from "babylonjs/scene";
  53350. import { Nullable } from "babylonjs/types";
  53351. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53352. /**
  53353. * This class will take all inputs from Keyboard, Pointer, and
  53354. * any Gamepads and provide a polling system that all devices
  53355. * will use. This class assumes that there will only be one
  53356. * pointer device and one keyboard.
  53357. */
  53358. export class DeviceInputSystem implements IDisposable {
  53359. /**
  53360. * Callback to be triggered when a device is connected
  53361. */
  53362. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53363. /**
  53364. * Callback to be triggered when a device is disconnected
  53365. */
  53366. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53367. /**
  53368. * Callback to be triggered when event driven input is updated
  53369. */
  53370. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53371. private _inputs;
  53372. private _gamepads;
  53373. private _keyboardActive;
  53374. private _pointerActive;
  53375. private _elementToAttachTo;
  53376. private _keyboardDownEvent;
  53377. private _keyboardUpEvent;
  53378. private _pointerMoveEvent;
  53379. private _pointerDownEvent;
  53380. private _pointerUpEvent;
  53381. private _gamepadConnectedEvent;
  53382. private _gamepadDisconnectedEvent;
  53383. private static _MAX_KEYCODES;
  53384. private static _MAX_POINTER_INPUTS;
  53385. private constructor();
  53386. /**
  53387. * Creates a new DeviceInputSystem instance
  53388. * @param engine Engine to pull input element from
  53389. * @returns The new instance
  53390. */
  53391. static Create(engine: Engine): DeviceInputSystem;
  53392. /**
  53393. * Checks for current device input value, given an id and input index
  53394. * @param deviceName Id of connected device
  53395. * @param inputIndex Index of device input
  53396. * @returns Current value of input
  53397. */
  53398. /**
  53399. * Checks for current device input value, given an id and input index
  53400. * @param deviceType Enum specifiying device type
  53401. * @param deviceSlot "Slot" or index that device is referenced in
  53402. * @param inputIndex Id of input to be checked
  53403. * @returns Current value of input
  53404. */
  53405. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53406. /**
  53407. * Dispose of all the eventlisteners
  53408. */
  53409. dispose(): void;
  53410. /**
  53411. * Add device and inputs to device array
  53412. * @param deviceType Enum specifiying device type
  53413. * @param deviceSlot "Slot" or index that device is referenced in
  53414. * @param numberOfInputs Number of input entries to create for given device
  53415. */
  53416. private _registerDevice;
  53417. /**
  53418. * Given a specific device name, remove that device from the device map
  53419. * @param deviceType Enum specifiying device type
  53420. * @param deviceSlot "Slot" or index that device is referenced in
  53421. */
  53422. private _unregisterDevice;
  53423. /**
  53424. * Handle all actions that come from keyboard interaction
  53425. */
  53426. private _handleKeyActions;
  53427. /**
  53428. * Handle all actions that come from pointer interaction
  53429. */
  53430. private _handlePointerActions;
  53431. /**
  53432. * Handle all actions that come from gamepad interaction
  53433. */
  53434. private _handleGamepadActions;
  53435. /**
  53436. * Update all non-event based devices with each frame
  53437. * @param deviceType Enum specifiying device type
  53438. * @param deviceSlot "Slot" or index that device is referenced in
  53439. * @param inputIndex Id of input to be checked
  53440. */
  53441. private _updateDevice;
  53442. /**
  53443. * Gets DeviceType from the device name
  53444. * @param deviceName Name of Device from DeviceInputSystem
  53445. * @returns DeviceType enum value
  53446. */
  53447. private _getGamepadDeviceType;
  53448. }
  53449. }
  53450. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53451. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53452. /**
  53453. * Type to handle enforcement of inputs
  53454. */
  53455. 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;
  53456. }
  53457. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53458. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53459. import { Engine } from "babylonjs/Engines/engine";
  53460. import { IDisposable } from "babylonjs/scene";
  53461. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53462. import { Nullable } from "babylonjs/types";
  53463. import { Observable } from "babylonjs/Misc/observable";
  53464. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53465. /**
  53466. * Class that handles all input for a specific device
  53467. */
  53468. export class DeviceSource<T extends DeviceType> {
  53469. /** Type of device */
  53470. readonly deviceType: DeviceType;
  53471. /** "Slot" or index that device is referenced in */
  53472. readonly deviceSlot: number;
  53473. /**
  53474. * Observable to handle device input changes per device
  53475. */
  53476. readonly onInputChangedObservable: Observable<{
  53477. inputIndex: DeviceInput<T>;
  53478. previousState: Nullable<number>;
  53479. currentState: Nullable<number>;
  53480. }>;
  53481. private readonly _deviceInputSystem;
  53482. /**
  53483. * Default Constructor
  53484. * @param deviceInputSystem Reference to DeviceInputSystem
  53485. * @param deviceType Type of device
  53486. * @param deviceSlot "Slot" or index that device is referenced in
  53487. */
  53488. constructor(deviceInputSystem: DeviceInputSystem,
  53489. /** Type of device */
  53490. deviceType: DeviceType,
  53491. /** "Slot" or index that device is referenced in */
  53492. deviceSlot?: number);
  53493. /**
  53494. * Get input for specific input
  53495. * @param inputIndex index of specific input on device
  53496. * @returns Input value from DeviceInputSystem
  53497. */
  53498. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53499. }
  53500. /**
  53501. * Class to keep track of devices
  53502. */
  53503. export class DeviceSourceManager implements IDisposable {
  53504. /**
  53505. * Observable to be triggered when before a device is connected
  53506. */
  53507. readonly onBeforeDeviceConnectedObservable: Observable<{
  53508. deviceType: DeviceType;
  53509. deviceSlot: number;
  53510. }>;
  53511. /**
  53512. * Observable to be triggered when before a device is disconnected
  53513. */
  53514. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53515. deviceType: DeviceType;
  53516. deviceSlot: number;
  53517. }>;
  53518. /**
  53519. * Observable to be triggered when after a device is connected
  53520. */
  53521. readonly onAfterDeviceConnectedObservable: Observable<{
  53522. deviceType: DeviceType;
  53523. deviceSlot: number;
  53524. }>;
  53525. /**
  53526. * Observable to be triggered when after a device is disconnected
  53527. */
  53528. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53529. deviceType: DeviceType;
  53530. deviceSlot: number;
  53531. }>;
  53532. private readonly _devices;
  53533. private readonly _firstDevice;
  53534. private readonly _deviceInputSystem;
  53535. /**
  53536. * Default Constructor
  53537. * @param engine engine to pull input element from
  53538. */
  53539. constructor(engine: Engine);
  53540. /**
  53541. * Gets a DeviceSource, given a type and slot
  53542. * @param deviceType Enum specifying device type
  53543. * @param deviceSlot "Slot" or index that device is referenced in
  53544. * @returns DeviceSource object
  53545. */
  53546. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53547. /**
  53548. * Gets an array of DeviceSource objects for a given device type
  53549. * @param deviceType Enum specifying device type
  53550. * @returns Array of DeviceSource objects
  53551. */
  53552. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53553. /**
  53554. * Dispose of DeviceInputSystem and other parts
  53555. */
  53556. dispose(): void;
  53557. /**
  53558. * Function to add device name to device list
  53559. * @param deviceType Enum specifying device type
  53560. * @param deviceSlot "Slot" or index that device is referenced in
  53561. */
  53562. private _addDevice;
  53563. /**
  53564. * Function to remove device name to device list
  53565. * @param deviceType Enum specifying device type
  53566. * @param deviceSlot "Slot" or index that device is referenced in
  53567. */
  53568. private _removeDevice;
  53569. /**
  53570. * Updates array storing first connected device of each type
  53571. * @param type Type of Device
  53572. */
  53573. private _updateFirstDevices;
  53574. }
  53575. }
  53576. declare module "babylonjs/DeviceInput/index" {
  53577. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53578. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53579. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53580. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53581. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53582. }
  53583. declare module "babylonjs/Engines/nullEngine" {
  53584. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53585. import { Engine } from "babylonjs/Engines/engine";
  53586. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53587. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53589. import { Effect } from "babylonjs/Materials/effect";
  53590. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53591. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53592. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53593. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53594. /**
  53595. * Options to create the null engine
  53596. */
  53597. export class NullEngineOptions {
  53598. /**
  53599. * Render width (Default: 512)
  53600. */
  53601. renderWidth: number;
  53602. /**
  53603. * Render height (Default: 256)
  53604. */
  53605. renderHeight: number;
  53606. /**
  53607. * Texture size (Default: 512)
  53608. */
  53609. textureSize: number;
  53610. /**
  53611. * If delta time between frames should be constant
  53612. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53613. */
  53614. deterministicLockstep: boolean;
  53615. /**
  53616. * Maximum about of steps between frames (Default: 4)
  53617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53618. */
  53619. lockstepMaxSteps: number;
  53620. /**
  53621. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53622. */
  53623. useHighPrecisionMatrix?: boolean;
  53624. }
  53625. /**
  53626. * The null engine class provides support for headless version of babylon.js.
  53627. * This can be used in server side scenario or for testing purposes
  53628. */
  53629. export class NullEngine extends Engine {
  53630. private _options;
  53631. /**
  53632. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53633. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53634. * @returns true if engine is in deterministic lock step mode
  53635. */
  53636. isDeterministicLockStep(): boolean;
  53637. /**
  53638. * Gets the max steps when engine is running in deterministic lock step
  53639. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53640. * @returns the max steps
  53641. */
  53642. getLockstepMaxSteps(): number;
  53643. /**
  53644. * Gets the current hardware scaling level.
  53645. * By default the hardware scaling level is computed from the window device ratio.
  53646. * 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.
  53647. * @returns a number indicating the current hardware scaling level
  53648. */
  53649. getHardwareScalingLevel(): number;
  53650. constructor(options?: NullEngineOptions);
  53651. /**
  53652. * Creates a vertex buffer
  53653. * @param vertices the data for the vertex buffer
  53654. * @returns the new WebGL static buffer
  53655. */
  53656. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53657. /**
  53658. * Creates a new index buffer
  53659. * @param indices defines the content of the index buffer
  53660. * @param updatable defines if the index buffer must be updatable
  53661. * @returns a new webGL buffer
  53662. */
  53663. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53664. /**
  53665. * Clear the current render buffer or the current render target (if any is set up)
  53666. * @param color defines the color to use
  53667. * @param backBuffer defines if the back buffer must be cleared
  53668. * @param depth defines if the depth buffer must be cleared
  53669. * @param stencil defines if the stencil buffer must be cleared
  53670. */
  53671. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53672. /**
  53673. * Gets the current render width
  53674. * @param useScreen defines if screen size must be used (or the current render target if any)
  53675. * @returns a number defining the current render width
  53676. */
  53677. getRenderWidth(useScreen?: boolean): number;
  53678. /**
  53679. * Gets the current render height
  53680. * @param useScreen defines if screen size must be used (or the current render target if any)
  53681. * @returns a number defining the current render height
  53682. */
  53683. getRenderHeight(useScreen?: boolean): number;
  53684. /**
  53685. * Set the WebGL's viewport
  53686. * @param viewport defines the viewport element to be used
  53687. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53688. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53689. */
  53690. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53691. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53692. /**
  53693. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53694. * @param pipelineContext defines the pipeline context to use
  53695. * @param uniformsNames defines the list of uniform names
  53696. * @returns an array of webGL uniform locations
  53697. */
  53698. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53699. /**
  53700. * Gets the lsit of active attributes for a given webGL program
  53701. * @param pipelineContext defines the pipeline context to use
  53702. * @param attributesNames defines the list of attribute names to get
  53703. * @returns an array of indices indicating the offset of each attribute
  53704. */
  53705. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53706. /**
  53707. * Binds an effect to the webGL context
  53708. * @param effect defines the effect to bind
  53709. */
  53710. bindSamplers(effect: Effect): void;
  53711. /**
  53712. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53713. * @param effect defines the effect to activate
  53714. */
  53715. enableEffect(effect: Effect): void;
  53716. /**
  53717. * Set various states to the webGL context
  53718. * @param culling defines backface culling state
  53719. * @param zOffset defines the value to apply to zOffset (0 by default)
  53720. * @param force defines if states must be applied even if cache is up to date
  53721. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53722. */
  53723. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53724. /**
  53725. * Set the value of an uniform to an array of int32
  53726. * @param uniform defines the webGL uniform location where to store the value
  53727. * @param array defines the array of int32 to store
  53728. */
  53729. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53730. /**
  53731. * Set the value of an uniform to an array of int32 (stored as vec2)
  53732. * @param uniform defines the webGL uniform location where to store the value
  53733. * @param array defines the array of int32 to store
  53734. */
  53735. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53736. /**
  53737. * Set the value of an uniform to an array of int32 (stored as vec3)
  53738. * @param uniform defines the webGL uniform location where to store the value
  53739. * @param array defines the array of int32 to store
  53740. */
  53741. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53742. /**
  53743. * Set the value of an uniform to an array of int32 (stored as vec4)
  53744. * @param uniform defines the webGL uniform location where to store the value
  53745. * @param array defines the array of int32 to store
  53746. */
  53747. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53748. /**
  53749. * Set the value of an uniform to an array of float32
  53750. * @param uniform defines the webGL uniform location where to store the value
  53751. * @param array defines the array of float32 to store
  53752. */
  53753. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53754. /**
  53755. * Set the value of an uniform to an array of float32 (stored as vec2)
  53756. * @param uniform defines the webGL uniform location where to store the value
  53757. * @param array defines the array of float32 to store
  53758. */
  53759. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53760. /**
  53761. * Set the value of an uniform to an array of float32 (stored as vec3)
  53762. * @param uniform defines the webGL uniform location where to store the value
  53763. * @param array defines the array of float32 to store
  53764. */
  53765. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53766. /**
  53767. * Set the value of an uniform to an array of float32 (stored as vec4)
  53768. * @param uniform defines the webGL uniform location where to store the value
  53769. * @param array defines the array of float32 to store
  53770. */
  53771. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53772. /**
  53773. * Set the value of an uniform to an array of number
  53774. * @param uniform defines the webGL uniform location where to store the value
  53775. * @param array defines the array of number to store
  53776. */
  53777. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53778. /**
  53779. * Set the value of an uniform to an array of number (stored as vec2)
  53780. * @param uniform defines the webGL uniform location where to store the value
  53781. * @param array defines the array of number to store
  53782. */
  53783. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53784. /**
  53785. * Set the value of an uniform to an array of number (stored as vec3)
  53786. * @param uniform defines the webGL uniform location where to store the value
  53787. * @param array defines the array of number to store
  53788. */
  53789. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53790. /**
  53791. * Set the value of an uniform to an array of number (stored as vec4)
  53792. * @param uniform defines the webGL uniform location where to store the value
  53793. * @param array defines the array of number to store
  53794. */
  53795. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53796. /**
  53797. * Set the value of an uniform to an array of float32 (stored as matrices)
  53798. * @param uniform defines the webGL uniform location where to store the value
  53799. * @param matrices defines the array of float32 to store
  53800. */
  53801. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53802. /**
  53803. * Set the value of an uniform to a matrix (3x3)
  53804. * @param uniform defines the webGL uniform location where to store the value
  53805. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53806. */
  53807. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53808. /**
  53809. * Set the value of an uniform to a matrix (2x2)
  53810. * @param uniform defines the webGL uniform location where to store the value
  53811. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53812. */
  53813. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53814. /**
  53815. * Set the value of an uniform to a number (float)
  53816. * @param uniform defines the webGL uniform location where to store the value
  53817. * @param value defines the float number to store
  53818. */
  53819. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53820. /**
  53821. * Set the value of an uniform to a vec2
  53822. * @param uniform defines the webGL uniform location where to store the value
  53823. * @param x defines the 1st component of the value
  53824. * @param y defines the 2nd component of the value
  53825. */
  53826. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53827. /**
  53828. * Set the value of an uniform to a vec3
  53829. * @param uniform defines the webGL uniform location where to store the value
  53830. * @param x defines the 1st component of the value
  53831. * @param y defines the 2nd component of the value
  53832. * @param z defines the 3rd component of the value
  53833. */
  53834. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53835. /**
  53836. * Set the value of an uniform to a boolean
  53837. * @param uniform defines the webGL uniform location where to store the value
  53838. * @param bool defines the boolean to store
  53839. */
  53840. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53841. /**
  53842. * Set the value of an uniform to a vec4
  53843. * @param uniform defines the webGL uniform location where to store the value
  53844. * @param x defines the 1st component of the value
  53845. * @param y defines the 2nd component of the value
  53846. * @param z defines the 3rd component of the value
  53847. * @param w defines the 4th component of the value
  53848. */
  53849. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53850. /**
  53851. * Sets the current alpha mode
  53852. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53853. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53854. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53855. */
  53856. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53857. /**
  53858. * Bind webGl buffers directly to the webGL context
  53859. * @param vertexBuffers defines the vertex buffer to bind
  53860. * @param indexBuffer defines the index buffer to bind
  53861. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53862. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53863. * @param effect defines the effect associated with the vertex buffer
  53864. */
  53865. bindBuffers(vertexBuffers: {
  53866. [key: string]: VertexBuffer;
  53867. }, indexBuffer: DataBuffer, effect: Effect): void;
  53868. /**
  53869. * Force the entire cache to be cleared
  53870. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53871. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53872. */
  53873. wipeCaches(bruteForce?: boolean): void;
  53874. /**
  53875. * Send a draw order
  53876. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53877. * @param indexStart defines the starting index
  53878. * @param indexCount defines the number of index to draw
  53879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53880. */
  53881. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53882. /**
  53883. * Draw a list of indexed primitives
  53884. * @param fillMode defines the primitive to use
  53885. * @param indexStart defines the starting index
  53886. * @param indexCount defines the number of index to draw
  53887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53888. */
  53889. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53890. /**
  53891. * Draw a list of unindexed primitives
  53892. * @param fillMode defines the primitive to use
  53893. * @param verticesStart defines the index of first vertex to draw
  53894. * @param verticesCount defines the count of vertices to draw
  53895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53896. */
  53897. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53898. /** @hidden */
  53899. _createTexture(): WebGLTexture;
  53900. /** @hidden */
  53901. _releaseTexture(texture: InternalTexture): void;
  53902. /**
  53903. * Usually called from Texture.ts.
  53904. * Passed information to create a WebGLTexture
  53905. * @param urlArg defines a value which contains one of the following:
  53906. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53907. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53908. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53910. * @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)
  53911. * @param scene needed for loading to the correct scene
  53912. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53913. * @param onLoad optional callback to be called upon successful completion
  53914. * @param onError optional callback to be called upon failure
  53915. * @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
  53916. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53917. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53918. * @param forcedExtension defines the extension to use to pick the right loader
  53919. * @param mimeType defines an optional mime type
  53920. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53921. */
  53922. 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;
  53923. /**
  53924. * Creates a new render target texture
  53925. * @param size defines the size of the texture
  53926. * @param options defines the options used to create the texture
  53927. * @returns a new render target texture stored in an InternalTexture
  53928. */
  53929. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53930. /**
  53931. * Update the sampling mode of a given texture
  53932. * @param samplingMode defines the required sampling mode
  53933. * @param texture defines the texture to update
  53934. */
  53935. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53936. /**
  53937. * Binds the frame buffer to the specified texture.
  53938. * @param texture The texture to render to or null for the default canvas
  53939. * @param faceIndex The face of the texture to render to in case of cube texture
  53940. * @param requiredWidth The width of the target to render to
  53941. * @param requiredHeight The height of the target to render to
  53942. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53943. * @param lodLevel defines le lod level to bind to the frame buffer
  53944. */
  53945. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53946. /**
  53947. * Unbind the current render target texture from the webGL context
  53948. * @param texture defines the render target texture to unbind
  53949. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53950. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53951. */
  53952. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53953. /**
  53954. * Creates a dynamic vertex buffer
  53955. * @param vertices the data for the dynamic vertex buffer
  53956. * @returns the new WebGL dynamic buffer
  53957. */
  53958. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53959. /**
  53960. * Update the content of a dynamic texture
  53961. * @param texture defines the texture to update
  53962. * @param canvas defines the canvas containing the source
  53963. * @param invertY defines if data must be stored with Y axis inverted
  53964. * @param premulAlpha defines if alpha is stored as premultiplied
  53965. * @param format defines the format of the data
  53966. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53967. */
  53968. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53969. /**
  53970. * Gets a boolean indicating if all created effects are ready
  53971. * @returns true if all effects are ready
  53972. */
  53973. areAllEffectsReady(): boolean;
  53974. /**
  53975. * @hidden
  53976. * Get the current error code of the webGL context
  53977. * @returns the error code
  53978. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53979. */
  53980. getError(): number;
  53981. /** @hidden */
  53982. _getUnpackAlignement(): number;
  53983. /** @hidden */
  53984. _unpackFlipY(value: boolean): void;
  53985. /**
  53986. * Update a dynamic index buffer
  53987. * @param indexBuffer defines the target index buffer
  53988. * @param indices defines the data to update
  53989. * @param offset defines the offset in the target index buffer where update should start
  53990. */
  53991. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53992. /**
  53993. * Updates a dynamic vertex buffer.
  53994. * @param vertexBuffer the vertex buffer to update
  53995. * @param vertices the data used to update the vertex buffer
  53996. * @param byteOffset the byte offset of the data (optional)
  53997. * @param byteLength the byte length of the data (optional)
  53998. */
  53999. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54000. /** @hidden */
  54001. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54002. /** @hidden */
  54003. _bindTexture(channel: number, texture: InternalTexture): void;
  54004. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54005. /**
  54006. * 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
  54007. */
  54008. releaseEffects(): void;
  54009. displayLoadingUI(): void;
  54010. hideLoadingUI(): void;
  54011. /** @hidden */
  54012. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54013. /** @hidden */
  54014. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54015. /** @hidden */
  54016. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54017. /** @hidden */
  54018. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54019. }
  54020. }
  54021. declare module "babylonjs/Instrumentation/timeToken" {
  54022. import { Nullable } from "babylonjs/types";
  54023. /**
  54024. * @hidden
  54025. **/
  54026. export class _TimeToken {
  54027. _startTimeQuery: Nullable<WebGLQuery>;
  54028. _endTimeQuery: Nullable<WebGLQuery>;
  54029. _timeElapsedQuery: Nullable<WebGLQuery>;
  54030. _timeElapsedQueryEnded: boolean;
  54031. }
  54032. }
  54033. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54034. import { Nullable, int } from "babylonjs/types";
  54035. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54036. /** @hidden */
  54037. export class _OcclusionDataStorage {
  54038. /** @hidden */
  54039. occlusionInternalRetryCounter: number;
  54040. /** @hidden */
  54041. isOcclusionQueryInProgress: boolean;
  54042. /** @hidden */
  54043. isOccluded: boolean;
  54044. /** @hidden */
  54045. occlusionRetryCount: number;
  54046. /** @hidden */
  54047. occlusionType: number;
  54048. /** @hidden */
  54049. occlusionQueryAlgorithmType: number;
  54050. }
  54051. module "babylonjs/Engines/engine" {
  54052. interface Engine {
  54053. /**
  54054. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54055. * @return the new query
  54056. */
  54057. createQuery(): WebGLQuery;
  54058. /**
  54059. * Delete and release a webGL query
  54060. * @param query defines the query to delete
  54061. * @return the current engine
  54062. */
  54063. deleteQuery(query: WebGLQuery): Engine;
  54064. /**
  54065. * Check if a given query has resolved and got its value
  54066. * @param query defines the query to check
  54067. * @returns true if the query got its value
  54068. */
  54069. isQueryResultAvailable(query: WebGLQuery): boolean;
  54070. /**
  54071. * Gets the value of a given query
  54072. * @param query defines the query to check
  54073. * @returns the value of the query
  54074. */
  54075. getQueryResult(query: WebGLQuery): number;
  54076. /**
  54077. * Initiates an occlusion query
  54078. * @param algorithmType defines the algorithm to use
  54079. * @param query defines the query to use
  54080. * @returns the current engine
  54081. * @see https://doc.babylonjs.com/features/occlusionquery
  54082. */
  54083. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54084. /**
  54085. * Ends an occlusion query
  54086. * @see https://doc.babylonjs.com/features/occlusionquery
  54087. * @param algorithmType defines the algorithm to use
  54088. * @returns the current engine
  54089. */
  54090. endOcclusionQuery(algorithmType: number): Engine;
  54091. /**
  54092. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54093. * Please note that only one query can be issued at a time
  54094. * @returns a time token used to track the time span
  54095. */
  54096. startTimeQuery(): Nullable<_TimeToken>;
  54097. /**
  54098. * Ends a time query
  54099. * @param token defines the token used to measure the time span
  54100. * @returns the time spent (in ns)
  54101. */
  54102. endTimeQuery(token: _TimeToken): int;
  54103. /** @hidden */
  54104. _currentNonTimestampToken: Nullable<_TimeToken>;
  54105. /** @hidden */
  54106. _createTimeQuery(): WebGLQuery;
  54107. /** @hidden */
  54108. _deleteTimeQuery(query: WebGLQuery): void;
  54109. /** @hidden */
  54110. _getGlAlgorithmType(algorithmType: number): number;
  54111. /** @hidden */
  54112. _getTimeQueryResult(query: WebGLQuery): any;
  54113. /** @hidden */
  54114. _getTimeQueryAvailability(query: WebGLQuery): any;
  54115. }
  54116. }
  54117. module "babylonjs/Meshes/abstractMesh" {
  54118. interface AbstractMesh {
  54119. /**
  54120. * Backing filed
  54121. * @hidden
  54122. */
  54123. __occlusionDataStorage: _OcclusionDataStorage;
  54124. /**
  54125. * Access property
  54126. * @hidden
  54127. */
  54128. _occlusionDataStorage: _OcclusionDataStorage;
  54129. /**
  54130. * 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.
  54131. * The default value is -1 which means don't break the query and wait till the result
  54132. * @see https://doc.babylonjs.com/features/occlusionquery
  54133. */
  54134. occlusionRetryCount: number;
  54135. /**
  54136. * 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:
  54137. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54138. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54139. * * 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.
  54140. * @see https://doc.babylonjs.com/features/occlusionquery
  54141. */
  54142. occlusionType: number;
  54143. /**
  54144. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54145. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54146. * * 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.
  54147. * @see https://doc.babylonjs.com/features/occlusionquery
  54148. */
  54149. occlusionQueryAlgorithmType: number;
  54150. /**
  54151. * 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
  54152. * @see https://doc.babylonjs.com/features/occlusionquery
  54153. */
  54154. isOccluded: boolean;
  54155. /**
  54156. * Flag to check the progress status of the query
  54157. * @see https://doc.babylonjs.com/features/occlusionquery
  54158. */
  54159. isOcclusionQueryInProgress: boolean;
  54160. }
  54161. }
  54162. }
  54163. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54164. import { Nullable } from "babylonjs/types";
  54165. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54166. /** @hidden */
  54167. export var _forceTransformFeedbackToBundle: boolean;
  54168. module "babylonjs/Engines/engine" {
  54169. interface Engine {
  54170. /**
  54171. * Creates a webGL transform feedback object
  54172. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54173. * @returns the webGL transform feedback object
  54174. */
  54175. createTransformFeedback(): WebGLTransformFeedback;
  54176. /**
  54177. * Delete a webGL transform feedback object
  54178. * @param value defines the webGL transform feedback object to delete
  54179. */
  54180. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54181. /**
  54182. * Bind a webGL transform feedback object to the webgl context
  54183. * @param value defines the webGL transform feedback object to bind
  54184. */
  54185. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54186. /**
  54187. * Begins a transform feedback operation
  54188. * @param usePoints defines if points or triangles must be used
  54189. */
  54190. beginTransformFeedback(usePoints: boolean): void;
  54191. /**
  54192. * Ends a transform feedback operation
  54193. */
  54194. endTransformFeedback(): void;
  54195. /**
  54196. * Specify the varyings to use with transform feedback
  54197. * @param program defines the associated webGL program
  54198. * @param value defines the list of strings representing the varying names
  54199. */
  54200. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54201. /**
  54202. * Bind a webGL buffer for a transform feedback operation
  54203. * @param value defines the webGL buffer to bind
  54204. */
  54205. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54206. }
  54207. }
  54208. }
  54209. declare module "babylonjs/Engines/Extensions/engine.views" {
  54210. import { Camera } from "babylonjs/Cameras/camera";
  54211. import { Nullable } from "babylonjs/types";
  54212. /**
  54213. * Class used to define an additional view for the engine
  54214. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54215. */
  54216. export class EngineView {
  54217. /** Defines the canvas where to render the view */
  54218. target: HTMLCanvasElement;
  54219. /** Defines an optional camera used to render the view (will use active camera else) */
  54220. camera?: Camera;
  54221. }
  54222. module "babylonjs/Engines/engine" {
  54223. interface Engine {
  54224. /**
  54225. * Gets or sets the HTML element to use for attaching events
  54226. */
  54227. inputElement: Nullable<HTMLElement>;
  54228. /**
  54229. * Gets the current engine view
  54230. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54231. */
  54232. activeView: Nullable<EngineView>;
  54233. /** Gets or sets the list of views */
  54234. views: EngineView[];
  54235. /**
  54236. * Register a new child canvas
  54237. * @param canvas defines the canvas to register
  54238. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54239. * @returns the associated view
  54240. */
  54241. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54242. /**
  54243. * Remove a registered child canvas
  54244. * @param canvas defines the canvas to remove
  54245. * @returns the current engine
  54246. */
  54247. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54248. }
  54249. }
  54250. }
  54251. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54252. import { Nullable } from "babylonjs/types";
  54253. module "babylonjs/Engines/engine" {
  54254. interface Engine {
  54255. /** @hidden */
  54256. _excludedCompressedTextures: string[];
  54257. /** @hidden */
  54258. _textureFormatInUse: string;
  54259. /**
  54260. * Gets the list of texture formats supported
  54261. */
  54262. readonly texturesSupported: Array<string>;
  54263. /**
  54264. * Gets the texture format in use
  54265. */
  54266. readonly textureFormatInUse: Nullable<string>;
  54267. /**
  54268. * Set the compressed texture extensions or file names to skip.
  54269. *
  54270. * @param skippedFiles defines the list of those texture files you want to skip
  54271. * Example: [".dds", ".env", "myfile.png"]
  54272. */
  54273. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54274. /**
  54275. * Set the compressed texture format to use, based on the formats you have, and the formats
  54276. * supported by the hardware / browser.
  54277. *
  54278. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54279. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54280. * to API arguments needed to compressed textures. This puts the burden on the container
  54281. * generator to house the arcane code for determining these for current & future formats.
  54282. *
  54283. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54284. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54285. *
  54286. * Note: The result of this call is not taken into account when a texture is base64.
  54287. *
  54288. * @param formatsAvailable defines the list of those format families you have created
  54289. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54290. *
  54291. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54292. * @returns The extension selected.
  54293. */
  54294. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54295. }
  54296. }
  54297. }
  54298. declare module "babylonjs/Engines/Extensions/index" {
  54299. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54300. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54301. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54302. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54303. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54304. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54305. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54306. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54307. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54308. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54309. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54310. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54311. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54312. export * from "babylonjs/Engines/Extensions/engine.views";
  54313. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54314. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54315. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54316. }
  54317. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54318. import { Nullable } from "babylonjs/types";
  54319. /**
  54320. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54321. */
  54322. export interface CubeMapInfo {
  54323. /**
  54324. * The pixel array for the front face.
  54325. * This is stored in format, left to right, up to down format.
  54326. */
  54327. front: Nullable<ArrayBufferView>;
  54328. /**
  54329. * The pixel array for the back face.
  54330. * This is stored in format, left to right, up to down format.
  54331. */
  54332. back: Nullable<ArrayBufferView>;
  54333. /**
  54334. * The pixel array for the left face.
  54335. * This is stored in format, left to right, up to down format.
  54336. */
  54337. left: Nullable<ArrayBufferView>;
  54338. /**
  54339. * The pixel array for the right face.
  54340. * This is stored in format, left to right, up to down format.
  54341. */
  54342. right: Nullable<ArrayBufferView>;
  54343. /**
  54344. * The pixel array for the up face.
  54345. * This is stored in format, left to right, up to down format.
  54346. */
  54347. up: Nullable<ArrayBufferView>;
  54348. /**
  54349. * The pixel array for the down face.
  54350. * This is stored in format, left to right, up to down format.
  54351. */
  54352. down: Nullable<ArrayBufferView>;
  54353. /**
  54354. * The size of the cubemap stored.
  54355. *
  54356. * Each faces will be size * size pixels.
  54357. */
  54358. size: number;
  54359. /**
  54360. * The format of the texture.
  54361. *
  54362. * RGBA, RGB.
  54363. */
  54364. format: number;
  54365. /**
  54366. * The type of the texture data.
  54367. *
  54368. * UNSIGNED_INT, FLOAT.
  54369. */
  54370. type: number;
  54371. /**
  54372. * Specifies whether the texture is in gamma space.
  54373. */
  54374. gammaSpace: boolean;
  54375. }
  54376. /**
  54377. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54378. */
  54379. export class PanoramaToCubeMapTools {
  54380. private static FACE_LEFT;
  54381. private static FACE_RIGHT;
  54382. private static FACE_FRONT;
  54383. private static FACE_BACK;
  54384. private static FACE_DOWN;
  54385. private static FACE_UP;
  54386. /**
  54387. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54388. *
  54389. * @param float32Array The source data.
  54390. * @param inputWidth The width of the input panorama.
  54391. * @param inputHeight The height of the input panorama.
  54392. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54393. * @return The cubemap data
  54394. */
  54395. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54396. private static CreateCubemapTexture;
  54397. private static CalcProjectionSpherical;
  54398. }
  54399. }
  54400. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54401. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54403. import { Nullable } from "babylonjs/types";
  54404. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54405. /**
  54406. * Helper class dealing with the extraction of spherical polynomial dataArray
  54407. * from a cube map.
  54408. */
  54409. export class CubeMapToSphericalPolynomialTools {
  54410. private static FileFaces;
  54411. /**
  54412. * Converts a texture to the according Spherical Polynomial data.
  54413. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54414. *
  54415. * @param texture The texture to extract the information from.
  54416. * @return The Spherical Polynomial data.
  54417. */
  54418. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54419. /**
  54420. * Converts a cubemap to the according Spherical Polynomial data.
  54421. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54422. *
  54423. * @param cubeInfo The Cube map to extract the information from.
  54424. * @return The Spherical Polynomial data.
  54425. */
  54426. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54427. }
  54428. }
  54429. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54430. import { Nullable } from "babylonjs/types";
  54431. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54432. module "babylonjs/Materials/Textures/baseTexture" {
  54433. interface BaseTexture {
  54434. /**
  54435. * Get the polynomial representation of the texture data.
  54436. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54437. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54438. */
  54439. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54440. }
  54441. }
  54442. }
  54443. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54444. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54445. /** @hidden */
  54446. export var rgbdEncodePixelShader: {
  54447. name: string;
  54448. shader: string;
  54449. };
  54450. }
  54451. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54453. /** @hidden */
  54454. export var rgbdDecodePixelShader: {
  54455. name: string;
  54456. shader: string;
  54457. };
  54458. }
  54459. declare module "babylonjs/Misc/environmentTextureTools" {
  54460. import { Nullable } from "babylonjs/types";
  54461. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54464. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54465. import "babylonjs/Engines/Extensions/engine.readTexture";
  54466. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54467. import "babylonjs/Shaders/rgbdEncode.fragment";
  54468. import "babylonjs/Shaders/rgbdDecode.fragment";
  54469. /**
  54470. * Raw texture data and descriptor sufficient for WebGL texture upload
  54471. */
  54472. export interface EnvironmentTextureInfo {
  54473. /**
  54474. * Version of the environment map
  54475. */
  54476. version: number;
  54477. /**
  54478. * Width of image
  54479. */
  54480. width: number;
  54481. /**
  54482. * Irradiance information stored in the file.
  54483. */
  54484. irradiance: any;
  54485. /**
  54486. * Specular information stored in the file.
  54487. */
  54488. specular: any;
  54489. }
  54490. /**
  54491. * Defines One Image in the file. It requires only the position in the file
  54492. * as well as the length.
  54493. */
  54494. interface BufferImageData {
  54495. /**
  54496. * Length of the image data.
  54497. */
  54498. length: number;
  54499. /**
  54500. * Position of the data from the null terminator delimiting the end of the JSON.
  54501. */
  54502. position: number;
  54503. }
  54504. /**
  54505. * Defines the specular data enclosed in the file.
  54506. * This corresponds to the version 1 of the data.
  54507. */
  54508. export interface EnvironmentTextureSpecularInfoV1 {
  54509. /**
  54510. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54511. */
  54512. specularDataPosition?: number;
  54513. /**
  54514. * This contains all the images data needed to reconstruct the cubemap.
  54515. */
  54516. mipmaps: Array<BufferImageData>;
  54517. /**
  54518. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54519. */
  54520. lodGenerationScale: number;
  54521. }
  54522. /**
  54523. * Sets of helpers addressing the serialization and deserialization of environment texture
  54524. * stored in a BabylonJS env file.
  54525. * Those files are usually stored as .env files.
  54526. */
  54527. export class EnvironmentTextureTools {
  54528. /**
  54529. * Magic number identifying the env file.
  54530. */
  54531. private static _MagicBytes;
  54532. /**
  54533. * Gets the environment info from an env file.
  54534. * @param data The array buffer containing the .env bytes.
  54535. * @returns the environment file info (the json header) if successfully parsed.
  54536. */
  54537. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54538. /**
  54539. * Creates an environment texture from a loaded cube texture.
  54540. * @param texture defines the cube texture to convert in env file
  54541. * @return a promise containing the environment data if succesfull.
  54542. */
  54543. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54544. /**
  54545. * Creates a JSON representation of the spherical data.
  54546. * @param texture defines the texture containing the polynomials
  54547. * @return the JSON representation of the spherical info
  54548. */
  54549. private static _CreateEnvTextureIrradiance;
  54550. /**
  54551. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54552. * @param data the image data
  54553. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54554. * @return the views described by info providing access to the underlying buffer
  54555. */
  54556. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54557. /**
  54558. * Uploads the texture info contained in the env file to the GPU.
  54559. * @param texture defines the internal texture to upload to
  54560. * @param data defines the data to load
  54561. * @param info defines the texture info retrieved through the GetEnvInfo method
  54562. * @returns a promise
  54563. */
  54564. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54565. private static _OnImageReadyAsync;
  54566. /**
  54567. * Uploads the levels of image data to the GPU.
  54568. * @param texture defines the internal texture to upload to
  54569. * @param imageData defines the array buffer views of image data [mipmap][face]
  54570. * @returns a promise
  54571. */
  54572. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54573. /**
  54574. * Uploads spherical polynomials information to the texture.
  54575. * @param texture defines the texture we are trying to upload the information to
  54576. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54577. */
  54578. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54579. /** @hidden */
  54580. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54581. }
  54582. }
  54583. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54584. /**
  54585. * Class used to inline functions in shader code
  54586. */
  54587. export class ShaderCodeInliner {
  54588. private static readonly _RegexpFindFunctionNameAndType;
  54589. private _sourceCode;
  54590. private _functionDescr;
  54591. private _numMaxIterations;
  54592. /** Gets or sets the token used to mark the functions to inline */
  54593. inlineToken: string;
  54594. /** Gets or sets the debug mode */
  54595. debug: boolean;
  54596. /** Gets the code after the inlining process */
  54597. get code(): string;
  54598. /**
  54599. * Initializes the inliner
  54600. * @param sourceCode shader code source to inline
  54601. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54602. */
  54603. constructor(sourceCode: string, numMaxIterations?: number);
  54604. /**
  54605. * Start the processing of the shader code
  54606. */
  54607. processCode(): void;
  54608. private _collectFunctions;
  54609. private _processInlining;
  54610. private _extractBetweenMarkers;
  54611. private _skipWhitespaces;
  54612. private _removeComments;
  54613. private _replaceFunctionCallsByCode;
  54614. private _findBackward;
  54615. private _escapeRegExp;
  54616. private _replaceNames;
  54617. }
  54618. }
  54619. declare module "babylonjs/Engines/nativeEngine" {
  54620. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54621. import { Engine } from "babylonjs/Engines/engine";
  54622. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54625. import { Effect } from "babylonjs/Materials/effect";
  54626. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54627. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54628. import { IColor4Like } from "babylonjs/Maths/math.like";
  54629. import { Scene } from "babylonjs/scene";
  54630. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54631. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54632. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54633. /**
  54634. * Container for accessors for natively-stored mesh data buffers.
  54635. */
  54636. class NativeDataBuffer extends DataBuffer {
  54637. /**
  54638. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54639. */
  54640. nativeIndexBuffer?: any;
  54641. /**
  54642. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54643. */
  54644. nativeVertexBuffer?: any;
  54645. }
  54646. /** @hidden */
  54647. class NativeTexture extends InternalTexture {
  54648. getInternalTexture(): InternalTexture;
  54649. getViewCount(): number;
  54650. }
  54651. /** @hidden */
  54652. export class NativeEngine extends Engine {
  54653. private readonly _native;
  54654. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54655. private readonly INVALID_HANDLE;
  54656. private _boundBuffersVertexArray;
  54657. getHardwareScalingLevel(): number;
  54658. constructor();
  54659. dispose(): void;
  54660. /**
  54661. * Can be used to override the current requestAnimationFrame requester.
  54662. * @hidden
  54663. */
  54664. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54665. /**
  54666. * Override default engine behavior.
  54667. * @param color
  54668. * @param backBuffer
  54669. * @param depth
  54670. * @param stencil
  54671. */
  54672. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54673. /**
  54674. * Gets host document
  54675. * @returns the host document object
  54676. */
  54677. getHostDocument(): Nullable<Document>;
  54678. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54679. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54680. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54681. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54682. [key: string]: VertexBuffer;
  54683. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54684. bindBuffers(vertexBuffers: {
  54685. [key: string]: VertexBuffer;
  54686. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54687. recordVertexArrayObject(vertexBuffers: {
  54688. [key: string]: VertexBuffer;
  54689. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54690. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54691. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54692. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54693. /**
  54694. * Draw a list of indexed primitives
  54695. * @param fillMode defines the primitive to use
  54696. * @param indexStart defines the starting index
  54697. * @param indexCount defines the number of index to draw
  54698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54699. */
  54700. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54701. /**
  54702. * Draw a list of unindexed primitives
  54703. * @param fillMode defines the primitive to use
  54704. * @param verticesStart defines the index of first vertex to draw
  54705. * @param verticesCount defines the count of vertices to draw
  54706. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54707. */
  54708. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54709. createPipelineContext(): IPipelineContext;
  54710. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54711. /** @hidden */
  54712. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54713. /** @hidden */
  54714. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54715. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54717. protected _setProgram(program: WebGLProgram): void;
  54718. _releaseEffect(effect: Effect): void;
  54719. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54720. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54721. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54722. bindSamplers(effect: Effect): void;
  54723. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54724. getRenderWidth(useScreen?: boolean): number;
  54725. getRenderHeight(useScreen?: boolean): number;
  54726. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54727. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54728. /**
  54729. * Set the z offset to apply to current rendering
  54730. * @param value defines the offset to apply
  54731. */
  54732. setZOffset(value: number): void;
  54733. /**
  54734. * Gets the current value of the zOffset
  54735. * @returns the current zOffset state
  54736. */
  54737. getZOffset(): number;
  54738. /**
  54739. * Enable or disable depth buffering
  54740. * @param enable defines the state to set
  54741. */
  54742. setDepthBuffer(enable: boolean): void;
  54743. /**
  54744. * Gets a boolean indicating if depth writing is enabled
  54745. * @returns the current depth writing state
  54746. */
  54747. getDepthWrite(): boolean;
  54748. /**
  54749. * Enable or disable depth writing
  54750. * @param enable defines the state to set
  54751. */
  54752. setDepthWrite(enable: boolean): void;
  54753. /**
  54754. * Enable or disable color writing
  54755. * @param enable defines the state to set
  54756. */
  54757. setColorWrite(enable: boolean): void;
  54758. /**
  54759. * Gets a boolean indicating if color writing is enabled
  54760. * @returns the current color writing state
  54761. */
  54762. getColorWrite(): boolean;
  54763. /**
  54764. * Sets alpha constants used by some alpha blending modes
  54765. * @param r defines the red component
  54766. * @param g defines the green component
  54767. * @param b defines the blue component
  54768. * @param a defines the alpha component
  54769. */
  54770. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54771. /**
  54772. * Sets the current alpha mode
  54773. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54774. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54775. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54776. */
  54777. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54778. /**
  54779. * Gets the current alpha mode
  54780. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54781. * @returns the current alpha mode
  54782. */
  54783. getAlphaMode(): number;
  54784. setInt(uniform: WebGLUniformLocation, int: number): void;
  54785. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54786. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54787. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54788. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54789. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54790. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54791. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54792. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54793. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54794. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54795. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54796. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54797. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54798. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54799. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54800. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54801. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54802. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54803. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54804. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54805. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54806. wipeCaches(bruteForce?: boolean): void;
  54807. _createTexture(): WebGLTexture;
  54808. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54809. /**
  54810. * Usually called from Texture.ts.
  54811. * Passed information to create a WebGLTexture
  54812. * @param url defines a value which contains one of the following:
  54813. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54814. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54815. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54816. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54817. * @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)
  54818. * @param scene needed for loading to the correct scene
  54819. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54820. * @param onLoad optional callback to be called upon successful completion
  54821. * @param onError optional callback to be called upon failure
  54822. * @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
  54823. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54824. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54825. * @param forcedExtension defines the extension to use to pick the right loader
  54826. * @param mimeType defines an optional mime type
  54827. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54828. */
  54829. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  54830. /**
  54831. * Creates a cube texture
  54832. * @param rootUrl defines the url where the files to load is located
  54833. * @param scene defines the current scene
  54834. * @param files defines the list of files to load (1 per face)
  54835. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54836. * @param onLoad defines an optional callback raised when the texture is loaded
  54837. * @param onError defines an optional callback raised if there is an issue to load the texture
  54838. * @param format defines the format of the data
  54839. * @param forcedExtension defines the extension to use to pick the right loader
  54840. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54843. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54844. * @returns the cube texture as an InternalTexture
  54845. */
  54846. 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;
  54847. private _getSamplingFilter;
  54848. private static _GetNativeTextureFormat;
  54849. createRenderTargetTexture(size: number | {
  54850. width: number;
  54851. height: number;
  54852. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54853. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54854. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54855. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54856. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54857. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54858. /**
  54859. * Updates a dynamic vertex buffer.
  54860. * @param vertexBuffer the vertex buffer to update
  54861. * @param data the data used to update the vertex buffer
  54862. * @param byteOffset the byte offset of the data (optional)
  54863. * @param byteLength the byte length of the data (optional)
  54864. */
  54865. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54866. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54867. private _updateAnisotropicLevel;
  54868. private _getAddressMode;
  54869. /** @hidden */
  54870. _bindTexture(channel: number, texture: InternalTexture): void;
  54871. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54872. releaseEffects(): void;
  54873. /** @hidden */
  54874. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54875. /** @hidden */
  54876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54877. /** @hidden */
  54878. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54879. /** @hidden */
  54880. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54881. }
  54882. }
  54883. declare module "babylonjs/Engines/index" {
  54884. export * from "babylonjs/Engines/constants";
  54885. export * from "babylonjs/Engines/engineCapabilities";
  54886. export * from "babylonjs/Engines/instancingAttributeInfo";
  54887. export * from "babylonjs/Engines/thinEngine";
  54888. export * from "babylonjs/Engines/engine";
  54889. export * from "babylonjs/Engines/engineStore";
  54890. export * from "babylonjs/Engines/nullEngine";
  54891. export * from "babylonjs/Engines/Extensions/index";
  54892. export * from "babylonjs/Engines/IPipelineContext";
  54893. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54894. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54895. export * from "babylonjs/Engines/nativeEngine";
  54896. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54897. export * from "babylonjs/Engines/performanceConfigurator";
  54898. }
  54899. declare module "babylonjs/Events/clipboardEvents" {
  54900. /**
  54901. * Gather the list of clipboard event types as constants.
  54902. */
  54903. export class ClipboardEventTypes {
  54904. /**
  54905. * The clipboard event is fired when a copy command is active (pressed).
  54906. */
  54907. static readonly COPY: number;
  54908. /**
  54909. * The clipboard event is fired when a cut command is active (pressed).
  54910. */
  54911. static readonly CUT: number;
  54912. /**
  54913. * The clipboard event is fired when a paste command is active (pressed).
  54914. */
  54915. static readonly PASTE: number;
  54916. }
  54917. /**
  54918. * This class is used to store clipboard related info for the onClipboardObservable event.
  54919. */
  54920. export class ClipboardInfo {
  54921. /**
  54922. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54923. */
  54924. type: number;
  54925. /**
  54926. * Defines the related dom event
  54927. */
  54928. event: ClipboardEvent;
  54929. /**
  54930. *Creates an instance of ClipboardInfo.
  54931. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54932. * @param event Defines the related dom event
  54933. */
  54934. constructor(
  54935. /**
  54936. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54937. */
  54938. type: number,
  54939. /**
  54940. * Defines the related dom event
  54941. */
  54942. event: ClipboardEvent);
  54943. /**
  54944. * Get the clipboard event's type from the keycode.
  54945. * @param keyCode Defines the keyCode for the current keyboard event.
  54946. * @return {number}
  54947. */
  54948. static GetTypeFromCharacter(keyCode: number): number;
  54949. }
  54950. }
  54951. declare module "babylonjs/Events/index" {
  54952. export * from "babylonjs/Events/keyboardEvents";
  54953. export * from "babylonjs/Events/pointerEvents";
  54954. export * from "babylonjs/Events/clipboardEvents";
  54955. }
  54956. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54957. import { Scene } from "babylonjs/scene";
  54958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54959. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54960. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54961. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54962. /**
  54963. * Google Daydream controller
  54964. */
  54965. export class DaydreamController extends WebVRController {
  54966. /**
  54967. * Base Url for the controller model.
  54968. */
  54969. static MODEL_BASE_URL: string;
  54970. /**
  54971. * File name for the controller model.
  54972. */
  54973. static MODEL_FILENAME: string;
  54974. /**
  54975. * Gamepad Id prefix used to identify Daydream Controller.
  54976. */
  54977. static readonly GAMEPAD_ID_PREFIX: string;
  54978. /**
  54979. * Creates a new DaydreamController from a gamepad
  54980. * @param vrGamepad the gamepad that the controller should be created from
  54981. */
  54982. constructor(vrGamepad: any);
  54983. /**
  54984. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54985. * @param scene scene in which to add meshes
  54986. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54987. */
  54988. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54989. /**
  54990. * Called once for each button that changed state since the last frame
  54991. * @param buttonIdx Which button index changed
  54992. * @param state New state of the button
  54993. * @param changes Which properties on the state changed since last frame
  54994. */
  54995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54996. }
  54997. }
  54998. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54999. import { Scene } from "babylonjs/scene";
  55000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55001. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55002. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55003. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55004. /**
  55005. * Gear VR Controller
  55006. */
  55007. export class GearVRController extends WebVRController {
  55008. /**
  55009. * Base Url for the controller model.
  55010. */
  55011. static MODEL_BASE_URL: string;
  55012. /**
  55013. * File name for the controller model.
  55014. */
  55015. static MODEL_FILENAME: string;
  55016. /**
  55017. * Gamepad Id prefix used to identify this controller.
  55018. */
  55019. static readonly GAMEPAD_ID_PREFIX: string;
  55020. private readonly _buttonIndexToObservableNameMap;
  55021. /**
  55022. * Creates a new GearVRController from a gamepad
  55023. * @param vrGamepad the gamepad that the controller should be created from
  55024. */
  55025. constructor(vrGamepad: any);
  55026. /**
  55027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55028. * @param scene scene in which to add meshes
  55029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55030. */
  55031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55032. /**
  55033. * Called once for each button that changed state since the last frame
  55034. * @param buttonIdx Which button index changed
  55035. * @param state New state of the button
  55036. * @param changes Which properties on the state changed since last frame
  55037. */
  55038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55039. }
  55040. }
  55041. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55042. import { Scene } from "babylonjs/scene";
  55043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55044. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55045. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55046. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55047. /**
  55048. * Generic Controller
  55049. */
  55050. export class GenericController extends WebVRController {
  55051. /**
  55052. * Base Url for the controller model.
  55053. */
  55054. static readonly MODEL_BASE_URL: string;
  55055. /**
  55056. * File name for the controller model.
  55057. */
  55058. static readonly MODEL_FILENAME: string;
  55059. /**
  55060. * Creates a new GenericController from a gamepad
  55061. * @param vrGamepad the gamepad that the controller should be created from
  55062. */
  55063. constructor(vrGamepad: any);
  55064. /**
  55065. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55066. * @param scene scene in which to add meshes
  55067. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55068. */
  55069. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55070. /**
  55071. * Called once for each button that changed state since the last frame
  55072. * @param buttonIdx Which button index changed
  55073. * @param state New state of the button
  55074. * @param changes Which properties on the state changed since last frame
  55075. */
  55076. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55077. }
  55078. }
  55079. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55080. import { Observable } from "babylonjs/Misc/observable";
  55081. import { Scene } from "babylonjs/scene";
  55082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55083. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55084. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55085. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55086. /**
  55087. * Oculus Touch Controller
  55088. */
  55089. export class OculusTouchController extends WebVRController {
  55090. /**
  55091. * Base Url for the controller model.
  55092. */
  55093. static MODEL_BASE_URL: string;
  55094. /**
  55095. * File name for the left controller model.
  55096. */
  55097. static MODEL_LEFT_FILENAME: string;
  55098. /**
  55099. * File name for the right controller model.
  55100. */
  55101. static MODEL_RIGHT_FILENAME: string;
  55102. /**
  55103. * Base Url for the Quest controller model.
  55104. */
  55105. static QUEST_MODEL_BASE_URL: string;
  55106. /**
  55107. * @hidden
  55108. * If the controllers are running on a device that needs the updated Quest controller models
  55109. */
  55110. static _IsQuest: boolean;
  55111. /**
  55112. * Fired when the secondary trigger on this controller is modified
  55113. */
  55114. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55115. /**
  55116. * Fired when the thumb rest on this controller is modified
  55117. */
  55118. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55119. /**
  55120. * Creates a new OculusTouchController from a gamepad
  55121. * @param vrGamepad the gamepad that the controller should be created from
  55122. */
  55123. constructor(vrGamepad: any);
  55124. /**
  55125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55126. * @param scene scene in which to add meshes
  55127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55128. */
  55129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55130. /**
  55131. * Fired when the A button on this controller is modified
  55132. */
  55133. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55134. /**
  55135. * Fired when the B button on this controller is modified
  55136. */
  55137. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55138. /**
  55139. * Fired when the X button on this controller is modified
  55140. */
  55141. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55142. /**
  55143. * Fired when the Y button on this controller is modified
  55144. */
  55145. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55146. /**
  55147. * Called once for each button that changed state since the last frame
  55148. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55149. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55150. * 2) secondary trigger (same)
  55151. * 3) A (right) X (left), touch, pressed = value
  55152. * 4) B / Y
  55153. * 5) thumb rest
  55154. * @param buttonIdx Which button index changed
  55155. * @param state New state of the button
  55156. * @param changes Which properties on the state changed since last frame
  55157. */
  55158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55159. }
  55160. }
  55161. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55162. import { Scene } from "babylonjs/scene";
  55163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55164. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55165. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55166. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55167. import { Observable } from "babylonjs/Misc/observable";
  55168. /**
  55169. * Vive Controller
  55170. */
  55171. export class ViveController extends WebVRController {
  55172. /**
  55173. * Base Url for the controller model.
  55174. */
  55175. static MODEL_BASE_URL: string;
  55176. /**
  55177. * File name for the controller model.
  55178. */
  55179. static MODEL_FILENAME: string;
  55180. /**
  55181. * Creates a new ViveController from a gamepad
  55182. * @param vrGamepad the gamepad that the controller should be created from
  55183. */
  55184. constructor(vrGamepad: any);
  55185. /**
  55186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55187. * @param scene scene in which to add meshes
  55188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55189. */
  55190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55191. /**
  55192. * Fired when the left button on this controller is modified
  55193. */
  55194. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55195. /**
  55196. * Fired when the right button on this controller is modified
  55197. */
  55198. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55199. /**
  55200. * Fired when the menu button on this controller is modified
  55201. */
  55202. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55203. /**
  55204. * Called once for each button that changed state since the last frame
  55205. * Vive mapping:
  55206. * 0: touchpad
  55207. * 1: trigger
  55208. * 2: left AND right buttons
  55209. * 3: menu button
  55210. * @param buttonIdx Which button index changed
  55211. * @param state New state of the button
  55212. * @param changes Which properties on the state changed since last frame
  55213. */
  55214. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55215. }
  55216. }
  55217. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55218. import { Observable } from "babylonjs/Misc/observable";
  55219. import { Scene } from "babylonjs/scene";
  55220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55221. import { Ray } from "babylonjs/Culling/ray";
  55222. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55223. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55224. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55225. /**
  55226. * Defines the WindowsMotionController object that the state of the windows motion controller
  55227. */
  55228. export class WindowsMotionController extends WebVRController {
  55229. /**
  55230. * The base url used to load the left and right controller models
  55231. */
  55232. static MODEL_BASE_URL: string;
  55233. /**
  55234. * The name of the left controller model file
  55235. */
  55236. static MODEL_LEFT_FILENAME: string;
  55237. /**
  55238. * The name of the right controller model file
  55239. */
  55240. static MODEL_RIGHT_FILENAME: string;
  55241. /**
  55242. * The controller name prefix for this controller type
  55243. */
  55244. static readonly GAMEPAD_ID_PREFIX: string;
  55245. /**
  55246. * The controller id pattern for this controller type
  55247. */
  55248. private static readonly GAMEPAD_ID_PATTERN;
  55249. private _loadedMeshInfo;
  55250. protected readonly _mapping: {
  55251. buttons: string[];
  55252. buttonMeshNames: {
  55253. trigger: string;
  55254. menu: string;
  55255. grip: string;
  55256. thumbstick: string;
  55257. trackpad: string;
  55258. };
  55259. buttonObservableNames: {
  55260. trigger: string;
  55261. menu: string;
  55262. grip: string;
  55263. thumbstick: string;
  55264. trackpad: string;
  55265. };
  55266. axisMeshNames: string[];
  55267. pointingPoseMeshName: string;
  55268. };
  55269. /**
  55270. * Fired when the trackpad on this controller is clicked
  55271. */
  55272. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55273. /**
  55274. * Fired when the trackpad on this controller is modified
  55275. */
  55276. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55277. /**
  55278. * The current x and y values of this controller's trackpad
  55279. */
  55280. trackpad: StickValues;
  55281. /**
  55282. * Creates a new WindowsMotionController from a gamepad
  55283. * @param vrGamepad the gamepad that the controller should be created from
  55284. */
  55285. constructor(vrGamepad: any);
  55286. /**
  55287. * Fired when the trigger on this controller is modified
  55288. */
  55289. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55290. /**
  55291. * Fired when the menu button on this controller is modified
  55292. */
  55293. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55294. /**
  55295. * Fired when the grip button on this controller is modified
  55296. */
  55297. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55298. /**
  55299. * Fired when the thumbstick button on this controller is modified
  55300. */
  55301. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55302. /**
  55303. * Fired when the touchpad button on this controller is modified
  55304. */
  55305. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55306. /**
  55307. * Fired when the touchpad values on this controller are modified
  55308. */
  55309. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55310. protected _updateTrackpad(): void;
  55311. /**
  55312. * Called once per frame by the engine.
  55313. */
  55314. update(): void;
  55315. /**
  55316. * Called once for each button that changed state since the last frame
  55317. * @param buttonIdx Which button index changed
  55318. * @param state New state of the button
  55319. * @param changes Which properties on the state changed since last frame
  55320. */
  55321. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55322. /**
  55323. * Moves the buttons on the controller mesh based on their current state
  55324. * @param buttonName the name of the button to move
  55325. * @param buttonValue the value of the button which determines the buttons new position
  55326. */
  55327. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55328. /**
  55329. * Moves the axis on the controller mesh based on its current state
  55330. * @param axis the index of the axis
  55331. * @param axisValue the value of the axis which determines the meshes new position
  55332. * @hidden
  55333. */
  55334. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55335. /**
  55336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55337. * @param scene scene in which to add meshes
  55338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55339. */
  55340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55341. /**
  55342. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55343. * can be transformed by button presses and axes values, based on this._mapping.
  55344. *
  55345. * @param scene scene in which the meshes exist
  55346. * @param meshes list of meshes that make up the controller model to process
  55347. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55348. */
  55349. private processModel;
  55350. private createMeshInfo;
  55351. /**
  55352. * Gets the ray of the controller in the direction the controller is pointing
  55353. * @param length the length the resulting ray should be
  55354. * @returns a ray in the direction the controller is pointing
  55355. */
  55356. getForwardRay(length?: number): Ray;
  55357. /**
  55358. * Disposes of the controller
  55359. */
  55360. dispose(): void;
  55361. }
  55362. /**
  55363. * This class represents a new windows motion controller in XR.
  55364. */
  55365. export class XRWindowsMotionController extends WindowsMotionController {
  55366. /**
  55367. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55368. */
  55369. protected readonly _mapping: {
  55370. buttons: string[];
  55371. buttonMeshNames: {
  55372. trigger: string;
  55373. menu: string;
  55374. grip: string;
  55375. thumbstick: string;
  55376. trackpad: string;
  55377. };
  55378. buttonObservableNames: {
  55379. trigger: string;
  55380. menu: string;
  55381. grip: string;
  55382. thumbstick: string;
  55383. trackpad: string;
  55384. };
  55385. axisMeshNames: string[];
  55386. pointingPoseMeshName: string;
  55387. };
  55388. /**
  55389. * Construct a new XR-Based windows motion controller
  55390. *
  55391. * @param gamepadInfo the gamepad object from the browser
  55392. */
  55393. constructor(gamepadInfo: any);
  55394. /**
  55395. * holds the thumbstick values (X,Y)
  55396. */
  55397. thumbstickValues: StickValues;
  55398. /**
  55399. * Fired when the thumbstick on this controller is clicked
  55400. */
  55401. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55402. /**
  55403. * Fired when the thumbstick on this controller is modified
  55404. */
  55405. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55406. /**
  55407. * Fired when the touchpad button on this controller is modified
  55408. */
  55409. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55410. /**
  55411. * Fired when the touchpad values on this controller are modified
  55412. */
  55413. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55414. /**
  55415. * Fired when the thumbstick button on this controller is modified
  55416. * here to prevent breaking changes
  55417. */
  55418. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55419. /**
  55420. * updating the thumbstick(!) and not the trackpad.
  55421. * This is named this way due to the difference between WebVR and XR and to avoid
  55422. * changing the parent class.
  55423. */
  55424. protected _updateTrackpad(): void;
  55425. /**
  55426. * Disposes the class with joy
  55427. */
  55428. dispose(): void;
  55429. }
  55430. }
  55431. declare module "babylonjs/Gamepads/Controllers/index" {
  55432. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55433. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55434. export * from "babylonjs/Gamepads/Controllers/genericController";
  55435. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55436. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55437. export * from "babylonjs/Gamepads/Controllers/viveController";
  55438. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55439. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55440. }
  55441. declare module "babylonjs/Gamepads/index" {
  55442. export * from "babylonjs/Gamepads/Controllers/index";
  55443. export * from "babylonjs/Gamepads/gamepad";
  55444. export * from "babylonjs/Gamepads/gamepadManager";
  55445. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55446. export * from "babylonjs/Gamepads/xboxGamepad";
  55447. export * from "babylonjs/Gamepads/dualShockGamepad";
  55448. }
  55449. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55450. import { Scene } from "babylonjs/scene";
  55451. import { Vector4 } from "babylonjs/Maths/math.vector";
  55452. import { Color4 } from "babylonjs/Maths/math.color";
  55453. import { Mesh } from "babylonjs/Meshes/mesh";
  55454. import { Nullable } from "babylonjs/types";
  55455. /**
  55456. * Class containing static functions to help procedurally build meshes
  55457. */
  55458. export class PolyhedronBuilder {
  55459. /**
  55460. * Creates a polyhedron mesh
  55461. * * 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
  55462. * * The parameter `size` (positive float, default 1) sets the polygon size
  55463. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55464. * * 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`
  55465. * * 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
  55466. * * 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)`)
  55467. * * 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
  55468. * * 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
  55469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55472. * @param name defines the name of the mesh
  55473. * @param options defines the options used to create the mesh
  55474. * @param scene defines the hosting scene
  55475. * @returns the polyhedron mesh
  55476. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55477. */
  55478. static CreatePolyhedron(name: string, options: {
  55479. type?: number;
  55480. size?: number;
  55481. sizeX?: number;
  55482. sizeY?: number;
  55483. sizeZ?: number;
  55484. custom?: any;
  55485. faceUV?: Vector4[];
  55486. faceColors?: Color4[];
  55487. flat?: boolean;
  55488. updatable?: boolean;
  55489. sideOrientation?: number;
  55490. frontUVs?: Vector4;
  55491. backUVs?: Vector4;
  55492. }, scene?: Nullable<Scene>): Mesh;
  55493. }
  55494. }
  55495. declare module "babylonjs/Gizmos/scaleGizmo" {
  55496. import { Observable } from "babylonjs/Misc/observable";
  55497. import { Nullable } from "babylonjs/types";
  55498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55499. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55500. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55501. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55502. import { Node } from "babylonjs/node";
  55503. /**
  55504. * Gizmo that enables scaling a mesh along 3 axis
  55505. */
  55506. export class ScaleGizmo extends Gizmo {
  55507. /**
  55508. * Internal gizmo used for interactions on the x axis
  55509. */
  55510. xGizmo: AxisScaleGizmo;
  55511. /**
  55512. * Internal gizmo used for interactions on the y axis
  55513. */
  55514. yGizmo: AxisScaleGizmo;
  55515. /**
  55516. * Internal gizmo used for interactions on the z axis
  55517. */
  55518. zGizmo: AxisScaleGizmo;
  55519. /**
  55520. * Internal gizmo used to scale all axis equally
  55521. */
  55522. uniformScaleGizmo: AxisScaleGizmo;
  55523. private _meshAttached;
  55524. private _nodeAttached;
  55525. private _updateGizmoRotationToMatchAttachedMesh;
  55526. private _snapDistance;
  55527. private _scaleRatio;
  55528. private _uniformScalingMesh;
  55529. private _octahedron;
  55530. private _sensitivity;
  55531. /** Fires an event when any of it's sub gizmos are dragged */
  55532. onDragStartObservable: Observable<unknown>;
  55533. /** Fires an event when any of it's sub gizmos are released from dragging */
  55534. onDragEndObservable: Observable<unknown>;
  55535. get attachedMesh(): Nullable<AbstractMesh>;
  55536. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55537. get attachedNode(): Nullable<Node>;
  55538. set attachedNode(node: Nullable<Node>);
  55539. /**
  55540. * Creates a ScaleGizmo
  55541. * @param gizmoLayer The utility layer the gizmo will be added to
  55542. * @param thickness display gizmo axis thickness
  55543. */
  55544. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55545. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55546. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55547. /**
  55548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55549. */
  55550. set snapDistance(value: number);
  55551. get snapDistance(): number;
  55552. /**
  55553. * Ratio for the scale of the gizmo (Default: 1)
  55554. */
  55555. set scaleRatio(value: number);
  55556. get scaleRatio(): number;
  55557. /**
  55558. * Sensitivity factor for dragging (Default: 1)
  55559. */
  55560. set sensitivity(value: number);
  55561. get sensitivity(): number;
  55562. /**
  55563. * Disposes of the gizmo
  55564. */
  55565. dispose(): void;
  55566. }
  55567. }
  55568. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55569. import { Observable } from "babylonjs/Misc/observable";
  55570. import { Nullable } from "babylonjs/types";
  55571. import { Vector3 } from "babylonjs/Maths/math.vector";
  55572. import { Node } from "babylonjs/node";
  55573. import { Mesh } from "babylonjs/Meshes/mesh";
  55574. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55575. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55577. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55578. import { Color3 } from "babylonjs/Maths/math.color";
  55579. /**
  55580. * Single axis scale gizmo
  55581. */
  55582. export class AxisScaleGizmo extends Gizmo {
  55583. /**
  55584. * Drag behavior responsible for the gizmos dragging interactions
  55585. */
  55586. dragBehavior: PointerDragBehavior;
  55587. private _pointerObserver;
  55588. /**
  55589. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55590. */
  55591. snapDistance: number;
  55592. /**
  55593. * Event that fires each time the gizmo snaps to a new location.
  55594. * * snapDistance is the the change in distance
  55595. */
  55596. onSnapObservable: Observable<{
  55597. snapDistance: number;
  55598. }>;
  55599. /**
  55600. * If the scaling operation should be done on all axis (default: false)
  55601. */
  55602. uniformScaling: boolean;
  55603. /**
  55604. * Custom sensitivity value for the drag strength
  55605. */
  55606. sensitivity: number;
  55607. private _isEnabled;
  55608. private _parent;
  55609. private _arrow;
  55610. private _coloredMaterial;
  55611. private _hoverMaterial;
  55612. /**
  55613. * Creates an AxisScaleGizmo
  55614. * @param gizmoLayer The utility layer the gizmo will be added to
  55615. * @param dragAxis The axis which the gizmo will be able to scale on
  55616. * @param color The color of the gizmo
  55617. * @param thickness display gizmo axis thickness
  55618. */
  55619. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55620. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55621. /**
  55622. * If the gizmo is enabled
  55623. */
  55624. set isEnabled(value: boolean);
  55625. get isEnabled(): boolean;
  55626. /**
  55627. * Disposes of the gizmo
  55628. */
  55629. dispose(): void;
  55630. /**
  55631. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55632. * @param mesh The mesh to replace the default mesh of the gizmo
  55633. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55634. */
  55635. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55636. }
  55637. }
  55638. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55639. import { Observable } from "babylonjs/Misc/observable";
  55640. import { Nullable } from "babylonjs/types";
  55641. import { Vector3 } from "babylonjs/Maths/math.vector";
  55642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55643. import { Mesh } from "babylonjs/Meshes/mesh";
  55644. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55645. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55646. import { Color3 } from "babylonjs/Maths/math.color";
  55647. import "babylonjs/Meshes/Builders/boxBuilder";
  55648. /**
  55649. * Bounding box gizmo
  55650. */
  55651. export class BoundingBoxGizmo extends Gizmo {
  55652. private _lineBoundingBox;
  55653. private _rotateSpheresParent;
  55654. private _scaleBoxesParent;
  55655. private _boundingDimensions;
  55656. private _renderObserver;
  55657. private _pointerObserver;
  55658. private _scaleDragSpeed;
  55659. private _tmpQuaternion;
  55660. private _tmpVector;
  55661. private _tmpRotationMatrix;
  55662. /**
  55663. * 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)
  55664. */
  55665. ignoreChildren: boolean;
  55666. /**
  55667. * 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)
  55668. */
  55669. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55670. /**
  55671. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55672. */
  55673. rotationSphereSize: number;
  55674. /**
  55675. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55676. */
  55677. scaleBoxSize: number;
  55678. /**
  55679. * 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)
  55680. */
  55681. fixedDragMeshScreenSize: boolean;
  55682. /**
  55683. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55684. */
  55685. fixedDragMeshScreenSizeDistanceFactor: number;
  55686. /**
  55687. * Fired when a rotation sphere or scale box is dragged
  55688. */
  55689. onDragStartObservable: Observable<{}>;
  55690. /**
  55691. * Fired when a scale box is dragged
  55692. */
  55693. onScaleBoxDragObservable: Observable<{}>;
  55694. /**
  55695. * Fired when a scale box drag is ended
  55696. */
  55697. onScaleBoxDragEndObservable: Observable<{}>;
  55698. /**
  55699. * Fired when a rotation sphere is dragged
  55700. */
  55701. onRotationSphereDragObservable: Observable<{}>;
  55702. /**
  55703. * Fired when a rotation sphere drag is ended
  55704. */
  55705. onRotationSphereDragEndObservable: Observable<{}>;
  55706. /**
  55707. * 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)
  55708. */
  55709. scalePivot: Nullable<Vector3>;
  55710. /**
  55711. * Mesh used as a pivot to rotate the attached node
  55712. */
  55713. private _anchorMesh;
  55714. private _existingMeshScale;
  55715. private _dragMesh;
  55716. private pointerDragBehavior;
  55717. private coloredMaterial;
  55718. private hoverColoredMaterial;
  55719. /**
  55720. * Sets the color of the bounding box gizmo
  55721. * @param color the color to set
  55722. */
  55723. setColor(color: Color3): void;
  55724. /**
  55725. * Creates an BoundingBoxGizmo
  55726. * @param gizmoLayer The utility layer the gizmo will be added to
  55727. * @param color The color of the gizmo
  55728. */
  55729. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55730. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55731. private _selectNode;
  55732. /**
  55733. * Updates the bounding box information for the Gizmo
  55734. */
  55735. updateBoundingBox(): void;
  55736. private _updateRotationSpheres;
  55737. private _updateScaleBoxes;
  55738. /**
  55739. * Enables rotation on the specified axis and disables rotation on the others
  55740. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55741. */
  55742. setEnabledRotationAxis(axis: string): void;
  55743. /**
  55744. * Enables/disables scaling
  55745. * @param enable if scaling should be enabled
  55746. * @param homogeneousScaling defines if scaling should only be homogeneous
  55747. */
  55748. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55749. private _updateDummy;
  55750. /**
  55751. * Enables a pointer drag behavior on the bounding box of the gizmo
  55752. */
  55753. enableDragBehavior(): void;
  55754. /**
  55755. * Disposes of the gizmo
  55756. */
  55757. dispose(): void;
  55758. /**
  55759. * 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)
  55760. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55761. * @returns the bounding box mesh with the passed in mesh as a child
  55762. */
  55763. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55764. /**
  55765. * CustomMeshes are not supported by this gizmo
  55766. * @param mesh The mesh to replace the default mesh of the gizmo
  55767. */
  55768. setCustomMesh(mesh: Mesh): void;
  55769. }
  55770. }
  55771. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55772. import { Observable } from "babylonjs/Misc/observable";
  55773. import { Nullable } from "babylonjs/types";
  55774. import { Vector3 } from "babylonjs/Maths/math.vector";
  55775. import { Color3 } from "babylonjs/Maths/math.color";
  55776. import { Node } from "babylonjs/node";
  55777. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55778. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55779. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55780. import "babylonjs/Meshes/Builders/linesBuilder";
  55781. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55782. /**
  55783. * Single plane rotation gizmo
  55784. */
  55785. export class PlaneRotationGizmo extends Gizmo {
  55786. /**
  55787. * Drag behavior responsible for the gizmos dragging interactions
  55788. */
  55789. dragBehavior: PointerDragBehavior;
  55790. private _pointerObserver;
  55791. /**
  55792. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55793. */
  55794. snapDistance: number;
  55795. /**
  55796. * Event that fires each time the gizmo snaps to a new location.
  55797. * * snapDistance is the the change in distance
  55798. */
  55799. onSnapObservable: Observable<{
  55800. snapDistance: number;
  55801. }>;
  55802. private _isEnabled;
  55803. private _parent;
  55804. /**
  55805. * Creates a PlaneRotationGizmo
  55806. * @param gizmoLayer The utility layer the gizmo will be added to
  55807. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55808. * @param color The color of the gizmo
  55809. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55810. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55811. * @param thickness display gizmo axis thickness
  55812. */
  55813. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55814. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55815. /**
  55816. * If the gizmo is enabled
  55817. */
  55818. set isEnabled(value: boolean);
  55819. get isEnabled(): boolean;
  55820. /**
  55821. * Disposes of the gizmo
  55822. */
  55823. dispose(): void;
  55824. }
  55825. }
  55826. declare module "babylonjs/Gizmos/rotationGizmo" {
  55827. import { Observable } from "babylonjs/Misc/observable";
  55828. import { Nullable } from "babylonjs/types";
  55829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55830. import { Mesh } from "babylonjs/Meshes/mesh";
  55831. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55832. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55833. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55834. import { Node } from "babylonjs/node";
  55835. /**
  55836. * Gizmo that enables rotating a mesh along 3 axis
  55837. */
  55838. export class RotationGizmo extends Gizmo {
  55839. /**
  55840. * Internal gizmo used for interactions on the x axis
  55841. */
  55842. xGizmo: PlaneRotationGizmo;
  55843. /**
  55844. * Internal gizmo used for interactions on the y axis
  55845. */
  55846. yGizmo: PlaneRotationGizmo;
  55847. /**
  55848. * Internal gizmo used for interactions on the z axis
  55849. */
  55850. zGizmo: PlaneRotationGizmo;
  55851. /** Fires an event when any of it's sub gizmos are dragged */
  55852. onDragStartObservable: Observable<unknown>;
  55853. /** Fires an event when any of it's sub gizmos are released from dragging */
  55854. onDragEndObservable: Observable<unknown>;
  55855. private _meshAttached;
  55856. private _nodeAttached;
  55857. get attachedMesh(): Nullable<AbstractMesh>;
  55858. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55859. get attachedNode(): Nullable<Node>;
  55860. set attachedNode(node: Nullable<Node>);
  55861. /**
  55862. * Creates a RotationGizmo
  55863. * @param gizmoLayer The utility layer the gizmo will be added to
  55864. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55865. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55866. * @param thickness display gizmo axis thickness
  55867. */
  55868. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55869. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55870. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55871. /**
  55872. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55873. */
  55874. set snapDistance(value: number);
  55875. get snapDistance(): number;
  55876. /**
  55877. * Ratio for the scale of the gizmo (Default: 1)
  55878. */
  55879. set scaleRatio(value: number);
  55880. get scaleRatio(): number;
  55881. /**
  55882. * Disposes of the gizmo
  55883. */
  55884. dispose(): void;
  55885. /**
  55886. * CustomMeshes are not supported by this gizmo
  55887. * @param mesh The mesh to replace the default mesh of the gizmo
  55888. */
  55889. setCustomMesh(mesh: Mesh): void;
  55890. }
  55891. }
  55892. declare module "babylonjs/Gizmos/gizmoManager" {
  55893. import { Observable } from "babylonjs/Misc/observable";
  55894. import { Nullable } from "babylonjs/types";
  55895. import { Scene, IDisposable } from "babylonjs/scene";
  55896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55898. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55899. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55900. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55901. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55902. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55903. /**
  55904. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55905. */
  55906. export class GizmoManager implements IDisposable {
  55907. private scene;
  55908. /**
  55909. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55910. */
  55911. gizmos: {
  55912. positionGizmo: Nullable<PositionGizmo>;
  55913. rotationGizmo: Nullable<RotationGizmo>;
  55914. scaleGizmo: Nullable<ScaleGizmo>;
  55915. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55916. };
  55917. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55918. clearGizmoOnEmptyPointerEvent: boolean;
  55919. /** Fires an event when the manager is attached to a mesh */
  55920. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55921. private _gizmosEnabled;
  55922. private _pointerObserver;
  55923. private _attachedMesh;
  55924. private _boundingBoxColor;
  55925. private _defaultUtilityLayer;
  55926. private _defaultKeepDepthUtilityLayer;
  55927. private _thickness;
  55928. /**
  55929. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55930. */
  55931. boundingBoxDragBehavior: SixDofDragBehavior;
  55932. /**
  55933. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55934. */
  55935. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55936. /**
  55937. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55938. */
  55939. usePointerToAttachGizmos: boolean;
  55940. /**
  55941. * Utility layer that the bounding box gizmo belongs to
  55942. */
  55943. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55944. /**
  55945. * Utility layer that all gizmos besides bounding box belong to
  55946. */
  55947. get utilityLayer(): UtilityLayerRenderer;
  55948. /**
  55949. * Instatiates a gizmo manager
  55950. * @param scene the scene to overlay the gizmos on top of
  55951. * @param thickness display gizmo axis thickness
  55952. */
  55953. constructor(scene: Scene, thickness?: number);
  55954. /**
  55955. * Attaches a set of gizmos to the specified mesh
  55956. * @param mesh The mesh the gizmo's should be attached to
  55957. */
  55958. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55959. /**
  55960. * If the position gizmo is enabled
  55961. */
  55962. set positionGizmoEnabled(value: boolean);
  55963. get positionGizmoEnabled(): boolean;
  55964. /**
  55965. * If the rotation gizmo is enabled
  55966. */
  55967. set rotationGizmoEnabled(value: boolean);
  55968. get rotationGizmoEnabled(): boolean;
  55969. /**
  55970. * If the scale gizmo is enabled
  55971. */
  55972. set scaleGizmoEnabled(value: boolean);
  55973. get scaleGizmoEnabled(): boolean;
  55974. /**
  55975. * If the boundingBox gizmo is enabled
  55976. */
  55977. set boundingBoxGizmoEnabled(value: boolean);
  55978. get boundingBoxGizmoEnabled(): boolean;
  55979. /**
  55980. * Disposes of the gizmo manager
  55981. */
  55982. dispose(): void;
  55983. }
  55984. }
  55985. declare module "babylonjs/Lights/directionalLight" {
  55986. import { Camera } from "babylonjs/Cameras/camera";
  55987. import { Scene } from "babylonjs/scene";
  55988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55990. import { Light } from "babylonjs/Lights/light";
  55991. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55992. import { Effect } from "babylonjs/Materials/effect";
  55993. /**
  55994. * A directional light is defined by a direction (what a surprise!).
  55995. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55996. * 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.
  55997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55998. */
  55999. export class DirectionalLight extends ShadowLight {
  56000. private _shadowFrustumSize;
  56001. /**
  56002. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56003. */
  56004. get shadowFrustumSize(): number;
  56005. /**
  56006. * Specifies a fix frustum size for the shadow generation.
  56007. */
  56008. set shadowFrustumSize(value: number);
  56009. private _shadowOrthoScale;
  56010. /**
  56011. * Gets the shadow projection scale against the optimal computed one.
  56012. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56013. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56014. */
  56015. get shadowOrthoScale(): number;
  56016. /**
  56017. * Sets the shadow projection scale against the optimal computed one.
  56018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56020. */
  56021. set shadowOrthoScale(value: number);
  56022. /**
  56023. * Automatically compute the projection matrix to best fit (including all the casters)
  56024. * on each frame.
  56025. */
  56026. autoUpdateExtends: boolean;
  56027. /**
  56028. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56029. * on each frame. autoUpdateExtends must be set to true for this to work
  56030. */
  56031. autoCalcShadowZBounds: boolean;
  56032. private _orthoLeft;
  56033. private _orthoRight;
  56034. private _orthoTop;
  56035. private _orthoBottom;
  56036. /**
  56037. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56038. * The directional light is emitted from everywhere in the given direction.
  56039. * It can cast shadows.
  56040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56041. * @param name The friendly name of the light
  56042. * @param direction The direction of the light
  56043. * @param scene The scene the light belongs to
  56044. */
  56045. constructor(name: string, direction: Vector3, scene: Scene);
  56046. /**
  56047. * Returns the string "DirectionalLight".
  56048. * @return The class name
  56049. */
  56050. getClassName(): string;
  56051. /**
  56052. * Returns the integer 1.
  56053. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56054. */
  56055. getTypeID(): number;
  56056. /**
  56057. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56058. * Returns the DirectionalLight Shadow projection matrix.
  56059. */
  56060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56061. /**
  56062. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56063. * Returns the DirectionalLight Shadow projection matrix.
  56064. */
  56065. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56066. /**
  56067. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56068. * Returns the DirectionalLight Shadow projection matrix.
  56069. */
  56070. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56071. protected _buildUniformLayout(): void;
  56072. /**
  56073. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56074. * @param effect The effect to update
  56075. * @param lightIndex The index of the light in the effect to update
  56076. * @returns The directional light
  56077. */
  56078. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56080. /**
  56081. * Gets the minZ used for shadow according to both the scene and the light.
  56082. *
  56083. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56084. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56085. * @param activeCamera The camera we are returning the min for
  56086. * @returns the depth min z
  56087. */
  56088. getDepthMinZ(activeCamera: Camera): number;
  56089. /**
  56090. * Gets the maxZ used for shadow according to both the scene and the light.
  56091. *
  56092. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56093. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56094. * @param activeCamera The camera we are returning the max for
  56095. * @returns the depth max z
  56096. */
  56097. getDepthMaxZ(activeCamera: Camera): number;
  56098. /**
  56099. * Prepares the list of defines specific to the light type.
  56100. * @param defines the list of defines
  56101. * @param lightIndex defines the index of the light for the effect
  56102. */
  56103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56104. }
  56105. }
  56106. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56107. import { Mesh } from "babylonjs/Meshes/mesh";
  56108. /**
  56109. * Class containing static functions to help procedurally build meshes
  56110. */
  56111. export class HemisphereBuilder {
  56112. /**
  56113. * Creates a hemisphere mesh
  56114. * @param name defines the name of the mesh
  56115. * @param options defines the options used to create the mesh
  56116. * @param scene defines the hosting scene
  56117. * @returns the hemisphere mesh
  56118. */
  56119. static CreateHemisphere(name: string, options: {
  56120. segments?: number;
  56121. diameter?: number;
  56122. sideOrientation?: number;
  56123. }, scene: any): Mesh;
  56124. }
  56125. }
  56126. declare module "babylonjs/Lights/spotLight" {
  56127. import { Nullable } from "babylonjs/types";
  56128. import { Scene } from "babylonjs/scene";
  56129. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56131. import { Effect } from "babylonjs/Materials/effect";
  56132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56133. import { Light } from "babylonjs/Lights/light";
  56134. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56135. /**
  56136. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56137. * These values define a cone of light starting from the position, emitting toward the direction.
  56138. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56139. * and the exponent defines the speed of the decay of the light with distance (reach).
  56140. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56141. */
  56142. export class SpotLight extends ShadowLight {
  56143. private _angle;
  56144. private _innerAngle;
  56145. private _cosHalfAngle;
  56146. private _lightAngleScale;
  56147. private _lightAngleOffset;
  56148. /**
  56149. * Gets the cone angle of the spot light in Radians.
  56150. */
  56151. get angle(): number;
  56152. /**
  56153. * Sets the cone angle of the spot light in Radians.
  56154. */
  56155. set angle(value: number);
  56156. /**
  56157. * Only used in gltf falloff mode, this defines the angle where
  56158. * the directional falloff will start before cutting at angle which could be seen
  56159. * as outer angle.
  56160. */
  56161. get innerAngle(): number;
  56162. /**
  56163. * Only used in gltf falloff mode, this defines the angle where
  56164. * the directional falloff will start before cutting at angle which could be seen
  56165. * as outer angle.
  56166. */
  56167. set innerAngle(value: number);
  56168. private _shadowAngleScale;
  56169. /**
  56170. * Allows scaling the angle of the light for shadow generation only.
  56171. */
  56172. get shadowAngleScale(): number;
  56173. /**
  56174. * Allows scaling the angle of the light for shadow generation only.
  56175. */
  56176. set shadowAngleScale(value: number);
  56177. /**
  56178. * The light decay speed with the distance from the emission spot.
  56179. */
  56180. exponent: number;
  56181. private _projectionTextureMatrix;
  56182. /**
  56183. * Allows reading the projecton texture
  56184. */
  56185. get projectionTextureMatrix(): Matrix;
  56186. protected _projectionTextureLightNear: number;
  56187. /**
  56188. * Gets the near clip of the Spotlight for texture projection.
  56189. */
  56190. get projectionTextureLightNear(): number;
  56191. /**
  56192. * Sets the near clip of the Spotlight for texture projection.
  56193. */
  56194. set projectionTextureLightNear(value: number);
  56195. protected _projectionTextureLightFar: number;
  56196. /**
  56197. * Gets the far clip of the Spotlight for texture projection.
  56198. */
  56199. get projectionTextureLightFar(): number;
  56200. /**
  56201. * Sets the far clip of the Spotlight for texture projection.
  56202. */
  56203. set projectionTextureLightFar(value: number);
  56204. protected _projectionTextureUpDirection: Vector3;
  56205. /**
  56206. * Gets the Up vector of the Spotlight for texture projection.
  56207. */
  56208. get projectionTextureUpDirection(): Vector3;
  56209. /**
  56210. * Sets the Up vector of the Spotlight for texture projection.
  56211. */
  56212. set projectionTextureUpDirection(value: Vector3);
  56213. private _projectionTexture;
  56214. /**
  56215. * Gets the projection texture of the light.
  56216. */
  56217. get projectionTexture(): Nullable<BaseTexture>;
  56218. /**
  56219. * Sets the projection texture of the light.
  56220. */
  56221. set projectionTexture(value: Nullable<BaseTexture>);
  56222. private _projectionTextureViewLightDirty;
  56223. private _projectionTextureProjectionLightDirty;
  56224. private _projectionTextureDirty;
  56225. private _projectionTextureViewTargetVector;
  56226. private _projectionTextureViewLightMatrix;
  56227. private _projectionTextureProjectionLightMatrix;
  56228. private _projectionTextureScalingMatrix;
  56229. /**
  56230. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56231. * It can cast shadows.
  56232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56233. * @param name The light friendly name
  56234. * @param position The position of the spot light in the scene
  56235. * @param direction The direction of the light in the scene
  56236. * @param angle The cone angle of the light in Radians
  56237. * @param exponent The light decay speed with the distance from the emission spot
  56238. * @param scene The scene the lights belongs to
  56239. */
  56240. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56241. /**
  56242. * Returns the string "SpotLight".
  56243. * @returns the class name
  56244. */
  56245. getClassName(): string;
  56246. /**
  56247. * Returns the integer 2.
  56248. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56249. */
  56250. getTypeID(): number;
  56251. /**
  56252. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56253. */
  56254. protected _setDirection(value: Vector3): void;
  56255. /**
  56256. * Overrides the position setter to recompute the projection texture view light Matrix.
  56257. */
  56258. protected _setPosition(value: Vector3): void;
  56259. /**
  56260. * 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.
  56261. * Returns the SpotLight.
  56262. */
  56263. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56264. protected _computeProjectionTextureViewLightMatrix(): void;
  56265. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56266. /**
  56267. * Main function for light texture projection matrix computing.
  56268. */
  56269. protected _computeProjectionTextureMatrix(): void;
  56270. protected _buildUniformLayout(): void;
  56271. private _computeAngleValues;
  56272. /**
  56273. * Sets the passed Effect "effect" with the Light textures.
  56274. * @param effect The effect to update
  56275. * @param lightIndex The index of the light in the effect to update
  56276. * @returns The light
  56277. */
  56278. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56279. /**
  56280. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56281. * @param effect The effect to update
  56282. * @param lightIndex The index of the light in the effect to update
  56283. * @returns The spot light
  56284. */
  56285. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56286. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56287. /**
  56288. * Disposes the light and the associated resources.
  56289. */
  56290. dispose(): void;
  56291. /**
  56292. * Prepares the list of defines specific to the light type.
  56293. * @param defines the list of defines
  56294. * @param lightIndex defines the index of the light for the effect
  56295. */
  56296. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56297. }
  56298. }
  56299. declare module "babylonjs/Gizmos/lightGizmo" {
  56300. import { Nullable } from "babylonjs/types";
  56301. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56302. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56303. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56304. import { Light } from "babylonjs/Lights/light";
  56305. /**
  56306. * Gizmo that enables viewing a light
  56307. */
  56308. export class LightGizmo extends Gizmo {
  56309. private _lightMesh;
  56310. private _material;
  56311. private _cachedPosition;
  56312. private _cachedForward;
  56313. private _attachedMeshParent;
  56314. /**
  56315. * Creates a LightGizmo
  56316. * @param gizmoLayer The utility layer the gizmo will be added to
  56317. */
  56318. constructor(gizmoLayer?: UtilityLayerRenderer);
  56319. private _light;
  56320. /**
  56321. * The light that the gizmo is attached to
  56322. */
  56323. set light(light: Nullable<Light>);
  56324. get light(): Nullable<Light>;
  56325. /**
  56326. * Gets the material used to render the light gizmo
  56327. */
  56328. get material(): StandardMaterial;
  56329. /**
  56330. * @hidden
  56331. * Updates the gizmo to match the attached mesh's position/rotation
  56332. */
  56333. protected _update(): void;
  56334. private static _Scale;
  56335. /**
  56336. * Creates the lines for a light mesh
  56337. */
  56338. private static _CreateLightLines;
  56339. /**
  56340. * Disposes of the light gizmo
  56341. */
  56342. dispose(): void;
  56343. private static _CreateHemisphericLightMesh;
  56344. private static _CreatePointLightMesh;
  56345. private static _CreateSpotLightMesh;
  56346. private static _CreateDirectionalLightMesh;
  56347. }
  56348. }
  56349. declare module "babylonjs/Gizmos/index" {
  56350. export * from "babylonjs/Gizmos/axisDragGizmo";
  56351. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56352. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56353. export * from "babylonjs/Gizmos/gizmo";
  56354. export * from "babylonjs/Gizmos/gizmoManager";
  56355. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56356. export * from "babylonjs/Gizmos/positionGizmo";
  56357. export * from "babylonjs/Gizmos/rotationGizmo";
  56358. export * from "babylonjs/Gizmos/scaleGizmo";
  56359. export * from "babylonjs/Gizmos/lightGizmo";
  56360. export * from "babylonjs/Gizmos/planeDragGizmo";
  56361. }
  56362. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56363. /** @hidden */
  56364. export var backgroundFragmentDeclaration: {
  56365. name: string;
  56366. shader: string;
  56367. };
  56368. }
  56369. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56370. /** @hidden */
  56371. export var backgroundUboDeclaration: {
  56372. name: string;
  56373. shader: string;
  56374. };
  56375. }
  56376. declare module "babylonjs/Shaders/background.fragment" {
  56377. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56378. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56379. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56380. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56381. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56382. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56383. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56384. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56385. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56386. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56387. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56388. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56389. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56390. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56391. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56392. /** @hidden */
  56393. export var backgroundPixelShader: {
  56394. name: string;
  56395. shader: string;
  56396. };
  56397. }
  56398. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56399. /** @hidden */
  56400. export var backgroundVertexDeclaration: {
  56401. name: string;
  56402. shader: string;
  56403. };
  56404. }
  56405. declare module "babylonjs/Shaders/background.vertex" {
  56406. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56407. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56409. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56410. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56411. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56412. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56413. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56414. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56415. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56416. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56417. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56418. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56419. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56420. /** @hidden */
  56421. export var backgroundVertexShader: {
  56422. name: string;
  56423. shader: string;
  56424. };
  56425. }
  56426. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56427. import { Nullable, int, float } from "babylonjs/types";
  56428. import { Scene } from "babylonjs/scene";
  56429. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56430. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56432. import { Mesh } from "babylonjs/Meshes/mesh";
  56433. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56434. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56435. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56437. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56438. import { Color3 } from "babylonjs/Maths/math.color";
  56439. import "babylonjs/Shaders/background.fragment";
  56440. import "babylonjs/Shaders/background.vertex";
  56441. /**
  56442. * Background material used to create an efficient environement around your scene.
  56443. */
  56444. export class BackgroundMaterial extends PushMaterial {
  56445. /**
  56446. * Standard reflectance value at parallel view angle.
  56447. */
  56448. static StandardReflectance0: number;
  56449. /**
  56450. * Standard reflectance value at grazing angle.
  56451. */
  56452. static StandardReflectance90: number;
  56453. protected _primaryColor: Color3;
  56454. /**
  56455. * Key light Color (multiply against the environement texture)
  56456. */
  56457. primaryColor: Color3;
  56458. protected __perceptualColor: Nullable<Color3>;
  56459. /**
  56460. * Experimental Internal Use Only.
  56461. *
  56462. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56463. * This acts as a helper to set the primary color to a more "human friendly" value.
  56464. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56465. * output color as close as possible from the chosen value.
  56466. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56467. * part of lighting setup.)
  56468. */
  56469. get _perceptualColor(): Nullable<Color3>;
  56470. set _perceptualColor(value: Nullable<Color3>);
  56471. protected _primaryColorShadowLevel: float;
  56472. /**
  56473. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56474. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56475. */
  56476. get primaryColorShadowLevel(): float;
  56477. set primaryColorShadowLevel(value: float);
  56478. protected _primaryColorHighlightLevel: float;
  56479. /**
  56480. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56481. * The primary color is used at the level chosen to define what the white area would look.
  56482. */
  56483. get primaryColorHighlightLevel(): float;
  56484. set primaryColorHighlightLevel(value: float);
  56485. protected _reflectionTexture: Nullable<BaseTexture>;
  56486. /**
  56487. * Reflection Texture used in the material.
  56488. * Should be author in a specific way for the best result (refer to the documentation).
  56489. */
  56490. reflectionTexture: Nullable<BaseTexture>;
  56491. protected _reflectionBlur: float;
  56492. /**
  56493. * Reflection Texture level of blur.
  56494. *
  56495. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56496. * texture twice.
  56497. */
  56498. reflectionBlur: float;
  56499. protected _diffuseTexture: Nullable<BaseTexture>;
  56500. /**
  56501. * Diffuse Texture used in the material.
  56502. * Should be author in a specific way for the best result (refer to the documentation).
  56503. */
  56504. diffuseTexture: Nullable<BaseTexture>;
  56505. protected _shadowLights: Nullable<IShadowLight[]>;
  56506. /**
  56507. * Specify the list of lights casting shadow on the material.
  56508. * All scene shadow lights will be included if null.
  56509. */
  56510. shadowLights: Nullable<IShadowLight[]>;
  56511. protected _shadowLevel: float;
  56512. /**
  56513. * Helps adjusting the shadow to a softer level if required.
  56514. * 0 means black shadows and 1 means no shadows.
  56515. */
  56516. shadowLevel: float;
  56517. protected _sceneCenter: Vector3;
  56518. /**
  56519. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56520. * It is usually zero but might be interesting to modify according to your setup.
  56521. */
  56522. sceneCenter: Vector3;
  56523. protected _opacityFresnel: boolean;
  56524. /**
  56525. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56526. * This helps ensuring a nice transition when the camera goes under the ground.
  56527. */
  56528. opacityFresnel: boolean;
  56529. protected _reflectionFresnel: boolean;
  56530. /**
  56531. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56532. * This helps adding a mirror texture on the ground.
  56533. */
  56534. reflectionFresnel: boolean;
  56535. protected _reflectionFalloffDistance: number;
  56536. /**
  56537. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56538. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56539. */
  56540. reflectionFalloffDistance: number;
  56541. protected _reflectionAmount: number;
  56542. /**
  56543. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56544. */
  56545. reflectionAmount: number;
  56546. protected _reflectionReflectance0: number;
  56547. /**
  56548. * This specifies the weight of the reflection at grazing angle.
  56549. */
  56550. reflectionReflectance0: number;
  56551. protected _reflectionReflectance90: number;
  56552. /**
  56553. * This specifies the weight of the reflection at a perpendicular point of view.
  56554. */
  56555. reflectionReflectance90: number;
  56556. /**
  56557. * Sets the reflection reflectance fresnel values according to the default standard
  56558. * empirically know to work well :-)
  56559. */
  56560. set reflectionStandardFresnelWeight(value: number);
  56561. protected _useRGBColor: boolean;
  56562. /**
  56563. * Helps to directly use the maps channels instead of their level.
  56564. */
  56565. useRGBColor: boolean;
  56566. protected _enableNoise: boolean;
  56567. /**
  56568. * This helps reducing the banding effect that could occur on the background.
  56569. */
  56570. enableNoise: boolean;
  56571. /**
  56572. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56573. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56574. * Recommended to be keep at 1.0 except for special cases.
  56575. */
  56576. get fovMultiplier(): number;
  56577. set fovMultiplier(value: number);
  56578. private _fovMultiplier;
  56579. /**
  56580. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56581. */
  56582. useEquirectangularFOV: boolean;
  56583. private _maxSimultaneousLights;
  56584. /**
  56585. * Number of Simultaneous lights allowed on the material.
  56586. */
  56587. maxSimultaneousLights: int;
  56588. private _shadowOnly;
  56589. /**
  56590. * Make the material only render shadows
  56591. */
  56592. shadowOnly: boolean;
  56593. /**
  56594. * Default configuration related to image processing available in the Background Material.
  56595. */
  56596. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56597. /**
  56598. * Keep track of the image processing observer to allow dispose and replace.
  56599. */
  56600. private _imageProcessingObserver;
  56601. /**
  56602. * Attaches a new image processing configuration to the PBR Material.
  56603. * @param configuration (if null the scene configuration will be use)
  56604. */
  56605. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56606. /**
  56607. * Gets the image processing configuration used either in this material.
  56608. */
  56609. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56610. /**
  56611. * Sets the Default image processing configuration used either in the this material.
  56612. *
  56613. * If sets to null, the scene one is in use.
  56614. */
  56615. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56616. /**
  56617. * Gets wether the color curves effect is enabled.
  56618. */
  56619. get cameraColorCurvesEnabled(): boolean;
  56620. /**
  56621. * Sets wether the color curves effect is enabled.
  56622. */
  56623. set cameraColorCurvesEnabled(value: boolean);
  56624. /**
  56625. * Gets wether the color grading effect is enabled.
  56626. */
  56627. get cameraColorGradingEnabled(): boolean;
  56628. /**
  56629. * Gets wether the color grading effect is enabled.
  56630. */
  56631. set cameraColorGradingEnabled(value: boolean);
  56632. /**
  56633. * Gets wether tonemapping is enabled or not.
  56634. */
  56635. get cameraToneMappingEnabled(): boolean;
  56636. /**
  56637. * Sets wether tonemapping is enabled or not
  56638. */
  56639. set cameraToneMappingEnabled(value: boolean);
  56640. /**
  56641. * The camera exposure used on this material.
  56642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56643. * This corresponds to a photographic exposure.
  56644. */
  56645. get cameraExposure(): float;
  56646. /**
  56647. * The camera exposure used on this material.
  56648. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56649. * This corresponds to a photographic exposure.
  56650. */
  56651. set cameraExposure(value: float);
  56652. /**
  56653. * Gets The camera contrast used on this material.
  56654. */
  56655. get cameraContrast(): float;
  56656. /**
  56657. * Sets The camera contrast used on this material.
  56658. */
  56659. set cameraContrast(value: float);
  56660. /**
  56661. * Gets the Color Grading 2D Lookup Texture.
  56662. */
  56663. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56664. /**
  56665. * Sets the Color Grading 2D Lookup Texture.
  56666. */
  56667. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56668. /**
  56669. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56670. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56671. * 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;
  56672. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56673. */
  56674. get cameraColorCurves(): Nullable<ColorCurves>;
  56675. /**
  56676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56678. * 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;
  56679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56680. */
  56681. set cameraColorCurves(value: Nullable<ColorCurves>);
  56682. /**
  56683. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56684. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56685. */
  56686. switchToBGR: boolean;
  56687. private _renderTargets;
  56688. private _reflectionControls;
  56689. private _white;
  56690. private _primaryShadowColor;
  56691. private _primaryHighlightColor;
  56692. /**
  56693. * Instantiates a Background Material in the given scene
  56694. * @param name The friendly name of the material
  56695. * @param scene The scene to add the material to
  56696. */
  56697. constructor(name: string, scene: Scene);
  56698. /**
  56699. * Gets a boolean indicating that current material needs to register RTT
  56700. */
  56701. get hasRenderTargetTextures(): boolean;
  56702. /**
  56703. * The entire material has been created in order to prevent overdraw.
  56704. * @returns false
  56705. */
  56706. needAlphaTesting(): boolean;
  56707. /**
  56708. * The entire material has been created in order to prevent overdraw.
  56709. * @returns true if blending is enable
  56710. */
  56711. needAlphaBlending(): boolean;
  56712. /**
  56713. * Checks wether the material is ready to be rendered for a given mesh.
  56714. * @param mesh The mesh to render
  56715. * @param subMesh The submesh to check against
  56716. * @param useInstances Specify wether or not the material is used with instances
  56717. * @returns true if all the dependencies are ready (Textures, Effects...)
  56718. */
  56719. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56720. /**
  56721. * Compute the primary color according to the chosen perceptual color.
  56722. */
  56723. private _computePrimaryColorFromPerceptualColor;
  56724. /**
  56725. * Compute the highlights and shadow colors according to their chosen levels.
  56726. */
  56727. private _computePrimaryColors;
  56728. /**
  56729. * Build the uniform buffer used in the material.
  56730. */
  56731. buildUniformLayout(): void;
  56732. /**
  56733. * Unbind the material.
  56734. */
  56735. unbind(): void;
  56736. /**
  56737. * Bind only the world matrix to the material.
  56738. * @param world The world matrix to bind.
  56739. */
  56740. bindOnlyWorldMatrix(world: Matrix): void;
  56741. /**
  56742. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56743. * @param world The world matrix to bind.
  56744. * @param subMesh The submesh to bind for.
  56745. */
  56746. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56747. /**
  56748. * Checks to see if a texture is used in the material.
  56749. * @param texture - Base texture to use.
  56750. * @returns - Boolean specifying if a texture is used in the material.
  56751. */
  56752. hasTexture(texture: BaseTexture): boolean;
  56753. /**
  56754. * Dispose the material.
  56755. * @param forceDisposeEffect Force disposal of the associated effect.
  56756. * @param forceDisposeTextures Force disposal of the associated textures.
  56757. */
  56758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56759. /**
  56760. * Clones the material.
  56761. * @param name The cloned name.
  56762. * @returns The cloned material.
  56763. */
  56764. clone(name: string): BackgroundMaterial;
  56765. /**
  56766. * Serializes the current material to its JSON representation.
  56767. * @returns The JSON representation.
  56768. */
  56769. serialize(): any;
  56770. /**
  56771. * Gets the class name of the material
  56772. * @returns "BackgroundMaterial"
  56773. */
  56774. getClassName(): string;
  56775. /**
  56776. * Parse a JSON input to create back a background material.
  56777. * @param source The JSON data to parse
  56778. * @param scene The scene to create the parsed material in
  56779. * @param rootUrl The root url of the assets the material depends upon
  56780. * @returns the instantiated BackgroundMaterial.
  56781. */
  56782. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56783. }
  56784. }
  56785. declare module "babylonjs/Helpers/environmentHelper" {
  56786. import { Observable } from "babylonjs/Misc/observable";
  56787. import { Nullable } from "babylonjs/types";
  56788. import { Scene } from "babylonjs/scene";
  56789. import { Vector3 } from "babylonjs/Maths/math.vector";
  56790. import { Color3 } from "babylonjs/Maths/math.color";
  56791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56792. import { Mesh } from "babylonjs/Meshes/mesh";
  56793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56794. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56795. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56796. import "babylonjs/Meshes/Builders/planeBuilder";
  56797. import "babylonjs/Meshes/Builders/boxBuilder";
  56798. /**
  56799. * Represents the different options available during the creation of
  56800. * a Environment helper.
  56801. *
  56802. * This can control the default ground, skybox and image processing setup of your scene.
  56803. */
  56804. export interface IEnvironmentHelperOptions {
  56805. /**
  56806. * Specifies whether or not to create a ground.
  56807. * True by default.
  56808. */
  56809. createGround: boolean;
  56810. /**
  56811. * Specifies the ground size.
  56812. * 15 by default.
  56813. */
  56814. groundSize: number;
  56815. /**
  56816. * The texture used on the ground for the main color.
  56817. * Comes from the BabylonJS CDN by default.
  56818. *
  56819. * Remarks: Can be either a texture or a url.
  56820. */
  56821. groundTexture: string | BaseTexture;
  56822. /**
  56823. * The color mixed in the ground texture by default.
  56824. * BabylonJS clearColor by default.
  56825. */
  56826. groundColor: Color3;
  56827. /**
  56828. * Specifies the ground opacity.
  56829. * 1 by default.
  56830. */
  56831. groundOpacity: number;
  56832. /**
  56833. * Enables the ground to receive shadows.
  56834. * True by default.
  56835. */
  56836. enableGroundShadow: boolean;
  56837. /**
  56838. * Helps preventing the shadow to be fully black on the ground.
  56839. * 0.5 by default.
  56840. */
  56841. groundShadowLevel: number;
  56842. /**
  56843. * Creates a mirror texture attach to the ground.
  56844. * false by default.
  56845. */
  56846. enableGroundMirror: boolean;
  56847. /**
  56848. * Specifies the ground mirror size ratio.
  56849. * 0.3 by default as the default kernel is 64.
  56850. */
  56851. groundMirrorSizeRatio: number;
  56852. /**
  56853. * Specifies the ground mirror blur kernel size.
  56854. * 64 by default.
  56855. */
  56856. groundMirrorBlurKernel: number;
  56857. /**
  56858. * Specifies the ground mirror visibility amount.
  56859. * 1 by default
  56860. */
  56861. groundMirrorAmount: number;
  56862. /**
  56863. * Specifies the ground mirror reflectance weight.
  56864. * This uses the standard weight of the background material to setup the fresnel effect
  56865. * of the mirror.
  56866. * 1 by default.
  56867. */
  56868. groundMirrorFresnelWeight: number;
  56869. /**
  56870. * Specifies the ground mirror Falloff distance.
  56871. * This can helps reducing the size of the reflection.
  56872. * 0 by Default.
  56873. */
  56874. groundMirrorFallOffDistance: number;
  56875. /**
  56876. * Specifies the ground mirror texture type.
  56877. * Unsigned Int by Default.
  56878. */
  56879. groundMirrorTextureType: number;
  56880. /**
  56881. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56882. * the shown objects.
  56883. */
  56884. groundYBias: number;
  56885. /**
  56886. * Specifies whether or not to create a skybox.
  56887. * True by default.
  56888. */
  56889. createSkybox: boolean;
  56890. /**
  56891. * Specifies the skybox size.
  56892. * 20 by default.
  56893. */
  56894. skyboxSize: number;
  56895. /**
  56896. * The texture used on the skybox for the main color.
  56897. * Comes from the BabylonJS CDN by default.
  56898. *
  56899. * Remarks: Can be either a texture or a url.
  56900. */
  56901. skyboxTexture: string | BaseTexture;
  56902. /**
  56903. * The color mixed in the skybox texture by default.
  56904. * BabylonJS clearColor by default.
  56905. */
  56906. skyboxColor: Color3;
  56907. /**
  56908. * The background rotation around the Y axis of the scene.
  56909. * This helps aligning the key lights of your scene with the background.
  56910. * 0 by default.
  56911. */
  56912. backgroundYRotation: number;
  56913. /**
  56914. * Compute automatically the size of the elements to best fit with the scene.
  56915. */
  56916. sizeAuto: boolean;
  56917. /**
  56918. * Default position of the rootMesh if autoSize is not true.
  56919. */
  56920. rootPosition: Vector3;
  56921. /**
  56922. * Sets up the image processing in the scene.
  56923. * true by default.
  56924. */
  56925. setupImageProcessing: boolean;
  56926. /**
  56927. * The texture used as your environment texture in the scene.
  56928. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56929. *
  56930. * Remarks: Can be either a texture or a url.
  56931. */
  56932. environmentTexture: string | BaseTexture;
  56933. /**
  56934. * The value of the exposure to apply to the scene.
  56935. * 0.6 by default if setupImageProcessing is true.
  56936. */
  56937. cameraExposure: number;
  56938. /**
  56939. * The value of the contrast to apply to the scene.
  56940. * 1.6 by default if setupImageProcessing is true.
  56941. */
  56942. cameraContrast: number;
  56943. /**
  56944. * Specifies whether or not tonemapping should be enabled in the scene.
  56945. * true by default if setupImageProcessing is true.
  56946. */
  56947. toneMappingEnabled: boolean;
  56948. }
  56949. /**
  56950. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56951. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56952. * It also helps with the default setup of your imageProcessing configuration.
  56953. */
  56954. export class EnvironmentHelper {
  56955. /**
  56956. * Default ground texture URL.
  56957. */
  56958. private static _groundTextureCDNUrl;
  56959. /**
  56960. * Default skybox texture URL.
  56961. */
  56962. private static _skyboxTextureCDNUrl;
  56963. /**
  56964. * Default environment texture URL.
  56965. */
  56966. private static _environmentTextureCDNUrl;
  56967. /**
  56968. * Creates the default options for the helper.
  56969. */
  56970. private static _getDefaultOptions;
  56971. private _rootMesh;
  56972. /**
  56973. * Gets the root mesh created by the helper.
  56974. */
  56975. get rootMesh(): Mesh;
  56976. private _skybox;
  56977. /**
  56978. * Gets the skybox created by the helper.
  56979. */
  56980. get skybox(): Nullable<Mesh>;
  56981. private _skyboxTexture;
  56982. /**
  56983. * Gets the skybox texture created by the helper.
  56984. */
  56985. get skyboxTexture(): Nullable<BaseTexture>;
  56986. private _skyboxMaterial;
  56987. /**
  56988. * Gets the skybox material created by the helper.
  56989. */
  56990. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56991. private _ground;
  56992. /**
  56993. * Gets the ground mesh created by the helper.
  56994. */
  56995. get ground(): Nullable<Mesh>;
  56996. private _groundTexture;
  56997. /**
  56998. * Gets the ground texture created by the helper.
  56999. */
  57000. get groundTexture(): Nullable<BaseTexture>;
  57001. private _groundMirror;
  57002. /**
  57003. * Gets the ground mirror created by the helper.
  57004. */
  57005. get groundMirror(): Nullable<MirrorTexture>;
  57006. /**
  57007. * Gets the ground mirror render list to helps pushing the meshes
  57008. * you wish in the ground reflection.
  57009. */
  57010. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57011. private _groundMaterial;
  57012. /**
  57013. * Gets the ground material created by the helper.
  57014. */
  57015. get groundMaterial(): Nullable<BackgroundMaterial>;
  57016. /**
  57017. * Stores the creation options.
  57018. */
  57019. private readonly _scene;
  57020. private _options;
  57021. /**
  57022. * This observable will be notified with any error during the creation of the environment,
  57023. * mainly texture creation errors.
  57024. */
  57025. onErrorObservable: Observable<{
  57026. message?: string;
  57027. exception?: any;
  57028. }>;
  57029. /**
  57030. * constructor
  57031. * @param options Defines the options we want to customize the helper
  57032. * @param scene The scene to add the material to
  57033. */
  57034. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57035. /**
  57036. * Updates the background according to the new options
  57037. * @param options
  57038. */
  57039. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57040. /**
  57041. * Sets the primary color of all the available elements.
  57042. * @param color the main color to affect to the ground and the background
  57043. */
  57044. setMainColor(color: Color3): void;
  57045. /**
  57046. * Setup the image processing according to the specified options.
  57047. */
  57048. private _setupImageProcessing;
  57049. /**
  57050. * Setup the environment texture according to the specified options.
  57051. */
  57052. private _setupEnvironmentTexture;
  57053. /**
  57054. * Setup the background according to the specified options.
  57055. */
  57056. private _setupBackground;
  57057. /**
  57058. * Get the scene sizes according to the setup.
  57059. */
  57060. private _getSceneSize;
  57061. /**
  57062. * Setup the ground according to the specified options.
  57063. */
  57064. private _setupGround;
  57065. /**
  57066. * Setup the ground material according to the specified options.
  57067. */
  57068. private _setupGroundMaterial;
  57069. /**
  57070. * Setup the ground diffuse texture according to the specified options.
  57071. */
  57072. private _setupGroundDiffuseTexture;
  57073. /**
  57074. * Setup the ground mirror texture according to the specified options.
  57075. */
  57076. private _setupGroundMirrorTexture;
  57077. /**
  57078. * Setup the ground to receive the mirror texture.
  57079. */
  57080. private _setupMirrorInGroundMaterial;
  57081. /**
  57082. * Setup the skybox according to the specified options.
  57083. */
  57084. private _setupSkybox;
  57085. /**
  57086. * Setup the skybox material according to the specified options.
  57087. */
  57088. private _setupSkyboxMaterial;
  57089. /**
  57090. * Setup the skybox reflection texture according to the specified options.
  57091. */
  57092. private _setupSkyboxReflectionTexture;
  57093. private _errorHandler;
  57094. /**
  57095. * Dispose all the elements created by the Helper.
  57096. */
  57097. dispose(): void;
  57098. }
  57099. }
  57100. declare module "babylonjs/Helpers/photoDome" {
  57101. import { Observable } from "babylonjs/Misc/observable";
  57102. import { Nullable } from "babylonjs/types";
  57103. import { Scene } from "babylonjs/scene";
  57104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57105. import { Mesh } from "babylonjs/Meshes/mesh";
  57106. import { Texture } from "babylonjs/Materials/Textures/texture";
  57107. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57108. import "babylonjs/Meshes/Builders/sphereBuilder";
  57109. /**
  57110. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57111. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57112. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57113. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57114. */
  57115. export class PhotoDome extends TransformNode {
  57116. /**
  57117. * Define the image as a Monoscopic panoramic 360 image.
  57118. */
  57119. static readonly MODE_MONOSCOPIC: number;
  57120. /**
  57121. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57122. */
  57123. static readonly MODE_TOPBOTTOM: number;
  57124. /**
  57125. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57126. */
  57127. static readonly MODE_SIDEBYSIDE: number;
  57128. private _useDirectMapping;
  57129. /**
  57130. * The texture being displayed on the sphere
  57131. */
  57132. protected _photoTexture: Texture;
  57133. /**
  57134. * Gets or sets the texture being displayed on the sphere
  57135. */
  57136. get photoTexture(): Texture;
  57137. set photoTexture(value: Texture);
  57138. /**
  57139. * Observable raised when an error occured while loading the 360 image
  57140. */
  57141. onLoadErrorObservable: Observable<string>;
  57142. /**
  57143. * The skybox material
  57144. */
  57145. protected _material: BackgroundMaterial;
  57146. /**
  57147. * The surface used for the skybox
  57148. */
  57149. protected _mesh: Mesh;
  57150. /**
  57151. * Gets the mesh used for the skybox.
  57152. */
  57153. get mesh(): Mesh;
  57154. /**
  57155. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57156. * Also see the options.resolution property.
  57157. */
  57158. get fovMultiplier(): number;
  57159. set fovMultiplier(value: number);
  57160. private _imageMode;
  57161. /**
  57162. * Gets or set the current video mode for the video. It can be:
  57163. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57164. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57165. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57166. */
  57167. get imageMode(): number;
  57168. set imageMode(value: number);
  57169. /**
  57170. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57171. * @param name Element's name, child elements will append suffixes for their own names.
  57172. * @param urlsOfPhoto defines the url of the photo to display
  57173. * @param options defines an object containing optional or exposed sub element properties
  57174. * @param onError defines a callback called when an error occured while loading the texture
  57175. */
  57176. constructor(name: string, urlOfPhoto: string, options: {
  57177. resolution?: number;
  57178. size?: number;
  57179. useDirectMapping?: boolean;
  57180. faceForward?: boolean;
  57181. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57182. private _onBeforeCameraRenderObserver;
  57183. private _changeImageMode;
  57184. /**
  57185. * Releases resources associated with this node.
  57186. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57187. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57188. */
  57189. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57190. }
  57191. }
  57192. declare module "babylonjs/Misc/rgbdTextureTools" {
  57193. import "babylonjs/Shaders/rgbdDecode.fragment";
  57194. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57195. import { Texture } from "babylonjs/Materials/Textures/texture";
  57196. /**
  57197. * Class used to host RGBD texture specific utilities
  57198. */
  57199. export class RGBDTextureTools {
  57200. /**
  57201. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57202. * @param texture the texture to expand.
  57203. */
  57204. static ExpandRGBDTexture(texture: Texture): void;
  57205. }
  57206. }
  57207. declare module "babylonjs/Misc/brdfTextureTools" {
  57208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57209. import { Scene } from "babylonjs/scene";
  57210. /**
  57211. * Class used to host texture specific utilities
  57212. */
  57213. export class BRDFTextureTools {
  57214. /**
  57215. * Prevents texture cache collision
  57216. */
  57217. private static _instanceNumber;
  57218. /**
  57219. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57220. * @param scene defines the hosting scene
  57221. * @returns the environment BRDF texture
  57222. */
  57223. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57224. private static _environmentBRDFBase64Texture;
  57225. }
  57226. }
  57227. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57228. import { Nullable } from "babylonjs/types";
  57229. import { Color3 } from "babylonjs/Maths/math.color";
  57230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57231. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57232. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57233. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57234. import { Engine } from "babylonjs/Engines/engine";
  57235. import { Scene } from "babylonjs/scene";
  57236. /**
  57237. * @hidden
  57238. */
  57239. export interface IMaterialClearCoatDefines {
  57240. CLEARCOAT: boolean;
  57241. CLEARCOAT_DEFAULTIOR: boolean;
  57242. CLEARCOAT_TEXTURE: boolean;
  57243. CLEARCOAT_TEXTUREDIRECTUV: number;
  57244. CLEARCOAT_BUMP: boolean;
  57245. CLEARCOAT_BUMPDIRECTUV: number;
  57246. CLEARCOAT_TINT: boolean;
  57247. CLEARCOAT_TINT_TEXTURE: boolean;
  57248. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57249. /** @hidden */
  57250. _areTexturesDirty: boolean;
  57251. }
  57252. /**
  57253. * Define the code related to the clear coat parameters of the pbr material.
  57254. */
  57255. export class PBRClearCoatConfiguration {
  57256. /**
  57257. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57258. * The default fits with a polyurethane material.
  57259. */
  57260. private static readonly _DefaultIndexOfRefraction;
  57261. private _isEnabled;
  57262. /**
  57263. * Defines if the clear coat is enabled in the material.
  57264. */
  57265. isEnabled: boolean;
  57266. /**
  57267. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57268. */
  57269. intensity: number;
  57270. /**
  57271. * Defines the clear coat layer roughness.
  57272. */
  57273. roughness: number;
  57274. private _indexOfRefraction;
  57275. /**
  57276. * Defines the index of refraction of the clear coat.
  57277. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57278. * The default fits with a polyurethane material.
  57279. * Changing the default value is more performance intensive.
  57280. */
  57281. indexOfRefraction: number;
  57282. private _texture;
  57283. /**
  57284. * Stores the clear coat values in a texture.
  57285. */
  57286. texture: Nullable<BaseTexture>;
  57287. private _bumpTexture;
  57288. /**
  57289. * Define the clear coat specific bump texture.
  57290. */
  57291. bumpTexture: Nullable<BaseTexture>;
  57292. private _isTintEnabled;
  57293. /**
  57294. * Defines if the clear coat tint is enabled in the material.
  57295. */
  57296. isTintEnabled: boolean;
  57297. /**
  57298. * Defines the clear coat tint of the material.
  57299. * This is only use if tint is enabled
  57300. */
  57301. tintColor: Color3;
  57302. /**
  57303. * Defines the distance at which the tint color should be found in the
  57304. * clear coat media.
  57305. * This is only use if tint is enabled
  57306. */
  57307. tintColorAtDistance: number;
  57308. /**
  57309. * Defines the clear coat layer thickness.
  57310. * This is only use if tint is enabled
  57311. */
  57312. tintThickness: number;
  57313. private _tintTexture;
  57314. /**
  57315. * Stores the clear tint values in a texture.
  57316. * rgb is tint
  57317. * a is a thickness factor
  57318. */
  57319. tintTexture: Nullable<BaseTexture>;
  57320. /** @hidden */
  57321. private _internalMarkAllSubMeshesAsTexturesDirty;
  57322. /** @hidden */
  57323. _markAllSubMeshesAsTexturesDirty(): void;
  57324. /**
  57325. * Instantiate a new istance of clear coat configuration.
  57326. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57327. */
  57328. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57329. /**
  57330. * Gets wehter the submesh is ready to be used or not.
  57331. * @param defines the list of "defines" to update.
  57332. * @param scene defines the scene the material belongs to.
  57333. * @param engine defines the engine the material belongs to.
  57334. * @param disableBumpMap defines wether the material disables bump or not.
  57335. * @returns - boolean indicating that the submesh is ready or not.
  57336. */
  57337. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57338. /**
  57339. * Checks to see if a texture is used in the material.
  57340. * @param defines the list of "defines" to update.
  57341. * @param scene defines the scene to the material belongs to.
  57342. */
  57343. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57344. /**
  57345. * Binds the material data.
  57346. * @param uniformBuffer defines the Uniform buffer to fill in.
  57347. * @param scene defines the scene the material belongs to.
  57348. * @param engine defines the engine the material belongs to.
  57349. * @param disableBumpMap defines wether the material disables bump or not.
  57350. * @param isFrozen defines wether the material is frozen or not.
  57351. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57352. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57353. */
  57354. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57355. /**
  57356. * Checks to see if a texture is used in the material.
  57357. * @param texture - Base texture to use.
  57358. * @returns - Boolean specifying if a texture is used in the material.
  57359. */
  57360. hasTexture(texture: BaseTexture): boolean;
  57361. /**
  57362. * Returns an array of the actively used textures.
  57363. * @param activeTextures Array of BaseTextures
  57364. */
  57365. getActiveTextures(activeTextures: BaseTexture[]): void;
  57366. /**
  57367. * Returns the animatable textures.
  57368. * @param animatables Array of animatable textures.
  57369. */
  57370. getAnimatables(animatables: IAnimatable[]): void;
  57371. /**
  57372. * Disposes the resources of the material.
  57373. * @param forceDisposeTextures - Forces the disposal of all textures.
  57374. */
  57375. dispose(forceDisposeTextures?: boolean): void;
  57376. /**
  57377. * Get the current class name of the texture useful for serialization or dynamic coding.
  57378. * @returns "PBRClearCoatConfiguration"
  57379. */
  57380. getClassName(): string;
  57381. /**
  57382. * Add fallbacks to the effect fallbacks list.
  57383. * @param defines defines the Base texture to use.
  57384. * @param fallbacks defines the current fallback list.
  57385. * @param currentRank defines the current fallback rank.
  57386. * @returns the new fallback rank.
  57387. */
  57388. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57389. /**
  57390. * Add the required uniforms to the current list.
  57391. * @param uniforms defines the current uniform list.
  57392. */
  57393. static AddUniforms(uniforms: string[]): void;
  57394. /**
  57395. * Add the required samplers to the current list.
  57396. * @param samplers defines the current sampler list.
  57397. */
  57398. static AddSamplers(samplers: string[]): void;
  57399. /**
  57400. * Add the required uniforms to the current buffer.
  57401. * @param uniformBuffer defines the current uniform buffer.
  57402. */
  57403. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57404. /**
  57405. * Makes a duplicate of the current configuration into another one.
  57406. * @param clearCoatConfiguration define the config where to copy the info
  57407. */
  57408. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57409. /**
  57410. * Serializes this clear coat configuration.
  57411. * @returns - An object with the serialized config.
  57412. */
  57413. serialize(): any;
  57414. /**
  57415. * Parses a anisotropy Configuration from a serialized object.
  57416. * @param source - Serialized object.
  57417. * @param scene Defines the scene we are parsing for
  57418. * @param rootUrl Defines the rootUrl to load from
  57419. */
  57420. parse(source: any, scene: Scene, rootUrl: string): void;
  57421. }
  57422. }
  57423. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57424. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57426. import { Vector2 } from "babylonjs/Maths/math.vector";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57429. import { Nullable } from "babylonjs/types";
  57430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57431. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57432. /**
  57433. * @hidden
  57434. */
  57435. export interface IMaterialAnisotropicDefines {
  57436. ANISOTROPIC: boolean;
  57437. ANISOTROPIC_TEXTURE: boolean;
  57438. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57439. MAINUV1: boolean;
  57440. _areTexturesDirty: boolean;
  57441. _needUVs: boolean;
  57442. }
  57443. /**
  57444. * Define the code related to the anisotropic parameters of the pbr material.
  57445. */
  57446. export class PBRAnisotropicConfiguration {
  57447. private _isEnabled;
  57448. /**
  57449. * Defines if the anisotropy is enabled in the material.
  57450. */
  57451. isEnabled: boolean;
  57452. /**
  57453. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57454. */
  57455. intensity: number;
  57456. /**
  57457. * Defines if the effect is along the tangents, bitangents or in between.
  57458. * By default, the effect is "strectching" the highlights along the tangents.
  57459. */
  57460. direction: Vector2;
  57461. private _texture;
  57462. /**
  57463. * Stores the anisotropy values in a texture.
  57464. * rg is direction (like normal from -1 to 1)
  57465. * b is a intensity
  57466. */
  57467. texture: Nullable<BaseTexture>;
  57468. /** @hidden */
  57469. private _internalMarkAllSubMeshesAsTexturesDirty;
  57470. /** @hidden */
  57471. _markAllSubMeshesAsTexturesDirty(): void;
  57472. /**
  57473. * Instantiate a new istance of anisotropy configuration.
  57474. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57475. */
  57476. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57477. /**
  57478. * Specifies that the submesh is ready to be used.
  57479. * @param defines the list of "defines" to update.
  57480. * @param scene defines the scene the material belongs to.
  57481. * @returns - boolean indicating that the submesh is ready or not.
  57482. */
  57483. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57484. /**
  57485. * Checks to see if a texture is used in the material.
  57486. * @param defines the list of "defines" to update.
  57487. * @param mesh the mesh we are preparing the defines for.
  57488. * @param scene defines the scene the material belongs to.
  57489. */
  57490. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57491. /**
  57492. * Binds the material data.
  57493. * @param uniformBuffer defines the Uniform buffer to fill in.
  57494. * @param scene defines the scene the material belongs to.
  57495. * @param isFrozen defines wether the material is frozen or not.
  57496. */
  57497. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57498. /**
  57499. * Checks to see if a texture is used in the material.
  57500. * @param texture - Base texture to use.
  57501. * @returns - Boolean specifying if a texture is used in the material.
  57502. */
  57503. hasTexture(texture: BaseTexture): boolean;
  57504. /**
  57505. * Returns an array of the actively used textures.
  57506. * @param activeTextures Array of BaseTextures
  57507. */
  57508. getActiveTextures(activeTextures: BaseTexture[]): void;
  57509. /**
  57510. * Returns the animatable textures.
  57511. * @param animatables Array of animatable textures.
  57512. */
  57513. getAnimatables(animatables: IAnimatable[]): void;
  57514. /**
  57515. * Disposes the resources of the material.
  57516. * @param forceDisposeTextures - Forces the disposal of all textures.
  57517. */
  57518. dispose(forceDisposeTextures?: boolean): void;
  57519. /**
  57520. * Get the current class name of the texture useful for serialization or dynamic coding.
  57521. * @returns "PBRAnisotropicConfiguration"
  57522. */
  57523. getClassName(): string;
  57524. /**
  57525. * Add fallbacks to the effect fallbacks list.
  57526. * @param defines defines the Base texture to use.
  57527. * @param fallbacks defines the current fallback list.
  57528. * @param currentRank defines the current fallback rank.
  57529. * @returns the new fallback rank.
  57530. */
  57531. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57532. /**
  57533. * Add the required uniforms to the current list.
  57534. * @param uniforms defines the current uniform list.
  57535. */
  57536. static AddUniforms(uniforms: string[]): void;
  57537. /**
  57538. * Add the required uniforms to the current buffer.
  57539. * @param uniformBuffer defines the current uniform buffer.
  57540. */
  57541. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57542. /**
  57543. * Add the required samplers to the current list.
  57544. * @param samplers defines the current sampler list.
  57545. */
  57546. static AddSamplers(samplers: string[]): void;
  57547. /**
  57548. * Makes a duplicate of the current configuration into another one.
  57549. * @param anisotropicConfiguration define the config where to copy the info
  57550. */
  57551. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57552. /**
  57553. * Serializes this anisotropy configuration.
  57554. * @returns - An object with the serialized config.
  57555. */
  57556. serialize(): any;
  57557. /**
  57558. * Parses a anisotropy Configuration from a serialized object.
  57559. * @param source - Serialized object.
  57560. * @param scene Defines the scene we are parsing for
  57561. * @param rootUrl Defines the rootUrl to load from
  57562. */
  57563. parse(source: any, scene: Scene, rootUrl: string): void;
  57564. }
  57565. }
  57566. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57567. import { Scene } from "babylonjs/scene";
  57568. /**
  57569. * @hidden
  57570. */
  57571. export interface IMaterialBRDFDefines {
  57572. BRDF_V_HEIGHT_CORRELATED: boolean;
  57573. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57574. SPHERICAL_HARMONICS: boolean;
  57575. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57576. /** @hidden */
  57577. _areMiscDirty: boolean;
  57578. }
  57579. /**
  57580. * Define the code related to the BRDF parameters of the pbr material.
  57581. */
  57582. export class PBRBRDFConfiguration {
  57583. /**
  57584. * Default value used for the energy conservation.
  57585. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57586. */
  57587. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57588. /**
  57589. * Default value used for the Smith Visibility Height Correlated mode.
  57590. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57591. */
  57592. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57593. /**
  57594. * Default value used for the IBL diffuse part.
  57595. * This can help switching back to the polynomials mode globally which is a tiny bit
  57596. * less GPU intensive at the drawback of a lower quality.
  57597. */
  57598. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57599. /**
  57600. * Default value used for activating energy conservation for the specular workflow.
  57601. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57602. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57603. */
  57604. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57605. private _useEnergyConservation;
  57606. /**
  57607. * Defines if the material uses energy conservation.
  57608. */
  57609. useEnergyConservation: boolean;
  57610. private _useSmithVisibilityHeightCorrelated;
  57611. /**
  57612. * LEGACY Mode set to false
  57613. * Defines if the material uses height smith correlated visibility term.
  57614. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57615. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57616. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57617. * Not relying on height correlated will also disable energy conservation.
  57618. */
  57619. useSmithVisibilityHeightCorrelated: boolean;
  57620. private _useSphericalHarmonics;
  57621. /**
  57622. * LEGACY Mode set to false
  57623. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57624. * diffuse part of the IBL.
  57625. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57626. * to the ground truth.
  57627. */
  57628. useSphericalHarmonics: boolean;
  57629. private _useSpecularGlossinessInputEnergyConservation;
  57630. /**
  57631. * Defines if the material uses energy conservation, when the specular workflow is active.
  57632. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57633. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57634. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57635. */
  57636. useSpecularGlossinessInputEnergyConservation: boolean;
  57637. /** @hidden */
  57638. private _internalMarkAllSubMeshesAsMiscDirty;
  57639. /** @hidden */
  57640. _markAllSubMeshesAsMiscDirty(): void;
  57641. /**
  57642. * Instantiate a new istance of clear coat configuration.
  57643. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57644. */
  57645. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57646. /**
  57647. * Checks to see if a texture is used in the material.
  57648. * @param defines the list of "defines" to update.
  57649. */
  57650. prepareDefines(defines: IMaterialBRDFDefines): void;
  57651. /**
  57652. * Get the current class name of the texture useful for serialization or dynamic coding.
  57653. * @returns "PBRClearCoatConfiguration"
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Makes a duplicate of the current configuration into another one.
  57658. * @param brdfConfiguration define the config where to copy the info
  57659. */
  57660. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57661. /**
  57662. * Serializes this BRDF configuration.
  57663. * @returns - An object with the serialized config.
  57664. */
  57665. serialize(): any;
  57666. /**
  57667. * Parses a anisotropy Configuration from a serialized object.
  57668. * @param source - Serialized object.
  57669. * @param scene Defines the scene we are parsing for
  57670. * @param rootUrl Defines the rootUrl to load from
  57671. */
  57672. parse(source: any, scene: Scene, rootUrl: string): void;
  57673. }
  57674. }
  57675. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57676. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57677. import { Color3 } from "babylonjs/Maths/math.color";
  57678. import { Scene } from "babylonjs/scene";
  57679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57680. import { Nullable } from "babylonjs/types";
  57681. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57682. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57683. /**
  57684. * @hidden
  57685. */
  57686. export interface IMaterialSheenDefines {
  57687. SHEEN: boolean;
  57688. SHEEN_TEXTURE: boolean;
  57689. SHEEN_TEXTUREDIRECTUV: number;
  57690. SHEEN_LINKWITHALBEDO: boolean;
  57691. SHEEN_ROUGHNESS: boolean;
  57692. SHEEN_ALBEDOSCALING: boolean;
  57693. /** @hidden */
  57694. _areTexturesDirty: boolean;
  57695. }
  57696. /**
  57697. * Define the code related to the Sheen parameters of the pbr material.
  57698. */
  57699. export class PBRSheenConfiguration {
  57700. private _isEnabled;
  57701. /**
  57702. * Defines if the material uses sheen.
  57703. */
  57704. isEnabled: boolean;
  57705. private _linkSheenWithAlbedo;
  57706. /**
  57707. * Defines if the sheen is linked to the sheen color.
  57708. */
  57709. linkSheenWithAlbedo: boolean;
  57710. /**
  57711. * Defines the sheen intensity.
  57712. */
  57713. intensity: number;
  57714. /**
  57715. * Defines the sheen color.
  57716. */
  57717. color: Color3;
  57718. private _texture;
  57719. /**
  57720. * Stores the sheen tint values in a texture.
  57721. * rgb is tint
  57722. * a is a intensity or roughness if roughness has been defined
  57723. */
  57724. texture: Nullable<BaseTexture>;
  57725. private _roughness;
  57726. /**
  57727. * Defines the sheen roughness.
  57728. * It is not taken into account if linkSheenWithAlbedo is true.
  57729. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57730. */
  57731. roughness: Nullable<number>;
  57732. private _albedoScaling;
  57733. /**
  57734. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57735. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57736. * making it easier to setup and tweak the effect
  57737. */
  57738. albedoScaling: boolean;
  57739. /** @hidden */
  57740. private _internalMarkAllSubMeshesAsTexturesDirty;
  57741. /** @hidden */
  57742. _markAllSubMeshesAsTexturesDirty(): void;
  57743. /**
  57744. * Instantiate a new istance of clear coat configuration.
  57745. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57746. */
  57747. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57748. /**
  57749. * Specifies that the submesh is ready to be used.
  57750. * @param defines the list of "defines" to update.
  57751. * @param scene defines the scene the material belongs to.
  57752. * @returns - boolean indicating that the submesh is ready or not.
  57753. */
  57754. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57755. /**
  57756. * Checks to see if a texture is used in the material.
  57757. * @param defines the list of "defines" to update.
  57758. * @param scene defines the scene the material belongs to.
  57759. */
  57760. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57761. /**
  57762. * Binds the material data.
  57763. * @param uniformBuffer defines the Uniform buffer to fill in.
  57764. * @param scene defines the scene the material belongs to.
  57765. * @param isFrozen defines wether the material is frozen or not.
  57766. */
  57767. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57768. /**
  57769. * Checks to see if a texture is used in the material.
  57770. * @param texture - Base texture to use.
  57771. * @returns - Boolean specifying if a texture is used in the material.
  57772. */
  57773. hasTexture(texture: BaseTexture): boolean;
  57774. /**
  57775. * Returns an array of the actively used textures.
  57776. * @param activeTextures Array of BaseTextures
  57777. */
  57778. getActiveTextures(activeTextures: BaseTexture[]): void;
  57779. /**
  57780. * Returns the animatable textures.
  57781. * @param animatables Array of animatable textures.
  57782. */
  57783. getAnimatables(animatables: IAnimatable[]): void;
  57784. /**
  57785. * Disposes the resources of the material.
  57786. * @param forceDisposeTextures - Forces the disposal of all textures.
  57787. */
  57788. dispose(forceDisposeTextures?: boolean): void;
  57789. /**
  57790. * Get the current class name of the texture useful for serialization or dynamic coding.
  57791. * @returns "PBRSheenConfiguration"
  57792. */
  57793. getClassName(): string;
  57794. /**
  57795. * Add fallbacks to the effect fallbacks list.
  57796. * @param defines defines the Base texture to use.
  57797. * @param fallbacks defines the current fallback list.
  57798. * @param currentRank defines the current fallback rank.
  57799. * @returns the new fallback rank.
  57800. */
  57801. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57802. /**
  57803. * Add the required uniforms to the current list.
  57804. * @param uniforms defines the current uniform list.
  57805. */
  57806. static AddUniforms(uniforms: string[]): void;
  57807. /**
  57808. * Add the required uniforms to the current buffer.
  57809. * @param uniformBuffer defines the current uniform buffer.
  57810. */
  57811. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57812. /**
  57813. * Add the required samplers to the current list.
  57814. * @param samplers defines the current sampler list.
  57815. */
  57816. static AddSamplers(samplers: string[]): void;
  57817. /**
  57818. * Makes a duplicate of the current configuration into another one.
  57819. * @param sheenConfiguration define the config where to copy the info
  57820. */
  57821. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57822. /**
  57823. * Serializes this BRDF configuration.
  57824. * @returns - An object with the serialized config.
  57825. */
  57826. serialize(): any;
  57827. /**
  57828. * Parses a anisotropy Configuration from a serialized object.
  57829. * @param source - Serialized object.
  57830. * @param scene Defines the scene we are parsing for
  57831. * @param rootUrl Defines the rootUrl to load from
  57832. */
  57833. parse(source: any, scene: Scene, rootUrl: string): void;
  57834. }
  57835. }
  57836. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57837. import { Nullable } from "babylonjs/types";
  57838. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57839. import { Color3 } from "babylonjs/Maths/math.color";
  57840. import { SmartArray } from "babylonjs/Misc/smartArray";
  57841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57843. import { Effect } from "babylonjs/Materials/effect";
  57844. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57845. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57846. import { Engine } from "babylonjs/Engines/engine";
  57847. import { Scene } from "babylonjs/scene";
  57848. /**
  57849. * @hidden
  57850. */
  57851. export interface IMaterialSubSurfaceDefines {
  57852. SUBSURFACE: boolean;
  57853. SS_REFRACTION: boolean;
  57854. SS_TRANSLUCENCY: boolean;
  57855. SS_SCATTERING: boolean;
  57856. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57857. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57858. SS_REFRACTIONMAP_3D: boolean;
  57859. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57860. SS_LODINREFRACTIONALPHA: boolean;
  57861. SS_GAMMAREFRACTION: boolean;
  57862. SS_RGBDREFRACTION: boolean;
  57863. SS_LINEARSPECULARREFRACTION: boolean;
  57864. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57865. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57866. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57867. /** @hidden */
  57868. _areTexturesDirty: boolean;
  57869. }
  57870. /**
  57871. * Define the code related to the sub surface parameters of the pbr material.
  57872. */
  57873. export class PBRSubSurfaceConfiguration {
  57874. private _isRefractionEnabled;
  57875. /**
  57876. * Defines if the refraction is enabled in the material.
  57877. */
  57878. isRefractionEnabled: boolean;
  57879. private _isTranslucencyEnabled;
  57880. /**
  57881. * Defines if the translucency is enabled in the material.
  57882. */
  57883. isTranslucencyEnabled: boolean;
  57884. private _isScatteringEnabled;
  57885. /**
  57886. * Defines if the sub surface scattering is enabled in the material.
  57887. */
  57888. isScatteringEnabled: boolean;
  57889. private _scatteringDiffusionProfileIndex;
  57890. /**
  57891. * Diffusion profile for subsurface scattering.
  57892. * Useful for better scattering in the skins or foliages.
  57893. */
  57894. get scatteringDiffusionProfile(): Nullable<Color3>;
  57895. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57896. /**
  57897. * Defines the refraction intensity of the material.
  57898. * The refraction when enabled replaces the Diffuse part of the material.
  57899. * The intensity helps transitionning between diffuse and refraction.
  57900. */
  57901. refractionIntensity: number;
  57902. /**
  57903. * Defines the translucency intensity of the material.
  57904. * When translucency has been enabled, this defines how much of the "translucency"
  57905. * is addded to the diffuse part of the material.
  57906. */
  57907. translucencyIntensity: number;
  57908. /**
  57909. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57910. */
  57911. useAlbedoToTintRefraction: boolean;
  57912. private _thicknessTexture;
  57913. /**
  57914. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57915. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57916. * 0 would mean minimumThickness
  57917. * 1 would mean maximumThickness
  57918. * The other channels might be use as a mask to vary the different effects intensity.
  57919. */
  57920. thicknessTexture: Nullable<BaseTexture>;
  57921. private _refractionTexture;
  57922. /**
  57923. * Defines the texture to use for refraction.
  57924. */
  57925. refractionTexture: Nullable<BaseTexture>;
  57926. private _indexOfRefraction;
  57927. /**
  57928. * Index of refraction of the material base layer.
  57929. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57930. *
  57931. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57932. *
  57933. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57934. */
  57935. indexOfRefraction: number;
  57936. private _volumeIndexOfRefraction;
  57937. /**
  57938. * Index of refraction of the material's volume.
  57939. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57940. *
  57941. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57942. * the volume will use the same IOR as the surface.
  57943. */
  57944. get volumeIndexOfRefraction(): number;
  57945. set volumeIndexOfRefraction(value: number);
  57946. private _invertRefractionY;
  57947. /**
  57948. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57949. */
  57950. invertRefractionY: boolean;
  57951. private _linkRefractionWithTransparency;
  57952. /**
  57953. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57954. * Materials half opaque for instance using refraction could benefit from this control.
  57955. */
  57956. linkRefractionWithTransparency: boolean;
  57957. /**
  57958. * Defines the minimum thickness stored in the thickness map.
  57959. * If no thickness map is defined, this value will be used to simulate thickness.
  57960. */
  57961. minimumThickness: number;
  57962. /**
  57963. * Defines the maximum thickness stored in the thickness map.
  57964. */
  57965. maximumThickness: number;
  57966. /**
  57967. * Defines the volume tint of the material.
  57968. * This is used for both translucency and scattering.
  57969. */
  57970. tintColor: Color3;
  57971. /**
  57972. * Defines the distance at which the tint color should be found in the media.
  57973. * This is used for refraction only.
  57974. */
  57975. tintColorAtDistance: number;
  57976. /**
  57977. * Defines how far each channel transmit through the media.
  57978. * It is defined as a color to simplify it selection.
  57979. */
  57980. diffusionDistance: Color3;
  57981. private _useMaskFromThicknessTexture;
  57982. /**
  57983. * Stores the intensity of the different subsurface effects in the thickness texture.
  57984. * * the green channel is the translucency intensity.
  57985. * * the blue channel is the scattering intensity.
  57986. * * the alpha channel is the refraction intensity.
  57987. */
  57988. useMaskFromThicknessTexture: boolean;
  57989. private _scene;
  57990. /** @hidden */
  57991. private _internalMarkAllSubMeshesAsTexturesDirty;
  57992. private _internalMarkScenePrePassDirty;
  57993. /** @hidden */
  57994. _markAllSubMeshesAsTexturesDirty(): void;
  57995. /** @hidden */
  57996. _markScenePrePassDirty(): void;
  57997. /**
  57998. * Instantiate a new istance of sub surface configuration.
  57999. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58000. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58001. * @param scene The scene
  58002. */
  58003. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58004. /**
  58005. * Gets wehter the submesh is ready to be used or not.
  58006. * @param defines the list of "defines" to update.
  58007. * @param scene defines the scene the material belongs to.
  58008. * @returns - boolean indicating that the submesh is ready or not.
  58009. */
  58010. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58011. /**
  58012. * Checks to see if a texture is used in the material.
  58013. * @param defines the list of "defines" to update.
  58014. * @param scene defines the scene to the material belongs to.
  58015. */
  58016. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58017. /**
  58018. * Binds the material data.
  58019. * @param uniformBuffer defines the Uniform buffer to fill in.
  58020. * @param scene defines the scene the material belongs to.
  58021. * @param engine defines the engine the material belongs to.
  58022. * @param isFrozen defines whether the material is frozen or not.
  58023. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58024. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58025. */
  58026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58027. /**
  58028. * Unbinds the material from the mesh.
  58029. * @param activeEffect defines the effect that should be unbound from.
  58030. * @returns true if unbound, otherwise false
  58031. */
  58032. unbind(activeEffect: Effect): boolean;
  58033. /**
  58034. * Returns the texture used for refraction or null if none is used.
  58035. * @param scene defines the scene the material belongs to.
  58036. * @returns - Refraction texture if present. If no refraction texture and refraction
  58037. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58038. */
  58039. private _getRefractionTexture;
  58040. /**
  58041. * Returns true if alpha blending should be disabled.
  58042. */
  58043. get disableAlphaBlending(): boolean;
  58044. /**
  58045. * Fills the list of render target textures.
  58046. * @param renderTargets the list of render targets to update
  58047. */
  58048. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58049. /**
  58050. * Checks to see if a texture is used in the material.
  58051. * @param texture - Base texture to use.
  58052. * @returns - Boolean specifying if a texture is used in the material.
  58053. */
  58054. hasTexture(texture: BaseTexture): boolean;
  58055. /**
  58056. * Gets a boolean indicating that current material needs to register RTT
  58057. * @returns true if this uses a render target otherwise false.
  58058. */
  58059. hasRenderTargetTextures(): boolean;
  58060. /**
  58061. * Returns an array of the actively used textures.
  58062. * @param activeTextures Array of BaseTextures
  58063. */
  58064. getActiveTextures(activeTextures: BaseTexture[]): void;
  58065. /**
  58066. * Returns the animatable textures.
  58067. * @param animatables Array of animatable textures.
  58068. */
  58069. getAnimatables(animatables: IAnimatable[]): void;
  58070. /**
  58071. * Disposes the resources of the material.
  58072. * @param forceDisposeTextures - Forces the disposal of all textures.
  58073. */
  58074. dispose(forceDisposeTextures?: boolean): void;
  58075. /**
  58076. * Get the current class name of the texture useful for serialization or dynamic coding.
  58077. * @returns "PBRSubSurfaceConfiguration"
  58078. */
  58079. getClassName(): string;
  58080. /**
  58081. * Add fallbacks to the effect fallbacks list.
  58082. * @param defines defines the Base texture to use.
  58083. * @param fallbacks defines the current fallback list.
  58084. * @param currentRank defines the current fallback rank.
  58085. * @returns the new fallback rank.
  58086. */
  58087. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58088. /**
  58089. * Add the required uniforms to the current list.
  58090. * @param uniforms defines the current uniform list.
  58091. */
  58092. static AddUniforms(uniforms: string[]): void;
  58093. /**
  58094. * Add the required samplers to the current list.
  58095. * @param samplers defines the current sampler list.
  58096. */
  58097. static AddSamplers(samplers: string[]): void;
  58098. /**
  58099. * Add the required uniforms to the current buffer.
  58100. * @param uniformBuffer defines the current uniform buffer.
  58101. */
  58102. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58103. /**
  58104. * Makes a duplicate of the current configuration into another one.
  58105. * @param configuration define the config where to copy the info
  58106. */
  58107. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58108. /**
  58109. * Serializes this Sub Surface configuration.
  58110. * @returns - An object with the serialized config.
  58111. */
  58112. serialize(): any;
  58113. /**
  58114. * Parses a anisotropy Configuration from a serialized object.
  58115. * @param source - Serialized object.
  58116. * @param scene Defines the scene we are parsing for
  58117. * @param rootUrl Defines the rootUrl to load from
  58118. */
  58119. parse(source: any, scene: Scene, rootUrl: string): void;
  58120. }
  58121. }
  58122. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58123. /** @hidden */
  58124. export var pbrFragmentDeclaration: {
  58125. name: string;
  58126. shader: string;
  58127. };
  58128. }
  58129. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58130. /** @hidden */
  58131. export var pbrUboDeclaration: {
  58132. name: string;
  58133. shader: string;
  58134. };
  58135. }
  58136. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58137. /** @hidden */
  58138. export var pbrFragmentExtraDeclaration: {
  58139. name: string;
  58140. shader: string;
  58141. };
  58142. }
  58143. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58144. /** @hidden */
  58145. export var pbrFragmentSamplersDeclaration: {
  58146. name: string;
  58147. shader: string;
  58148. };
  58149. }
  58150. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58151. /** @hidden */
  58152. export var importanceSampling: {
  58153. name: string;
  58154. shader: string;
  58155. };
  58156. }
  58157. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58158. /** @hidden */
  58159. export var pbrHelperFunctions: {
  58160. name: string;
  58161. shader: string;
  58162. };
  58163. }
  58164. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58165. /** @hidden */
  58166. export var harmonicsFunctions: {
  58167. name: string;
  58168. shader: string;
  58169. };
  58170. }
  58171. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58172. /** @hidden */
  58173. export var pbrDirectLightingSetupFunctions: {
  58174. name: string;
  58175. shader: string;
  58176. };
  58177. }
  58178. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58179. /** @hidden */
  58180. export var pbrDirectLightingFalloffFunctions: {
  58181. name: string;
  58182. shader: string;
  58183. };
  58184. }
  58185. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58186. /** @hidden */
  58187. export var pbrBRDFFunctions: {
  58188. name: string;
  58189. shader: string;
  58190. };
  58191. }
  58192. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58193. /** @hidden */
  58194. export var hdrFilteringFunctions: {
  58195. name: string;
  58196. shader: string;
  58197. };
  58198. }
  58199. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58200. /** @hidden */
  58201. export var pbrDirectLightingFunctions: {
  58202. name: string;
  58203. shader: string;
  58204. };
  58205. }
  58206. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58207. /** @hidden */
  58208. export var pbrIBLFunctions: {
  58209. name: string;
  58210. shader: string;
  58211. };
  58212. }
  58213. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58214. /** @hidden */
  58215. export var pbrBlockAlbedoOpacity: {
  58216. name: string;
  58217. shader: string;
  58218. };
  58219. }
  58220. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58221. /** @hidden */
  58222. export var pbrBlockReflectivity: {
  58223. name: string;
  58224. shader: string;
  58225. };
  58226. }
  58227. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58228. /** @hidden */
  58229. export var pbrBlockAmbientOcclusion: {
  58230. name: string;
  58231. shader: string;
  58232. };
  58233. }
  58234. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58235. /** @hidden */
  58236. export var pbrBlockAlphaFresnel: {
  58237. name: string;
  58238. shader: string;
  58239. };
  58240. }
  58241. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58242. /** @hidden */
  58243. export var pbrBlockAnisotropic: {
  58244. name: string;
  58245. shader: string;
  58246. };
  58247. }
  58248. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58249. /** @hidden */
  58250. export var pbrBlockReflection: {
  58251. name: string;
  58252. shader: string;
  58253. };
  58254. }
  58255. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58256. /** @hidden */
  58257. export var pbrBlockSheen: {
  58258. name: string;
  58259. shader: string;
  58260. };
  58261. }
  58262. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58263. /** @hidden */
  58264. export var pbrBlockClearcoat: {
  58265. name: string;
  58266. shader: string;
  58267. };
  58268. }
  58269. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58270. /** @hidden */
  58271. export var pbrBlockSubSurface: {
  58272. name: string;
  58273. shader: string;
  58274. };
  58275. }
  58276. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58277. /** @hidden */
  58278. export var pbrBlockNormalGeometric: {
  58279. name: string;
  58280. shader: string;
  58281. };
  58282. }
  58283. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58284. /** @hidden */
  58285. export var pbrBlockNormalFinal: {
  58286. name: string;
  58287. shader: string;
  58288. };
  58289. }
  58290. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58291. /** @hidden */
  58292. export var pbrBlockLightmapInit: {
  58293. name: string;
  58294. shader: string;
  58295. };
  58296. }
  58297. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58298. /** @hidden */
  58299. export var pbrBlockGeometryInfo: {
  58300. name: string;
  58301. shader: string;
  58302. };
  58303. }
  58304. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58305. /** @hidden */
  58306. export var pbrBlockReflectance0: {
  58307. name: string;
  58308. shader: string;
  58309. };
  58310. }
  58311. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58312. /** @hidden */
  58313. export var pbrBlockReflectance: {
  58314. name: string;
  58315. shader: string;
  58316. };
  58317. }
  58318. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58319. /** @hidden */
  58320. export var pbrBlockDirectLighting: {
  58321. name: string;
  58322. shader: string;
  58323. };
  58324. }
  58325. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58326. /** @hidden */
  58327. export var pbrBlockFinalLitComponents: {
  58328. name: string;
  58329. shader: string;
  58330. };
  58331. }
  58332. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58333. /** @hidden */
  58334. export var pbrBlockFinalUnlitComponents: {
  58335. name: string;
  58336. shader: string;
  58337. };
  58338. }
  58339. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58340. /** @hidden */
  58341. export var pbrBlockFinalColorComposition: {
  58342. name: string;
  58343. shader: string;
  58344. };
  58345. }
  58346. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58347. /** @hidden */
  58348. export var pbrBlockImageProcessing: {
  58349. name: string;
  58350. shader: string;
  58351. };
  58352. }
  58353. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58354. /** @hidden */
  58355. export var pbrDebug: {
  58356. name: string;
  58357. shader: string;
  58358. };
  58359. }
  58360. declare module "babylonjs/Shaders/pbr.fragment" {
  58361. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58362. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58363. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58364. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58365. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58366. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58367. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58368. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58369. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58370. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58371. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58372. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58373. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58374. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58375. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58376. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58377. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58378. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58379. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58380. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58381. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58382. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58383. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58384. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58385. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58386. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58387. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58388. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58389. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58390. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58391. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58392. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58393. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58394. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58395. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58396. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58397. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58398. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58399. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58400. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58401. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58402. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58403. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58404. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58405. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58406. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58407. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58408. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58409. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58410. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58411. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58412. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58413. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58414. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58415. /** @hidden */
  58416. export var pbrPixelShader: {
  58417. name: string;
  58418. shader: string;
  58419. };
  58420. }
  58421. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58422. /** @hidden */
  58423. export var pbrVertexDeclaration: {
  58424. name: string;
  58425. shader: string;
  58426. };
  58427. }
  58428. declare module "babylonjs/Shaders/pbr.vertex" {
  58429. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58430. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58431. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58432. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58433. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58434. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58435. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58436. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58437. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58438. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58439. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58441. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58442. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58444. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58445. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58446. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58447. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58448. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58449. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58450. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58451. /** @hidden */
  58452. export var pbrVertexShader: {
  58453. name: string;
  58454. shader: string;
  58455. };
  58456. }
  58457. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58458. import { Nullable } from "babylonjs/types";
  58459. import { Scene } from "babylonjs/scene";
  58460. import { Matrix } from "babylonjs/Maths/math.vector";
  58461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58463. import { Mesh } from "babylonjs/Meshes/mesh";
  58464. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58465. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58466. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58467. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58468. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58469. import { Color3 } from "babylonjs/Maths/math.color";
  58470. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58471. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58476. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58477. import "babylonjs/Shaders/pbr.fragment";
  58478. import "babylonjs/Shaders/pbr.vertex";
  58479. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58480. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58481. /**
  58482. * Manages the defines for the PBR Material.
  58483. * @hidden
  58484. */
  58485. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58486. PBR: boolean;
  58487. NUM_SAMPLES: string;
  58488. REALTIME_FILTERING: boolean;
  58489. MAINUV1: boolean;
  58490. MAINUV2: boolean;
  58491. UV1: boolean;
  58492. UV2: boolean;
  58493. ALBEDO: boolean;
  58494. GAMMAALBEDO: boolean;
  58495. ALBEDODIRECTUV: number;
  58496. VERTEXCOLOR: boolean;
  58497. DETAIL: boolean;
  58498. DETAILDIRECTUV: number;
  58499. DETAIL_NORMALBLENDMETHOD: number;
  58500. AMBIENT: boolean;
  58501. AMBIENTDIRECTUV: number;
  58502. AMBIENTINGRAYSCALE: boolean;
  58503. OPACITY: boolean;
  58504. VERTEXALPHA: boolean;
  58505. OPACITYDIRECTUV: number;
  58506. OPACITYRGB: boolean;
  58507. ALPHATEST: boolean;
  58508. DEPTHPREPASS: boolean;
  58509. ALPHABLEND: boolean;
  58510. ALPHAFROMALBEDO: boolean;
  58511. ALPHATESTVALUE: string;
  58512. SPECULAROVERALPHA: boolean;
  58513. RADIANCEOVERALPHA: boolean;
  58514. ALPHAFRESNEL: boolean;
  58515. LINEARALPHAFRESNEL: boolean;
  58516. PREMULTIPLYALPHA: boolean;
  58517. EMISSIVE: boolean;
  58518. EMISSIVEDIRECTUV: number;
  58519. REFLECTIVITY: boolean;
  58520. REFLECTIVITYDIRECTUV: number;
  58521. SPECULARTERM: boolean;
  58522. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58523. MICROSURFACEAUTOMATIC: boolean;
  58524. LODBASEDMICROSFURACE: boolean;
  58525. MICROSURFACEMAP: boolean;
  58526. MICROSURFACEMAPDIRECTUV: number;
  58527. METALLICWORKFLOW: boolean;
  58528. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58529. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58530. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58531. AOSTOREINMETALMAPRED: boolean;
  58532. METALLIC_REFLECTANCE: boolean;
  58533. METALLIC_REFLECTANCEDIRECTUV: number;
  58534. ENVIRONMENTBRDF: boolean;
  58535. ENVIRONMENTBRDF_RGBD: boolean;
  58536. NORMAL: boolean;
  58537. TANGENT: boolean;
  58538. BUMP: boolean;
  58539. BUMPDIRECTUV: number;
  58540. OBJECTSPACE_NORMALMAP: boolean;
  58541. PARALLAX: boolean;
  58542. PARALLAXOCCLUSION: boolean;
  58543. NORMALXYSCALE: boolean;
  58544. LIGHTMAP: boolean;
  58545. LIGHTMAPDIRECTUV: number;
  58546. USELIGHTMAPASSHADOWMAP: boolean;
  58547. GAMMALIGHTMAP: boolean;
  58548. RGBDLIGHTMAP: boolean;
  58549. REFLECTION: boolean;
  58550. REFLECTIONMAP_3D: boolean;
  58551. REFLECTIONMAP_SPHERICAL: boolean;
  58552. REFLECTIONMAP_PLANAR: boolean;
  58553. REFLECTIONMAP_CUBIC: boolean;
  58554. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58555. REFLECTIONMAP_PROJECTION: boolean;
  58556. REFLECTIONMAP_SKYBOX: boolean;
  58557. REFLECTIONMAP_EXPLICIT: boolean;
  58558. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58559. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58560. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58561. INVERTCUBICMAP: boolean;
  58562. USESPHERICALFROMREFLECTIONMAP: boolean;
  58563. USEIRRADIANCEMAP: boolean;
  58564. SPHERICAL_HARMONICS: boolean;
  58565. USESPHERICALINVERTEX: boolean;
  58566. REFLECTIONMAP_OPPOSITEZ: boolean;
  58567. LODINREFLECTIONALPHA: boolean;
  58568. GAMMAREFLECTION: boolean;
  58569. RGBDREFLECTION: boolean;
  58570. LINEARSPECULARREFLECTION: boolean;
  58571. RADIANCEOCCLUSION: boolean;
  58572. HORIZONOCCLUSION: boolean;
  58573. INSTANCES: boolean;
  58574. THIN_INSTANCES: boolean;
  58575. PREPASS: boolean;
  58576. SCENE_MRT_COUNT: number;
  58577. NUM_BONE_INFLUENCERS: number;
  58578. BonesPerMesh: number;
  58579. BONETEXTURE: boolean;
  58580. NONUNIFORMSCALING: boolean;
  58581. MORPHTARGETS: boolean;
  58582. MORPHTARGETS_NORMAL: boolean;
  58583. MORPHTARGETS_TANGENT: boolean;
  58584. MORPHTARGETS_UV: boolean;
  58585. NUM_MORPH_INFLUENCERS: number;
  58586. IMAGEPROCESSING: boolean;
  58587. VIGNETTE: boolean;
  58588. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58589. VIGNETTEBLENDMODEOPAQUE: boolean;
  58590. TONEMAPPING: boolean;
  58591. TONEMAPPING_ACES: boolean;
  58592. CONTRAST: boolean;
  58593. COLORCURVES: boolean;
  58594. COLORGRADING: boolean;
  58595. COLORGRADING3D: boolean;
  58596. SAMPLER3DGREENDEPTH: boolean;
  58597. SAMPLER3DBGRMAP: boolean;
  58598. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58599. EXPOSURE: boolean;
  58600. MULTIVIEW: boolean;
  58601. USEPHYSICALLIGHTFALLOFF: boolean;
  58602. USEGLTFLIGHTFALLOFF: boolean;
  58603. TWOSIDEDLIGHTING: boolean;
  58604. SHADOWFLOAT: boolean;
  58605. CLIPPLANE: boolean;
  58606. CLIPPLANE2: boolean;
  58607. CLIPPLANE3: boolean;
  58608. CLIPPLANE4: boolean;
  58609. CLIPPLANE5: boolean;
  58610. CLIPPLANE6: boolean;
  58611. POINTSIZE: boolean;
  58612. FOG: boolean;
  58613. LOGARITHMICDEPTH: boolean;
  58614. FORCENORMALFORWARD: boolean;
  58615. SPECULARAA: boolean;
  58616. CLEARCOAT: boolean;
  58617. CLEARCOAT_DEFAULTIOR: boolean;
  58618. CLEARCOAT_TEXTURE: boolean;
  58619. CLEARCOAT_TEXTUREDIRECTUV: number;
  58620. CLEARCOAT_BUMP: boolean;
  58621. CLEARCOAT_BUMPDIRECTUV: number;
  58622. CLEARCOAT_TINT: boolean;
  58623. CLEARCOAT_TINT_TEXTURE: boolean;
  58624. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58625. ANISOTROPIC: boolean;
  58626. ANISOTROPIC_TEXTURE: boolean;
  58627. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58628. BRDF_V_HEIGHT_CORRELATED: boolean;
  58629. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58630. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58631. SHEEN: boolean;
  58632. SHEEN_TEXTURE: boolean;
  58633. SHEEN_TEXTUREDIRECTUV: number;
  58634. SHEEN_LINKWITHALBEDO: boolean;
  58635. SHEEN_ROUGHNESS: boolean;
  58636. SHEEN_ALBEDOSCALING: boolean;
  58637. SUBSURFACE: boolean;
  58638. SS_REFRACTION: boolean;
  58639. SS_TRANSLUCENCY: boolean;
  58640. SS_SCATTERING: boolean;
  58641. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58642. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58643. SS_REFRACTIONMAP_3D: boolean;
  58644. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58645. SS_LODINREFRACTIONALPHA: boolean;
  58646. SS_GAMMAREFRACTION: boolean;
  58647. SS_RGBDREFRACTION: boolean;
  58648. SS_LINEARSPECULARREFRACTION: boolean;
  58649. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58650. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58651. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58652. UNLIT: boolean;
  58653. DEBUGMODE: number;
  58654. /**
  58655. * Initializes the PBR Material defines.
  58656. */
  58657. constructor();
  58658. /**
  58659. * Resets the PBR Material defines.
  58660. */
  58661. reset(): void;
  58662. }
  58663. /**
  58664. * The Physically based material base class of BJS.
  58665. *
  58666. * This offers the main features of a standard PBR material.
  58667. * For more information, please refer to the documentation :
  58668. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58669. */
  58670. export abstract class PBRBaseMaterial extends PushMaterial {
  58671. /**
  58672. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58673. */
  58674. static readonly PBRMATERIAL_OPAQUE: number;
  58675. /**
  58676. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58677. */
  58678. static readonly PBRMATERIAL_ALPHATEST: number;
  58679. /**
  58680. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58681. */
  58682. static readonly PBRMATERIAL_ALPHABLEND: number;
  58683. /**
  58684. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58685. * They are also discarded below the alpha cutoff threshold to improve performances.
  58686. */
  58687. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58688. /**
  58689. * Defines the default value of how much AO map is occluding the analytical lights
  58690. * (point spot...).
  58691. */
  58692. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58693. /**
  58694. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58695. */
  58696. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58697. /**
  58698. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58699. * to enhance interoperability with other engines.
  58700. */
  58701. static readonly LIGHTFALLOFF_GLTF: number;
  58702. /**
  58703. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58704. * to enhance interoperability with other materials.
  58705. */
  58706. static readonly LIGHTFALLOFF_STANDARD: number;
  58707. /**
  58708. * Intensity of the direct lights e.g. the four lights available in your scene.
  58709. * This impacts both the direct diffuse and specular highlights.
  58710. */
  58711. protected _directIntensity: number;
  58712. /**
  58713. * Intensity of the emissive part of the material.
  58714. * This helps controlling the emissive effect without modifying the emissive color.
  58715. */
  58716. protected _emissiveIntensity: number;
  58717. /**
  58718. * Intensity of the environment e.g. how much the environment will light the object
  58719. * either through harmonics for rough material or through the refelction for shiny ones.
  58720. */
  58721. protected _environmentIntensity: number;
  58722. /**
  58723. * This is a special control allowing the reduction of the specular highlights coming from the
  58724. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58725. */
  58726. protected _specularIntensity: number;
  58727. /**
  58728. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58729. */
  58730. private _lightingInfos;
  58731. /**
  58732. * Debug Control allowing disabling the bump map on this material.
  58733. */
  58734. protected _disableBumpMap: boolean;
  58735. /**
  58736. * AKA Diffuse Texture in standard nomenclature.
  58737. */
  58738. protected _albedoTexture: Nullable<BaseTexture>;
  58739. /**
  58740. * AKA Occlusion Texture in other nomenclature.
  58741. */
  58742. protected _ambientTexture: Nullable<BaseTexture>;
  58743. /**
  58744. * AKA Occlusion Texture Intensity in other nomenclature.
  58745. */
  58746. protected _ambientTextureStrength: number;
  58747. /**
  58748. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58749. * 1 means it completely occludes it
  58750. * 0 mean it has no impact
  58751. */
  58752. protected _ambientTextureImpactOnAnalyticalLights: number;
  58753. /**
  58754. * Stores the alpha values in a texture.
  58755. */
  58756. protected _opacityTexture: Nullable<BaseTexture>;
  58757. /**
  58758. * Stores the reflection values in a texture.
  58759. */
  58760. protected _reflectionTexture: Nullable<BaseTexture>;
  58761. /**
  58762. * Stores the emissive values in a texture.
  58763. */
  58764. protected _emissiveTexture: Nullable<BaseTexture>;
  58765. /**
  58766. * AKA Specular texture in other nomenclature.
  58767. */
  58768. protected _reflectivityTexture: Nullable<BaseTexture>;
  58769. /**
  58770. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58771. */
  58772. protected _metallicTexture: Nullable<BaseTexture>;
  58773. /**
  58774. * Specifies the metallic scalar of the metallic/roughness workflow.
  58775. * Can also be used to scale the metalness values of the metallic texture.
  58776. */
  58777. protected _metallic: Nullable<number>;
  58778. /**
  58779. * Specifies the roughness scalar of the metallic/roughness workflow.
  58780. * Can also be used to scale the roughness values of the metallic texture.
  58781. */
  58782. protected _roughness: Nullable<number>;
  58783. /**
  58784. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58785. * By default the indexOfrefraction is used to compute F0;
  58786. *
  58787. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58788. *
  58789. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58790. * F90 = metallicReflectanceColor;
  58791. */
  58792. protected _metallicF0Factor: number;
  58793. /**
  58794. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58795. * By default the F90 is always 1;
  58796. *
  58797. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58798. *
  58799. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58800. * F90 = metallicReflectanceColor;
  58801. */
  58802. protected _metallicReflectanceColor: Color3;
  58803. /**
  58804. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58805. * This is multiply against the scalar values defined in the material.
  58806. */
  58807. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58808. /**
  58809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58811. */
  58812. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58813. /**
  58814. * Stores surface normal data used to displace a mesh in a texture.
  58815. */
  58816. protected _bumpTexture: Nullable<BaseTexture>;
  58817. /**
  58818. * Stores the pre-calculated light information of a mesh in a texture.
  58819. */
  58820. protected _lightmapTexture: Nullable<BaseTexture>;
  58821. /**
  58822. * The color of a material in ambient lighting.
  58823. */
  58824. protected _ambientColor: Color3;
  58825. /**
  58826. * AKA Diffuse Color in other nomenclature.
  58827. */
  58828. protected _albedoColor: Color3;
  58829. /**
  58830. * AKA Specular Color in other nomenclature.
  58831. */
  58832. protected _reflectivityColor: Color3;
  58833. /**
  58834. * The color applied when light is reflected from a material.
  58835. */
  58836. protected _reflectionColor: Color3;
  58837. /**
  58838. * The color applied when light is emitted from a material.
  58839. */
  58840. protected _emissiveColor: Color3;
  58841. /**
  58842. * AKA Glossiness in other nomenclature.
  58843. */
  58844. protected _microSurface: number;
  58845. /**
  58846. * Specifies that the material will use the light map as a show map.
  58847. */
  58848. protected _useLightmapAsShadowmap: boolean;
  58849. /**
  58850. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58851. * makes the reflect vector face the model (under horizon).
  58852. */
  58853. protected _useHorizonOcclusion: boolean;
  58854. /**
  58855. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58856. * too much the area relying on ambient texture to define their ambient occlusion.
  58857. */
  58858. protected _useRadianceOcclusion: boolean;
  58859. /**
  58860. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58861. */
  58862. protected _useAlphaFromAlbedoTexture: boolean;
  58863. /**
  58864. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58865. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58866. */
  58867. protected _useSpecularOverAlpha: boolean;
  58868. /**
  58869. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58870. */
  58871. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58872. /**
  58873. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58874. */
  58875. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58876. /**
  58877. * Specifies if the metallic texture contains the roughness information in its green channel.
  58878. */
  58879. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58880. /**
  58881. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58882. */
  58883. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58884. /**
  58885. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58886. */
  58887. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58888. /**
  58889. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58890. */
  58891. protected _useAmbientInGrayScale: boolean;
  58892. /**
  58893. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58894. * The material will try to infer what glossiness each pixel should be.
  58895. */
  58896. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58897. /**
  58898. * Defines the falloff type used in this material.
  58899. * It by default is Physical.
  58900. */
  58901. protected _lightFalloff: number;
  58902. /**
  58903. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58904. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58905. */
  58906. protected _useRadianceOverAlpha: boolean;
  58907. /**
  58908. * Allows using an object space normal map (instead of tangent space).
  58909. */
  58910. protected _useObjectSpaceNormalMap: boolean;
  58911. /**
  58912. * Allows using the bump map in parallax mode.
  58913. */
  58914. protected _useParallax: boolean;
  58915. /**
  58916. * Allows using the bump map in parallax occlusion mode.
  58917. */
  58918. protected _useParallaxOcclusion: boolean;
  58919. /**
  58920. * Controls the scale bias of the parallax mode.
  58921. */
  58922. protected _parallaxScaleBias: number;
  58923. /**
  58924. * If sets to true, disables all the lights affecting the material.
  58925. */
  58926. protected _disableLighting: boolean;
  58927. /**
  58928. * Number of Simultaneous lights allowed on the material.
  58929. */
  58930. protected _maxSimultaneousLights: number;
  58931. /**
  58932. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58933. */
  58934. protected _invertNormalMapX: boolean;
  58935. /**
  58936. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58937. */
  58938. protected _invertNormalMapY: boolean;
  58939. /**
  58940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58941. */
  58942. protected _twoSidedLighting: boolean;
  58943. /**
  58944. * Defines the alpha limits in alpha test mode.
  58945. */
  58946. protected _alphaCutOff: number;
  58947. /**
  58948. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58949. */
  58950. protected _forceAlphaTest: boolean;
  58951. /**
  58952. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58953. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58954. */
  58955. protected _useAlphaFresnel: boolean;
  58956. /**
  58957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58958. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58959. */
  58960. protected _useLinearAlphaFresnel: boolean;
  58961. /**
  58962. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58963. * from cos thetav and roughness:
  58964. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58965. */
  58966. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58967. /**
  58968. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58969. */
  58970. protected _forceIrradianceInFragment: boolean;
  58971. private _realTimeFiltering;
  58972. /**
  58973. * Enables realtime filtering on the texture.
  58974. */
  58975. get realTimeFiltering(): boolean;
  58976. set realTimeFiltering(b: boolean);
  58977. private _realTimeFilteringQuality;
  58978. /**
  58979. * Quality switch for realtime filtering
  58980. */
  58981. get realTimeFilteringQuality(): number;
  58982. set realTimeFilteringQuality(n: number);
  58983. /**
  58984. * Can this material render to several textures at once
  58985. */
  58986. get canRenderToMRT(): boolean;
  58987. /**
  58988. * Force normal to face away from face.
  58989. */
  58990. protected _forceNormalForward: boolean;
  58991. /**
  58992. * Enables specular anti aliasing in the PBR shader.
  58993. * It will both interacts on the Geometry for analytical and IBL lighting.
  58994. * It also prefilter the roughness map based on the bump values.
  58995. */
  58996. protected _enableSpecularAntiAliasing: boolean;
  58997. /**
  58998. * Default configuration related to image processing available in the PBR Material.
  58999. */
  59000. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59001. /**
  59002. * Keep track of the image processing observer to allow dispose and replace.
  59003. */
  59004. private _imageProcessingObserver;
  59005. /**
  59006. * Attaches a new image processing configuration to the PBR Material.
  59007. * @param configuration
  59008. */
  59009. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59010. /**
  59011. * Stores the available render targets.
  59012. */
  59013. private _renderTargets;
  59014. /**
  59015. * Sets the global ambient color for the material used in lighting calculations.
  59016. */
  59017. private _globalAmbientColor;
  59018. /**
  59019. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59020. */
  59021. private _useLogarithmicDepth;
  59022. /**
  59023. * If set to true, no lighting calculations will be applied.
  59024. */
  59025. private _unlit;
  59026. private _debugMode;
  59027. /**
  59028. * @hidden
  59029. * This is reserved for the inspector.
  59030. * Defines the material debug mode.
  59031. * It helps seeing only some components of the material while troubleshooting.
  59032. */
  59033. debugMode: number;
  59034. /**
  59035. * @hidden
  59036. * This is reserved for the inspector.
  59037. * Specify from where on screen the debug mode should start.
  59038. * The value goes from -1 (full screen) to 1 (not visible)
  59039. * It helps with side by side comparison against the final render
  59040. * This defaults to -1
  59041. */
  59042. private debugLimit;
  59043. /**
  59044. * @hidden
  59045. * This is reserved for the inspector.
  59046. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59047. * You can use the factor to better multiply the final value.
  59048. */
  59049. private debugFactor;
  59050. /**
  59051. * Defines the clear coat layer parameters for the material.
  59052. */
  59053. readonly clearCoat: PBRClearCoatConfiguration;
  59054. /**
  59055. * Defines the anisotropic parameters for the material.
  59056. */
  59057. readonly anisotropy: PBRAnisotropicConfiguration;
  59058. /**
  59059. * Defines the BRDF parameters for the material.
  59060. */
  59061. readonly brdf: PBRBRDFConfiguration;
  59062. /**
  59063. * Defines the Sheen parameters for the material.
  59064. */
  59065. readonly sheen: PBRSheenConfiguration;
  59066. /**
  59067. * Defines the SubSurface parameters for the material.
  59068. */
  59069. readonly subSurface: PBRSubSurfaceConfiguration;
  59070. /**
  59071. * Defines the detail map parameters for the material.
  59072. */
  59073. readonly detailMap: DetailMapConfiguration;
  59074. protected _rebuildInParallel: boolean;
  59075. /**
  59076. * Instantiates a new PBRMaterial instance.
  59077. *
  59078. * @param name The material name
  59079. * @param scene The scene the material will be use in.
  59080. */
  59081. constructor(name: string, scene: Scene);
  59082. /**
  59083. * Gets a boolean indicating that current material needs to register RTT
  59084. */
  59085. get hasRenderTargetTextures(): boolean;
  59086. /**
  59087. * Gets the name of the material class.
  59088. */
  59089. getClassName(): string;
  59090. /**
  59091. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59092. */
  59093. get useLogarithmicDepth(): boolean;
  59094. /**
  59095. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59096. */
  59097. set useLogarithmicDepth(value: boolean);
  59098. /**
  59099. * Returns true if alpha blending should be disabled.
  59100. */
  59101. protected get _disableAlphaBlending(): boolean;
  59102. /**
  59103. * Specifies whether or not this material should be rendered in alpha blend mode.
  59104. */
  59105. needAlphaBlending(): boolean;
  59106. /**
  59107. * Specifies whether or not this material should be rendered in alpha test mode.
  59108. */
  59109. needAlphaTesting(): boolean;
  59110. /**
  59111. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59112. */
  59113. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59114. /**
  59115. * Gets the texture used for the alpha test.
  59116. */
  59117. getAlphaTestTexture(): Nullable<BaseTexture>;
  59118. /**
  59119. * Specifies that the submesh is ready to be used.
  59120. * @param mesh - BJS mesh.
  59121. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59122. * @param useInstances - Specifies that instances should be used.
  59123. * @returns - boolean indicating that the submesh is ready or not.
  59124. */
  59125. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59126. /**
  59127. * Specifies if the material uses metallic roughness workflow.
  59128. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59129. */
  59130. isMetallicWorkflow(): boolean;
  59131. private _prepareEffect;
  59132. private _prepareDefines;
  59133. /**
  59134. * Force shader compilation
  59135. */
  59136. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59137. /**
  59138. * Initializes the uniform buffer layout for the shader.
  59139. */
  59140. buildUniformLayout(): void;
  59141. /**
  59142. * Unbinds the material from the mesh
  59143. */
  59144. unbind(): void;
  59145. /**
  59146. * Binds the submesh data.
  59147. * @param world - The world matrix.
  59148. * @param mesh - The BJS mesh.
  59149. * @param subMesh - A submesh of the BJS mesh.
  59150. */
  59151. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59152. /**
  59153. * Returns the animatable textures.
  59154. * @returns - Array of animatable textures.
  59155. */
  59156. getAnimatables(): IAnimatable[];
  59157. /**
  59158. * Returns the texture used for reflections.
  59159. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59160. */
  59161. private _getReflectionTexture;
  59162. /**
  59163. * Returns an array of the actively used textures.
  59164. * @returns - Array of BaseTextures
  59165. */
  59166. getActiveTextures(): BaseTexture[];
  59167. /**
  59168. * Checks to see if a texture is used in the material.
  59169. * @param texture - Base texture to use.
  59170. * @returns - Boolean specifying if a texture is used in the material.
  59171. */
  59172. hasTexture(texture: BaseTexture): boolean;
  59173. /**
  59174. * Sets the required values to the prepass renderer.
  59175. * @param prePassRenderer defines the prepass renderer to setup
  59176. */
  59177. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59178. /**
  59179. * Disposes the resources of the material.
  59180. * @param forceDisposeEffect - Forces the disposal of effects.
  59181. * @param forceDisposeTextures - Forces the disposal of all textures.
  59182. */
  59183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59184. }
  59185. }
  59186. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59187. import { Nullable } from "babylonjs/types";
  59188. import { Scene } from "babylonjs/scene";
  59189. import { Color3 } from "babylonjs/Maths/math.color";
  59190. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59191. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59193. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59194. /**
  59195. * The Physically based material of BJS.
  59196. *
  59197. * This offers the main features of a standard PBR material.
  59198. * For more information, please refer to the documentation :
  59199. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59200. */
  59201. export class PBRMaterial extends PBRBaseMaterial {
  59202. /**
  59203. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59204. */
  59205. static readonly PBRMATERIAL_OPAQUE: number;
  59206. /**
  59207. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59208. */
  59209. static readonly PBRMATERIAL_ALPHATEST: number;
  59210. /**
  59211. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59212. */
  59213. static readonly PBRMATERIAL_ALPHABLEND: number;
  59214. /**
  59215. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59216. * They are also discarded below the alpha cutoff threshold to improve performances.
  59217. */
  59218. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59219. /**
  59220. * Defines the default value of how much AO map is occluding the analytical lights
  59221. * (point spot...).
  59222. */
  59223. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59224. /**
  59225. * Intensity of the direct lights e.g. the four lights available in your scene.
  59226. * This impacts both the direct diffuse and specular highlights.
  59227. */
  59228. directIntensity: number;
  59229. /**
  59230. * Intensity of the emissive part of the material.
  59231. * This helps controlling the emissive effect without modifying the emissive color.
  59232. */
  59233. emissiveIntensity: number;
  59234. /**
  59235. * Intensity of the environment e.g. how much the environment will light the object
  59236. * either through harmonics for rough material or through the refelction for shiny ones.
  59237. */
  59238. environmentIntensity: number;
  59239. /**
  59240. * This is a special control allowing the reduction of the specular highlights coming from the
  59241. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59242. */
  59243. specularIntensity: number;
  59244. /**
  59245. * Debug Control allowing disabling the bump map on this material.
  59246. */
  59247. disableBumpMap: boolean;
  59248. /**
  59249. * AKA Diffuse Texture in standard nomenclature.
  59250. */
  59251. albedoTexture: BaseTexture;
  59252. /**
  59253. * AKA Occlusion Texture in other nomenclature.
  59254. */
  59255. ambientTexture: BaseTexture;
  59256. /**
  59257. * AKA Occlusion Texture Intensity in other nomenclature.
  59258. */
  59259. ambientTextureStrength: number;
  59260. /**
  59261. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59262. * 1 means it completely occludes it
  59263. * 0 mean it has no impact
  59264. */
  59265. ambientTextureImpactOnAnalyticalLights: number;
  59266. /**
  59267. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59268. */
  59269. opacityTexture: BaseTexture;
  59270. /**
  59271. * Stores the reflection values in a texture.
  59272. */
  59273. reflectionTexture: Nullable<BaseTexture>;
  59274. /**
  59275. * Stores the emissive values in a texture.
  59276. */
  59277. emissiveTexture: BaseTexture;
  59278. /**
  59279. * AKA Specular texture in other nomenclature.
  59280. */
  59281. reflectivityTexture: BaseTexture;
  59282. /**
  59283. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59284. */
  59285. metallicTexture: BaseTexture;
  59286. /**
  59287. * Specifies the metallic scalar of the metallic/roughness workflow.
  59288. * Can also be used to scale the metalness values of the metallic texture.
  59289. */
  59290. metallic: Nullable<number>;
  59291. /**
  59292. * Specifies the roughness scalar of the metallic/roughness workflow.
  59293. * Can also be used to scale the roughness values of the metallic texture.
  59294. */
  59295. roughness: Nullable<number>;
  59296. /**
  59297. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59298. * By default the indexOfrefraction is used to compute F0;
  59299. *
  59300. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59301. *
  59302. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59303. * F90 = metallicReflectanceColor;
  59304. */
  59305. metallicF0Factor: number;
  59306. /**
  59307. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59308. * By default the F90 is always 1;
  59309. *
  59310. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59311. *
  59312. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59313. * F90 = metallicReflectanceColor;
  59314. */
  59315. metallicReflectanceColor: Color3;
  59316. /**
  59317. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59318. * This is multiply against the scalar values defined in the material.
  59319. */
  59320. metallicReflectanceTexture: Nullable<BaseTexture>;
  59321. /**
  59322. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59323. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59324. */
  59325. microSurfaceTexture: BaseTexture;
  59326. /**
  59327. * Stores surface normal data used to displace a mesh in a texture.
  59328. */
  59329. bumpTexture: BaseTexture;
  59330. /**
  59331. * Stores the pre-calculated light information of a mesh in a texture.
  59332. */
  59333. lightmapTexture: BaseTexture;
  59334. /**
  59335. * Stores the refracted light information in a texture.
  59336. */
  59337. get refractionTexture(): Nullable<BaseTexture>;
  59338. set refractionTexture(value: Nullable<BaseTexture>);
  59339. /**
  59340. * The color of a material in ambient lighting.
  59341. */
  59342. ambientColor: Color3;
  59343. /**
  59344. * AKA Diffuse Color in other nomenclature.
  59345. */
  59346. albedoColor: Color3;
  59347. /**
  59348. * AKA Specular Color in other nomenclature.
  59349. */
  59350. reflectivityColor: Color3;
  59351. /**
  59352. * The color reflected from the material.
  59353. */
  59354. reflectionColor: Color3;
  59355. /**
  59356. * The color emitted from the material.
  59357. */
  59358. emissiveColor: Color3;
  59359. /**
  59360. * AKA Glossiness in other nomenclature.
  59361. */
  59362. microSurface: number;
  59363. /**
  59364. * Index of refraction of the material base layer.
  59365. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59366. *
  59367. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59368. *
  59369. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59370. */
  59371. get indexOfRefraction(): number;
  59372. set indexOfRefraction(value: number);
  59373. /**
  59374. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59375. */
  59376. get invertRefractionY(): boolean;
  59377. set invertRefractionY(value: boolean);
  59378. /**
  59379. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59380. * Materials half opaque for instance using refraction could benefit from this control.
  59381. */
  59382. get linkRefractionWithTransparency(): boolean;
  59383. set linkRefractionWithTransparency(value: boolean);
  59384. /**
  59385. * If true, the light map contains occlusion information instead of lighting info.
  59386. */
  59387. useLightmapAsShadowmap: boolean;
  59388. /**
  59389. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59390. */
  59391. useAlphaFromAlbedoTexture: boolean;
  59392. /**
  59393. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59394. */
  59395. forceAlphaTest: boolean;
  59396. /**
  59397. * Defines the alpha limits in alpha test mode.
  59398. */
  59399. alphaCutOff: number;
  59400. /**
  59401. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59402. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59403. */
  59404. useSpecularOverAlpha: boolean;
  59405. /**
  59406. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59407. */
  59408. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59409. /**
  59410. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59411. */
  59412. useRoughnessFromMetallicTextureAlpha: boolean;
  59413. /**
  59414. * Specifies if the metallic texture contains the roughness information in its green channel.
  59415. */
  59416. useRoughnessFromMetallicTextureGreen: boolean;
  59417. /**
  59418. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59419. */
  59420. useMetallnessFromMetallicTextureBlue: boolean;
  59421. /**
  59422. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59423. */
  59424. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59425. /**
  59426. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59427. */
  59428. useAmbientInGrayScale: boolean;
  59429. /**
  59430. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59431. * The material will try to infer what glossiness each pixel should be.
  59432. */
  59433. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59434. /**
  59435. * BJS is using an harcoded light falloff based on a manually sets up range.
  59436. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59437. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59438. */
  59439. get usePhysicalLightFalloff(): boolean;
  59440. /**
  59441. * BJS is using an harcoded light falloff based on a manually sets up range.
  59442. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59443. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59444. */
  59445. set usePhysicalLightFalloff(value: boolean);
  59446. /**
  59447. * In order to support the falloff compatibility with gltf, a special mode has been added
  59448. * to reproduce the gltf light falloff.
  59449. */
  59450. get useGLTFLightFalloff(): boolean;
  59451. /**
  59452. * In order to support the falloff compatibility with gltf, a special mode has been added
  59453. * to reproduce the gltf light falloff.
  59454. */
  59455. set useGLTFLightFalloff(value: boolean);
  59456. /**
  59457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59459. */
  59460. useRadianceOverAlpha: boolean;
  59461. /**
  59462. * Allows using an object space normal map (instead of tangent space).
  59463. */
  59464. useObjectSpaceNormalMap: boolean;
  59465. /**
  59466. * Allows using the bump map in parallax mode.
  59467. */
  59468. useParallax: boolean;
  59469. /**
  59470. * Allows using the bump map in parallax occlusion mode.
  59471. */
  59472. useParallaxOcclusion: boolean;
  59473. /**
  59474. * Controls the scale bias of the parallax mode.
  59475. */
  59476. parallaxScaleBias: number;
  59477. /**
  59478. * If sets to true, disables all the lights affecting the material.
  59479. */
  59480. disableLighting: boolean;
  59481. /**
  59482. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59483. */
  59484. forceIrradianceInFragment: boolean;
  59485. /**
  59486. * Number of Simultaneous lights allowed on the material.
  59487. */
  59488. maxSimultaneousLights: number;
  59489. /**
  59490. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59491. */
  59492. invertNormalMapX: boolean;
  59493. /**
  59494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59495. */
  59496. invertNormalMapY: boolean;
  59497. /**
  59498. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59499. */
  59500. twoSidedLighting: boolean;
  59501. /**
  59502. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59503. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59504. */
  59505. useAlphaFresnel: boolean;
  59506. /**
  59507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59508. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59509. */
  59510. useLinearAlphaFresnel: boolean;
  59511. /**
  59512. * Let user defines the brdf lookup texture used for IBL.
  59513. * A default 8bit version is embedded but you could point at :
  59514. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59515. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59516. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59517. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59518. */
  59519. environmentBRDFTexture: Nullable<BaseTexture>;
  59520. /**
  59521. * Force normal to face away from face.
  59522. */
  59523. forceNormalForward: boolean;
  59524. /**
  59525. * Enables specular anti aliasing in the PBR shader.
  59526. * It will both interacts on the Geometry for analytical and IBL lighting.
  59527. * It also prefilter the roughness map based on the bump values.
  59528. */
  59529. enableSpecularAntiAliasing: boolean;
  59530. /**
  59531. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59532. * makes the reflect vector face the model (under horizon).
  59533. */
  59534. useHorizonOcclusion: boolean;
  59535. /**
  59536. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59537. * too much the area relying on ambient texture to define their ambient occlusion.
  59538. */
  59539. useRadianceOcclusion: boolean;
  59540. /**
  59541. * If set to true, no lighting calculations will be applied.
  59542. */
  59543. unlit: boolean;
  59544. /**
  59545. * Gets the image processing configuration used either in this material.
  59546. */
  59547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59548. /**
  59549. * Sets the Default image processing configuration used either in the this material.
  59550. *
  59551. * If sets to null, the scene one is in use.
  59552. */
  59553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59554. /**
  59555. * Gets wether the color curves effect is enabled.
  59556. */
  59557. get cameraColorCurvesEnabled(): boolean;
  59558. /**
  59559. * Sets wether the color curves effect is enabled.
  59560. */
  59561. set cameraColorCurvesEnabled(value: boolean);
  59562. /**
  59563. * Gets wether the color grading effect is enabled.
  59564. */
  59565. get cameraColorGradingEnabled(): boolean;
  59566. /**
  59567. * Gets wether the color grading effect is enabled.
  59568. */
  59569. set cameraColorGradingEnabled(value: boolean);
  59570. /**
  59571. * Gets wether tonemapping is enabled or not.
  59572. */
  59573. get cameraToneMappingEnabled(): boolean;
  59574. /**
  59575. * Sets wether tonemapping is enabled or not
  59576. */
  59577. set cameraToneMappingEnabled(value: boolean);
  59578. /**
  59579. * The camera exposure used on this material.
  59580. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59581. * This corresponds to a photographic exposure.
  59582. */
  59583. get cameraExposure(): number;
  59584. /**
  59585. * The camera exposure used on this material.
  59586. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59587. * This corresponds to a photographic exposure.
  59588. */
  59589. set cameraExposure(value: number);
  59590. /**
  59591. * Gets The camera contrast used on this material.
  59592. */
  59593. get cameraContrast(): number;
  59594. /**
  59595. * Sets The camera contrast used on this material.
  59596. */
  59597. set cameraContrast(value: number);
  59598. /**
  59599. * Gets the Color Grading 2D Lookup Texture.
  59600. */
  59601. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59602. /**
  59603. * Sets the Color Grading 2D Lookup Texture.
  59604. */
  59605. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59606. /**
  59607. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59608. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59609. * 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;
  59610. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59611. */
  59612. get cameraColorCurves(): Nullable<ColorCurves>;
  59613. /**
  59614. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59615. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59616. * 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;
  59617. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59618. */
  59619. set cameraColorCurves(value: Nullable<ColorCurves>);
  59620. /**
  59621. * Instantiates a new PBRMaterial instance.
  59622. *
  59623. * @param name The material name
  59624. * @param scene The scene the material will be use in.
  59625. */
  59626. constructor(name: string, scene: Scene);
  59627. /**
  59628. * Returns the name of this material class.
  59629. */
  59630. getClassName(): string;
  59631. /**
  59632. * Makes a duplicate of the current material.
  59633. * @param name - name to use for the new material.
  59634. */
  59635. clone(name: string): PBRMaterial;
  59636. /**
  59637. * Serializes this PBR Material.
  59638. * @returns - An object with the serialized material.
  59639. */
  59640. serialize(): any;
  59641. /**
  59642. * Parses a PBR Material from a serialized object.
  59643. * @param source - Serialized object.
  59644. * @param scene - BJS scene instance.
  59645. * @param rootUrl - url for the scene object
  59646. * @returns - PBRMaterial
  59647. */
  59648. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59649. }
  59650. }
  59651. declare module "babylonjs/Misc/dds" {
  59652. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59654. import { Nullable } from "babylonjs/types";
  59655. import { Scene } from "babylonjs/scene";
  59656. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59657. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59658. /**
  59659. * Direct draw surface info
  59660. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59661. */
  59662. export interface DDSInfo {
  59663. /**
  59664. * Width of the texture
  59665. */
  59666. width: number;
  59667. /**
  59668. * Width of the texture
  59669. */
  59670. height: number;
  59671. /**
  59672. * Number of Mipmaps for the texture
  59673. * @see https://en.wikipedia.org/wiki/Mipmap
  59674. */
  59675. mipmapCount: number;
  59676. /**
  59677. * If the textures format is a known fourCC format
  59678. * @see https://www.fourcc.org/
  59679. */
  59680. isFourCC: boolean;
  59681. /**
  59682. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59683. */
  59684. isRGB: boolean;
  59685. /**
  59686. * If the texture is a lumincance format
  59687. */
  59688. isLuminance: boolean;
  59689. /**
  59690. * If this is a cube texture
  59691. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59692. */
  59693. isCube: boolean;
  59694. /**
  59695. * If the texture is a compressed format eg. FOURCC_DXT1
  59696. */
  59697. isCompressed: boolean;
  59698. /**
  59699. * The dxgiFormat of the texture
  59700. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59701. */
  59702. dxgiFormat: number;
  59703. /**
  59704. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59705. */
  59706. textureType: number;
  59707. /**
  59708. * Sphericle polynomial created for the dds texture
  59709. */
  59710. sphericalPolynomial?: SphericalPolynomial;
  59711. }
  59712. /**
  59713. * Class used to provide DDS decompression tools
  59714. */
  59715. export class DDSTools {
  59716. /**
  59717. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59718. */
  59719. static StoreLODInAlphaChannel: boolean;
  59720. /**
  59721. * Gets DDS information from an array buffer
  59722. * @param data defines the array buffer view to read data from
  59723. * @returns the DDS information
  59724. */
  59725. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59726. private static _FloatView;
  59727. private static _Int32View;
  59728. private static _ToHalfFloat;
  59729. private static _FromHalfFloat;
  59730. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59731. private static _GetHalfFloatRGBAArrayBuffer;
  59732. private static _GetFloatRGBAArrayBuffer;
  59733. private static _GetFloatAsUIntRGBAArrayBuffer;
  59734. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59735. private static _GetRGBAArrayBuffer;
  59736. private static _ExtractLongWordOrder;
  59737. private static _GetRGBArrayBuffer;
  59738. private static _GetLuminanceArrayBuffer;
  59739. /**
  59740. * Uploads DDS Levels to a Babylon Texture
  59741. * @hidden
  59742. */
  59743. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59744. }
  59745. module "babylonjs/Engines/thinEngine" {
  59746. interface ThinEngine {
  59747. /**
  59748. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59749. * @param rootUrl defines the url where the file to load is located
  59750. * @param scene defines the current scene
  59751. * @param lodScale defines scale to apply to the mip map selection
  59752. * @param lodOffset defines offset to apply to the mip map selection
  59753. * @param onLoad defines an optional callback raised when the texture is loaded
  59754. * @param onError defines an optional callback raised if there is an issue to load the texture
  59755. * @param format defines the format of the data
  59756. * @param forcedExtension defines the extension to use to pick the right loader
  59757. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59758. * @returns the cube texture as an InternalTexture
  59759. */
  59760. 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;
  59761. }
  59762. }
  59763. }
  59764. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59765. import { Nullable } from "babylonjs/types";
  59766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59767. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59768. /**
  59769. * Implementation of the DDS Texture Loader.
  59770. * @hidden
  59771. */
  59772. export class _DDSTextureLoader implements IInternalTextureLoader {
  59773. /**
  59774. * Defines wether the loader supports cascade loading the different faces.
  59775. */
  59776. readonly supportCascades: boolean;
  59777. /**
  59778. * This returns if the loader support the current file information.
  59779. * @param extension defines the file extension of the file being loaded
  59780. * @returns true if the loader can load the specified file
  59781. */
  59782. canLoad(extension: string): boolean;
  59783. /**
  59784. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59785. * @param data contains the texture data
  59786. * @param texture defines the BabylonJS internal texture
  59787. * @param createPolynomials will be true if polynomials have been requested
  59788. * @param onLoad defines the callback to trigger once the texture is ready
  59789. * @param onError defines the callback to trigger in case of error
  59790. */
  59791. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59792. /**
  59793. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59794. * @param data contains the texture data
  59795. * @param texture defines the BabylonJS internal texture
  59796. * @param callback defines the method to call once ready to upload
  59797. */
  59798. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59799. }
  59800. }
  59801. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59802. import { Nullable } from "babylonjs/types";
  59803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59804. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59805. /**
  59806. * Implementation of the ENV Texture Loader.
  59807. * @hidden
  59808. */
  59809. export class _ENVTextureLoader implements IInternalTextureLoader {
  59810. /**
  59811. * Defines wether the loader supports cascade loading the different faces.
  59812. */
  59813. readonly supportCascades: boolean;
  59814. /**
  59815. * This returns if the loader support the current file information.
  59816. * @param extension defines the file extension of the file being loaded
  59817. * @returns true if the loader can load the specified file
  59818. */
  59819. canLoad(extension: string): boolean;
  59820. /**
  59821. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59822. * @param data contains the texture data
  59823. * @param texture defines the BabylonJS internal texture
  59824. * @param createPolynomials will be true if polynomials have been requested
  59825. * @param onLoad defines the callback to trigger once the texture is ready
  59826. * @param onError defines the callback to trigger in case of error
  59827. */
  59828. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59829. /**
  59830. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59831. * @param data contains the texture data
  59832. * @param texture defines the BabylonJS internal texture
  59833. * @param callback defines the method to call once ready to upload
  59834. */
  59835. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59836. }
  59837. }
  59838. declare module "babylonjs/Misc/khronosTextureContainer" {
  59839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59840. /**
  59841. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59842. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59843. */
  59844. export class KhronosTextureContainer {
  59845. /** contents of the KTX container file */
  59846. data: ArrayBufferView;
  59847. private static HEADER_LEN;
  59848. private static COMPRESSED_2D;
  59849. private static COMPRESSED_3D;
  59850. private static TEX_2D;
  59851. private static TEX_3D;
  59852. /**
  59853. * Gets the openGL type
  59854. */
  59855. glType: number;
  59856. /**
  59857. * Gets the openGL type size
  59858. */
  59859. glTypeSize: number;
  59860. /**
  59861. * Gets the openGL format
  59862. */
  59863. glFormat: number;
  59864. /**
  59865. * Gets the openGL internal format
  59866. */
  59867. glInternalFormat: number;
  59868. /**
  59869. * Gets the base internal format
  59870. */
  59871. glBaseInternalFormat: number;
  59872. /**
  59873. * Gets image width in pixel
  59874. */
  59875. pixelWidth: number;
  59876. /**
  59877. * Gets image height in pixel
  59878. */
  59879. pixelHeight: number;
  59880. /**
  59881. * Gets image depth in pixels
  59882. */
  59883. pixelDepth: number;
  59884. /**
  59885. * Gets the number of array elements
  59886. */
  59887. numberOfArrayElements: number;
  59888. /**
  59889. * Gets the number of faces
  59890. */
  59891. numberOfFaces: number;
  59892. /**
  59893. * Gets the number of mipmap levels
  59894. */
  59895. numberOfMipmapLevels: number;
  59896. /**
  59897. * Gets the bytes of key value data
  59898. */
  59899. bytesOfKeyValueData: number;
  59900. /**
  59901. * Gets the load type
  59902. */
  59903. loadType: number;
  59904. /**
  59905. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59906. */
  59907. isInvalid: boolean;
  59908. /**
  59909. * Creates a new KhronosTextureContainer
  59910. * @param data contents of the KTX container file
  59911. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59912. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59913. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59914. */
  59915. constructor(
  59916. /** contents of the KTX container file */
  59917. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59918. /**
  59919. * Uploads KTX content to a Babylon Texture.
  59920. * It is assumed that the texture has already been created & is currently bound
  59921. * @hidden
  59922. */
  59923. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59924. private _upload2DCompressedLevels;
  59925. /**
  59926. * Checks if the given data starts with a KTX file identifier.
  59927. * @param data the data to check
  59928. * @returns true if the data is a KTX file or false otherwise
  59929. */
  59930. static IsValid(data: ArrayBufferView): boolean;
  59931. }
  59932. }
  59933. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59935. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59936. /**
  59937. * Class for loading KTX2 files
  59938. * !!! Experimental Extension Subject to Changes !!!
  59939. * @hidden
  59940. */
  59941. export class KhronosTextureContainer2 {
  59942. private static _ModulePromise;
  59943. private static _TranscodeFormat;
  59944. constructor(engine: ThinEngine);
  59945. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59946. private _determineTranscodeFormat;
  59947. /**
  59948. * Checks if the given data starts with a KTX2 file identifier.
  59949. * @param data the data to check
  59950. * @returns true if the data is a KTX2 file or false otherwise
  59951. */
  59952. static IsValid(data: ArrayBufferView): boolean;
  59953. }
  59954. }
  59955. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59956. import { Nullable } from "babylonjs/types";
  59957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59958. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59959. /**
  59960. * Implementation of the KTX Texture Loader.
  59961. * @hidden
  59962. */
  59963. export class _KTXTextureLoader implements IInternalTextureLoader {
  59964. /**
  59965. * Defines wether the loader supports cascade loading the different faces.
  59966. */
  59967. readonly supportCascades: boolean;
  59968. /**
  59969. * This returns if the loader support the current file information.
  59970. * @param extension defines the file extension of the file being loaded
  59971. * @param mimeType defines the optional mime type of the file being loaded
  59972. * @returns true if the loader can load the specified file
  59973. */
  59974. canLoad(extension: string, mimeType?: string): boolean;
  59975. /**
  59976. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59977. * @param data contains the texture data
  59978. * @param texture defines the BabylonJS internal texture
  59979. * @param createPolynomials will be true if polynomials have been requested
  59980. * @param onLoad defines the callback to trigger once the texture is ready
  59981. * @param onError defines the callback to trigger in case of error
  59982. */
  59983. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59984. /**
  59985. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59986. * @param data contains the texture data
  59987. * @param texture defines the BabylonJS internal texture
  59988. * @param callback defines the method to call once ready to upload
  59989. */
  59990. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59991. }
  59992. }
  59993. declare module "babylonjs/Helpers/sceneHelpers" {
  59994. import { Nullable } from "babylonjs/types";
  59995. import { Mesh } from "babylonjs/Meshes/mesh";
  59996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59997. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59998. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59999. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60000. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60001. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60002. import "babylonjs/Meshes/Builders/boxBuilder";
  60003. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60004. /** @hidden */
  60005. export var _forceSceneHelpersToBundle: boolean;
  60006. module "babylonjs/scene" {
  60007. interface Scene {
  60008. /**
  60009. * Creates a default light for the scene.
  60010. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60011. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60012. */
  60013. createDefaultLight(replace?: boolean): void;
  60014. /**
  60015. * Creates a default camera for the scene.
  60016. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60017. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60018. * @param replace has default false, when true replaces the active camera in the scene
  60019. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60020. */
  60021. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60022. /**
  60023. * Creates a default camera and a default light.
  60024. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60025. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60026. * @param replace has the default false, when true replaces the active camera/light in the scene
  60027. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60028. */
  60029. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60030. /**
  60031. * Creates a new sky box
  60032. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60033. * @param environmentTexture defines the texture to use as environment texture
  60034. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60035. * @param scale defines the overall scale of the skybox
  60036. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60037. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60038. * @returns a new mesh holding the sky box
  60039. */
  60040. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60041. /**
  60042. * Creates a new environment
  60043. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60044. * @param options defines the options you can use to configure the environment
  60045. * @returns the new EnvironmentHelper
  60046. */
  60047. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60048. /**
  60049. * Creates a new VREXperienceHelper
  60050. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60051. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60052. * @returns a new VREXperienceHelper
  60053. */
  60054. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60055. /**
  60056. * Creates a new WebXRDefaultExperience
  60057. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60058. * @param options experience options
  60059. * @returns a promise for a new WebXRDefaultExperience
  60060. */
  60061. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60062. }
  60063. }
  60064. }
  60065. declare module "babylonjs/Helpers/videoDome" {
  60066. import { Scene } from "babylonjs/scene";
  60067. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60068. import { Mesh } from "babylonjs/Meshes/mesh";
  60069. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60070. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60071. import "babylonjs/Meshes/Builders/sphereBuilder";
  60072. /**
  60073. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60074. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60075. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60076. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60077. */
  60078. export class VideoDome extends TransformNode {
  60079. /**
  60080. * Define the video source as a Monoscopic panoramic 360 video.
  60081. */
  60082. static readonly MODE_MONOSCOPIC: number;
  60083. /**
  60084. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60085. */
  60086. static readonly MODE_TOPBOTTOM: number;
  60087. /**
  60088. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60089. */
  60090. static readonly MODE_SIDEBYSIDE: number;
  60091. private _halfDome;
  60092. private _useDirectMapping;
  60093. /**
  60094. * The video texture being displayed on the sphere
  60095. */
  60096. protected _videoTexture: VideoTexture;
  60097. /**
  60098. * Gets the video texture being displayed on the sphere
  60099. */
  60100. get videoTexture(): VideoTexture;
  60101. /**
  60102. * The skybox material
  60103. */
  60104. protected _material: BackgroundMaterial;
  60105. /**
  60106. * The surface used for the video dome
  60107. */
  60108. protected _mesh: Mesh;
  60109. /**
  60110. * Gets the mesh used for the video dome.
  60111. */
  60112. get mesh(): Mesh;
  60113. /**
  60114. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  60115. */
  60116. private _halfDomeMask;
  60117. /**
  60118. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60119. * Also see the options.resolution property.
  60120. */
  60121. get fovMultiplier(): number;
  60122. set fovMultiplier(value: number);
  60123. private _videoMode;
  60124. /**
  60125. * Gets or set the current video mode for the video. It can be:
  60126. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60127. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60128. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60129. */
  60130. get videoMode(): number;
  60131. set videoMode(value: number);
  60132. /**
  60133. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60134. *
  60135. */
  60136. get halfDome(): boolean;
  60137. /**
  60138. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60139. */
  60140. set halfDome(enabled: boolean);
  60141. /**
  60142. * Oberserver used in Stereoscopic VR Mode.
  60143. */
  60144. private _onBeforeCameraRenderObserver;
  60145. /**
  60146. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60147. * @param name Element's name, child elements will append suffixes for their own names.
  60148. * @param urlsOrVideo defines the url(s) or the video element to use
  60149. * @param options An object containing optional or exposed sub element properties
  60150. */
  60151. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60152. resolution?: number;
  60153. clickToPlay?: boolean;
  60154. autoPlay?: boolean;
  60155. loop?: boolean;
  60156. size?: number;
  60157. poster?: string;
  60158. faceForward?: boolean;
  60159. useDirectMapping?: boolean;
  60160. halfDomeMode?: boolean;
  60161. }, scene: Scene);
  60162. private _changeVideoMode;
  60163. /**
  60164. * Releases resources associated with this node.
  60165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60167. */
  60168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60169. }
  60170. }
  60171. declare module "babylonjs/Helpers/index" {
  60172. export * from "babylonjs/Helpers/environmentHelper";
  60173. export * from "babylonjs/Helpers/photoDome";
  60174. export * from "babylonjs/Helpers/sceneHelpers";
  60175. export * from "babylonjs/Helpers/videoDome";
  60176. }
  60177. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60178. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60179. import { IDisposable } from "babylonjs/scene";
  60180. import { Engine } from "babylonjs/Engines/engine";
  60181. /**
  60182. * This class can be used to get instrumentation data from a Babylon engine
  60183. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60184. */
  60185. export class EngineInstrumentation implements IDisposable {
  60186. /**
  60187. * Define the instrumented engine.
  60188. */
  60189. engine: Engine;
  60190. private _captureGPUFrameTime;
  60191. private _gpuFrameTimeToken;
  60192. private _gpuFrameTime;
  60193. private _captureShaderCompilationTime;
  60194. private _shaderCompilationTime;
  60195. private _onBeginFrameObserver;
  60196. private _onEndFrameObserver;
  60197. private _onBeforeShaderCompilationObserver;
  60198. private _onAfterShaderCompilationObserver;
  60199. /**
  60200. * Gets the perf counter used for GPU frame time
  60201. */
  60202. get gpuFrameTimeCounter(): PerfCounter;
  60203. /**
  60204. * Gets the GPU frame time capture status
  60205. */
  60206. get captureGPUFrameTime(): boolean;
  60207. /**
  60208. * Enable or disable the GPU frame time capture
  60209. */
  60210. set captureGPUFrameTime(value: boolean);
  60211. /**
  60212. * Gets the perf counter used for shader compilation time
  60213. */
  60214. get shaderCompilationTimeCounter(): PerfCounter;
  60215. /**
  60216. * Gets the shader compilation time capture status
  60217. */
  60218. get captureShaderCompilationTime(): boolean;
  60219. /**
  60220. * Enable or disable the shader compilation time capture
  60221. */
  60222. set captureShaderCompilationTime(value: boolean);
  60223. /**
  60224. * Instantiates a new engine instrumentation.
  60225. * This class can be used to get instrumentation data from a Babylon engine
  60226. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60227. * @param engine Defines the engine to instrument
  60228. */
  60229. constructor(
  60230. /**
  60231. * Define the instrumented engine.
  60232. */
  60233. engine: Engine);
  60234. /**
  60235. * Dispose and release associated resources.
  60236. */
  60237. dispose(): void;
  60238. }
  60239. }
  60240. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60241. import { Scene, IDisposable } from "babylonjs/scene";
  60242. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60243. /**
  60244. * This class can be used to get instrumentation data from a Babylon engine
  60245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60246. */
  60247. export class SceneInstrumentation implements IDisposable {
  60248. /**
  60249. * Defines the scene to instrument
  60250. */
  60251. scene: Scene;
  60252. private _captureActiveMeshesEvaluationTime;
  60253. private _activeMeshesEvaluationTime;
  60254. private _captureRenderTargetsRenderTime;
  60255. private _renderTargetsRenderTime;
  60256. private _captureFrameTime;
  60257. private _frameTime;
  60258. private _captureRenderTime;
  60259. private _renderTime;
  60260. private _captureInterFrameTime;
  60261. private _interFrameTime;
  60262. private _captureParticlesRenderTime;
  60263. private _particlesRenderTime;
  60264. private _captureSpritesRenderTime;
  60265. private _spritesRenderTime;
  60266. private _capturePhysicsTime;
  60267. private _physicsTime;
  60268. private _captureAnimationsTime;
  60269. private _animationsTime;
  60270. private _captureCameraRenderTime;
  60271. private _cameraRenderTime;
  60272. private _onBeforeActiveMeshesEvaluationObserver;
  60273. private _onAfterActiveMeshesEvaluationObserver;
  60274. private _onBeforeRenderTargetsRenderObserver;
  60275. private _onAfterRenderTargetsRenderObserver;
  60276. private _onAfterRenderObserver;
  60277. private _onBeforeDrawPhaseObserver;
  60278. private _onAfterDrawPhaseObserver;
  60279. private _onBeforeAnimationsObserver;
  60280. private _onBeforeParticlesRenderingObserver;
  60281. private _onAfterParticlesRenderingObserver;
  60282. private _onBeforeSpritesRenderingObserver;
  60283. private _onAfterSpritesRenderingObserver;
  60284. private _onBeforePhysicsObserver;
  60285. private _onAfterPhysicsObserver;
  60286. private _onAfterAnimationsObserver;
  60287. private _onBeforeCameraRenderObserver;
  60288. private _onAfterCameraRenderObserver;
  60289. /**
  60290. * Gets the perf counter used for active meshes evaluation time
  60291. */
  60292. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60293. /**
  60294. * Gets the active meshes evaluation time capture status
  60295. */
  60296. get captureActiveMeshesEvaluationTime(): boolean;
  60297. /**
  60298. * Enable or disable the active meshes evaluation time capture
  60299. */
  60300. set captureActiveMeshesEvaluationTime(value: boolean);
  60301. /**
  60302. * Gets the perf counter used for render targets render time
  60303. */
  60304. get renderTargetsRenderTimeCounter(): PerfCounter;
  60305. /**
  60306. * Gets the render targets render time capture status
  60307. */
  60308. get captureRenderTargetsRenderTime(): boolean;
  60309. /**
  60310. * Enable or disable the render targets render time capture
  60311. */
  60312. set captureRenderTargetsRenderTime(value: boolean);
  60313. /**
  60314. * Gets the perf counter used for particles render time
  60315. */
  60316. get particlesRenderTimeCounter(): PerfCounter;
  60317. /**
  60318. * Gets the particles render time capture status
  60319. */
  60320. get captureParticlesRenderTime(): boolean;
  60321. /**
  60322. * Enable or disable the particles render time capture
  60323. */
  60324. set captureParticlesRenderTime(value: boolean);
  60325. /**
  60326. * Gets the perf counter used for sprites render time
  60327. */
  60328. get spritesRenderTimeCounter(): PerfCounter;
  60329. /**
  60330. * Gets the sprites render time capture status
  60331. */
  60332. get captureSpritesRenderTime(): boolean;
  60333. /**
  60334. * Enable or disable the sprites render time capture
  60335. */
  60336. set captureSpritesRenderTime(value: boolean);
  60337. /**
  60338. * Gets the perf counter used for physics time
  60339. */
  60340. get physicsTimeCounter(): PerfCounter;
  60341. /**
  60342. * Gets the physics time capture status
  60343. */
  60344. get capturePhysicsTime(): boolean;
  60345. /**
  60346. * Enable or disable the physics time capture
  60347. */
  60348. set capturePhysicsTime(value: boolean);
  60349. /**
  60350. * Gets the perf counter used for animations time
  60351. */
  60352. get animationsTimeCounter(): PerfCounter;
  60353. /**
  60354. * Gets the animations time capture status
  60355. */
  60356. get captureAnimationsTime(): boolean;
  60357. /**
  60358. * Enable or disable the animations time capture
  60359. */
  60360. set captureAnimationsTime(value: boolean);
  60361. /**
  60362. * Gets the perf counter used for frame time capture
  60363. */
  60364. get frameTimeCounter(): PerfCounter;
  60365. /**
  60366. * Gets the frame time capture status
  60367. */
  60368. get captureFrameTime(): boolean;
  60369. /**
  60370. * Enable or disable the frame time capture
  60371. */
  60372. set captureFrameTime(value: boolean);
  60373. /**
  60374. * Gets the perf counter used for inter-frames time capture
  60375. */
  60376. get interFrameTimeCounter(): PerfCounter;
  60377. /**
  60378. * Gets the inter-frames time capture status
  60379. */
  60380. get captureInterFrameTime(): boolean;
  60381. /**
  60382. * Enable or disable the inter-frames time capture
  60383. */
  60384. set captureInterFrameTime(value: boolean);
  60385. /**
  60386. * Gets the perf counter used for render time capture
  60387. */
  60388. get renderTimeCounter(): PerfCounter;
  60389. /**
  60390. * Gets the render time capture status
  60391. */
  60392. get captureRenderTime(): boolean;
  60393. /**
  60394. * Enable or disable the render time capture
  60395. */
  60396. set captureRenderTime(value: boolean);
  60397. /**
  60398. * Gets the perf counter used for camera render time capture
  60399. */
  60400. get cameraRenderTimeCounter(): PerfCounter;
  60401. /**
  60402. * Gets the camera render time capture status
  60403. */
  60404. get captureCameraRenderTime(): boolean;
  60405. /**
  60406. * Enable or disable the camera render time capture
  60407. */
  60408. set captureCameraRenderTime(value: boolean);
  60409. /**
  60410. * Gets the perf counter used for draw calls
  60411. */
  60412. get drawCallsCounter(): PerfCounter;
  60413. /**
  60414. * Instantiates a new scene instrumentation.
  60415. * This class can be used to get instrumentation data from a Babylon engine
  60416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60417. * @param scene Defines the scene to instrument
  60418. */
  60419. constructor(
  60420. /**
  60421. * Defines the scene to instrument
  60422. */
  60423. scene: Scene);
  60424. /**
  60425. * Dispose and release associated resources.
  60426. */
  60427. dispose(): void;
  60428. }
  60429. }
  60430. declare module "babylonjs/Instrumentation/index" {
  60431. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60432. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60433. export * from "babylonjs/Instrumentation/timeToken";
  60434. }
  60435. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60436. /** @hidden */
  60437. export var glowMapGenerationPixelShader: {
  60438. name: string;
  60439. shader: string;
  60440. };
  60441. }
  60442. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60443. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60444. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60445. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60446. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60448. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60449. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60450. /** @hidden */
  60451. export var glowMapGenerationVertexShader: {
  60452. name: string;
  60453. shader: string;
  60454. };
  60455. }
  60456. declare module "babylonjs/Layers/effectLayer" {
  60457. import { Observable } from "babylonjs/Misc/observable";
  60458. import { Nullable } from "babylonjs/types";
  60459. import { Camera } from "babylonjs/Cameras/camera";
  60460. import { Scene } from "babylonjs/scene";
  60461. import { ISize } from "babylonjs/Maths/math.size";
  60462. import { Color4 } from "babylonjs/Maths/math.color";
  60463. import { Engine } from "babylonjs/Engines/engine";
  60464. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60466. import { Mesh } from "babylonjs/Meshes/mesh";
  60467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60470. import { Effect } from "babylonjs/Materials/effect";
  60471. import { Material } from "babylonjs/Materials/material";
  60472. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60473. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60474. /**
  60475. * Effect layer options. This helps customizing the behaviour
  60476. * of the effect layer.
  60477. */
  60478. export interface IEffectLayerOptions {
  60479. /**
  60480. * Multiplication factor apply to the canvas size to compute the render target size
  60481. * used to generated the objects (the smaller the faster).
  60482. */
  60483. mainTextureRatio: number;
  60484. /**
  60485. * Enforces a fixed size texture to ensure effect stability across devices.
  60486. */
  60487. mainTextureFixedSize?: number;
  60488. /**
  60489. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60490. */
  60491. alphaBlendingMode: number;
  60492. /**
  60493. * The camera attached to the layer.
  60494. */
  60495. camera: Nullable<Camera>;
  60496. /**
  60497. * The rendering group to draw the layer in.
  60498. */
  60499. renderingGroupId: number;
  60500. }
  60501. /**
  60502. * The effect layer Helps adding post process effect blended with the main pass.
  60503. *
  60504. * This can be for instance use to generate glow or higlight effects on the scene.
  60505. *
  60506. * The effect layer class can not be used directly and is intented to inherited from to be
  60507. * customized per effects.
  60508. */
  60509. export abstract class EffectLayer {
  60510. private _vertexBuffers;
  60511. private _indexBuffer;
  60512. private _cachedDefines;
  60513. private _effectLayerMapGenerationEffect;
  60514. private _effectLayerOptions;
  60515. private _mergeEffect;
  60516. protected _scene: Scene;
  60517. protected _engine: Engine;
  60518. protected _maxSize: number;
  60519. protected _mainTextureDesiredSize: ISize;
  60520. protected _mainTexture: RenderTargetTexture;
  60521. protected _shouldRender: boolean;
  60522. protected _postProcesses: PostProcess[];
  60523. protected _textures: BaseTexture[];
  60524. protected _emissiveTextureAndColor: {
  60525. texture: Nullable<BaseTexture>;
  60526. color: Color4;
  60527. };
  60528. /**
  60529. * The name of the layer
  60530. */
  60531. name: string;
  60532. /**
  60533. * The clear color of the texture used to generate the glow map.
  60534. */
  60535. neutralColor: Color4;
  60536. /**
  60537. * Specifies whether the highlight layer is enabled or not.
  60538. */
  60539. isEnabled: boolean;
  60540. /**
  60541. * Gets the camera attached to the layer.
  60542. */
  60543. get camera(): Nullable<Camera>;
  60544. /**
  60545. * Gets the rendering group id the layer should render in.
  60546. */
  60547. get renderingGroupId(): number;
  60548. set renderingGroupId(renderingGroupId: number);
  60549. /**
  60550. * An event triggered when the effect layer has been disposed.
  60551. */
  60552. onDisposeObservable: Observable<EffectLayer>;
  60553. /**
  60554. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60555. */
  60556. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60557. /**
  60558. * An event triggered when the generated texture is being merged in the scene.
  60559. */
  60560. onBeforeComposeObservable: Observable<EffectLayer>;
  60561. /**
  60562. * An event triggered when the mesh is rendered into the effect render target.
  60563. */
  60564. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60565. /**
  60566. * An event triggered after the mesh has been rendered into the effect render target.
  60567. */
  60568. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60569. /**
  60570. * An event triggered when the generated texture has been merged in the scene.
  60571. */
  60572. onAfterComposeObservable: Observable<EffectLayer>;
  60573. /**
  60574. * An event triggered when the efffect layer changes its size.
  60575. */
  60576. onSizeChangedObservable: Observable<EffectLayer>;
  60577. /** @hidden */
  60578. static _SceneComponentInitialization: (scene: Scene) => void;
  60579. /**
  60580. * Instantiates a new effect Layer and references it in the scene.
  60581. * @param name The name of the layer
  60582. * @param scene The scene to use the layer in
  60583. */
  60584. constructor(
  60585. /** The Friendly of the effect in the scene */
  60586. name: string, scene: Scene);
  60587. /**
  60588. * Get the effect name of the layer.
  60589. * @return The effect name
  60590. */
  60591. abstract getEffectName(): string;
  60592. /**
  60593. * Checks for the readiness of the element composing the layer.
  60594. * @param subMesh the mesh to check for
  60595. * @param useInstances specify whether or not to use instances to render the mesh
  60596. * @return true if ready otherwise, false
  60597. */
  60598. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60599. /**
  60600. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60601. * @returns true if the effect requires stencil during the main canvas render pass.
  60602. */
  60603. abstract needStencil(): boolean;
  60604. /**
  60605. * Create the merge effect. This is the shader use to blit the information back
  60606. * to the main canvas at the end of the scene rendering.
  60607. * @returns The effect containing the shader used to merge the effect on the main canvas
  60608. */
  60609. protected abstract _createMergeEffect(): Effect;
  60610. /**
  60611. * Creates the render target textures and post processes used in the effect layer.
  60612. */
  60613. protected abstract _createTextureAndPostProcesses(): void;
  60614. /**
  60615. * Implementation specific of rendering the generating effect on the main canvas.
  60616. * @param effect The effect used to render through
  60617. */
  60618. protected abstract _internalRender(effect: Effect): void;
  60619. /**
  60620. * Sets the required values for both the emissive texture and and the main color.
  60621. */
  60622. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60623. /**
  60624. * Free any resources and references associated to a mesh.
  60625. * Internal use
  60626. * @param mesh The mesh to free.
  60627. */
  60628. abstract _disposeMesh(mesh: Mesh): void;
  60629. /**
  60630. * Serializes this layer (Glow or Highlight for example)
  60631. * @returns a serialized layer object
  60632. */
  60633. abstract serialize?(): any;
  60634. /**
  60635. * Initializes the effect layer with the required options.
  60636. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60637. */
  60638. protected _init(options: Partial<IEffectLayerOptions>): void;
  60639. /**
  60640. * Generates the index buffer of the full screen quad blending to the main canvas.
  60641. */
  60642. private _generateIndexBuffer;
  60643. /**
  60644. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60645. */
  60646. private _generateVertexBuffer;
  60647. /**
  60648. * Sets the main texture desired size which is the closest power of two
  60649. * of the engine canvas size.
  60650. */
  60651. private _setMainTextureSize;
  60652. /**
  60653. * Creates the main texture for the effect layer.
  60654. */
  60655. protected _createMainTexture(): void;
  60656. /**
  60657. * Adds specific effects defines.
  60658. * @param defines The defines to add specifics to.
  60659. */
  60660. protected _addCustomEffectDefines(defines: string[]): void;
  60661. /**
  60662. * Checks for the readiness of the element composing the layer.
  60663. * @param subMesh the mesh to check for
  60664. * @param useInstances specify whether or not to use instances to render the mesh
  60665. * @param emissiveTexture the associated emissive texture used to generate the glow
  60666. * @return true if ready otherwise, false
  60667. */
  60668. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60669. /**
  60670. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60671. */
  60672. render(): void;
  60673. /**
  60674. * Determine if a given mesh will be used in the current effect.
  60675. * @param mesh mesh to test
  60676. * @returns true if the mesh will be used
  60677. */
  60678. hasMesh(mesh: AbstractMesh): boolean;
  60679. /**
  60680. * Returns true if the layer contains information to display, otherwise false.
  60681. * @returns true if the glow layer should be rendered
  60682. */
  60683. shouldRender(): boolean;
  60684. /**
  60685. * Returns true if the mesh should render, otherwise false.
  60686. * @param mesh The mesh to render
  60687. * @returns true if it should render otherwise false
  60688. */
  60689. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60690. /**
  60691. * Returns true if the mesh can be rendered, otherwise false.
  60692. * @param mesh The mesh to render
  60693. * @param material The material used on the mesh
  60694. * @returns true if it can be rendered otherwise false
  60695. */
  60696. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60697. /**
  60698. * Returns true if the mesh should render, otherwise false.
  60699. * @param mesh The mesh to render
  60700. * @returns true if it should render otherwise false
  60701. */
  60702. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60703. /**
  60704. * Renders the submesh passed in parameter to the generation map.
  60705. */
  60706. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60707. /**
  60708. * Defines whether the current material of the mesh should be use to render the effect.
  60709. * @param mesh defines the current mesh to render
  60710. */
  60711. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60712. /**
  60713. * Rebuild the required buffers.
  60714. * @hidden Internal use only.
  60715. */
  60716. _rebuild(): void;
  60717. /**
  60718. * Dispose only the render target textures and post process.
  60719. */
  60720. private _disposeTextureAndPostProcesses;
  60721. /**
  60722. * Dispose the highlight layer and free resources.
  60723. */
  60724. dispose(): void;
  60725. /**
  60726. * Gets the class name of the effect layer
  60727. * @returns the string with the class name of the effect layer
  60728. */
  60729. getClassName(): string;
  60730. /**
  60731. * Creates an effect layer from parsed effect layer data
  60732. * @param parsedEffectLayer defines effect layer data
  60733. * @param scene defines the current scene
  60734. * @param rootUrl defines the root URL containing the effect layer information
  60735. * @returns a parsed effect Layer
  60736. */
  60737. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60738. }
  60739. }
  60740. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60741. import { Scene } from "babylonjs/scene";
  60742. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60743. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60744. import { AbstractScene } from "babylonjs/abstractScene";
  60745. module "babylonjs/abstractScene" {
  60746. interface AbstractScene {
  60747. /**
  60748. * The list of effect layers (highlights/glow) added to the scene
  60749. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60750. * @see https://doc.babylonjs.com/how_to/glow_layer
  60751. */
  60752. effectLayers: Array<EffectLayer>;
  60753. /**
  60754. * Removes the given effect layer from this scene.
  60755. * @param toRemove defines the effect layer to remove
  60756. * @returns the index of the removed effect layer
  60757. */
  60758. removeEffectLayer(toRemove: EffectLayer): number;
  60759. /**
  60760. * Adds the given effect layer to this scene
  60761. * @param newEffectLayer defines the effect layer to add
  60762. */
  60763. addEffectLayer(newEffectLayer: EffectLayer): void;
  60764. }
  60765. }
  60766. /**
  60767. * Defines the layer scene component responsible to manage any effect layers
  60768. * in a given scene.
  60769. */
  60770. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60771. /**
  60772. * The component name helpfull to identify the component in the list of scene components.
  60773. */
  60774. readonly name: string;
  60775. /**
  60776. * The scene the component belongs to.
  60777. */
  60778. scene: Scene;
  60779. private _engine;
  60780. private _renderEffects;
  60781. private _needStencil;
  60782. private _previousStencilState;
  60783. /**
  60784. * Creates a new instance of the component for the given scene
  60785. * @param scene Defines the scene to register the component in
  60786. */
  60787. constructor(scene: Scene);
  60788. /**
  60789. * Registers the component in a given scene
  60790. */
  60791. register(): void;
  60792. /**
  60793. * Rebuilds the elements related to this component in case of
  60794. * context lost for instance.
  60795. */
  60796. rebuild(): void;
  60797. /**
  60798. * Serializes the component data to the specified json object
  60799. * @param serializationObject The object to serialize to
  60800. */
  60801. serialize(serializationObject: any): void;
  60802. /**
  60803. * Adds all the elements from the container to the scene
  60804. * @param container the container holding the elements
  60805. */
  60806. addFromContainer(container: AbstractScene): void;
  60807. /**
  60808. * Removes all the elements in the container from the scene
  60809. * @param container contains the elements to remove
  60810. * @param dispose if the removed element should be disposed (default: false)
  60811. */
  60812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60813. /**
  60814. * Disposes the component and the associated ressources.
  60815. */
  60816. dispose(): void;
  60817. private _isReadyForMesh;
  60818. private _renderMainTexture;
  60819. private _setStencil;
  60820. private _setStencilBack;
  60821. private _draw;
  60822. private _drawCamera;
  60823. private _drawRenderingGroup;
  60824. }
  60825. }
  60826. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60827. /** @hidden */
  60828. export var glowMapMergePixelShader: {
  60829. name: string;
  60830. shader: string;
  60831. };
  60832. }
  60833. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60834. /** @hidden */
  60835. export var glowMapMergeVertexShader: {
  60836. name: string;
  60837. shader: string;
  60838. };
  60839. }
  60840. declare module "babylonjs/Layers/glowLayer" {
  60841. import { Nullable } from "babylonjs/types";
  60842. import { Camera } from "babylonjs/Cameras/camera";
  60843. import { Scene } from "babylonjs/scene";
  60844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60846. import { Mesh } from "babylonjs/Meshes/mesh";
  60847. import { Texture } from "babylonjs/Materials/Textures/texture";
  60848. import { Effect } from "babylonjs/Materials/effect";
  60849. import { Material } from "babylonjs/Materials/material";
  60850. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60851. import { Color4 } from "babylonjs/Maths/math.color";
  60852. import "babylonjs/Shaders/glowMapMerge.fragment";
  60853. import "babylonjs/Shaders/glowMapMerge.vertex";
  60854. import "babylonjs/Layers/effectLayerSceneComponent";
  60855. module "babylonjs/abstractScene" {
  60856. interface AbstractScene {
  60857. /**
  60858. * Return a the first highlight layer of the scene with a given name.
  60859. * @param name The name of the highlight layer to look for.
  60860. * @return The highlight layer if found otherwise null.
  60861. */
  60862. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60863. }
  60864. }
  60865. /**
  60866. * Glow layer options. This helps customizing the behaviour
  60867. * of the glow layer.
  60868. */
  60869. export interface IGlowLayerOptions {
  60870. /**
  60871. * Multiplication factor apply to the canvas size to compute the render target size
  60872. * used to generated the glowing objects (the smaller the faster).
  60873. */
  60874. mainTextureRatio: number;
  60875. /**
  60876. * Enforces a fixed size texture to ensure resize independant blur.
  60877. */
  60878. mainTextureFixedSize?: number;
  60879. /**
  60880. * How big is the kernel of the blur texture.
  60881. */
  60882. blurKernelSize: number;
  60883. /**
  60884. * The camera attached to the layer.
  60885. */
  60886. camera: Nullable<Camera>;
  60887. /**
  60888. * Enable MSAA by chosing the number of samples.
  60889. */
  60890. mainTextureSamples?: number;
  60891. /**
  60892. * The rendering group to draw the layer in.
  60893. */
  60894. renderingGroupId: number;
  60895. }
  60896. /**
  60897. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60898. *
  60899. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60900. *
  60901. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60902. */
  60903. export class GlowLayer extends EffectLayer {
  60904. /**
  60905. * Effect Name of the layer.
  60906. */
  60907. static readonly EffectName: string;
  60908. /**
  60909. * The default blur kernel size used for the glow.
  60910. */
  60911. static DefaultBlurKernelSize: number;
  60912. /**
  60913. * The default texture size ratio used for the glow.
  60914. */
  60915. static DefaultTextureRatio: number;
  60916. /**
  60917. * Sets the kernel size of the blur.
  60918. */
  60919. set blurKernelSize(value: number);
  60920. /**
  60921. * Gets the kernel size of the blur.
  60922. */
  60923. get blurKernelSize(): number;
  60924. /**
  60925. * Sets the glow intensity.
  60926. */
  60927. set intensity(value: number);
  60928. /**
  60929. * Gets the glow intensity.
  60930. */
  60931. get intensity(): number;
  60932. private _options;
  60933. private _intensity;
  60934. private _horizontalBlurPostprocess1;
  60935. private _verticalBlurPostprocess1;
  60936. private _horizontalBlurPostprocess2;
  60937. private _verticalBlurPostprocess2;
  60938. private _blurTexture1;
  60939. private _blurTexture2;
  60940. private _postProcesses1;
  60941. private _postProcesses2;
  60942. private _includedOnlyMeshes;
  60943. private _excludedMeshes;
  60944. private _meshesUsingTheirOwnMaterials;
  60945. /**
  60946. * Callback used to let the user override the color selection on a per mesh basis
  60947. */
  60948. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60949. /**
  60950. * Callback used to let the user override the texture selection on a per mesh basis
  60951. */
  60952. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60953. /**
  60954. * Instantiates a new glow Layer and references it to the scene.
  60955. * @param name The name of the layer
  60956. * @param scene The scene to use the layer in
  60957. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60958. */
  60959. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60960. /**
  60961. * Get the effect name of the layer.
  60962. * @return The effect name
  60963. */
  60964. getEffectName(): string;
  60965. /**
  60966. * Create the merge effect. This is the shader use to blit the information back
  60967. * to the main canvas at the end of the scene rendering.
  60968. */
  60969. protected _createMergeEffect(): Effect;
  60970. /**
  60971. * Creates the render target textures and post processes used in the glow layer.
  60972. */
  60973. protected _createTextureAndPostProcesses(): void;
  60974. /**
  60975. * Checks for the readiness of the element composing the layer.
  60976. * @param subMesh the mesh to check for
  60977. * @param useInstances specify wether or not to use instances to render the mesh
  60978. * @param emissiveTexture the associated emissive texture used to generate the glow
  60979. * @return true if ready otherwise, false
  60980. */
  60981. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60982. /**
  60983. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60984. */
  60985. needStencil(): boolean;
  60986. /**
  60987. * Returns true if the mesh can be rendered, otherwise false.
  60988. * @param mesh The mesh to render
  60989. * @param material The material used on the mesh
  60990. * @returns true if it can be rendered otherwise false
  60991. */
  60992. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60993. /**
  60994. * Implementation specific of rendering the generating effect on the main canvas.
  60995. * @param effect The effect used to render through
  60996. */
  60997. protected _internalRender(effect: Effect): void;
  60998. /**
  60999. * Sets the required values for both the emissive texture and and the main color.
  61000. */
  61001. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61002. /**
  61003. * Returns true if the mesh should render, otherwise false.
  61004. * @param mesh The mesh to render
  61005. * @returns true if it should render otherwise false
  61006. */
  61007. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61008. /**
  61009. * Adds specific effects defines.
  61010. * @param defines The defines to add specifics to.
  61011. */
  61012. protected _addCustomEffectDefines(defines: string[]): void;
  61013. /**
  61014. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61015. * @param mesh The mesh to exclude from the glow layer
  61016. */
  61017. addExcludedMesh(mesh: Mesh): void;
  61018. /**
  61019. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61020. * @param mesh The mesh to remove
  61021. */
  61022. removeExcludedMesh(mesh: Mesh): void;
  61023. /**
  61024. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61025. * @param mesh The mesh to include in the glow layer
  61026. */
  61027. addIncludedOnlyMesh(mesh: Mesh): void;
  61028. /**
  61029. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61030. * @param mesh The mesh to remove
  61031. */
  61032. removeIncludedOnlyMesh(mesh: Mesh): void;
  61033. /**
  61034. * Determine if a given mesh will be used in the glow layer
  61035. * @param mesh The mesh to test
  61036. * @returns true if the mesh will be highlighted by the current glow layer
  61037. */
  61038. hasMesh(mesh: AbstractMesh): boolean;
  61039. /**
  61040. * Defines whether the current material of the mesh should be use to render the effect.
  61041. * @param mesh defines the current mesh to render
  61042. */
  61043. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61044. /**
  61045. * Add a mesh to be rendered through its own material and not with emissive only.
  61046. * @param mesh The mesh for which we need to use its material
  61047. */
  61048. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61049. /**
  61050. * Remove a mesh from being rendered through its own material and not with emissive only.
  61051. * @param mesh The mesh for which we need to not use its material
  61052. */
  61053. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61054. /**
  61055. * Free any resources and references associated to a mesh.
  61056. * Internal use
  61057. * @param mesh The mesh to free.
  61058. * @hidden
  61059. */
  61060. _disposeMesh(mesh: Mesh): void;
  61061. /**
  61062. * Gets the class name of the effect layer
  61063. * @returns the string with the class name of the effect layer
  61064. */
  61065. getClassName(): string;
  61066. /**
  61067. * Serializes this glow layer
  61068. * @returns a serialized glow layer object
  61069. */
  61070. serialize(): any;
  61071. /**
  61072. * Creates a Glow Layer from parsed glow layer data
  61073. * @param parsedGlowLayer defines glow layer data
  61074. * @param scene defines the current scene
  61075. * @param rootUrl defines the root URL containing the glow layer information
  61076. * @returns a parsed Glow Layer
  61077. */
  61078. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61079. }
  61080. }
  61081. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61082. /** @hidden */
  61083. export var glowBlurPostProcessPixelShader: {
  61084. name: string;
  61085. shader: string;
  61086. };
  61087. }
  61088. declare module "babylonjs/Layers/highlightLayer" {
  61089. import { Observable } from "babylonjs/Misc/observable";
  61090. import { Nullable } from "babylonjs/types";
  61091. import { Camera } from "babylonjs/Cameras/camera";
  61092. import { Scene } from "babylonjs/scene";
  61093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61095. import { Mesh } from "babylonjs/Meshes/mesh";
  61096. import { Effect } from "babylonjs/Materials/effect";
  61097. import { Material } from "babylonjs/Materials/material";
  61098. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61099. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61100. import "babylonjs/Shaders/glowMapMerge.fragment";
  61101. import "babylonjs/Shaders/glowMapMerge.vertex";
  61102. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61103. module "babylonjs/abstractScene" {
  61104. interface AbstractScene {
  61105. /**
  61106. * Return a the first highlight layer of the scene with a given name.
  61107. * @param name The name of the highlight layer to look for.
  61108. * @return The highlight layer if found otherwise null.
  61109. */
  61110. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61111. }
  61112. }
  61113. /**
  61114. * Highlight layer options. This helps customizing the behaviour
  61115. * of the highlight layer.
  61116. */
  61117. export interface IHighlightLayerOptions {
  61118. /**
  61119. * Multiplication factor apply to the canvas size to compute the render target size
  61120. * used to generated the glowing objects (the smaller the faster).
  61121. */
  61122. mainTextureRatio: number;
  61123. /**
  61124. * Enforces a fixed size texture to ensure resize independant blur.
  61125. */
  61126. mainTextureFixedSize?: number;
  61127. /**
  61128. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61129. * of the picture to blur (the smaller the faster).
  61130. */
  61131. blurTextureSizeRatio: number;
  61132. /**
  61133. * How big in texel of the blur texture is the vertical blur.
  61134. */
  61135. blurVerticalSize: number;
  61136. /**
  61137. * How big in texel of the blur texture is the horizontal blur.
  61138. */
  61139. blurHorizontalSize: number;
  61140. /**
  61141. * Alpha blending mode used to apply the blur. Default is combine.
  61142. */
  61143. alphaBlendingMode: number;
  61144. /**
  61145. * The camera attached to the layer.
  61146. */
  61147. camera: Nullable<Camera>;
  61148. /**
  61149. * Should we display highlight as a solid stroke?
  61150. */
  61151. isStroke?: boolean;
  61152. /**
  61153. * The rendering group to draw the layer in.
  61154. */
  61155. renderingGroupId: number;
  61156. }
  61157. /**
  61158. * The highlight layer Helps adding a glow effect around a mesh.
  61159. *
  61160. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61161. * glowy meshes to your scene.
  61162. *
  61163. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61164. */
  61165. export class HighlightLayer extends EffectLayer {
  61166. name: string;
  61167. /**
  61168. * Effect Name of the highlight layer.
  61169. */
  61170. static readonly EffectName: string;
  61171. /**
  61172. * The neutral color used during the preparation of the glow effect.
  61173. * This is black by default as the blend operation is a blend operation.
  61174. */
  61175. static NeutralColor: Color4;
  61176. /**
  61177. * Stencil value used for glowing meshes.
  61178. */
  61179. static GlowingMeshStencilReference: number;
  61180. /**
  61181. * Stencil value used for the other meshes in the scene.
  61182. */
  61183. static NormalMeshStencilReference: number;
  61184. /**
  61185. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61186. */
  61187. innerGlow: boolean;
  61188. /**
  61189. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61190. */
  61191. outerGlow: boolean;
  61192. /**
  61193. * Specifies the horizontal size of the blur.
  61194. */
  61195. set blurHorizontalSize(value: number);
  61196. /**
  61197. * Specifies the vertical size of the blur.
  61198. */
  61199. set blurVerticalSize(value: number);
  61200. /**
  61201. * Gets the horizontal size of the blur.
  61202. */
  61203. get blurHorizontalSize(): number;
  61204. /**
  61205. * Gets the vertical size of the blur.
  61206. */
  61207. get blurVerticalSize(): number;
  61208. /**
  61209. * An event triggered when the highlight layer is being blurred.
  61210. */
  61211. onBeforeBlurObservable: Observable<HighlightLayer>;
  61212. /**
  61213. * An event triggered when the highlight layer has been blurred.
  61214. */
  61215. onAfterBlurObservable: Observable<HighlightLayer>;
  61216. private _instanceGlowingMeshStencilReference;
  61217. private _options;
  61218. private _downSamplePostprocess;
  61219. private _horizontalBlurPostprocess;
  61220. private _verticalBlurPostprocess;
  61221. private _blurTexture;
  61222. private _meshes;
  61223. private _excludedMeshes;
  61224. /**
  61225. * Instantiates a new highlight Layer and references it to the scene..
  61226. * @param name The name of the layer
  61227. * @param scene The scene to use the layer in
  61228. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61229. */
  61230. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61231. /**
  61232. * Get the effect name of the layer.
  61233. * @return The effect name
  61234. */
  61235. getEffectName(): string;
  61236. /**
  61237. * Create the merge effect. This is the shader use to blit the information back
  61238. * to the main canvas at the end of the scene rendering.
  61239. */
  61240. protected _createMergeEffect(): Effect;
  61241. /**
  61242. * Creates the render target textures and post processes used in the highlight layer.
  61243. */
  61244. protected _createTextureAndPostProcesses(): void;
  61245. /**
  61246. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61247. */
  61248. needStencil(): boolean;
  61249. /**
  61250. * Checks for the readiness of the element composing the layer.
  61251. * @param subMesh the mesh to check for
  61252. * @param useInstances specify wether or not to use instances to render the mesh
  61253. * @param emissiveTexture the associated emissive texture used to generate the glow
  61254. * @return true if ready otherwise, false
  61255. */
  61256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61257. /**
  61258. * Implementation specific of rendering the generating effect on the main canvas.
  61259. * @param effect The effect used to render through
  61260. */
  61261. protected _internalRender(effect: Effect): void;
  61262. /**
  61263. * Returns true if the layer contains information to display, otherwise false.
  61264. */
  61265. shouldRender(): boolean;
  61266. /**
  61267. * Returns true if the mesh should render, otherwise false.
  61268. * @param mesh The mesh to render
  61269. * @returns true if it should render otherwise false
  61270. */
  61271. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61272. /**
  61273. * Returns true if the mesh can be rendered, otherwise false.
  61274. * @param mesh The mesh to render
  61275. * @param material The material used on the mesh
  61276. * @returns true if it can be rendered otherwise false
  61277. */
  61278. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61279. /**
  61280. * Adds specific effects defines.
  61281. * @param defines The defines to add specifics to.
  61282. */
  61283. protected _addCustomEffectDefines(defines: string[]): void;
  61284. /**
  61285. * Sets the required values for both the emissive texture and and the main color.
  61286. */
  61287. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61288. /**
  61289. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61290. * @param mesh The mesh to exclude from the highlight layer
  61291. */
  61292. addExcludedMesh(mesh: Mesh): void;
  61293. /**
  61294. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61295. * @param mesh The mesh to highlight
  61296. */
  61297. removeExcludedMesh(mesh: Mesh): void;
  61298. /**
  61299. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61300. * @param mesh mesh to test
  61301. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61302. */
  61303. hasMesh(mesh: AbstractMesh): boolean;
  61304. /**
  61305. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61306. * @param mesh The mesh to highlight
  61307. * @param color The color of the highlight
  61308. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61309. */
  61310. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61311. /**
  61312. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61313. * @param mesh The mesh to highlight
  61314. */
  61315. removeMesh(mesh: Mesh): void;
  61316. /**
  61317. * Remove all the meshes currently referenced in the highlight layer
  61318. */
  61319. removeAllMeshes(): void;
  61320. /**
  61321. * Force the stencil to the normal expected value for none glowing parts
  61322. */
  61323. private _defaultStencilReference;
  61324. /**
  61325. * Free any resources and references associated to a mesh.
  61326. * Internal use
  61327. * @param mesh The mesh to free.
  61328. * @hidden
  61329. */
  61330. _disposeMesh(mesh: Mesh): void;
  61331. /**
  61332. * Dispose the highlight layer and free resources.
  61333. */
  61334. dispose(): void;
  61335. /**
  61336. * Gets the class name of the effect layer
  61337. * @returns the string with the class name of the effect layer
  61338. */
  61339. getClassName(): string;
  61340. /**
  61341. * Serializes this Highlight layer
  61342. * @returns a serialized Highlight layer object
  61343. */
  61344. serialize(): any;
  61345. /**
  61346. * Creates a Highlight layer from parsed Highlight layer data
  61347. * @param parsedHightlightLayer defines the Highlight layer data
  61348. * @param scene defines the current scene
  61349. * @param rootUrl defines the root URL containing the Highlight layer information
  61350. * @returns a parsed Highlight layer
  61351. */
  61352. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61353. }
  61354. }
  61355. declare module "babylonjs/Layers/layerSceneComponent" {
  61356. import { Scene } from "babylonjs/scene";
  61357. import { ISceneComponent } from "babylonjs/sceneComponent";
  61358. import { Layer } from "babylonjs/Layers/layer";
  61359. import { AbstractScene } from "babylonjs/abstractScene";
  61360. module "babylonjs/abstractScene" {
  61361. interface AbstractScene {
  61362. /**
  61363. * The list of layers (background and foreground) of the scene
  61364. */
  61365. layers: Array<Layer>;
  61366. }
  61367. }
  61368. /**
  61369. * Defines the layer scene component responsible to manage any layers
  61370. * in a given scene.
  61371. */
  61372. export class LayerSceneComponent implements ISceneComponent {
  61373. /**
  61374. * The component name helpfull to identify the component in the list of scene components.
  61375. */
  61376. readonly name: string;
  61377. /**
  61378. * The scene the component belongs to.
  61379. */
  61380. scene: Scene;
  61381. private _engine;
  61382. /**
  61383. * Creates a new instance of the component for the given scene
  61384. * @param scene Defines the scene to register the component in
  61385. */
  61386. constructor(scene: Scene);
  61387. /**
  61388. * Registers the component in a given scene
  61389. */
  61390. register(): void;
  61391. /**
  61392. * Rebuilds the elements related to this component in case of
  61393. * context lost for instance.
  61394. */
  61395. rebuild(): void;
  61396. /**
  61397. * Disposes the component and the associated ressources.
  61398. */
  61399. dispose(): void;
  61400. private _draw;
  61401. private _drawCameraPredicate;
  61402. private _drawCameraBackground;
  61403. private _drawCameraForeground;
  61404. private _drawRenderTargetPredicate;
  61405. private _drawRenderTargetBackground;
  61406. private _drawRenderTargetForeground;
  61407. /**
  61408. * Adds all the elements from the container to the scene
  61409. * @param container the container holding the elements
  61410. */
  61411. addFromContainer(container: AbstractScene): void;
  61412. /**
  61413. * Removes all the elements in the container from the scene
  61414. * @param container contains the elements to remove
  61415. * @param dispose if the removed element should be disposed (default: false)
  61416. */
  61417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61418. }
  61419. }
  61420. declare module "babylonjs/Shaders/layer.fragment" {
  61421. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61422. /** @hidden */
  61423. export var layerPixelShader: {
  61424. name: string;
  61425. shader: string;
  61426. };
  61427. }
  61428. declare module "babylonjs/Shaders/layer.vertex" {
  61429. /** @hidden */
  61430. export var layerVertexShader: {
  61431. name: string;
  61432. shader: string;
  61433. };
  61434. }
  61435. declare module "babylonjs/Layers/layer" {
  61436. import { Observable } from "babylonjs/Misc/observable";
  61437. import { Nullable } from "babylonjs/types";
  61438. import { Scene } from "babylonjs/scene";
  61439. import { Vector2 } from "babylonjs/Maths/math.vector";
  61440. import { Color4 } from "babylonjs/Maths/math.color";
  61441. import { Texture } from "babylonjs/Materials/Textures/texture";
  61442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61443. import "babylonjs/Shaders/layer.fragment";
  61444. import "babylonjs/Shaders/layer.vertex";
  61445. /**
  61446. * This represents a full screen 2d layer.
  61447. * This can be useful to display a picture in the background of your scene for instance.
  61448. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61449. */
  61450. export class Layer {
  61451. /**
  61452. * Define the name of the layer.
  61453. */
  61454. name: string;
  61455. /**
  61456. * Define the texture the layer should display.
  61457. */
  61458. texture: Nullable<Texture>;
  61459. /**
  61460. * Is the layer in background or foreground.
  61461. */
  61462. isBackground: boolean;
  61463. /**
  61464. * Define the color of the layer (instead of texture).
  61465. */
  61466. color: Color4;
  61467. /**
  61468. * Define the scale of the layer in order to zoom in out of the texture.
  61469. */
  61470. scale: Vector2;
  61471. /**
  61472. * Define an offset for the layer in order to shift the texture.
  61473. */
  61474. offset: Vector2;
  61475. /**
  61476. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61477. */
  61478. alphaBlendingMode: number;
  61479. /**
  61480. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61481. * Alpha test will not mix with the background color in case of transparency.
  61482. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61483. */
  61484. alphaTest: boolean;
  61485. /**
  61486. * Define a mask to restrict the layer to only some of the scene cameras.
  61487. */
  61488. layerMask: number;
  61489. /**
  61490. * Define the list of render target the layer is visible into.
  61491. */
  61492. renderTargetTextures: RenderTargetTexture[];
  61493. /**
  61494. * Define if the layer is only used in renderTarget or if it also
  61495. * renders in the main frame buffer of the canvas.
  61496. */
  61497. renderOnlyInRenderTargetTextures: boolean;
  61498. private _scene;
  61499. private _vertexBuffers;
  61500. private _indexBuffer;
  61501. private _effect;
  61502. private _previousDefines;
  61503. /**
  61504. * An event triggered when the layer is disposed.
  61505. */
  61506. onDisposeObservable: Observable<Layer>;
  61507. private _onDisposeObserver;
  61508. /**
  61509. * Back compatibility with callback before the onDisposeObservable existed.
  61510. * The set callback will be triggered when the layer has been disposed.
  61511. */
  61512. set onDispose(callback: () => void);
  61513. /**
  61514. * An event triggered before rendering the scene
  61515. */
  61516. onBeforeRenderObservable: Observable<Layer>;
  61517. private _onBeforeRenderObserver;
  61518. /**
  61519. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61520. * The set callback will be triggered just before rendering the layer.
  61521. */
  61522. set onBeforeRender(callback: () => void);
  61523. /**
  61524. * An event triggered after rendering the scene
  61525. */
  61526. onAfterRenderObservable: Observable<Layer>;
  61527. private _onAfterRenderObserver;
  61528. /**
  61529. * Back compatibility with callback before the onAfterRenderObservable existed.
  61530. * The set callback will be triggered just after rendering the layer.
  61531. */
  61532. set onAfterRender(callback: () => void);
  61533. /**
  61534. * Instantiates a new layer.
  61535. * This represents a full screen 2d layer.
  61536. * This can be useful to display a picture in the background of your scene for instance.
  61537. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61538. * @param name Define the name of the layer in the scene
  61539. * @param imgUrl Define the url of the texture to display in the layer
  61540. * @param scene Define the scene the layer belongs to
  61541. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61542. * @param color Defines a color for the layer
  61543. */
  61544. constructor(
  61545. /**
  61546. * Define the name of the layer.
  61547. */
  61548. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61549. private _createIndexBuffer;
  61550. /** @hidden */
  61551. _rebuild(): void;
  61552. /**
  61553. * Renders the layer in the scene.
  61554. */
  61555. render(): void;
  61556. /**
  61557. * Disposes and releases the associated ressources.
  61558. */
  61559. dispose(): void;
  61560. }
  61561. }
  61562. declare module "babylonjs/Layers/index" {
  61563. export * from "babylonjs/Layers/effectLayer";
  61564. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61565. export * from "babylonjs/Layers/glowLayer";
  61566. export * from "babylonjs/Layers/highlightLayer";
  61567. export * from "babylonjs/Layers/layer";
  61568. export * from "babylonjs/Layers/layerSceneComponent";
  61569. }
  61570. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61571. /** @hidden */
  61572. export var lensFlarePixelShader: {
  61573. name: string;
  61574. shader: string;
  61575. };
  61576. }
  61577. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61578. /** @hidden */
  61579. export var lensFlareVertexShader: {
  61580. name: string;
  61581. shader: string;
  61582. };
  61583. }
  61584. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61585. import { Scene } from "babylonjs/scene";
  61586. import { Vector3 } from "babylonjs/Maths/math.vector";
  61587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61588. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61589. import "babylonjs/Shaders/lensFlare.fragment";
  61590. import "babylonjs/Shaders/lensFlare.vertex";
  61591. import { Viewport } from "babylonjs/Maths/math.viewport";
  61592. /**
  61593. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61594. * It is usually composed of several `lensFlare`.
  61595. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61596. */
  61597. export class LensFlareSystem {
  61598. /**
  61599. * Define the name of the lens flare system
  61600. */
  61601. name: string;
  61602. /**
  61603. * List of lens flares used in this system.
  61604. */
  61605. lensFlares: LensFlare[];
  61606. /**
  61607. * Define a limit from the border the lens flare can be visible.
  61608. */
  61609. borderLimit: number;
  61610. /**
  61611. * Define a viewport border we do not want to see the lens flare in.
  61612. */
  61613. viewportBorder: number;
  61614. /**
  61615. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61616. */
  61617. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61618. /**
  61619. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61620. */
  61621. layerMask: number;
  61622. /**
  61623. * Define the id of the lens flare system in the scene.
  61624. * (equal to name by default)
  61625. */
  61626. id: string;
  61627. private _scene;
  61628. private _emitter;
  61629. private _vertexBuffers;
  61630. private _indexBuffer;
  61631. private _effect;
  61632. private _positionX;
  61633. private _positionY;
  61634. private _isEnabled;
  61635. /** @hidden */
  61636. static _SceneComponentInitialization: (scene: Scene) => void;
  61637. /**
  61638. * Instantiates a lens flare system.
  61639. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61640. * It is usually composed of several `lensFlare`.
  61641. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61642. * @param name Define the name of the lens flare system in the scene
  61643. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61644. * @param scene Define the scene the lens flare system belongs to
  61645. */
  61646. constructor(
  61647. /**
  61648. * Define the name of the lens flare system
  61649. */
  61650. name: string, emitter: any, scene: Scene);
  61651. /**
  61652. * Define if the lens flare system is enabled.
  61653. */
  61654. get isEnabled(): boolean;
  61655. set isEnabled(value: boolean);
  61656. /**
  61657. * Get the scene the effects belongs to.
  61658. * @returns the scene holding the lens flare system
  61659. */
  61660. getScene(): Scene;
  61661. /**
  61662. * Get the emitter of the lens flare system.
  61663. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61664. * @returns the emitter of the lens flare system
  61665. */
  61666. getEmitter(): any;
  61667. /**
  61668. * Set the emitter of the lens flare system.
  61669. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61670. * @param newEmitter Define the new emitter of the system
  61671. */
  61672. setEmitter(newEmitter: any): void;
  61673. /**
  61674. * Get the lens flare system emitter position.
  61675. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61676. * @returns the position
  61677. */
  61678. getEmitterPosition(): Vector3;
  61679. /**
  61680. * @hidden
  61681. */
  61682. computeEffectivePosition(globalViewport: Viewport): boolean;
  61683. /** @hidden */
  61684. _isVisible(): boolean;
  61685. /**
  61686. * @hidden
  61687. */
  61688. render(): boolean;
  61689. /**
  61690. * Dispose and release the lens flare with its associated resources.
  61691. */
  61692. dispose(): void;
  61693. /**
  61694. * Parse a lens flare system from a JSON repressentation
  61695. * @param parsedLensFlareSystem Define the JSON to parse
  61696. * @param scene Define the scene the parsed system should be instantiated in
  61697. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61698. * @returns the parsed system
  61699. */
  61700. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61701. /**
  61702. * Serialize the current Lens Flare System into a JSON representation.
  61703. * @returns the serialized JSON
  61704. */
  61705. serialize(): any;
  61706. }
  61707. }
  61708. declare module "babylonjs/LensFlares/lensFlare" {
  61709. import { Nullable } from "babylonjs/types";
  61710. import { Color3 } from "babylonjs/Maths/math.color";
  61711. import { Texture } from "babylonjs/Materials/Textures/texture";
  61712. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61713. /**
  61714. * This represents one of the lens effect in a `lensFlareSystem`.
  61715. * It controls one of the indiviual texture used in the effect.
  61716. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61717. */
  61718. export class LensFlare {
  61719. /**
  61720. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61721. */
  61722. size: number;
  61723. /**
  61724. * 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.
  61725. */
  61726. position: number;
  61727. /**
  61728. * Define the lens color.
  61729. */
  61730. color: Color3;
  61731. /**
  61732. * Define the lens texture.
  61733. */
  61734. texture: Nullable<Texture>;
  61735. /**
  61736. * Define the alpha mode to render this particular lens.
  61737. */
  61738. alphaMode: number;
  61739. private _system;
  61740. /**
  61741. * Creates a new Lens Flare.
  61742. * This represents one of the lens effect in a `lensFlareSystem`.
  61743. * It controls one of the indiviual texture used in the effect.
  61744. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61745. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61746. * @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.
  61747. * @param color Define the lens color
  61748. * @param imgUrl Define the lens texture url
  61749. * @param system Define the `lensFlareSystem` this flare is part of
  61750. * @returns The newly created Lens Flare
  61751. */
  61752. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61753. /**
  61754. * Instantiates a new Lens Flare.
  61755. * This represents one of the lens effect in a `lensFlareSystem`.
  61756. * It controls one of the indiviual texture used in the effect.
  61757. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61758. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61759. * @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.
  61760. * @param color Define the lens color
  61761. * @param imgUrl Define the lens texture url
  61762. * @param system Define the `lensFlareSystem` this flare is part of
  61763. */
  61764. constructor(
  61765. /**
  61766. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61767. */
  61768. size: number,
  61769. /**
  61770. * 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.
  61771. */
  61772. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61773. /**
  61774. * Dispose and release the lens flare with its associated resources.
  61775. */
  61776. dispose(): void;
  61777. }
  61778. }
  61779. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61780. import { Nullable } from "babylonjs/types";
  61781. import { Scene } from "babylonjs/scene";
  61782. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61783. import { AbstractScene } from "babylonjs/abstractScene";
  61784. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61785. module "babylonjs/abstractScene" {
  61786. interface AbstractScene {
  61787. /**
  61788. * The list of lens flare system added to the scene
  61789. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61790. */
  61791. lensFlareSystems: Array<LensFlareSystem>;
  61792. /**
  61793. * Removes the given lens flare system from this scene.
  61794. * @param toRemove The lens flare system to remove
  61795. * @returns The index of the removed lens flare system
  61796. */
  61797. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61798. /**
  61799. * Adds the given lens flare system to this scene
  61800. * @param newLensFlareSystem The lens flare system to add
  61801. */
  61802. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61803. /**
  61804. * Gets a lens flare system using its name
  61805. * @param name defines the name to look for
  61806. * @returns the lens flare system or null if not found
  61807. */
  61808. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61809. /**
  61810. * Gets a lens flare system using its id
  61811. * @param id defines the id to look for
  61812. * @returns the lens flare system or null if not found
  61813. */
  61814. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61815. }
  61816. }
  61817. /**
  61818. * Defines the lens flare scene component responsible to manage any lens flares
  61819. * in a given scene.
  61820. */
  61821. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61822. /**
  61823. * The component name helpfull to identify the component in the list of scene components.
  61824. */
  61825. readonly name: string;
  61826. /**
  61827. * The scene the component belongs to.
  61828. */
  61829. scene: Scene;
  61830. /**
  61831. * Creates a new instance of the component for the given scene
  61832. * @param scene Defines the scene to register the component in
  61833. */
  61834. constructor(scene: Scene);
  61835. /**
  61836. * Registers the component in a given scene
  61837. */
  61838. register(): void;
  61839. /**
  61840. * Rebuilds the elements related to this component in case of
  61841. * context lost for instance.
  61842. */
  61843. rebuild(): void;
  61844. /**
  61845. * Adds all the elements from the container to the scene
  61846. * @param container the container holding the elements
  61847. */
  61848. addFromContainer(container: AbstractScene): void;
  61849. /**
  61850. * Removes all the elements in the container from the scene
  61851. * @param container contains the elements to remove
  61852. * @param dispose if the removed element should be disposed (default: false)
  61853. */
  61854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61855. /**
  61856. * Serializes the component data to the specified json object
  61857. * @param serializationObject The object to serialize to
  61858. */
  61859. serialize(serializationObject: any): void;
  61860. /**
  61861. * Disposes the component and the associated ressources.
  61862. */
  61863. dispose(): void;
  61864. private _draw;
  61865. }
  61866. }
  61867. declare module "babylonjs/LensFlares/index" {
  61868. export * from "babylonjs/LensFlares/lensFlare";
  61869. export * from "babylonjs/LensFlares/lensFlareSystem";
  61870. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61871. }
  61872. declare module "babylonjs/Shaders/depth.fragment" {
  61873. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61874. /** @hidden */
  61875. export var depthPixelShader: {
  61876. name: string;
  61877. shader: string;
  61878. };
  61879. }
  61880. declare module "babylonjs/Shaders/depth.vertex" {
  61881. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61884. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61886. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61887. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61888. /** @hidden */
  61889. export var depthVertexShader: {
  61890. name: string;
  61891. shader: string;
  61892. };
  61893. }
  61894. declare module "babylonjs/Rendering/depthRenderer" {
  61895. import { Nullable } from "babylonjs/types";
  61896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61897. import { Scene } from "babylonjs/scene";
  61898. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61899. import { Camera } from "babylonjs/Cameras/camera";
  61900. import "babylonjs/Shaders/depth.fragment";
  61901. import "babylonjs/Shaders/depth.vertex";
  61902. /**
  61903. * This represents a depth renderer in Babylon.
  61904. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61905. */
  61906. export class DepthRenderer {
  61907. private _scene;
  61908. private _depthMap;
  61909. private _effect;
  61910. private readonly _storeNonLinearDepth;
  61911. private readonly _clearColor;
  61912. /** Get if the depth renderer is using packed depth or not */
  61913. readonly isPacked: boolean;
  61914. private _cachedDefines;
  61915. private _camera;
  61916. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61917. enabled: boolean;
  61918. /**
  61919. * Specifiess that the depth renderer will only be used within
  61920. * the camera it is created for.
  61921. * This can help forcing its rendering during the camera processing.
  61922. */
  61923. useOnlyInActiveCamera: boolean;
  61924. /** @hidden */
  61925. static _SceneComponentInitialization: (scene: Scene) => void;
  61926. /**
  61927. * Instantiates a depth renderer
  61928. * @param scene The scene the renderer belongs to
  61929. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61930. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61931. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61932. */
  61933. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61934. /**
  61935. * Creates the depth rendering effect and checks if the effect is ready.
  61936. * @param subMesh The submesh to be used to render the depth map of
  61937. * @param useInstances If multiple world instances should be used
  61938. * @returns if the depth renderer is ready to render the depth map
  61939. */
  61940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61941. /**
  61942. * Gets the texture which the depth map will be written to.
  61943. * @returns The depth map texture
  61944. */
  61945. getDepthMap(): RenderTargetTexture;
  61946. /**
  61947. * Disposes of the depth renderer.
  61948. */
  61949. dispose(): void;
  61950. }
  61951. }
  61952. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61953. /** @hidden */
  61954. export var minmaxReduxPixelShader: {
  61955. name: string;
  61956. shader: string;
  61957. };
  61958. }
  61959. declare module "babylonjs/Misc/minMaxReducer" {
  61960. import { Nullable } from "babylonjs/types";
  61961. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61962. import { Camera } from "babylonjs/Cameras/camera";
  61963. import { Observer } from "babylonjs/Misc/observable";
  61964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61965. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61966. import { Observable } from "babylonjs/Misc/observable";
  61967. import "babylonjs/Shaders/minmaxRedux.fragment";
  61968. /**
  61969. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61970. * and maximum values from all values of the texture.
  61971. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61972. * The source values are read from the red channel of the texture.
  61973. */
  61974. export class MinMaxReducer {
  61975. /**
  61976. * Observable triggered when the computation has been performed
  61977. */
  61978. onAfterReductionPerformed: Observable<{
  61979. min: number;
  61980. max: number;
  61981. }>;
  61982. protected _camera: Camera;
  61983. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61984. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61985. protected _postProcessManager: PostProcessManager;
  61986. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61987. protected _forceFullscreenViewport: boolean;
  61988. /**
  61989. * Creates a min/max reducer
  61990. * @param camera The camera to use for the post processes
  61991. */
  61992. constructor(camera: Camera);
  61993. /**
  61994. * Gets the texture used to read the values from.
  61995. */
  61996. get sourceTexture(): Nullable<RenderTargetTexture>;
  61997. /**
  61998. * Sets the source texture to read the values from.
  61999. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62000. * because in such textures '1' value must not be taken into account to compute the maximum
  62001. * as this value is used to clear the texture.
  62002. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62003. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62004. * @param depthRedux Indicates if the texture is a depth texture or not
  62005. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62006. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62007. */
  62008. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62009. /**
  62010. * Defines the refresh rate of the computation.
  62011. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62012. */
  62013. get refreshRate(): number;
  62014. set refreshRate(value: number);
  62015. protected _activated: boolean;
  62016. /**
  62017. * Gets the activation status of the reducer
  62018. */
  62019. get activated(): boolean;
  62020. /**
  62021. * Activates the reduction computation.
  62022. * When activated, the observers registered in onAfterReductionPerformed are
  62023. * called after the compuation is performed
  62024. */
  62025. activate(): void;
  62026. /**
  62027. * Deactivates the reduction computation.
  62028. */
  62029. deactivate(): void;
  62030. /**
  62031. * Disposes the min/max reducer
  62032. * @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.
  62033. */
  62034. dispose(disposeAll?: boolean): void;
  62035. }
  62036. }
  62037. declare module "babylonjs/Misc/depthReducer" {
  62038. import { Nullable } from "babylonjs/types";
  62039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62040. import { Camera } from "babylonjs/Cameras/camera";
  62041. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62042. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62043. /**
  62044. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62045. */
  62046. export class DepthReducer extends MinMaxReducer {
  62047. private _depthRenderer;
  62048. private _depthRendererId;
  62049. /**
  62050. * Gets the depth renderer used for the computation.
  62051. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62052. */
  62053. get depthRenderer(): Nullable<DepthRenderer>;
  62054. /**
  62055. * Creates a depth reducer
  62056. * @param camera The camera used to render the depth texture
  62057. */
  62058. constructor(camera: Camera);
  62059. /**
  62060. * Sets the depth renderer to use to generate the depth map
  62061. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62062. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62063. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62064. */
  62065. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62066. /** @hidden */
  62067. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62068. /**
  62069. * Activates the reduction computation.
  62070. * When activated, the observers registered in onAfterReductionPerformed are
  62071. * called after the compuation is performed
  62072. */
  62073. activate(): void;
  62074. /**
  62075. * Deactivates the reduction computation.
  62076. */
  62077. deactivate(): void;
  62078. /**
  62079. * Disposes the depth reducer
  62080. * @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.
  62081. */
  62082. dispose(disposeAll?: boolean): void;
  62083. }
  62084. }
  62085. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62086. import { Nullable } from "babylonjs/types";
  62087. import { Scene } from "babylonjs/scene";
  62088. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62089. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62091. import { Effect } from "babylonjs/Materials/effect";
  62092. import "babylonjs/Shaders/shadowMap.fragment";
  62093. import "babylonjs/Shaders/shadowMap.vertex";
  62094. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62095. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62096. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62097. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62098. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62099. /**
  62100. * A CSM implementation allowing casting shadows on large scenes.
  62101. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62102. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62103. */
  62104. export class CascadedShadowGenerator extends ShadowGenerator {
  62105. private static readonly frustumCornersNDCSpace;
  62106. /**
  62107. * Name of the CSM class
  62108. */
  62109. static CLASSNAME: string;
  62110. /**
  62111. * Defines the default number of cascades used by the CSM.
  62112. */
  62113. static readonly DEFAULT_CASCADES_COUNT: number;
  62114. /**
  62115. * Defines the minimum number of cascades used by the CSM.
  62116. */
  62117. static readonly MIN_CASCADES_COUNT: number;
  62118. /**
  62119. * Defines the maximum number of cascades used by the CSM.
  62120. */
  62121. static readonly MAX_CASCADES_COUNT: number;
  62122. protected _validateFilter(filter: number): number;
  62123. /**
  62124. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62125. */
  62126. penumbraDarkness: number;
  62127. private _numCascades;
  62128. /**
  62129. * Gets or set the number of cascades used by the CSM.
  62130. */
  62131. get numCascades(): number;
  62132. set numCascades(value: number);
  62133. /**
  62134. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62135. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62136. */
  62137. stabilizeCascades: boolean;
  62138. private _freezeShadowCastersBoundingInfo;
  62139. private _freezeShadowCastersBoundingInfoObservable;
  62140. /**
  62141. * Enables or disables the shadow casters bounding info computation.
  62142. * If your shadow casters don't move, you can disable this feature.
  62143. * If it is enabled, the bounding box computation is done every frame.
  62144. */
  62145. get freezeShadowCastersBoundingInfo(): boolean;
  62146. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62147. private _scbiMin;
  62148. private _scbiMax;
  62149. protected _computeShadowCastersBoundingInfo(): void;
  62150. protected _shadowCastersBoundingInfo: BoundingInfo;
  62151. /**
  62152. * Gets or sets the shadow casters bounding info.
  62153. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62154. * so that the system won't overwrite the bounds you provide
  62155. */
  62156. get shadowCastersBoundingInfo(): BoundingInfo;
  62157. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62158. protected _breaksAreDirty: boolean;
  62159. protected _minDistance: number;
  62160. protected _maxDistance: number;
  62161. /**
  62162. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62163. *
  62164. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62165. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62166. * @param min minimal distance for the breaks (default to 0.)
  62167. * @param max maximal distance for the breaks (default to 1.)
  62168. */
  62169. setMinMaxDistance(min: number, max: number): void;
  62170. /** Gets the minimal distance used in the cascade break computation */
  62171. get minDistance(): number;
  62172. /** Gets the maximal distance used in the cascade break computation */
  62173. get maxDistance(): number;
  62174. /**
  62175. * Gets the class name of that object
  62176. * @returns "CascadedShadowGenerator"
  62177. */
  62178. getClassName(): string;
  62179. private _cascadeMinExtents;
  62180. private _cascadeMaxExtents;
  62181. /**
  62182. * Gets a cascade minimum extents
  62183. * @param cascadeIndex index of the cascade
  62184. * @returns the minimum cascade extents
  62185. */
  62186. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62187. /**
  62188. * Gets a cascade maximum extents
  62189. * @param cascadeIndex index of the cascade
  62190. * @returns the maximum cascade extents
  62191. */
  62192. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62193. private _cascades;
  62194. private _currentLayer;
  62195. private _viewSpaceFrustumsZ;
  62196. private _viewMatrices;
  62197. private _projectionMatrices;
  62198. private _transformMatrices;
  62199. private _transformMatricesAsArray;
  62200. private _frustumLengths;
  62201. private _lightSizeUVCorrection;
  62202. private _depthCorrection;
  62203. private _frustumCornersWorldSpace;
  62204. private _frustumCenter;
  62205. private _shadowCameraPos;
  62206. private _shadowMaxZ;
  62207. /**
  62208. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62209. * It defaults to camera.maxZ
  62210. */
  62211. get shadowMaxZ(): number;
  62212. /**
  62213. * Sets the shadow max z distance.
  62214. */
  62215. set shadowMaxZ(value: number);
  62216. protected _debug: boolean;
  62217. /**
  62218. * Gets or sets the debug flag.
  62219. * When enabled, the cascades are materialized by different colors on the screen.
  62220. */
  62221. get debug(): boolean;
  62222. set debug(dbg: boolean);
  62223. private _depthClamp;
  62224. /**
  62225. * Gets or sets the depth clamping value.
  62226. *
  62227. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62228. * to account for the shadow casters far away.
  62229. *
  62230. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62231. */
  62232. get depthClamp(): boolean;
  62233. set depthClamp(value: boolean);
  62234. private _cascadeBlendPercentage;
  62235. /**
  62236. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62237. * It defaults to 0.1 (10% blending).
  62238. */
  62239. get cascadeBlendPercentage(): number;
  62240. set cascadeBlendPercentage(value: number);
  62241. private _lambda;
  62242. /**
  62243. * Gets or set the lambda parameter.
  62244. * This parameter is used to split the camera frustum and create the cascades.
  62245. * 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.
  62246. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62247. */
  62248. get lambda(): number;
  62249. set lambda(value: number);
  62250. /**
  62251. * Gets the view matrix corresponding to a given cascade
  62252. * @param cascadeNum cascade to retrieve the view matrix from
  62253. * @returns the cascade view matrix
  62254. */
  62255. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62256. /**
  62257. * Gets the projection matrix corresponding to a given cascade
  62258. * @param cascadeNum cascade to retrieve the projection matrix from
  62259. * @returns the cascade projection matrix
  62260. */
  62261. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62262. /**
  62263. * Gets the transformation matrix corresponding to a given cascade
  62264. * @param cascadeNum cascade to retrieve the transformation matrix from
  62265. * @returns the cascade transformation matrix
  62266. */
  62267. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62268. private _depthRenderer;
  62269. /**
  62270. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62271. *
  62272. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62273. *
  62274. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62275. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62276. * @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
  62277. */
  62278. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62279. private _depthReducer;
  62280. private _autoCalcDepthBounds;
  62281. /**
  62282. * Gets or sets the autoCalcDepthBounds property.
  62283. *
  62284. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62285. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62286. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62287. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62288. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62289. */
  62290. get autoCalcDepthBounds(): boolean;
  62291. set autoCalcDepthBounds(value: boolean);
  62292. /**
  62293. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62294. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62295. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62296. * for setting the refresh rate on the renderer yourself!
  62297. */
  62298. get autoCalcDepthBoundsRefreshRate(): number;
  62299. set autoCalcDepthBoundsRefreshRate(value: number);
  62300. /**
  62301. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62302. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62303. * you change the camera near/far planes!
  62304. */
  62305. splitFrustum(): void;
  62306. private _splitFrustum;
  62307. private _computeMatrices;
  62308. private _computeFrustumInWorldSpace;
  62309. private _computeCascadeFrustum;
  62310. /**
  62311. * Support test.
  62312. */
  62313. static get IsSupported(): boolean;
  62314. /** @hidden */
  62315. static _SceneComponentInitialization: (scene: Scene) => void;
  62316. /**
  62317. * Creates a Cascaded Shadow Generator object.
  62318. * A ShadowGenerator is the required tool to use the shadows.
  62319. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62320. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62321. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62322. * @param light The directional light object generating the shadows.
  62323. * @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.
  62324. */
  62325. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62326. protected _initializeGenerator(): void;
  62327. protected _createTargetRenderTexture(): void;
  62328. protected _initializeShadowMap(): void;
  62329. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62330. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62331. /**
  62332. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62333. * @param defines Defines of the material we want to update
  62334. * @param lightIndex Index of the light in the enabled light list of the material
  62335. */
  62336. prepareDefines(defines: any, lightIndex: number): void;
  62337. /**
  62338. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62339. * defined in the generator but impacting the effect).
  62340. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62341. * @param effect The effect we are binfing the information for
  62342. */
  62343. bindShadowLight(lightIndex: string, effect: Effect): void;
  62344. /**
  62345. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62346. * (eq to view projection * shadow projection matrices)
  62347. * @returns The transform matrix used to create the shadow map
  62348. */
  62349. getTransformMatrix(): Matrix;
  62350. /**
  62351. * Disposes the ShadowGenerator.
  62352. * Returns nothing.
  62353. */
  62354. dispose(): void;
  62355. /**
  62356. * Serializes the shadow generator setup to a json object.
  62357. * @returns The serialized JSON object
  62358. */
  62359. serialize(): any;
  62360. /**
  62361. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62362. * @param parsedShadowGenerator The JSON object to parse
  62363. * @param scene The scene to create the shadow map for
  62364. * @returns The parsed shadow generator
  62365. */
  62366. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62367. }
  62368. }
  62369. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62370. import { Scene } from "babylonjs/scene";
  62371. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62372. import { AbstractScene } from "babylonjs/abstractScene";
  62373. /**
  62374. * Defines the shadow generator component responsible to manage any shadow generators
  62375. * in a given scene.
  62376. */
  62377. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62378. /**
  62379. * The component name helpfull to identify the component in the list of scene components.
  62380. */
  62381. readonly name: string;
  62382. /**
  62383. * The scene the component belongs to.
  62384. */
  62385. scene: Scene;
  62386. /**
  62387. * Creates a new instance of the component for the given scene
  62388. * @param scene Defines the scene to register the component in
  62389. */
  62390. constructor(scene: Scene);
  62391. /**
  62392. * Registers the component in a given scene
  62393. */
  62394. register(): void;
  62395. /**
  62396. * Rebuilds the elements related to this component in case of
  62397. * context lost for instance.
  62398. */
  62399. rebuild(): void;
  62400. /**
  62401. * Serializes the component data to the specified json object
  62402. * @param serializationObject The object to serialize to
  62403. */
  62404. serialize(serializationObject: any): void;
  62405. /**
  62406. * Adds all the elements from the container to the scene
  62407. * @param container the container holding the elements
  62408. */
  62409. addFromContainer(container: AbstractScene): void;
  62410. /**
  62411. * Removes all the elements in the container from the scene
  62412. * @param container contains the elements to remove
  62413. * @param dispose if the removed element should be disposed (default: false)
  62414. */
  62415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62416. /**
  62417. * Rebuilds the elements related to this component in case of
  62418. * context lost for instance.
  62419. */
  62420. dispose(): void;
  62421. private _gatherRenderTargets;
  62422. }
  62423. }
  62424. declare module "babylonjs/Lights/Shadows/index" {
  62425. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62426. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62427. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62428. }
  62429. declare module "babylonjs/Lights/pointLight" {
  62430. import { Scene } from "babylonjs/scene";
  62431. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62433. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62434. import { Effect } from "babylonjs/Materials/effect";
  62435. /**
  62436. * A point light is a light defined by an unique point in world space.
  62437. * The light is emitted in every direction from this point.
  62438. * A good example of a point light is a standard light bulb.
  62439. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62440. */
  62441. export class PointLight extends ShadowLight {
  62442. private _shadowAngle;
  62443. /**
  62444. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62445. * This specifies what angle the shadow will use to be created.
  62446. *
  62447. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62448. */
  62449. get shadowAngle(): number;
  62450. /**
  62451. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62452. * This specifies what angle the shadow will use to be created.
  62453. *
  62454. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62455. */
  62456. set shadowAngle(value: number);
  62457. /**
  62458. * Gets the direction if it has been set.
  62459. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62460. */
  62461. get direction(): Vector3;
  62462. /**
  62463. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62464. */
  62465. set direction(value: Vector3);
  62466. /**
  62467. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62468. * A PointLight emits the light in every direction.
  62469. * It can cast shadows.
  62470. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62471. * ```javascript
  62472. * var pointLight = new PointLight("pl", camera.position, scene);
  62473. * ```
  62474. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62475. * @param name The light friendly name
  62476. * @param position The position of the point light in the scene
  62477. * @param scene The scene the lights belongs to
  62478. */
  62479. constructor(name: string, position: Vector3, scene: Scene);
  62480. /**
  62481. * Returns the string "PointLight"
  62482. * @returns the class name
  62483. */
  62484. getClassName(): string;
  62485. /**
  62486. * Returns the integer 0.
  62487. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62488. */
  62489. getTypeID(): number;
  62490. /**
  62491. * Specifies wether or not the shadowmap should be a cube texture.
  62492. * @returns true if the shadowmap needs to be a cube texture.
  62493. */
  62494. needCube(): boolean;
  62495. /**
  62496. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62497. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62498. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62499. */
  62500. getShadowDirection(faceIndex?: number): Vector3;
  62501. /**
  62502. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62503. * - fov = PI / 2
  62504. * - aspect ratio : 1.0
  62505. * - z-near and far equal to the active camera minZ and maxZ.
  62506. * Returns the PointLight.
  62507. */
  62508. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62509. protected _buildUniformLayout(): void;
  62510. /**
  62511. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62512. * @param effect The effect to update
  62513. * @param lightIndex The index of the light in the effect to update
  62514. * @returns The point light
  62515. */
  62516. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62517. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62518. /**
  62519. * Prepares the list of defines specific to the light type.
  62520. * @param defines the list of defines
  62521. * @param lightIndex defines the index of the light for the effect
  62522. */
  62523. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62524. }
  62525. }
  62526. declare module "babylonjs/Lights/index" {
  62527. export * from "babylonjs/Lights/light";
  62528. export * from "babylonjs/Lights/shadowLight";
  62529. export * from "babylonjs/Lights/Shadows/index";
  62530. export * from "babylonjs/Lights/directionalLight";
  62531. export * from "babylonjs/Lights/hemisphericLight";
  62532. export * from "babylonjs/Lights/pointLight";
  62533. export * from "babylonjs/Lights/spotLight";
  62534. }
  62535. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62536. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62537. /**
  62538. * Header information of HDR texture files.
  62539. */
  62540. export interface HDRInfo {
  62541. /**
  62542. * The height of the texture in pixels.
  62543. */
  62544. height: number;
  62545. /**
  62546. * The width of the texture in pixels.
  62547. */
  62548. width: number;
  62549. /**
  62550. * The index of the beginning of the data in the binary file.
  62551. */
  62552. dataPosition: number;
  62553. }
  62554. /**
  62555. * This groups tools to convert HDR texture to native colors array.
  62556. */
  62557. export class HDRTools {
  62558. private static Ldexp;
  62559. private static Rgbe2float;
  62560. private static readStringLine;
  62561. /**
  62562. * Reads header information from an RGBE texture stored in a native array.
  62563. * More information on this format are available here:
  62564. * https://en.wikipedia.org/wiki/RGBE_image_format
  62565. *
  62566. * @param uint8array The binary file stored in native array.
  62567. * @return The header information.
  62568. */
  62569. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62570. /**
  62571. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62572. * This RGBE texture needs to store the information as a panorama.
  62573. *
  62574. * More information on this format are available here:
  62575. * https://en.wikipedia.org/wiki/RGBE_image_format
  62576. *
  62577. * @param buffer The binary file stored in an array buffer.
  62578. * @param size The expected size of the extracted cubemap.
  62579. * @return The Cube Map information.
  62580. */
  62581. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62582. /**
  62583. * Returns the pixels data extracted from an RGBE texture.
  62584. * This pixels will be stored left to right up to down in the R G B order in one array.
  62585. *
  62586. * More information on this format are available here:
  62587. * https://en.wikipedia.org/wiki/RGBE_image_format
  62588. *
  62589. * @param uint8array The binary file stored in an array buffer.
  62590. * @param hdrInfo The header information of the file.
  62591. * @return The pixels data in RGB right to left up to down order.
  62592. */
  62593. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62594. private static RGBE_ReadPixels_RLE;
  62595. private static RGBE_ReadPixels_NOT_RLE;
  62596. }
  62597. }
  62598. declare module "babylonjs/Materials/effectRenderer" {
  62599. import { Nullable } from "babylonjs/types";
  62600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62601. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62602. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62603. import { Viewport } from "babylonjs/Maths/math.viewport";
  62604. import { Observable } from "babylonjs/Misc/observable";
  62605. import { Effect } from "babylonjs/Materials/effect";
  62606. import "babylonjs/Shaders/postprocess.vertex";
  62607. /**
  62608. * Effect Render Options
  62609. */
  62610. export interface IEffectRendererOptions {
  62611. /**
  62612. * Defines the vertices positions.
  62613. */
  62614. positions?: number[];
  62615. /**
  62616. * Defines the indices.
  62617. */
  62618. indices?: number[];
  62619. }
  62620. /**
  62621. * Helper class to render one or more effects.
  62622. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62623. */
  62624. export class EffectRenderer {
  62625. private engine;
  62626. private static _DefaultOptions;
  62627. private _vertexBuffers;
  62628. private _indexBuffer;
  62629. private _fullscreenViewport;
  62630. /**
  62631. * Creates an effect renderer
  62632. * @param engine the engine to use for rendering
  62633. * @param options defines the options of the effect renderer
  62634. */
  62635. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62636. /**
  62637. * Sets the current viewport in normalized coordinates 0-1
  62638. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62639. */
  62640. setViewport(viewport?: Viewport): void;
  62641. /**
  62642. * Binds the embedded attributes buffer to the effect.
  62643. * @param effect Defines the effect to bind the attributes for
  62644. */
  62645. bindBuffers(effect: Effect): void;
  62646. /**
  62647. * Sets the current effect wrapper to use during draw.
  62648. * The effect needs to be ready before calling this api.
  62649. * This also sets the default full screen position attribute.
  62650. * @param effectWrapper Defines the effect to draw with
  62651. */
  62652. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62653. /**
  62654. * Restores engine states
  62655. */
  62656. restoreStates(): void;
  62657. /**
  62658. * Draws a full screen quad.
  62659. */
  62660. draw(): void;
  62661. private isRenderTargetTexture;
  62662. /**
  62663. * renders one or more effects to a specified texture
  62664. * @param effectWrapper the effect to renderer
  62665. * @param outputTexture texture to draw to, if null it will render to the screen.
  62666. */
  62667. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62668. /**
  62669. * Disposes of the effect renderer
  62670. */
  62671. dispose(): void;
  62672. }
  62673. /**
  62674. * Options to create an EffectWrapper
  62675. */
  62676. interface EffectWrapperCreationOptions {
  62677. /**
  62678. * Engine to use to create the effect
  62679. */
  62680. engine: ThinEngine;
  62681. /**
  62682. * Fragment shader for the effect
  62683. */
  62684. fragmentShader: string;
  62685. /**
  62686. * Use the shader store instead of direct source code
  62687. */
  62688. useShaderStore?: boolean;
  62689. /**
  62690. * Vertex shader for the effect
  62691. */
  62692. vertexShader?: string;
  62693. /**
  62694. * Attributes to use in the shader
  62695. */
  62696. attributeNames?: Array<string>;
  62697. /**
  62698. * Uniforms to use in the shader
  62699. */
  62700. uniformNames?: Array<string>;
  62701. /**
  62702. * Texture sampler names to use in the shader
  62703. */
  62704. samplerNames?: Array<string>;
  62705. /**
  62706. * Defines to use in the shader
  62707. */
  62708. defines?: Array<string>;
  62709. /**
  62710. * Callback when effect is compiled
  62711. */
  62712. onCompiled?: Nullable<(effect: Effect) => void>;
  62713. /**
  62714. * The friendly name of the effect displayed in Spector.
  62715. */
  62716. name?: string;
  62717. }
  62718. /**
  62719. * Wraps an effect to be used for rendering
  62720. */
  62721. export class EffectWrapper {
  62722. /**
  62723. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62724. */
  62725. onApplyObservable: Observable<{}>;
  62726. /**
  62727. * The underlying effect
  62728. */
  62729. effect: Effect;
  62730. /**
  62731. * Creates an effect to be renderer
  62732. * @param creationOptions options to create the effect
  62733. */
  62734. constructor(creationOptions: EffectWrapperCreationOptions);
  62735. /**
  62736. * Disposes of the effect wrapper
  62737. */
  62738. dispose(): void;
  62739. }
  62740. }
  62741. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62742. /** @hidden */
  62743. export var hdrFilteringVertexShader: {
  62744. name: string;
  62745. shader: string;
  62746. };
  62747. }
  62748. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62749. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62750. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62751. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62752. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62753. /** @hidden */
  62754. export var hdrFilteringPixelShader: {
  62755. name: string;
  62756. shader: string;
  62757. };
  62758. }
  62759. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62761. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62762. import { Nullable } from "babylonjs/types";
  62763. import "babylonjs/Shaders/hdrFiltering.vertex";
  62764. import "babylonjs/Shaders/hdrFiltering.fragment";
  62765. /**
  62766. * Options for texture filtering
  62767. */
  62768. interface IHDRFilteringOptions {
  62769. /**
  62770. * Scales pixel intensity for the input HDR map.
  62771. */
  62772. hdrScale?: number;
  62773. /**
  62774. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62775. */
  62776. quality?: number;
  62777. }
  62778. /**
  62779. * Filters HDR maps to get correct renderings of PBR reflections
  62780. */
  62781. export class HDRFiltering {
  62782. private _engine;
  62783. private _effectRenderer;
  62784. private _effectWrapper;
  62785. private _lodGenerationOffset;
  62786. private _lodGenerationScale;
  62787. /**
  62788. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62789. * you care about baking speed.
  62790. */
  62791. quality: number;
  62792. /**
  62793. * Scales pixel intensity for the input HDR map.
  62794. */
  62795. hdrScale: number;
  62796. /**
  62797. * Instantiates HDR filter for reflection maps
  62798. *
  62799. * @param engine Thin engine
  62800. * @param options Options
  62801. */
  62802. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62803. private _createRenderTarget;
  62804. private _prefilterInternal;
  62805. private _createEffect;
  62806. /**
  62807. * Get a value indicating if the filter is ready to be used
  62808. * @param texture Texture to filter
  62809. * @returns true if the filter is ready
  62810. */
  62811. isReady(texture: BaseTexture): boolean;
  62812. /**
  62813. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62814. * Prefiltering will be invoked at the end of next rendering pass.
  62815. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62816. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62817. * @param texture Texture to filter
  62818. * @param onFinished Callback when filtering is done
  62819. * @return Promise called when prefiltering is done
  62820. */
  62821. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62822. }
  62823. }
  62824. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62825. import { Nullable } from "babylonjs/types";
  62826. import { Scene } from "babylonjs/scene";
  62827. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62829. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62830. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62831. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62832. /**
  62833. * This represents a texture coming from an HDR input.
  62834. *
  62835. * The only supported format is currently panorama picture stored in RGBE format.
  62836. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62837. */
  62838. export class HDRCubeTexture extends BaseTexture {
  62839. private static _facesMapping;
  62840. private _generateHarmonics;
  62841. private _noMipmap;
  62842. private _prefilterOnLoad;
  62843. private _textureMatrix;
  62844. private _size;
  62845. private _onLoad;
  62846. private _onError;
  62847. /**
  62848. * The texture URL.
  62849. */
  62850. url: string;
  62851. /**
  62852. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62853. */
  62854. coordinatesMode: number;
  62855. protected _isBlocking: boolean;
  62856. /**
  62857. * Sets wether or not the texture is blocking during loading.
  62858. */
  62859. set isBlocking(value: boolean);
  62860. /**
  62861. * Gets wether or not the texture is blocking during loading.
  62862. */
  62863. get isBlocking(): boolean;
  62864. protected _rotationY: number;
  62865. /**
  62866. * Sets texture matrix rotation angle around Y axis in radians.
  62867. */
  62868. set rotationY(value: number);
  62869. /**
  62870. * Gets texture matrix rotation angle around Y axis radians.
  62871. */
  62872. get rotationY(): number;
  62873. /**
  62874. * Gets or sets the center of the bounding box associated with the cube texture
  62875. * It must define where the camera used to render the texture was set
  62876. */
  62877. boundingBoxPosition: Vector3;
  62878. private _boundingBoxSize;
  62879. /**
  62880. * Gets or sets the size of the bounding box associated with the cube texture
  62881. * When defined, the cubemap will switch to local mode
  62882. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62883. * @example https://www.babylonjs-playground.com/#RNASML
  62884. */
  62885. set boundingBoxSize(value: Vector3);
  62886. get boundingBoxSize(): Vector3;
  62887. /**
  62888. * Instantiates an HDRTexture from the following parameters.
  62889. *
  62890. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62891. * @param sceneOrEngine The scene or engine the texture will be used in
  62892. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62893. * @param noMipmap Forces to not generate the mipmap if true
  62894. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62895. * @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)
  62896. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62897. */
  62898. 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>);
  62899. /**
  62900. * Get the current class name of the texture useful for serialization or dynamic coding.
  62901. * @returns "HDRCubeTexture"
  62902. */
  62903. getClassName(): string;
  62904. /**
  62905. * Occurs when the file is raw .hdr file.
  62906. */
  62907. private loadTexture;
  62908. clone(): HDRCubeTexture;
  62909. delayLoad(): void;
  62910. /**
  62911. * Get the texture reflection matrix used to rotate/transform the reflection.
  62912. * @returns the reflection matrix
  62913. */
  62914. getReflectionTextureMatrix(): Matrix;
  62915. /**
  62916. * Set the texture reflection matrix used to rotate/transform the reflection.
  62917. * @param value Define the reflection matrix to set
  62918. */
  62919. setReflectionTextureMatrix(value: Matrix): void;
  62920. /**
  62921. * Parses a JSON representation of an HDR Texture in order to create the texture
  62922. * @param parsedTexture Define the JSON representation
  62923. * @param scene Define the scene the texture should be created in
  62924. * @param rootUrl Define the root url in case we need to load relative dependencies
  62925. * @returns the newly created texture after parsing
  62926. */
  62927. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62928. serialize(): any;
  62929. }
  62930. }
  62931. declare module "babylonjs/Physics/physicsEngine" {
  62932. import { Nullable } from "babylonjs/types";
  62933. import { Vector3 } from "babylonjs/Maths/math.vector";
  62934. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62935. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62936. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62937. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62938. /**
  62939. * Class used to control physics engine
  62940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62941. */
  62942. export class PhysicsEngine implements IPhysicsEngine {
  62943. private _physicsPlugin;
  62944. /**
  62945. * Global value used to control the smallest number supported by the simulation
  62946. */
  62947. static Epsilon: number;
  62948. private _impostors;
  62949. private _joints;
  62950. private _subTimeStep;
  62951. /**
  62952. * Gets the gravity vector used by the simulation
  62953. */
  62954. gravity: Vector3;
  62955. /**
  62956. * Factory used to create the default physics plugin.
  62957. * @returns The default physics plugin
  62958. */
  62959. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62960. /**
  62961. * Creates a new Physics Engine
  62962. * @param gravity defines the gravity vector used by the simulation
  62963. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62964. */
  62965. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62966. /**
  62967. * Sets the gravity vector used by the simulation
  62968. * @param gravity defines the gravity vector to use
  62969. */
  62970. setGravity(gravity: Vector3): void;
  62971. /**
  62972. * Set the time step of the physics engine.
  62973. * Default is 1/60.
  62974. * To slow it down, enter 1/600 for example.
  62975. * To speed it up, 1/30
  62976. * @param newTimeStep defines the new timestep to apply to this world.
  62977. */
  62978. setTimeStep(newTimeStep?: number): void;
  62979. /**
  62980. * Get the time step of the physics engine.
  62981. * @returns the current time step
  62982. */
  62983. getTimeStep(): number;
  62984. /**
  62985. * Set the sub time step of the physics engine.
  62986. * Default is 0 meaning there is no sub steps
  62987. * To increase physics resolution precision, set a small value (like 1 ms)
  62988. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62989. */
  62990. setSubTimeStep(subTimeStep?: number): void;
  62991. /**
  62992. * Get the sub time step of the physics engine.
  62993. * @returns the current sub time step
  62994. */
  62995. getSubTimeStep(): number;
  62996. /**
  62997. * Release all resources
  62998. */
  62999. dispose(): void;
  63000. /**
  63001. * Gets the name of the current physics plugin
  63002. * @returns the name of the plugin
  63003. */
  63004. getPhysicsPluginName(): string;
  63005. /**
  63006. * Adding a new impostor for the impostor tracking.
  63007. * This will be done by the impostor itself.
  63008. * @param impostor the impostor to add
  63009. */
  63010. addImpostor(impostor: PhysicsImpostor): void;
  63011. /**
  63012. * Remove an impostor from the engine.
  63013. * This impostor and its mesh will not longer be updated by the physics engine.
  63014. * @param impostor the impostor to remove
  63015. */
  63016. removeImpostor(impostor: PhysicsImpostor): void;
  63017. /**
  63018. * Add a joint to the physics engine
  63019. * @param mainImpostor defines the main impostor to which the joint is added.
  63020. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63021. * @param joint defines the joint that will connect both impostors.
  63022. */
  63023. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63024. /**
  63025. * Removes a joint from the simulation
  63026. * @param mainImpostor defines the impostor used with the joint
  63027. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63028. * @param joint defines the joint to remove
  63029. */
  63030. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63031. /**
  63032. * Called by the scene. No need to call it.
  63033. * @param delta defines the timespam between frames
  63034. */
  63035. _step(delta: number): void;
  63036. /**
  63037. * Gets the current plugin used to run the simulation
  63038. * @returns current plugin
  63039. */
  63040. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63041. /**
  63042. * Gets the list of physic impostors
  63043. * @returns an array of PhysicsImpostor
  63044. */
  63045. getImpostors(): Array<PhysicsImpostor>;
  63046. /**
  63047. * Gets the impostor for a physics enabled object
  63048. * @param object defines the object impersonated by the impostor
  63049. * @returns the PhysicsImpostor or null if not found
  63050. */
  63051. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63052. /**
  63053. * Gets the impostor for a physics body object
  63054. * @param body defines physics body used by the impostor
  63055. * @returns the PhysicsImpostor or null if not found
  63056. */
  63057. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63058. /**
  63059. * Does a raycast in the physics world
  63060. * @param from when should the ray start?
  63061. * @param to when should the ray end?
  63062. * @returns PhysicsRaycastResult
  63063. */
  63064. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63065. }
  63066. }
  63067. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63068. import { Nullable } from "babylonjs/types";
  63069. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63071. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63072. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63073. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63074. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63075. /** @hidden */
  63076. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63077. private _useDeltaForWorldStep;
  63078. world: any;
  63079. name: string;
  63080. private _physicsMaterials;
  63081. private _fixedTimeStep;
  63082. private _cannonRaycastResult;
  63083. private _raycastResult;
  63084. private _physicsBodysToRemoveAfterStep;
  63085. private _firstFrame;
  63086. BJSCANNON: any;
  63087. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63088. setGravity(gravity: Vector3): void;
  63089. setTimeStep(timeStep: number): void;
  63090. getTimeStep(): number;
  63091. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63092. private _removeMarkedPhysicsBodiesFromWorld;
  63093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63094. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63096. private _processChildMeshes;
  63097. removePhysicsBody(impostor: PhysicsImpostor): void;
  63098. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63099. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63100. private _addMaterial;
  63101. private _checkWithEpsilon;
  63102. private _createShape;
  63103. private _createHeightmap;
  63104. private _minus90X;
  63105. private _plus90X;
  63106. private _tmpPosition;
  63107. private _tmpDeltaPosition;
  63108. private _tmpUnityRotation;
  63109. private _updatePhysicsBodyTransformation;
  63110. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63111. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63112. isSupported(): boolean;
  63113. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63114. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63115. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63116. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63117. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63118. getBodyMass(impostor: PhysicsImpostor): number;
  63119. getBodyFriction(impostor: PhysicsImpostor): number;
  63120. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63121. getBodyRestitution(impostor: PhysicsImpostor): number;
  63122. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63123. sleepBody(impostor: PhysicsImpostor): void;
  63124. wakeUpBody(impostor: PhysicsImpostor): void;
  63125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63126. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63129. getRadius(impostor: PhysicsImpostor): number;
  63130. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63131. dispose(): void;
  63132. private _extendNamespace;
  63133. /**
  63134. * Does a raycast in the physics world
  63135. * @param from when should the ray start?
  63136. * @param to when should the ray end?
  63137. * @returns PhysicsRaycastResult
  63138. */
  63139. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63140. }
  63141. }
  63142. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63143. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63144. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63145. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63147. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63148. import { Nullable } from "babylonjs/types";
  63149. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63150. /** @hidden */
  63151. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63152. private _useDeltaForWorldStep;
  63153. world: any;
  63154. name: string;
  63155. BJSOIMO: any;
  63156. private _raycastResult;
  63157. private _fixedTimeStep;
  63158. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63159. setGravity(gravity: Vector3): void;
  63160. setTimeStep(timeStep: number): void;
  63161. getTimeStep(): number;
  63162. private _tmpImpostorsArray;
  63163. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63164. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63165. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63166. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63167. private _tmpPositionVector;
  63168. removePhysicsBody(impostor: PhysicsImpostor): void;
  63169. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63170. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63171. isSupported(): boolean;
  63172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63179. getBodyMass(impostor: PhysicsImpostor): number;
  63180. getBodyFriction(impostor: PhysicsImpostor): number;
  63181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63182. getBodyRestitution(impostor: PhysicsImpostor): number;
  63183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63184. sleepBody(impostor: PhysicsImpostor): void;
  63185. wakeUpBody(impostor: PhysicsImpostor): void;
  63186. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63187. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63189. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63190. getRadius(impostor: PhysicsImpostor): number;
  63191. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63192. dispose(): void;
  63193. /**
  63194. * Does a raycast in the physics world
  63195. * @param from when should the ray start?
  63196. * @param to when should the ray end?
  63197. * @returns PhysicsRaycastResult
  63198. */
  63199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63200. }
  63201. }
  63202. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63203. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63204. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63205. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63206. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63207. import { Nullable } from "babylonjs/types";
  63208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63209. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63210. /**
  63211. * AmmoJS Physics plugin
  63212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63213. * @see https://github.com/kripken/ammo.js/
  63214. */
  63215. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63216. private _useDeltaForWorldStep;
  63217. /**
  63218. * Reference to the Ammo library
  63219. */
  63220. bjsAMMO: any;
  63221. /**
  63222. * Created ammoJS world which physics bodies are added to
  63223. */
  63224. world: any;
  63225. /**
  63226. * Name of the plugin
  63227. */
  63228. name: string;
  63229. private _timeStep;
  63230. private _fixedTimeStep;
  63231. private _maxSteps;
  63232. private _tmpQuaternion;
  63233. private _tmpAmmoTransform;
  63234. private _tmpAmmoQuaternion;
  63235. private _tmpAmmoConcreteContactResultCallback;
  63236. private _collisionConfiguration;
  63237. private _dispatcher;
  63238. private _overlappingPairCache;
  63239. private _solver;
  63240. private _softBodySolver;
  63241. private _tmpAmmoVectorA;
  63242. private _tmpAmmoVectorB;
  63243. private _tmpAmmoVectorC;
  63244. private _tmpAmmoVectorD;
  63245. private _tmpContactCallbackResult;
  63246. private _tmpAmmoVectorRCA;
  63247. private _tmpAmmoVectorRCB;
  63248. private _raycastResult;
  63249. private static readonly DISABLE_COLLISION_FLAG;
  63250. private static readonly KINEMATIC_FLAG;
  63251. private static readonly DISABLE_DEACTIVATION_FLAG;
  63252. /**
  63253. * Initializes the ammoJS plugin
  63254. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63255. * @param ammoInjection can be used to inject your own ammo reference
  63256. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63257. */
  63258. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63259. /**
  63260. * Sets the gravity of the physics world (m/(s^2))
  63261. * @param gravity Gravity to set
  63262. */
  63263. setGravity(gravity: Vector3): void;
  63264. /**
  63265. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63266. * @param timeStep timestep to use in seconds
  63267. */
  63268. setTimeStep(timeStep: number): void;
  63269. /**
  63270. * 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)
  63271. * @param fixedTimeStep fixedTimeStep to use in seconds
  63272. */
  63273. setFixedTimeStep(fixedTimeStep: number): void;
  63274. /**
  63275. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63276. * @param maxSteps the maximum number of steps by the physics engine per frame
  63277. */
  63278. setMaxSteps(maxSteps: number): void;
  63279. /**
  63280. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63281. * @returns the current timestep in seconds
  63282. */
  63283. getTimeStep(): number;
  63284. /**
  63285. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63286. */
  63287. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63288. private _isImpostorInContact;
  63289. private _isImpostorPairInContact;
  63290. private _stepSimulation;
  63291. /**
  63292. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63293. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63294. * After the step the babylon meshes are set to the position of the physics imposters
  63295. * @param delta amount of time to step forward
  63296. * @param impostors array of imposters to update before/after the step
  63297. */
  63298. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63299. /**
  63300. * Update babylon mesh to match physics world object
  63301. * @param impostor imposter to match
  63302. */
  63303. private _afterSoftStep;
  63304. /**
  63305. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63306. * @param impostor imposter to match
  63307. */
  63308. private _ropeStep;
  63309. /**
  63310. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63311. * @param impostor imposter to match
  63312. */
  63313. private _softbodyOrClothStep;
  63314. private _tmpMatrix;
  63315. /**
  63316. * Applies an impulse on the imposter
  63317. * @param impostor imposter to apply impulse to
  63318. * @param force amount of force to be applied to the imposter
  63319. * @param contactPoint the location to apply the impulse on the imposter
  63320. */
  63321. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63322. /**
  63323. * Applies a force on the imposter
  63324. * @param impostor imposter to apply force
  63325. * @param force amount of force to be applied to the imposter
  63326. * @param contactPoint the location to apply the force on the imposter
  63327. */
  63328. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63329. /**
  63330. * Creates a physics body using the plugin
  63331. * @param impostor the imposter to create the physics body on
  63332. */
  63333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63334. /**
  63335. * Removes the physics body from the imposter and disposes of the body's memory
  63336. * @param impostor imposter to remove the physics body from
  63337. */
  63338. removePhysicsBody(impostor: PhysicsImpostor): void;
  63339. /**
  63340. * Generates a joint
  63341. * @param impostorJoint the imposter joint to create the joint with
  63342. */
  63343. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63344. /**
  63345. * Removes a joint
  63346. * @param impostorJoint the imposter joint to remove the joint from
  63347. */
  63348. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63349. private _addMeshVerts;
  63350. /**
  63351. * Initialise the soft body vertices to match its object's (mesh) vertices
  63352. * Softbody vertices (nodes) are in world space and to match this
  63353. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63354. * @param impostor to create the softbody for
  63355. */
  63356. private _softVertexData;
  63357. /**
  63358. * Create an impostor's soft body
  63359. * @param impostor to create the softbody for
  63360. */
  63361. private _createSoftbody;
  63362. /**
  63363. * Create cloth for an impostor
  63364. * @param impostor to create the softbody for
  63365. */
  63366. private _createCloth;
  63367. /**
  63368. * Create rope for an impostor
  63369. * @param impostor to create the softbody for
  63370. */
  63371. private _createRope;
  63372. /**
  63373. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63374. * @param impostor to create the custom physics shape for
  63375. */
  63376. private _createCustom;
  63377. private _addHullVerts;
  63378. private _createShape;
  63379. /**
  63380. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63381. * @param impostor imposter containing the physics body and babylon object
  63382. */
  63383. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63384. /**
  63385. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63386. * @param impostor imposter containing the physics body and babylon object
  63387. * @param newPosition new position
  63388. * @param newRotation new rotation
  63389. */
  63390. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63391. /**
  63392. * If this plugin is supported
  63393. * @returns true if its supported
  63394. */
  63395. isSupported(): boolean;
  63396. /**
  63397. * Sets the linear velocity of the physics body
  63398. * @param impostor imposter to set the velocity on
  63399. * @param velocity velocity to set
  63400. */
  63401. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63402. /**
  63403. * Sets the angular velocity of the physics body
  63404. * @param impostor imposter to set the velocity on
  63405. * @param velocity velocity to set
  63406. */
  63407. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63408. /**
  63409. * gets the linear velocity
  63410. * @param impostor imposter to get linear velocity from
  63411. * @returns linear velocity
  63412. */
  63413. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63414. /**
  63415. * gets the angular velocity
  63416. * @param impostor imposter to get angular velocity from
  63417. * @returns angular velocity
  63418. */
  63419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63420. /**
  63421. * Sets the mass of physics body
  63422. * @param impostor imposter to set the mass on
  63423. * @param mass mass to set
  63424. */
  63425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63426. /**
  63427. * Gets the mass of the physics body
  63428. * @param impostor imposter to get the mass from
  63429. * @returns mass
  63430. */
  63431. getBodyMass(impostor: PhysicsImpostor): number;
  63432. /**
  63433. * Gets friction of the impostor
  63434. * @param impostor impostor to get friction from
  63435. * @returns friction value
  63436. */
  63437. getBodyFriction(impostor: PhysicsImpostor): number;
  63438. /**
  63439. * Sets friction of the impostor
  63440. * @param impostor impostor to set friction on
  63441. * @param friction friction value
  63442. */
  63443. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63444. /**
  63445. * Gets restitution of the impostor
  63446. * @param impostor impostor to get restitution from
  63447. * @returns restitution value
  63448. */
  63449. getBodyRestitution(impostor: PhysicsImpostor): number;
  63450. /**
  63451. * Sets resitution of the impostor
  63452. * @param impostor impostor to set resitution on
  63453. * @param restitution resitution value
  63454. */
  63455. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63456. /**
  63457. * Gets pressure inside the impostor
  63458. * @param impostor impostor to get pressure from
  63459. * @returns pressure value
  63460. */
  63461. getBodyPressure(impostor: PhysicsImpostor): number;
  63462. /**
  63463. * Sets pressure inside a soft body impostor
  63464. * Cloth and rope must remain 0 pressure
  63465. * @param impostor impostor to set pressure on
  63466. * @param pressure pressure value
  63467. */
  63468. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63469. /**
  63470. * Gets stiffness of the impostor
  63471. * @param impostor impostor to get stiffness from
  63472. * @returns pressure value
  63473. */
  63474. getBodyStiffness(impostor: PhysicsImpostor): number;
  63475. /**
  63476. * Sets stiffness of the impostor
  63477. * @param impostor impostor to set stiffness on
  63478. * @param stiffness stiffness value from 0 to 1
  63479. */
  63480. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63481. /**
  63482. * Gets velocityIterations of the impostor
  63483. * @param impostor impostor to get velocity iterations from
  63484. * @returns velocityIterations value
  63485. */
  63486. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63487. /**
  63488. * Sets velocityIterations of the impostor
  63489. * @param impostor impostor to set velocity iterations on
  63490. * @param velocityIterations velocityIterations value
  63491. */
  63492. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63493. /**
  63494. * Gets positionIterations of the impostor
  63495. * @param impostor impostor to get position iterations from
  63496. * @returns positionIterations value
  63497. */
  63498. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63499. /**
  63500. * Sets positionIterations of the impostor
  63501. * @param impostor impostor to set position on
  63502. * @param positionIterations positionIterations value
  63503. */
  63504. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63505. /**
  63506. * Append an anchor to a cloth object
  63507. * @param impostor is the cloth impostor to add anchor to
  63508. * @param otherImpostor is the rigid impostor to anchor to
  63509. * @param width ratio across width from 0 to 1
  63510. * @param height ratio up height from 0 to 1
  63511. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63512. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63513. */
  63514. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63515. /**
  63516. * Append an hook to a rope object
  63517. * @param impostor is the rope impostor to add hook to
  63518. * @param otherImpostor is the rigid impostor to hook to
  63519. * @param length ratio along the rope from 0 to 1
  63520. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63521. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63522. */
  63523. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63524. /**
  63525. * Sleeps the physics body and stops it from being active
  63526. * @param impostor impostor to sleep
  63527. */
  63528. sleepBody(impostor: PhysicsImpostor): void;
  63529. /**
  63530. * Activates the physics body
  63531. * @param impostor impostor to activate
  63532. */
  63533. wakeUpBody(impostor: PhysicsImpostor): void;
  63534. /**
  63535. * Updates the distance parameters of the joint
  63536. * @param joint joint to update
  63537. * @param maxDistance maximum distance of the joint
  63538. * @param minDistance minimum distance of the joint
  63539. */
  63540. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63541. /**
  63542. * Sets a motor on the joint
  63543. * @param joint joint to set motor on
  63544. * @param speed speed of the motor
  63545. * @param maxForce maximum force of the motor
  63546. * @param motorIndex index of the motor
  63547. */
  63548. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63549. /**
  63550. * Sets the motors limit
  63551. * @param joint joint to set limit on
  63552. * @param upperLimit upper limit
  63553. * @param lowerLimit lower limit
  63554. */
  63555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63556. /**
  63557. * Syncs the position and rotation of a mesh with the impostor
  63558. * @param mesh mesh to sync
  63559. * @param impostor impostor to update the mesh with
  63560. */
  63561. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63562. /**
  63563. * Gets the radius of the impostor
  63564. * @param impostor impostor to get radius from
  63565. * @returns the radius
  63566. */
  63567. getRadius(impostor: PhysicsImpostor): number;
  63568. /**
  63569. * Gets the box size of the impostor
  63570. * @param impostor impostor to get box size from
  63571. * @param result the resulting box size
  63572. */
  63573. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63574. /**
  63575. * Disposes of the impostor
  63576. */
  63577. dispose(): void;
  63578. /**
  63579. * Does a raycast in the physics world
  63580. * @param from when should the ray start?
  63581. * @param to when should the ray end?
  63582. * @returns PhysicsRaycastResult
  63583. */
  63584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63585. }
  63586. }
  63587. declare module "babylonjs/Probes/reflectionProbe" {
  63588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63589. import { Vector3 } from "babylonjs/Maths/math.vector";
  63590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63591. import { Nullable } from "babylonjs/types";
  63592. import { Scene } from "babylonjs/scene";
  63593. module "babylonjs/abstractScene" {
  63594. interface AbstractScene {
  63595. /**
  63596. * The list of reflection probes added to the scene
  63597. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63598. */
  63599. reflectionProbes: Array<ReflectionProbe>;
  63600. /**
  63601. * Removes the given reflection probe from this scene.
  63602. * @param toRemove The reflection probe to remove
  63603. * @returns The index of the removed reflection probe
  63604. */
  63605. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63606. /**
  63607. * Adds the given reflection probe to this scene.
  63608. * @param newReflectionProbe The reflection probe to add
  63609. */
  63610. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63611. }
  63612. }
  63613. /**
  63614. * Class used to generate realtime reflection / refraction cube textures
  63615. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63616. */
  63617. export class ReflectionProbe {
  63618. /** defines the name of the probe */
  63619. name: string;
  63620. private _scene;
  63621. private _renderTargetTexture;
  63622. private _projectionMatrix;
  63623. private _viewMatrix;
  63624. private _target;
  63625. private _add;
  63626. private _attachedMesh;
  63627. private _invertYAxis;
  63628. /** Gets or sets probe position (center of the cube map) */
  63629. position: Vector3;
  63630. /**
  63631. * Creates a new reflection probe
  63632. * @param name defines the name of the probe
  63633. * @param size defines the texture resolution (for each face)
  63634. * @param scene defines the hosting scene
  63635. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63636. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63637. */
  63638. constructor(
  63639. /** defines the name of the probe */
  63640. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63641. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63642. get samples(): number;
  63643. set samples(value: number);
  63644. /** Gets or sets the refresh rate to use (on every frame by default) */
  63645. get refreshRate(): number;
  63646. set refreshRate(value: number);
  63647. /**
  63648. * Gets the hosting scene
  63649. * @returns a Scene
  63650. */
  63651. getScene(): Scene;
  63652. /** Gets the internal CubeTexture used to render to */
  63653. get cubeTexture(): RenderTargetTexture;
  63654. /** Gets the list of meshes to render */
  63655. get renderList(): Nullable<AbstractMesh[]>;
  63656. /**
  63657. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63658. * @param mesh defines the mesh to attach to
  63659. */
  63660. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63661. /**
  63662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63663. * @param renderingGroupId The rendering group id corresponding to its index
  63664. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63665. */
  63666. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63667. /**
  63668. * Clean all associated resources
  63669. */
  63670. dispose(): void;
  63671. /**
  63672. * Converts the reflection probe information to a readable string for debug purpose.
  63673. * @param fullDetails Supports for multiple levels of logging within scene loading
  63674. * @returns the human readable reflection probe info
  63675. */
  63676. toString(fullDetails?: boolean): string;
  63677. /**
  63678. * Get the class name of the relfection probe.
  63679. * @returns "ReflectionProbe"
  63680. */
  63681. getClassName(): string;
  63682. /**
  63683. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63684. * @returns The JSON representation of the texture
  63685. */
  63686. serialize(): any;
  63687. /**
  63688. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63689. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63690. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63691. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63692. * @returns The parsed reflection probe if successful
  63693. */
  63694. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63695. }
  63696. }
  63697. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63698. /** @hidden */
  63699. export var _BabylonLoaderRegistered: boolean;
  63700. /**
  63701. * Helps setting up some configuration for the babylon file loader.
  63702. */
  63703. export class BabylonFileLoaderConfiguration {
  63704. /**
  63705. * The loader does not allow injecting custom physix engine into the plugins.
  63706. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63707. * So you could set this variable to your engine import to make it work.
  63708. */
  63709. static LoaderInjectedPhysicsEngine: any;
  63710. }
  63711. }
  63712. declare module "babylonjs/Loading/Plugins/index" {
  63713. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63714. }
  63715. declare module "babylonjs/Loading/index" {
  63716. export * from "babylonjs/Loading/loadingScreen";
  63717. export * from "babylonjs/Loading/Plugins/index";
  63718. export * from "babylonjs/Loading/sceneLoader";
  63719. export * from "babylonjs/Loading/sceneLoaderFlags";
  63720. }
  63721. declare module "babylonjs/Materials/Background/index" {
  63722. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63723. }
  63724. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63725. import { Scene } from "babylonjs/scene";
  63726. import { Color3 } from "babylonjs/Maths/math.color";
  63727. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63729. /**
  63730. * The Physically based simple base material of BJS.
  63731. *
  63732. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63733. * It is used as the base class for both the specGloss and metalRough conventions.
  63734. */
  63735. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63736. /**
  63737. * Number of Simultaneous lights allowed on the material.
  63738. */
  63739. maxSimultaneousLights: number;
  63740. /**
  63741. * If sets to true, disables all the lights affecting the material.
  63742. */
  63743. disableLighting: boolean;
  63744. /**
  63745. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63746. */
  63747. environmentTexture: BaseTexture;
  63748. /**
  63749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63750. */
  63751. invertNormalMapX: boolean;
  63752. /**
  63753. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63754. */
  63755. invertNormalMapY: boolean;
  63756. /**
  63757. * Normal map used in the model.
  63758. */
  63759. normalTexture: BaseTexture;
  63760. /**
  63761. * Emissivie color used to self-illuminate the model.
  63762. */
  63763. emissiveColor: Color3;
  63764. /**
  63765. * Emissivie texture used to self-illuminate the model.
  63766. */
  63767. emissiveTexture: BaseTexture;
  63768. /**
  63769. * Occlusion Channel Strenght.
  63770. */
  63771. occlusionStrength: number;
  63772. /**
  63773. * Occlusion Texture of the material (adding extra occlusion effects).
  63774. */
  63775. occlusionTexture: BaseTexture;
  63776. /**
  63777. * Defines the alpha limits in alpha test mode.
  63778. */
  63779. alphaCutOff: number;
  63780. /**
  63781. * Gets the current double sided mode.
  63782. */
  63783. get doubleSided(): boolean;
  63784. /**
  63785. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63786. */
  63787. set doubleSided(value: boolean);
  63788. /**
  63789. * Stores the pre-calculated light information of a mesh in a texture.
  63790. */
  63791. lightmapTexture: BaseTexture;
  63792. /**
  63793. * If true, the light map contains occlusion information instead of lighting info.
  63794. */
  63795. useLightmapAsShadowmap: boolean;
  63796. /**
  63797. * Instantiates a new PBRMaterial instance.
  63798. *
  63799. * @param name The material name
  63800. * @param scene The scene the material will be use in.
  63801. */
  63802. constructor(name: string, scene: Scene);
  63803. getClassName(): string;
  63804. }
  63805. }
  63806. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63807. import { Scene } from "babylonjs/scene";
  63808. import { Color3 } from "babylonjs/Maths/math.color";
  63809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63810. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63811. /**
  63812. * The PBR material of BJS following the metal roughness convention.
  63813. *
  63814. * This fits to the PBR convention in the GLTF definition:
  63815. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63816. */
  63817. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63818. /**
  63819. * The base color has two different interpretations depending on the value of metalness.
  63820. * When the material is a metal, the base color is the specific measured reflectance value
  63821. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63822. * of the material.
  63823. */
  63824. baseColor: Color3;
  63825. /**
  63826. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63827. * well as opacity information in the alpha channel.
  63828. */
  63829. baseTexture: BaseTexture;
  63830. /**
  63831. * Specifies the metallic scalar value of the material.
  63832. * Can also be used to scale the metalness values of the metallic texture.
  63833. */
  63834. metallic: number;
  63835. /**
  63836. * Specifies the roughness scalar value of the material.
  63837. * Can also be used to scale the roughness values of the metallic texture.
  63838. */
  63839. roughness: number;
  63840. /**
  63841. * Texture containing both the metallic value in the B channel and the
  63842. * roughness value in the G channel to keep better precision.
  63843. */
  63844. metallicRoughnessTexture: BaseTexture;
  63845. /**
  63846. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63847. *
  63848. * @param name The material name
  63849. * @param scene The scene the material will be use in.
  63850. */
  63851. constructor(name: string, scene: Scene);
  63852. /**
  63853. * Return the currrent class name of the material.
  63854. */
  63855. getClassName(): string;
  63856. /**
  63857. * Makes a duplicate of the current material.
  63858. * @param name - name to use for the new material.
  63859. */
  63860. clone(name: string): PBRMetallicRoughnessMaterial;
  63861. /**
  63862. * Serialize the material to a parsable JSON object.
  63863. */
  63864. serialize(): any;
  63865. /**
  63866. * Parses a JSON object correponding to the serialize function.
  63867. */
  63868. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63869. }
  63870. }
  63871. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63872. import { Scene } from "babylonjs/scene";
  63873. import { Color3 } from "babylonjs/Maths/math.color";
  63874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63875. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63876. /**
  63877. * The PBR material of BJS following the specular glossiness convention.
  63878. *
  63879. * This fits to the PBR convention in the GLTF definition:
  63880. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63881. */
  63882. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63883. /**
  63884. * Specifies the diffuse color of the material.
  63885. */
  63886. diffuseColor: Color3;
  63887. /**
  63888. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63889. * channel.
  63890. */
  63891. diffuseTexture: BaseTexture;
  63892. /**
  63893. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63894. */
  63895. specularColor: Color3;
  63896. /**
  63897. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63898. */
  63899. glossiness: number;
  63900. /**
  63901. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63902. */
  63903. specularGlossinessTexture: BaseTexture;
  63904. /**
  63905. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63906. *
  63907. * @param name The material name
  63908. * @param scene The scene the material will be use in.
  63909. */
  63910. constructor(name: string, scene: Scene);
  63911. /**
  63912. * Return the currrent class name of the material.
  63913. */
  63914. getClassName(): string;
  63915. /**
  63916. * Makes a duplicate of the current material.
  63917. * @param name - name to use for the new material.
  63918. */
  63919. clone(name: string): PBRSpecularGlossinessMaterial;
  63920. /**
  63921. * Serialize the material to a parsable JSON object.
  63922. */
  63923. serialize(): any;
  63924. /**
  63925. * Parses a JSON object correponding to the serialize function.
  63926. */
  63927. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63928. }
  63929. }
  63930. declare module "babylonjs/Materials/PBR/index" {
  63931. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63932. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63933. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63934. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63935. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63936. }
  63937. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63938. import { Nullable } from "babylonjs/types";
  63939. import { Scene } from "babylonjs/scene";
  63940. import { Matrix } from "babylonjs/Maths/math.vector";
  63941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63942. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63943. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63944. /**
  63945. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63946. * It can help converting any input color in a desired output one. This can then be used to create effects
  63947. * from sepia, black and white to sixties or futuristic rendering...
  63948. *
  63949. * The only supported format is currently 3dl.
  63950. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63951. */
  63952. export class ColorGradingTexture extends BaseTexture {
  63953. /**
  63954. * The texture URL.
  63955. */
  63956. url: string;
  63957. /**
  63958. * Empty line regex stored for GC.
  63959. */
  63960. private static _noneEmptyLineRegex;
  63961. private _textureMatrix;
  63962. private _onLoad;
  63963. /**
  63964. * Instantiates a ColorGradingTexture from the following parameters.
  63965. *
  63966. * @param url The location of the color gradind data (currently only supporting 3dl)
  63967. * @param sceneOrEngine The scene or engine the texture will be used in
  63968. * @param onLoad defines a callback triggered when the texture has been loaded
  63969. */
  63970. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63971. /**
  63972. * Fires the onload event from the constructor if requested.
  63973. */
  63974. private _triggerOnLoad;
  63975. /**
  63976. * Returns the texture matrix used in most of the material.
  63977. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63978. */
  63979. getTextureMatrix(): Matrix;
  63980. /**
  63981. * Occurs when the file being loaded is a .3dl LUT file.
  63982. */
  63983. private load3dlTexture;
  63984. /**
  63985. * Starts the loading process of the texture.
  63986. */
  63987. private loadTexture;
  63988. /**
  63989. * Clones the color gradind texture.
  63990. */
  63991. clone(): ColorGradingTexture;
  63992. /**
  63993. * Called during delayed load for textures.
  63994. */
  63995. delayLoad(): void;
  63996. /**
  63997. * Parses a color grading texture serialized by Babylon.
  63998. * @param parsedTexture The texture information being parsedTexture
  63999. * @param scene The scene to load the texture in
  64000. * @param rootUrl The root url of the data assets to load
  64001. * @return A color gradind texture
  64002. */
  64003. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64004. /**
  64005. * Serializes the LUT texture to json format.
  64006. */
  64007. serialize(): any;
  64008. }
  64009. }
  64010. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64012. import { Scene } from "babylonjs/scene";
  64013. import { Nullable } from "babylonjs/types";
  64014. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64015. /**
  64016. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64017. */
  64018. export class EquiRectangularCubeTexture extends BaseTexture {
  64019. /** The six faces of the cube. */
  64020. private static _FacesMapping;
  64021. private _noMipmap;
  64022. private _onLoad;
  64023. private _onError;
  64024. /** The size of the cubemap. */
  64025. private _size;
  64026. /** The buffer of the image. */
  64027. private _buffer;
  64028. /** The width of the input image. */
  64029. private _width;
  64030. /** The height of the input image. */
  64031. private _height;
  64032. /** The URL to the image. */
  64033. url: string;
  64034. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  64035. coordinatesMode: number;
  64036. /**
  64037. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64038. * @param url The location of the image
  64039. * @param scene The scene the texture will be used in
  64040. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64041. * @param noMipmap Forces to not generate the mipmap if true
  64042. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64043. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64044. * @param onLoad — defines a callback called when texture is loaded
  64045. * @param onError — defines a callback called if there is an error
  64046. */
  64047. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64048. /**
  64049. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64050. */
  64051. private loadImage;
  64052. /**
  64053. * Convert the image buffer into a cubemap and create a CubeTexture.
  64054. */
  64055. private loadTexture;
  64056. /**
  64057. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64058. * @param buffer The ArrayBuffer that should be converted.
  64059. * @returns The buffer as Float32Array.
  64060. */
  64061. private getFloat32ArrayFromArrayBuffer;
  64062. /**
  64063. * Get the current class name of the texture useful for serialization or dynamic coding.
  64064. * @returns "EquiRectangularCubeTexture"
  64065. */
  64066. getClassName(): string;
  64067. /**
  64068. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64069. * @returns A clone of the current EquiRectangularCubeTexture.
  64070. */
  64071. clone(): EquiRectangularCubeTexture;
  64072. }
  64073. }
  64074. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64075. import { Nullable } from "babylonjs/types";
  64076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64077. import { Matrix } from "babylonjs/Maths/math.vector";
  64078. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64079. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64080. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64081. import { Scene } from "babylonjs/scene";
  64082. /**
  64083. * Defines the options related to the creation of an HtmlElementTexture
  64084. */
  64085. export interface IHtmlElementTextureOptions {
  64086. /**
  64087. * Defines wether mip maps should be created or not.
  64088. */
  64089. generateMipMaps?: boolean;
  64090. /**
  64091. * Defines the sampling mode of the texture.
  64092. */
  64093. samplingMode?: number;
  64094. /**
  64095. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64096. */
  64097. engine: Nullable<ThinEngine>;
  64098. /**
  64099. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64100. */
  64101. scene: Nullable<Scene>;
  64102. }
  64103. /**
  64104. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64105. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64106. * is automatically managed.
  64107. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64108. * in your application.
  64109. *
  64110. * As the update is not automatic, you need to call them manually.
  64111. */
  64112. export class HtmlElementTexture extends BaseTexture {
  64113. /**
  64114. * The texture URL.
  64115. */
  64116. element: HTMLVideoElement | HTMLCanvasElement;
  64117. private static readonly DefaultOptions;
  64118. private _textureMatrix;
  64119. private _isVideo;
  64120. private _generateMipMaps;
  64121. private _samplingMode;
  64122. /**
  64123. * Instantiates a HtmlElementTexture from the following parameters.
  64124. *
  64125. * @param name Defines the name of the texture
  64126. * @param element Defines the video or canvas the texture is filled with
  64127. * @param options Defines the other none mandatory texture creation options
  64128. */
  64129. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64130. private _createInternalTexture;
  64131. /**
  64132. * Returns the texture matrix used in most of the material.
  64133. */
  64134. getTextureMatrix(): Matrix;
  64135. /**
  64136. * Updates the content of the texture.
  64137. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64138. */
  64139. update(invertY?: Nullable<boolean>): void;
  64140. }
  64141. }
  64142. declare module "babylonjs/Misc/tga" {
  64143. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64144. /**
  64145. * Based on jsTGALoader - Javascript loader for TGA file
  64146. * By Vincent Thibault
  64147. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64148. */
  64149. export class TGATools {
  64150. private static _TYPE_INDEXED;
  64151. private static _TYPE_RGB;
  64152. private static _TYPE_GREY;
  64153. private static _TYPE_RLE_INDEXED;
  64154. private static _TYPE_RLE_RGB;
  64155. private static _TYPE_RLE_GREY;
  64156. private static _ORIGIN_MASK;
  64157. private static _ORIGIN_SHIFT;
  64158. private static _ORIGIN_BL;
  64159. private static _ORIGIN_BR;
  64160. private static _ORIGIN_UL;
  64161. private static _ORIGIN_UR;
  64162. /**
  64163. * Gets the header of a TGA file
  64164. * @param data defines the TGA data
  64165. * @returns the header
  64166. */
  64167. static GetTGAHeader(data: Uint8Array): any;
  64168. /**
  64169. * Uploads TGA content to a Babylon Texture
  64170. * @hidden
  64171. */
  64172. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64173. /** @hidden */
  64174. 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;
  64175. /** @hidden */
  64176. 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;
  64177. /** @hidden */
  64178. 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;
  64179. /** @hidden */
  64180. 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;
  64181. /** @hidden */
  64182. 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;
  64183. /** @hidden */
  64184. 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;
  64185. }
  64186. }
  64187. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64188. import { Nullable } from "babylonjs/types";
  64189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64190. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64191. /**
  64192. * Implementation of the TGA Texture Loader.
  64193. * @hidden
  64194. */
  64195. export class _TGATextureLoader implements IInternalTextureLoader {
  64196. /**
  64197. * Defines wether the loader supports cascade loading the different faces.
  64198. */
  64199. readonly supportCascades: boolean;
  64200. /**
  64201. * This returns if the loader support the current file information.
  64202. * @param extension defines the file extension of the file being loaded
  64203. * @returns true if the loader can load the specified file
  64204. */
  64205. canLoad(extension: string): boolean;
  64206. /**
  64207. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64208. * @param data contains the texture data
  64209. * @param texture defines the BabylonJS internal texture
  64210. * @param createPolynomials will be true if polynomials have been requested
  64211. * @param onLoad defines the callback to trigger once the texture is ready
  64212. * @param onError defines the callback to trigger in case of error
  64213. */
  64214. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64215. /**
  64216. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64217. * @param data contains the texture data
  64218. * @param texture defines the BabylonJS internal texture
  64219. * @param callback defines the method to call once ready to upload
  64220. */
  64221. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64222. }
  64223. }
  64224. declare module "babylonjs/Misc/basis" {
  64225. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64226. /**
  64227. * Info about the .basis files
  64228. */
  64229. class BasisFileInfo {
  64230. /**
  64231. * If the file has alpha
  64232. */
  64233. hasAlpha: boolean;
  64234. /**
  64235. * Info about each image of the basis file
  64236. */
  64237. images: Array<{
  64238. levels: Array<{
  64239. width: number;
  64240. height: number;
  64241. transcodedPixels: ArrayBufferView;
  64242. }>;
  64243. }>;
  64244. }
  64245. /**
  64246. * Result of transcoding a basis file
  64247. */
  64248. class TranscodeResult {
  64249. /**
  64250. * Info about the .basis file
  64251. */
  64252. fileInfo: BasisFileInfo;
  64253. /**
  64254. * Format to use when loading the file
  64255. */
  64256. format: number;
  64257. }
  64258. /**
  64259. * Configuration options for the Basis transcoder
  64260. */
  64261. export class BasisTranscodeConfiguration {
  64262. /**
  64263. * Supported compression formats used to determine the supported output format of the transcoder
  64264. */
  64265. supportedCompressionFormats?: {
  64266. /**
  64267. * etc1 compression format
  64268. */
  64269. etc1?: boolean;
  64270. /**
  64271. * s3tc compression format
  64272. */
  64273. s3tc?: boolean;
  64274. /**
  64275. * pvrtc compression format
  64276. */
  64277. pvrtc?: boolean;
  64278. /**
  64279. * etc2 compression format
  64280. */
  64281. etc2?: boolean;
  64282. };
  64283. /**
  64284. * If mipmap levels should be loaded for transcoded images (Default: true)
  64285. */
  64286. loadMipmapLevels?: boolean;
  64287. /**
  64288. * Index of a single image to load (Default: all images)
  64289. */
  64290. loadSingleImage?: number;
  64291. }
  64292. /**
  64293. * Used to load .Basis files
  64294. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64295. */
  64296. export class BasisTools {
  64297. private static _IgnoreSupportedFormats;
  64298. /**
  64299. * URL to use when loading the basis transcoder
  64300. */
  64301. static JSModuleURL: string;
  64302. /**
  64303. * URL to use when loading the wasm module for the transcoder
  64304. */
  64305. static WasmModuleURL: string;
  64306. /**
  64307. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64308. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64309. * @returns internal format corresponding to the Basis format
  64310. */
  64311. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64312. private static _WorkerPromise;
  64313. private static _Worker;
  64314. private static _actionId;
  64315. private static _CreateWorkerAsync;
  64316. /**
  64317. * Transcodes a loaded image file to compressed pixel data
  64318. * @param data image data to transcode
  64319. * @param config configuration options for the transcoding
  64320. * @returns a promise resulting in the transcoded image
  64321. */
  64322. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64323. /**
  64324. * Loads a texture from the transcode result
  64325. * @param texture texture load to
  64326. * @param transcodeResult the result of transcoding the basis file to load from
  64327. */
  64328. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64329. }
  64330. }
  64331. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64332. import { Nullable } from "babylonjs/types";
  64333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64334. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64335. /**
  64336. * Loader for .basis file format
  64337. */
  64338. export class _BasisTextureLoader implements IInternalTextureLoader {
  64339. /**
  64340. * Defines whether the loader supports cascade loading the different faces.
  64341. */
  64342. readonly supportCascades: boolean;
  64343. /**
  64344. * This returns if the loader support the current file information.
  64345. * @param extension defines the file extension of the file being loaded
  64346. * @returns true if the loader can load the specified file
  64347. */
  64348. canLoad(extension: string): boolean;
  64349. /**
  64350. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64351. * @param data contains the texture data
  64352. * @param texture defines the BabylonJS internal texture
  64353. * @param createPolynomials will be true if polynomials have been requested
  64354. * @param onLoad defines the callback to trigger once the texture is ready
  64355. * @param onError defines the callback to trigger in case of error
  64356. */
  64357. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64358. /**
  64359. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64360. * @param data contains the texture data
  64361. * @param texture defines the BabylonJS internal texture
  64362. * @param callback defines the method to call once ready to upload
  64363. */
  64364. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64365. }
  64366. }
  64367. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64368. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64369. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64370. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64371. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64372. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64373. }
  64374. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64375. import { Vector2 } from "babylonjs/Maths/math.vector";
  64376. /**
  64377. * Defines the basic options interface of a TexturePacker Frame
  64378. */
  64379. export interface ITexturePackerFrame {
  64380. /**
  64381. * The frame ID
  64382. */
  64383. id: number;
  64384. /**
  64385. * The frames Scale
  64386. */
  64387. scale: Vector2;
  64388. /**
  64389. * The Frames offset
  64390. */
  64391. offset: Vector2;
  64392. }
  64393. /**
  64394. * This is a support class for frame Data on texture packer sets.
  64395. */
  64396. export class TexturePackerFrame implements ITexturePackerFrame {
  64397. /**
  64398. * The frame ID
  64399. */
  64400. id: number;
  64401. /**
  64402. * The frames Scale
  64403. */
  64404. scale: Vector2;
  64405. /**
  64406. * The Frames offset
  64407. */
  64408. offset: Vector2;
  64409. /**
  64410. * Initializes a texture package frame.
  64411. * @param id The numerical frame identifier
  64412. * @param scale Scalar Vector2 for UV frame
  64413. * @param offset Vector2 for the frame position in UV units.
  64414. * @returns TexturePackerFrame
  64415. */
  64416. constructor(id: number, scale: Vector2, offset: Vector2);
  64417. }
  64418. }
  64419. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64421. import { Scene } from "babylonjs/scene";
  64422. import { Nullable } from "babylonjs/types";
  64423. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64424. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64425. /**
  64426. * Defines the basic options interface of a TexturePacker
  64427. */
  64428. export interface ITexturePackerOptions {
  64429. /**
  64430. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64431. */
  64432. map?: string[];
  64433. /**
  64434. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64435. */
  64436. uvsIn?: string;
  64437. /**
  64438. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64439. */
  64440. uvsOut?: string;
  64441. /**
  64442. * number representing the layout style. Defaults to LAYOUT_STRIP
  64443. */
  64444. layout?: number;
  64445. /**
  64446. * number of columns if using custom column count layout(2). This defaults to 4.
  64447. */
  64448. colnum?: number;
  64449. /**
  64450. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64451. */
  64452. updateInputMeshes?: boolean;
  64453. /**
  64454. * boolean flag to dispose all the source textures. Defaults to true.
  64455. */
  64456. disposeSources?: boolean;
  64457. /**
  64458. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64459. */
  64460. fillBlanks?: boolean;
  64461. /**
  64462. * string value representing the context fill style color. Defaults to 'black'.
  64463. */
  64464. customFillColor?: string;
  64465. /**
  64466. * Width and Height Value of each Frame in the TexturePacker Sets
  64467. */
  64468. frameSize?: number;
  64469. /**
  64470. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64471. */
  64472. paddingRatio?: number;
  64473. /**
  64474. * Number that declares the fill method for the padding gutter.
  64475. */
  64476. paddingMode?: number;
  64477. /**
  64478. * If in SUBUV_COLOR padding mode what color to use.
  64479. */
  64480. paddingColor?: Color3 | Color4;
  64481. }
  64482. /**
  64483. * Defines the basic interface of a TexturePacker JSON File
  64484. */
  64485. export interface ITexturePackerJSON {
  64486. /**
  64487. * The frame ID
  64488. */
  64489. name: string;
  64490. /**
  64491. * The base64 channel data
  64492. */
  64493. sets: any;
  64494. /**
  64495. * The options of the Packer
  64496. */
  64497. options: ITexturePackerOptions;
  64498. /**
  64499. * The frame data of the Packer
  64500. */
  64501. frames: Array<number>;
  64502. }
  64503. /**
  64504. * This is a support class that generates a series of packed texture sets.
  64505. * @see https://doc.babylonjs.com/babylon101/materials
  64506. */
  64507. export class TexturePacker {
  64508. /** Packer Layout Constant 0 */
  64509. static readonly LAYOUT_STRIP: number;
  64510. /** Packer Layout Constant 1 */
  64511. static readonly LAYOUT_POWER2: number;
  64512. /** Packer Layout Constant 2 */
  64513. static readonly LAYOUT_COLNUM: number;
  64514. /** Packer Layout Constant 0 */
  64515. static readonly SUBUV_WRAP: number;
  64516. /** Packer Layout Constant 1 */
  64517. static readonly SUBUV_EXTEND: number;
  64518. /** Packer Layout Constant 2 */
  64519. static readonly SUBUV_COLOR: number;
  64520. /** The Name of the Texture Package */
  64521. name: string;
  64522. /** The scene scope of the TexturePacker */
  64523. scene: Scene;
  64524. /** The Meshes to target */
  64525. meshes: AbstractMesh[];
  64526. /** Arguments passed with the Constructor */
  64527. options: ITexturePackerOptions;
  64528. /** The promise that is started upon initialization */
  64529. promise: Nullable<Promise<TexturePacker | string>>;
  64530. /** The Container object for the channel sets that are generated */
  64531. sets: object;
  64532. /** The Container array for the frames that are generated */
  64533. frames: TexturePackerFrame[];
  64534. /** The expected number of textures the system is parsing. */
  64535. private _expecting;
  64536. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64537. private _paddingValue;
  64538. /**
  64539. * Initializes a texture package series from an array of meshes or a single mesh.
  64540. * @param name The name of the package
  64541. * @param meshes The target meshes to compose the package from
  64542. * @param options The arguments that texture packer should follow while building.
  64543. * @param scene The scene which the textures are scoped to.
  64544. * @returns TexturePacker
  64545. */
  64546. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64547. /**
  64548. * Starts the package process
  64549. * @param resolve The promises resolution function
  64550. * @returns TexturePacker
  64551. */
  64552. private _createFrames;
  64553. /**
  64554. * Calculates the Size of the Channel Sets
  64555. * @returns Vector2
  64556. */
  64557. private _calculateSize;
  64558. /**
  64559. * Calculates the UV data for the frames.
  64560. * @param baseSize the base frameSize
  64561. * @param padding the base frame padding
  64562. * @param dtSize size of the Dynamic Texture for that channel
  64563. * @param dtUnits is 1/dtSize
  64564. * @param update flag to update the input meshes
  64565. */
  64566. private _calculateMeshUVFrames;
  64567. /**
  64568. * Calculates the frames Offset.
  64569. * @param index of the frame
  64570. * @returns Vector2
  64571. */
  64572. private _getFrameOffset;
  64573. /**
  64574. * Updates a Mesh to the frame data
  64575. * @param mesh that is the target
  64576. * @param frameID or the frame index
  64577. */
  64578. private _updateMeshUV;
  64579. /**
  64580. * Updates a Meshes materials to use the texture packer channels
  64581. * @param m is the mesh to target
  64582. * @param force all channels on the packer to be set.
  64583. */
  64584. private _updateTextureReferences;
  64585. /**
  64586. * Public method to set a Mesh to a frame
  64587. * @param m that is the target
  64588. * @param frameID or the frame index
  64589. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64590. */
  64591. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64592. /**
  64593. * Starts the async promise to compile the texture packer.
  64594. * @returns Promise<void>
  64595. */
  64596. processAsync(): Promise<void>;
  64597. /**
  64598. * Disposes all textures associated with this packer
  64599. */
  64600. dispose(): void;
  64601. /**
  64602. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64603. * @param imageType is the image type to use.
  64604. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64605. */
  64606. download(imageType?: string, quality?: number): void;
  64607. /**
  64608. * Public method to load a texturePacker JSON file.
  64609. * @param data of the JSON file in string format.
  64610. */
  64611. updateFromJSON(data: string): void;
  64612. }
  64613. }
  64614. declare module "babylonjs/Materials/Textures/Packer/index" {
  64615. export * from "babylonjs/Materials/Textures/Packer/packer";
  64616. export * from "babylonjs/Materials/Textures/Packer/frame";
  64617. }
  64618. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64619. import { Scene } from "babylonjs/scene";
  64620. import { Texture } from "babylonjs/Materials/Textures/texture";
  64621. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64622. /**
  64623. * 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.
  64624. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64625. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64626. */
  64627. export class CustomProceduralTexture extends ProceduralTexture {
  64628. private _animate;
  64629. private _time;
  64630. private _config;
  64631. private _texturePath;
  64632. /**
  64633. * Instantiates a new Custom Procedural Texture.
  64634. * 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.
  64635. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64636. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64637. * @param name Define the name of the texture
  64638. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64639. * @param size Define the size of the texture to create
  64640. * @param scene Define the scene the texture belongs to
  64641. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64642. * @param generateMipMaps Define if the texture should creates mip maps or not
  64643. */
  64644. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64645. private _loadJson;
  64646. /**
  64647. * Is the texture ready to be used ? (rendered at least once)
  64648. * @returns true if ready, otherwise, false.
  64649. */
  64650. isReady(): boolean;
  64651. /**
  64652. * Render the texture to its associated render target.
  64653. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64654. */
  64655. render(useCameraPostProcess?: boolean): void;
  64656. /**
  64657. * Update the list of dependant textures samplers in the shader.
  64658. */
  64659. updateTextures(): void;
  64660. /**
  64661. * Update the uniform values of the procedural texture in the shader.
  64662. */
  64663. updateShaderUniforms(): void;
  64664. /**
  64665. * Define if the texture animates or not.
  64666. */
  64667. get animate(): boolean;
  64668. set animate(value: boolean);
  64669. }
  64670. }
  64671. declare module "babylonjs/Shaders/noise.fragment" {
  64672. /** @hidden */
  64673. export var noisePixelShader: {
  64674. name: string;
  64675. shader: string;
  64676. };
  64677. }
  64678. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64679. import { Nullable } from "babylonjs/types";
  64680. import { Scene } from "babylonjs/scene";
  64681. import { Texture } from "babylonjs/Materials/Textures/texture";
  64682. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64683. import "babylonjs/Shaders/noise.fragment";
  64684. /**
  64685. * Class used to generate noise procedural textures
  64686. */
  64687. export class NoiseProceduralTexture extends ProceduralTexture {
  64688. private _time;
  64689. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64690. brightness: number;
  64691. /** Defines the number of octaves to process */
  64692. octaves: number;
  64693. /** Defines the level of persistence (0.8 by default) */
  64694. persistence: number;
  64695. /** Gets or sets animation speed factor (default is 1) */
  64696. animationSpeedFactor: number;
  64697. /**
  64698. * Creates a new NoiseProceduralTexture
  64699. * @param name defines the name fo the texture
  64700. * @param size defines the size of the texture (default is 256)
  64701. * @param scene defines the hosting scene
  64702. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64703. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64704. */
  64705. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64706. private _updateShaderUniforms;
  64707. protected _getDefines(): string;
  64708. /** Generate the current state of the procedural texture */
  64709. render(useCameraPostProcess?: boolean): void;
  64710. /**
  64711. * Serializes this noise procedural texture
  64712. * @returns a serialized noise procedural texture object
  64713. */
  64714. serialize(): any;
  64715. /**
  64716. * Clone the texture.
  64717. * @returns the cloned texture
  64718. */
  64719. clone(): NoiseProceduralTexture;
  64720. /**
  64721. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64722. * @param parsedTexture defines parsed texture data
  64723. * @param scene defines the current scene
  64724. * @param rootUrl defines the root URL containing noise procedural texture information
  64725. * @returns a parsed NoiseProceduralTexture
  64726. */
  64727. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64728. }
  64729. }
  64730. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64731. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64732. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64733. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64734. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64735. }
  64736. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64737. import { Nullable } from "babylonjs/types";
  64738. import { Scene } from "babylonjs/scene";
  64739. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64740. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64741. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64742. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64743. /**
  64744. * Raw cube texture where the raw buffers are passed in
  64745. */
  64746. export class RawCubeTexture extends CubeTexture {
  64747. /**
  64748. * Creates a cube texture where the raw buffers are passed in.
  64749. * @param scene defines the scene the texture is attached to
  64750. * @param data defines the array of data to use to create each face
  64751. * @param size defines the size of the textures
  64752. * @param format defines the format of the data
  64753. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64754. * @param generateMipMaps defines if the engine should generate the mip levels
  64755. * @param invertY defines if data must be stored with Y axis inverted
  64756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64757. * @param compression defines the compression used (null by default)
  64758. */
  64759. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64760. /**
  64761. * Updates the raw cube texture.
  64762. * @param data defines the data to store
  64763. * @param format defines the data format
  64764. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64765. * @param invertY defines if data must be stored with Y axis inverted
  64766. * @param compression defines the compression used (null by default)
  64767. * @param level defines which level of the texture to update
  64768. */
  64769. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64770. /**
  64771. * Updates a raw cube texture with RGBD encoded data.
  64772. * @param data defines the array of data [mipmap][face] to use to create each face
  64773. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64774. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64775. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64776. * @returns a promsie that resolves when the operation is complete
  64777. */
  64778. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64779. /**
  64780. * Clones the raw cube texture.
  64781. * @return a new cube texture
  64782. */
  64783. clone(): CubeTexture;
  64784. /** @hidden */
  64785. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64786. }
  64787. }
  64788. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64789. import { Scene } from "babylonjs/scene";
  64790. import { Texture } from "babylonjs/Materials/Textures/texture";
  64791. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64792. /**
  64793. * Class used to store 2D array textures containing user data
  64794. */
  64795. export class RawTexture2DArray extends Texture {
  64796. /** Gets or sets the texture format to use */
  64797. format: number;
  64798. /**
  64799. * Create a new RawTexture2DArray
  64800. * @param data defines the data of the texture
  64801. * @param width defines the width of the texture
  64802. * @param height defines the height of the texture
  64803. * @param depth defines the number of layers of the texture
  64804. * @param format defines the texture format to use
  64805. * @param scene defines the hosting scene
  64806. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64807. * @param invertY defines if texture must be stored with Y axis inverted
  64808. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64809. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64810. */
  64811. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64812. /** Gets or sets the texture format to use */
  64813. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64814. /**
  64815. * Update the texture with new data
  64816. * @param data defines the data to store in the texture
  64817. */
  64818. update(data: ArrayBufferView): void;
  64819. }
  64820. }
  64821. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64822. import { Scene } from "babylonjs/scene";
  64823. import { Texture } from "babylonjs/Materials/Textures/texture";
  64824. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64825. /**
  64826. * Class used to store 3D textures containing user data
  64827. */
  64828. export class RawTexture3D extends Texture {
  64829. /** Gets or sets the texture format to use */
  64830. format: number;
  64831. /**
  64832. * Create a new RawTexture3D
  64833. * @param data defines the data of the texture
  64834. * @param width defines the width of the texture
  64835. * @param height defines the height of the texture
  64836. * @param depth defines the depth of the texture
  64837. * @param format defines the texture format to use
  64838. * @param scene defines the hosting scene
  64839. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64840. * @param invertY defines if texture must be stored with Y axis inverted
  64841. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64842. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64843. */
  64844. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64845. /** Gets or sets the texture format to use */
  64846. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64847. /**
  64848. * Update the texture with new data
  64849. * @param data defines the data to store in the texture
  64850. */
  64851. update(data: ArrayBufferView): void;
  64852. }
  64853. }
  64854. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64855. import { Scene } from "babylonjs/scene";
  64856. import { Plane } from "babylonjs/Maths/math.plane";
  64857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64858. /**
  64859. * Creates a refraction texture used by refraction channel of the standard material.
  64860. * It is like a mirror but to see through a material.
  64861. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64862. */
  64863. export class RefractionTexture extends RenderTargetTexture {
  64864. /**
  64865. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64866. * 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.
  64867. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64868. */
  64869. refractionPlane: Plane;
  64870. /**
  64871. * Define how deep under the surface we should see.
  64872. */
  64873. depth: number;
  64874. /**
  64875. * Creates a refraction texture used by refraction channel of the standard material.
  64876. * It is like a mirror but to see through a material.
  64877. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64878. * @param name Define the texture name
  64879. * @param size Define the size of the underlying texture
  64880. * @param scene Define the scene the refraction belongs to
  64881. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64882. */
  64883. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64884. /**
  64885. * Clone the refraction texture.
  64886. * @returns the cloned texture
  64887. */
  64888. clone(): RefractionTexture;
  64889. /**
  64890. * Serialize the texture to a JSON representation you could use in Parse later on
  64891. * @returns the serialized JSON representation
  64892. */
  64893. serialize(): any;
  64894. }
  64895. }
  64896. declare module "babylonjs/Materials/Textures/index" {
  64897. export * from "babylonjs/Materials/Textures/baseTexture";
  64898. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64899. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64900. export * from "babylonjs/Materials/Textures/cubeTexture";
  64901. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64902. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64903. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64904. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64905. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64906. export * from "babylonjs/Materials/Textures/internalTexture";
  64907. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64908. export * from "babylonjs/Materials/Textures/Loaders/index";
  64909. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64910. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64911. export * from "babylonjs/Materials/Textures/Packer/index";
  64912. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64913. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64914. export * from "babylonjs/Materials/Textures/rawTexture";
  64915. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64916. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64917. export * from "babylonjs/Materials/Textures/refractionTexture";
  64918. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64919. export * from "babylonjs/Materials/Textures/texture";
  64920. export * from "babylonjs/Materials/Textures/videoTexture";
  64921. }
  64922. declare module "babylonjs/Materials/Node/Enums/index" {
  64923. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64924. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64925. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64926. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64927. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64928. }
  64929. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64933. import { Mesh } from "babylonjs/Meshes/mesh";
  64934. import { Effect } from "babylonjs/Materials/effect";
  64935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64936. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64938. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64939. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64940. /**
  64941. * Block used to add support for vertex skinning (bones)
  64942. */
  64943. export class BonesBlock extends NodeMaterialBlock {
  64944. /**
  64945. * Creates a new BonesBlock
  64946. * @param name defines the block name
  64947. */
  64948. constructor(name: string);
  64949. /**
  64950. * Initialize the block and prepare the context for build
  64951. * @param state defines the state that will be used for the build
  64952. */
  64953. initialize(state: NodeMaterialBuildState): void;
  64954. /**
  64955. * Gets the current class name
  64956. * @returns the class name
  64957. */
  64958. getClassName(): string;
  64959. /**
  64960. * Gets the matrix indices input component
  64961. */
  64962. get matricesIndices(): NodeMaterialConnectionPoint;
  64963. /**
  64964. * Gets the matrix weights input component
  64965. */
  64966. get matricesWeights(): NodeMaterialConnectionPoint;
  64967. /**
  64968. * Gets the extra matrix indices input component
  64969. */
  64970. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the extra matrix weights input component
  64973. */
  64974. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64975. /**
  64976. * Gets the world input component
  64977. */
  64978. get world(): NodeMaterialConnectionPoint;
  64979. /**
  64980. * Gets the output component
  64981. */
  64982. get output(): NodeMaterialConnectionPoint;
  64983. autoConfigure(material: NodeMaterial): void;
  64984. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64987. protected _buildBlock(state: NodeMaterialBuildState): this;
  64988. }
  64989. }
  64990. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64995. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64997. /**
  64998. * Block used to add support for instances
  64999. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65000. */
  65001. export class InstancesBlock extends NodeMaterialBlock {
  65002. /**
  65003. * Creates a new InstancesBlock
  65004. * @param name defines the block name
  65005. */
  65006. constructor(name: string);
  65007. /**
  65008. * Gets the current class name
  65009. * @returns the class name
  65010. */
  65011. getClassName(): string;
  65012. /**
  65013. * Gets the first world row input component
  65014. */
  65015. get world0(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the second world row input component
  65018. */
  65019. get world1(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the third world row input component
  65022. */
  65023. get world2(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the forth world row input component
  65026. */
  65027. get world3(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the world input component
  65030. */
  65031. get world(): NodeMaterialConnectionPoint;
  65032. /**
  65033. * Gets the output component
  65034. */
  65035. get output(): NodeMaterialConnectionPoint;
  65036. /**
  65037. * Gets the isntanceID component
  65038. */
  65039. get instanceID(): NodeMaterialConnectionPoint;
  65040. autoConfigure(material: NodeMaterial): void;
  65041. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65042. protected _buildBlock(state: NodeMaterialBuildState): this;
  65043. }
  65044. }
  65045. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65050. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65051. import { Effect } from "babylonjs/Materials/effect";
  65052. import { Mesh } from "babylonjs/Meshes/mesh";
  65053. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65054. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65055. /**
  65056. * Block used to add morph targets support to vertex shader
  65057. */
  65058. export class MorphTargetsBlock extends NodeMaterialBlock {
  65059. private _repeatableContentAnchor;
  65060. /**
  65061. * Create a new MorphTargetsBlock
  65062. * @param name defines the block name
  65063. */
  65064. constructor(name: string);
  65065. /**
  65066. * Gets the current class name
  65067. * @returns the class name
  65068. */
  65069. getClassName(): string;
  65070. /**
  65071. * Gets the position input component
  65072. */
  65073. get position(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the normal input component
  65076. */
  65077. get normal(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the tangent input component
  65080. */
  65081. get tangent(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the tangent input component
  65084. */
  65085. get uv(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the position output component
  65088. */
  65089. get positionOutput(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the normal output component
  65092. */
  65093. get normalOutput(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the tangent output component
  65096. */
  65097. get tangentOutput(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the tangent output component
  65100. */
  65101. get uvOutput(): NodeMaterialConnectionPoint;
  65102. initialize(state: NodeMaterialBuildState): void;
  65103. autoConfigure(material: NodeMaterial): void;
  65104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65106. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65107. protected _buildBlock(state: NodeMaterialBuildState): this;
  65108. }
  65109. }
  65110. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65114. import { Nullable } from "babylonjs/types";
  65115. import { Scene } from "babylonjs/scene";
  65116. import { Effect } from "babylonjs/Materials/effect";
  65117. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65118. import { Mesh } from "babylonjs/Meshes/mesh";
  65119. import { Light } from "babylonjs/Lights/light";
  65120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65121. /**
  65122. * Block used to get data information from a light
  65123. */
  65124. export class LightInformationBlock extends NodeMaterialBlock {
  65125. private _lightDataUniformName;
  65126. private _lightColorUniformName;
  65127. private _lightTypeDefineName;
  65128. /**
  65129. * Gets or sets the light associated with this block
  65130. */
  65131. light: Nullable<Light>;
  65132. /**
  65133. * Creates a new LightInformationBlock
  65134. * @param name defines the block name
  65135. */
  65136. constructor(name: string);
  65137. /**
  65138. * Gets the current class name
  65139. * @returns the class name
  65140. */
  65141. getClassName(): string;
  65142. /**
  65143. * Gets the world position input component
  65144. */
  65145. get worldPosition(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Gets the direction output component
  65148. */
  65149. get direction(): NodeMaterialConnectionPoint;
  65150. /**
  65151. * Gets the direction output component
  65152. */
  65153. get color(): NodeMaterialConnectionPoint;
  65154. /**
  65155. * Gets the direction output component
  65156. */
  65157. get intensity(): NodeMaterialConnectionPoint;
  65158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65160. protected _buildBlock(state: NodeMaterialBuildState): this;
  65161. serialize(): any;
  65162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65163. }
  65164. }
  65165. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65166. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65167. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65168. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65169. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65170. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65171. }
  65172. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65177. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65178. import { Effect } from "babylonjs/Materials/effect";
  65179. import { Mesh } from "babylonjs/Meshes/mesh";
  65180. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65181. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65182. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65183. /**
  65184. * Block used to add image processing support to fragment shader
  65185. */
  65186. export class ImageProcessingBlock extends NodeMaterialBlock {
  65187. /**
  65188. * Create a new ImageProcessingBlock
  65189. * @param name defines the block name
  65190. */
  65191. constructor(name: string);
  65192. /**
  65193. * Gets the current class name
  65194. * @returns the class name
  65195. */
  65196. getClassName(): string;
  65197. /**
  65198. * Gets the color input component
  65199. */
  65200. get color(): NodeMaterialConnectionPoint;
  65201. /**
  65202. * Gets the output component
  65203. */
  65204. get output(): NodeMaterialConnectionPoint;
  65205. /**
  65206. * Initialize the block and prepare the context for build
  65207. * @param state defines the state that will be used for the build
  65208. */
  65209. initialize(state: NodeMaterialBuildState): void;
  65210. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65213. protected _buildBlock(state: NodeMaterialBuildState): this;
  65214. }
  65215. }
  65216. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65220. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65222. import { Effect } from "babylonjs/Materials/effect";
  65223. import { Mesh } from "babylonjs/Meshes/mesh";
  65224. import { Scene } from "babylonjs/scene";
  65225. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65226. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65227. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65228. /**
  65229. * Block used to pertub normals based on a normal map
  65230. */
  65231. export class PerturbNormalBlock extends NodeMaterialBlock {
  65232. private _tangentSpaceParameterName;
  65233. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65234. invertX: boolean;
  65235. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65236. invertY: boolean;
  65237. /**
  65238. * Create a new PerturbNormalBlock
  65239. * @param name defines the block name
  65240. */
  65241. constructor(name: string);
  65242. /**
  65243. * Gets the current class name
  65244. * @returns the class name
  65245. */
  65246. getClassName(): string;
  65247. /**
  65248. * Gets the world position input component
  65249. */
  65250. get worldPosition(): NodeMaterialConnectionPoint;
  65251. /**
  65252. * Gets the world normal input component
  65253. */
  65254. get worldNormal(): NodeMaterialConnectionPoint;
  65255. /**
  65256. * Gets the world tangent input component
  65257. */
  65258. get worldTangent(): NodeMaterialConnectionPoint;
  65259. /**
  65260. * Gets the uv input component
  65261. */
  65262. get uv(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the normal map color input component
  65265. */
  65266. get normalMapColor(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Gets the strength input component
  65269. */
  65270. get strength(): NodeMaterialConnectionPoint;
  65271. /**
  65272. * Gets the output component
  65273. */
  65274. get output(): NodeMaterialConnectionPoint;
  65275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65277. autoConfigure(material: NodeMaterial): void;
  65278. protected _buildBlock(state: NodeMaterialBuildState): this;
  65279. protected _dumpPropertiesCode(): string;
  65280. serialize(): any;
  65281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65282. }
  65283. }
  65284. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65288. /**
  65289. * Block used to discard a pixel if a value is smaller than a cutoff
  65290. */
  65291. export class DiscardBlock extends NodeMaterialBlock {
  65292. /**
  65293. * Create a new DiscardBlock
  65294. * @param name defines the block name
  65295. */
  65296. constructor(name: string);
  65297. /**
  65298. * Gets the current class name
  65299. * @returns the class name
  65300. */
  65301. getClassName(): string;
  65302. /**
  65303. * Gets the color input component
  65304. */
  65305. get value(): NodeMaterialConnectionPoint;
  65306. /**
  65307. * Gets the cutoff input component
  65308. */
  65309. get cutoff(): NodeMaterialConnectionPoint;
  65310. protected _buildBlock(state: NodeMaterialBuildState): this;
  65311. }
  65312. }
  65313. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65317. /**
  65318. * Block used to test if the fragment shader is front facing
  65319. */
  65320. export class FrontFacingBlock extends NodeMaterialBlock {
  65321. /**
  65322. * Creates a new FrontFacingBlock
  65323. * @param name defines the block name
  65324. */
  65325. constructor(name: string);
  65326. /**
  65327. * Gets the current class name
  65328. * @returns the class name
  65329. */
  65330. getClassName(): string;
  65331. /**
  65332. * Gets the output component
  65333. */
  65334. get output(): NodeMaterialConnectionPoint;
  65335. protected _buildBlock(state: NodeMaterialBuildState): this;
  65336. }
  65337. }
  65338. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65341. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65342. /**
  65343. * Block used to get the derivative value on x and y of a given input
  65344. */
  65345. export class DerivativeBlock extends NodeMaterialBlock {
  65346. /**
  65347. * Create a new DerivativeBlock
  65348. * @param name defines the block name
  65349. */
  65350. constructor(name: string);
  65351. /**
  65352. * Gets the current class name
  65353. * @returns the class name
  65354. */
  65355. getClassName(): string;
  65356. /**
  65357. * Gets the input component
  65358. */
  65359. get input(): NodeMaterialConnectionPoint;
  65360. /**
  65361. * Gets the derivative output on x
  65362. */
  65363. get dx(): NodeMaterialConnectionPoint;
  65364. /**
  65365. * Gets the derivative output on y
  65366. */
  65367. get dy(): NodeMaterialConnectionPoint;
  65368. protected _buildBlock(state: NodeMaterialBuildState): this;
  65369. }
  65370. }
  65371. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65375. /**
  65376. * Block used to make gl_FragCoord available
  65377. */
  65378. export class FragCoordBlock extends NodeMaterialBlock {
  65379. /**
  65380. * Creates a new FragCoordBlock
  65381. * @param name defines the block name
  65382. */
  65383. constructor(name: string);
  65384. /**
  65385. * Gets the current class name
  65386. * @returns the class name
  65387. */
  65388. getClassName(): string;
  65389. /**
  65390. * Gets the xy component
  65391. */
  65392. get xy(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the xyz component
  65395. */
  65396. get xyz(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the xyzw component
  65399. */
  65400. get xyzw(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the x component
  65403. */
  65404. get x(): NodeMaterialConnectionPoint;
  65405. /**
  65406. * Gets the y component
  65407. */
  65408. get y(): NodeMaterialConnectionPoint;
  65409. /**
  65410. * Gets the z component
  65411. */
  65412. get z(): NodeMaterialConnectionPoint;
  65413. /**
  65414. * Gets the w component
  65415. */
  65416. get output(): NodeMaterialConnectionPoint;
  65417. protected writeOutputs(state: NodeMaterialBuildState): string;
  65418. protected _buildBlock(state: NodeMaterialBuildState): this;
  65419. }
  65420. }
  65421. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65425. import { Effect } from "babylonjs/Materials/effect";
  65426. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65427. import { Mesh } from "babylonjs/Meshes/mesh";
  65428. /**
  65429. * Block used to get the screen sizes
  65430. */
  65431. export class ScreenSizeBlock extends NodeMaterialBlock {
  65432. private _varName;
  65433. private _scene;
  65434. /**
  65435. * Creates a new ScreenSizeBlock
  65436. * @param name defines the block name
  65437. */
  65438. constructor(name: string);
  65439. /**
  65440. * Gets the current class name
  65441. * @returns the class name
  65442. */
  65443. getClassName(): string;
  65444. /**
  65445. * Gets the xy component
  65446. */
  65447. get xy(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the x component
  65450. */
  65451. get x(): NodeMaterialConnectionPoint;
  65452. /**
  65453. * Gets the y component
  65454. */
  65455. get y(): NodeMaterialConnectionPoint;
  65456. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65457. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65458. protected _buildBlock(state: NodeMaterialBuildState): this;
  65459. }
  65460. }
  65461. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65462. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65463. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65464. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65465. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65466. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65467. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65468. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65469. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65470. }
  65471. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65474. import { Mesh } from "babylonjs/Meshes/mesh";
  65475. import { Effect } from "babylonjs/Materials/effect";
  65476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65478. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65479. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65480. /**
  65481. * Block used to add support for scene fog
  65482. */
  65483. export class FogBlock extends NodeMaterialBlock {
  65484. private _fogDistanceName;
  65485. private _fogParameters;
  65486. /**
  65487. * Create a new FogBlock
  65488. * @param name defines the block name
  65489. */
  65490. constructor(name: string);
  65491. /**
  65492. * Gets the current class name
  65493. * @returns the class name
  65494. */
  65495. getClassName(): string;
  65496. /**
  65497. * Gets the world position input component
  65498. */
  65499. get worldPosition(): NodeMaterialConnectionPoint;
  65500. /**
  65501. * Gets the view input component
  65502. */
  65503. get view(): NodeMaterialConnectionPoint;
  65504. /**
  65505. * Gets the color input component
  65506. */
  65507. get input(): NodeMaterialConnectionPoint;
  65508. /**
  65509. * Gets the fog color input component
  65510. */
  65511. get fogColor(): NodeMaterialConnectionPoint;
  65512. /**
  65513. * Gets the output component
  65514. */
  65515. get output(): NodeMaterialConnectionPoint;
  65516. autoConfigure(material: NodeMaterial): void;
  65517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65519. protected _buildBlock(state: NodeMaterialBuildState): this;
  65520. }
  65521. }
  65522. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65527. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65528. import { Effect } from "babylonjs/Materials/effect";
  65529. import { Mesh } from "babylonjs/Meshes/mesh";
  65530. import { Light } from "babylonjs/Lights/light";
  65531. import { Nullable } from "babylonjs/types";
  65532. import { Scene } from "babylonjs/scene";
  65533. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65534. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65535. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65536. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65537. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65538. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65539. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65540. /**
  65541. * Block used to add light in the fragment shader
  65542. */
  65543. export class LightBlock extends NodeMaterialBlock {
  65544. private _lightId;
  65545. /**
  65546. * Gets or sets the light associated with this block
  65547. */
  65548. light: Nullable<Light>;
  65549. /**
  65550. * Create a new LightBlock
  65551. * @param name defines the block name
  65552. */
  65553. constructor(name: string);
  65554. /**
  65555. * Gets the current class name
  65556. * @returns the class name
  65557. */
  65558. getClassName(): string;
  65559. /**
  65560. * Gets the world position input component
  65561. */
  65562. get worldPosition(): NodeMaterialConnectionPoint;
  65563. /**
  65564. * Gets the world normal input component
  65565. */
  65566. get worldNormal(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the camera (or eye) position component
  65569. */
  65570. get cameraPosition(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the glossiness component
  65573. */
  65574. get glossiness(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the glossinness power component
  65577. */
  65578. get glossPower(): NodeMaterialConnectionPoint;
  65579. /**
  65580. * Gets the diffuse color component
  65581. */
  65582. get diffuseColor(): NodeMaterialConnectionPoint;
  65583. /**
  65584. * Gets the specular color component
  65585. */
  65586. get specularColor(): NodeMaterialConnectionPoint;
  65587. /**
  65588. * Gets the diffuse output component
  65589. */
  65590. get diffuseOutput(): NodeMaterialConnectionPoint;
  65591. /**
  65592. * Gets the specular output component
  65593. */
  65594. get specularOutput(): NodeMaterialConnectionPoint;
  65595. /**
  65596. * Gets the shadow output component
  65597. */
  65598. get shadow(): NodeMaterialConnectionPoint;
  65599. autoConfigure(material: NodeMaterial): void;
  65600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65601. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65602. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65603. private _injectVertexCode;
  65604. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65605. serialize(): any;
  65606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65607. }
  65608. }
  65609. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65612. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65613. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65614. /**
  65615. * Block used to read a reflection texture from a sampler
  65616. */
  65617. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65618. /**
  65619. * Create a new ReflectionTextureBlock
  65620. * @param name defines the block name
  65621. */
  65622. constructor(name: string);
  65623. /**
  65624. * Gets the current class name
  65625. * @returns the class name
  65626. */
  65627. getClassName(): string;
  65628. /**
  65629. * Gets the world position input component
  65630. */
  65631. get position(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the world position input component
  65634. */
  65635. get worldPosition(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the world normal input component
  65638. */
  65639. get worldNormal(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the world input component
  65642. */
  65643. get world(): NodeMaterialConnectionPoint;
  65644. /**
  65645. * Gets the camera (or eye) position component
  65646. */
  65647. get cameraPosition(): NodeMaterialConnectionPoint;
  65648. /**
  65649. * Gets the view input component
  65650. */
  65651. get view(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the rgb output component
  65654. */
  65655. get rgb(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the rgba output component
  65658. */
  65659. get rgba(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the r output component
  65662. */
  65663. get r(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the g output component
  65666. */
  65667. get g(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the b output component
  65670. */
  65671. get b(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the a output component
  65674. */
  65675. get a(): NodeMaterialConnectionPoint;
  65676. autoConfigure(material: NodeMaterial): void;
  65677. protected _buildBlock(state: NodeMaterialBuildState): this;
  65678. }
  65679. }
  65680. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65681. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65682. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65683. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65684. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65685. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65686. }
  65687. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65688. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65689. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65690. }
  65691. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65695. /**
  65696. * Block used to add 2 vectors
  65697. */
  65698. export class AddBlock extends NodeMaterialBlock {
  65699. /**
  65700. * Creates a new AddBlock
  65701. * @param name defines the block name
  65702. */
  65703. constructor(name: string);
  65704. /**
  65705. * Gets the current class name
  65706. * @returns the class name
  65707. */
  65708. getClassName(): string;
  65709. /**
  65710. * Gets the left operand input component
  65711. */
  65712. get left(): NodeMaterialConnectionPoint;
  65713. /**
  65714. * Gets the right operand input component
  65715. */
  65716. get right(): NodeMaterialConnectionPoint;
  65717. /**
  65718. * Gets the output component
  65719. */
  65720. get output(): NodeMaterialConnectionPoint;
  65721. protected _buildBlock(state: NodeMaterialBuildState): this;
  65722. }
  65723. }
  65724. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65728. /**
  65729. * Block used to scale a vector by a float
  65730. */
  65731. export class ScaleBlock extends NodeMaterialBlock {
  65732. /**
  65733. * Creates a new ScaleBlock
  65734. * @param name defines the block name
  65735. */
  65736. constructor(name: string);
  65737. /**
  65738. * Gets the current class name
  65739. * @returns the class name
  65740. */
  65741. getClassName(): string;
  65742. /**
  65743. * Gets the input component
  65744. */
  65745. get input(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the factor input component
  65748. */
  65749. get factor(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the output component
  65752. */
  65753. get output(): NodeMaterialConnectionPoint;
  65754. protected _buildBlock(state: NodeMaterialBuildState): this;
  65755. }
  65756. }
  65757. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65761. import { Scene } from "babylonjs/scene";
  65762. /**
  65763. * Block used to clamp a float
  65764. */
  65765. export class ClampBlock extends NodeMaterialBlock {
  65766. /** Gets or sets the minimum range */
  65767. minimum: number;
  65768. /** Gets or sets the maximum range */
  65769. maximum: number;
  65770. /**
  65771. * Creates a new ClampBlock
  65772. * @param name defines the block name
  65773. */
  65774. constructor(name: string);
  65775. /**
  65776. * Gets the current class name
  65777. * @returns the class name
  65778. */
  65779. getClassName(): string;
  65780. /**
  65781. * Gets the value input component
  65782. */
  65783. get value(): NodeMaterialConnectionPoint;
  65784. /**
  65785. * Gets the output component
  65786. */
  65787. get output(): NodeMaterialConnectionPoint;
  65788. protected _buildBlock(state: NodeMaterialBuildState): this;
  65789. protected _dumpPropertiesCode(): string;
  65790. serialize(): any;
  65791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65792. }
  65793. }
  65794. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65798. /**
  65799. * Block used to apply a cross product between 2 vectors
  65800. */
  65801. export class CrossBlock extends NodeMaterialBlock {
  65802. /**
  65803. * Creates a new CrossBlock
  65804. * @param name defines the block name
  65805. */
  65806. constructor(name: string);
  65807. /**
  65808. * Gets the current class name
  65809. * @returns the class name
  65810. */
  65811. getClassName(): string;
  65812. /**
  65813. * Gets the left operand input component
  65814. */
  65815. get left(): NodeMaterialConnectionPoint;
  65816. /**
  65817. * Gets the right operand input component
  65818. */
  65819. get right(): NodeMaterialConnectionPoint;
  65820. /**
  65821. * Gets the output component
  65822. */
  65823. get output(): NodeMaterialConnectionPoint;
  65824. protected _buildBlock(state: NodeMaterialBuildState): this;
  65825. }
  65826. }
  65827. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65831. /**
  65832. * Block used to apply a dot product between 2 vectors
  65833. */
  65834. export class DotBlock extends NodeMaterialBlock {
  65835. /**
  65836. * Creates a new DotBlock
  65837. * @param name defines the block name
  65838. */
  65839. constructor(name: string);
  65840. /**
  65841. * Gets the current class name
  65842. * @returns the class name
  65843. */
  65844. getClassName(): string;
  65845. /**
  65846. * Gets the left operand input component
  65847. */
  65848. get left(): NodeMaterialConnectionPoint;
  65849. /**
  65850. * Gets the right operand input component
  65851. */
  65852. get right(): NodeMaterialConnectionPoint;
  65853. /**
  65854. * Gets the output component
  65855. */
  65856. get output(): NodeMaterialConnectionPoint;
  65857. protected _buildBlock(state: NodeMaterialBuildState): this;
  65858. }
  65859. }
  65860. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65864. /**
  65865. * Block used to normalize a vector
  65866. */
  65867. export class NormalizeBlock extends NodeMaterialBlock {
  65868. /**
  65869. * Creates a new NormalizeBlock
  65870. * @param name defines the block name
  65871. */
  65872. constructor(name: string);
  65873. /**
  65874. * Gets the current class name
  65875. * @returns the class name
  65876. */
  65877. getClassName(): string;
  65878. /**
  65879. * Gets the input component
  65880. */
  65881. get input(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the output component
  65884. */
  65885. get output(): NodeMaterialConnectionPoint;
  65886. protected _buildBlock(state: NodeMaterialBuildState): this;
  65887. }
  65888. }
  65889. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65893. import { Scene } from "babylonjs/scene";
  65894. /**
  65895. * Operations supported by the Trigonometry block
  65896. */
  65897. export enum TrigonometryBlockOperations {
  65898. /** Cos */
  65899. Cos = 0,
  65900. /** Sin */
  65901. Sin = 1,
  65902. /** Abs */
  65903. Abs = 2,
  65904. /** Exp */
  65905. Exp = 3,
  65906. /** Exp2 */
  65907. Exp2 = 4,
  65908. /** Round */
  65909. Round = 5,
  65910. /** Floor */
  65911. Floor = 6,
  65912. /** Ceiling */
  65913. Ceiling = 7,
  65914. /** Square root */
  65915. Sqrt = 8,
  65916. /** Log */
  65917. Log = 9,
  65918. /** Tangent */
  65919. Tan = 10,
  65920. /** Arc tangent */
  65921. ArcTan = 11,
  65922. /** Arc cosinus */
  65923. ArcCos = 12,
  65924. /** Arc sinus */
  65925. ArcSin = 13,
  65926. /** Fraction */
  65927. Fract = 14,
  65928. /** Sign */
  65929. Sign = 15,
  65930. /** To radians (from degrees) */
  65931. Radians = 16,
  65932. /** To degrees (from radians) */
  65933. Degrees = 17
  65934. }
  65935. /**
  65936. * Block used to apply trigonometry operation to floats
  65937. */
  65938. export class TrigonometryBlock extends NodeMaterialBlock {
  65939. /**
  65940. * Gets or sets the operation applied by the block
  65941. */
  65942. operation: TrigonometryBlockOperations;
  65943. /**
  65944. * Creates a new TrigonometryBlock
  65945. * @param name defines the block name
  65946. */
  65947. constructor(name: string);
  65948. /**
  65949. * Gets the current class name
  65950. * @returns the class name
  65951. */
  65952. getClassName(): string;
  65953. /**
  65954. * Gets the input component
  65955. */
  65956. get input(): NodeMaterialConnectionPoint;
  65957. /**
  65958. * Gets the output component
  65959. */
  65960. get output(): NodeMaterialConnectionPoint;
  65961. protected _buildBlock(state: NodeMaterialBuildState): this;
  65962. serialize(): any;
  65963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65964. protected _dumpPropertiesCode(): string;
  65965. }
  65966. }
  65967. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65971. /**
  65972. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65973. */
  65974. export class ColorMergerBlock extends NodeMaterialBlock {
  65975. /**
  65976. * Create a new ColorMergerBlock
  65977. * @param name defines the block name
  65978. */
  65979. constructor(name: string);
  65980. /**
  65981. * Gets the current class name
  65982. * @returns the class name
  65983. */
  65984. getClassName(): string;
  65985. /**
  65986. * Gets the rgb component (input)
  65987. */
  65988. get rgbIn(): NodeMaterialConnectionPoint;
  65989. /**
  65990. * Gets the r component (input)
  65991. */
  65992. get r(): NodeMaterialConnectionPoint;
  65993. /**
  65994. * Gets the g component (input)
  65995. */
  65996. get g(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the b component (input)
  65999. */
  66000. get b(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the a component (input)
  66003. */
  66004. get a(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the rgba component (output)
  66007. */
  66008. get rgba(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the rgb component (output)
  66011. */
  66012. get rgbOut(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the rgb component (output)
  66015. * @deprecated Please use rgbOut instead.
  66016. */
  66017. get rgb(): NodeMaterialConnectionPoint;
  66018. protected _buildBlock(state: NodeMaterialBuildState): this;
  66019. }
  66020. }
  66021. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66025. /**
  66026. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66027. */
  66028. export class VectorSplitterBlock extends NodeMaterialBlock {
  66029. /**
  66030. * Create a new VectorSplitterBlock
  66031. * @param name defines the block name
  66032. */
  66033. constructor(name: string);
  66034. /**
  66035. * Gets the current class name
  66036. * @returns the class name
  66037. */
  66038. getClassName(): string;
  66039. /**
  66040. * Gets the xyzw component (input)
  66041. */
  66042. get xyzw(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the xyz component (input)
  66045. */
  66046. get xyzIn(): NodeMaterialConnectionPoint;
  66047. /**
  66048. * Gets the xy component (input)
  66049. */
  66050. get xyIn(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the xyz component (output)
  66053. */
  66054. get xyzOut(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the xy component (output)
  66057. */
  66058. get xyOut(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the x component (output)
  66061. */
  66062. get x(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the y component (output)
  66065. */
  66066. get y(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the z component (output)
  66069. */
  66070. get z(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the w component (output)
  66073. */
  66074. get w(): NodeMaterialConnectionPoint;
  66075. protected _inputRename(name: string): string;
  66076. protected _outputRename(name: string): string;
  66077. protected _buildBlock(state: NodeMaterialBuildState): this;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66084. /**
  66085. * Block used to lerp between 2 values
  66086. */
  66087. export class LerpBlock extends NodeMaterialBlock {
  66088. /**
  66089. * Creates a new LerpBlock
  66090. * @param name defines the block name
  66091. */
  66092. constructor(name: string);
  66093. /**
  66094. * Gets the current class name
  66095. * @returns the class name
  66096. */
  66097. getClassName(): string;
  66098. /**
  66099. * Gets the left operand input component
  66100. */
  66101. get left(): NodeMaterialConnectionPoint;
  66102. /**
  66103. * Gets the right operand input component
  66104. */
  66105. get right(): NodeMaterialConnectionPoint;
  66106. /**
  66107. * Gets the gradient operand input component
  66108. */
  66109. get gradient(): NodeMaterialConnectionPoint;
  66110. /**
  66111. * Gets the output component
  66112. */
  66113. get output(): NodeMaterialConnectionPoint;
  66114. protected _buildBlock(state: NodeMaterialBuildState): this;
  66115. }
  66116. }
  66117. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66121. /**
  66122. * Block used to divide 2 vectors
  66123. */
  66124. export class DivideBlock extends NodeMaterialBlock {
  66125. /**
  66126. * Creates a new DivideBlock
  66127. * @param name defines the block name
  66128. */
  66129. constructor(name: string);
  66130. /**
  66131. * Gets the current class name
  66132. * @returns the class name
  66133. */
  66134. getClassName(): string;
  66135. /**
  66136. * Gets the left operand input component
  66137. */
  66138. get left(): NodeMaterialConnectionPoint;
  66139. /**
  66140. * Gets the right operand input component
  66141. */
  66142. get right(): NodeMaterialConnectionPoint;
  66143. /**
  66144. * Gets the output component
  66145. */
  66146. get output(): NodeMaterialConnectionPoint;
  66147. protected _buildBlock(state: NodeMaterialBuildState): this;
  66148. }
  66149. }
  66150. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66154. /**
  66155. * Block used to subtract 2 vectors
  66156. */
  66157. export class SubtractBlock extends NodeMaterialBlock {
  66158. /**
  66159. * Creates a new SubtractBlock
  66160. * @param name defines the block name
  66161. */
  66162. constructor(name: string);
  66163. /**
  66164. * Gets the current class name
  66165. * @returns the class name
  66166. */
  66167. getClassName(): string;
  66168. /**
  66169. * Gets the left operand input component
  66170. */
  66171. get left(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the right operand input component
  66174. */
  66175. get right(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the output component
  66178. */
  66179. get output(): NodeMaterialConnectionPoint;
  66180. protected _buildBlock(state: NodeMaterialBuildState): this;
  66181. }
  66182. }
  66183. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66187. /**
  66188. * Block used to step a value
  66189. */
  66190. export class StepBlock extends NodeMaterialBlock {
  66191. /**
  66192. * Creates a new StepBlock
  66193. * @param name defines the block name
  66194. */
  66195. constructor(name: string);
  66196. /**
  66197. * Gets the current class name
  66198. * @returns the class name
  66199. */
  66200. getClassName(): string;
  66201. /**
  66202. * Gets the value operand input component
  66203. */
  66204. get value(): NodeMaterialConnectionPoint;
  66205. /**
  66206. * Gets the edge operand input component
  66207. */
  66208. get edge(): NodeMaterialConnectionPoint;
  66209. /**
  66210. * Gets the output component
  66211. */
  66212. get output(): NodeMaterialConnectionPoint;
  66213. protected _buildBlock(state: NodeMaterialBuildState): this;
  66214. }
  66215. }
  66216. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66220. /**
  66221. * Block used to get the opposite (1 - x) of a value
  66222. */
  66223. export class OneMinusBlock extends NodeMaterialBlock {
  66224. /**
  66225. * Creates a new OneMinusBlock
  66226. * @param name defines the block name
  66227. */
  66228. constructor(name: string);
  66229. /**
  66230. * Gets the current class name
  66231. * @returns the class name
  66232. */
  66233. getClassName(): string;
  66234. /**
  66235. * Gets the input component
  66236. */
  66237. get input(): NodeMaterialConnectionPoint;
  66238. /**
  66239. * Gets the output component
  66240. */
  66241. get output(): NodeMaterialConnectionPoint;
  66242. protected _buildBlock(state: NodeMaterialBuildState): this;
  66243. }
  66244. }
  66245. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66249. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66250. /**
  66251. * Block used to get the view direction
  66252. */
  66253. export class ViewDirectionBlock extends NodeMaterialBlock {
  66254. /**
  66255. * Creates a new ViewDirectionBlock
  66256. * @param name defines the block name
  66257. */
  66258. constructor(name: string);
  66259. /**
  66260. * Gets the current class name
  66261. * @returns the class name
  66262. */
  66263. getClassName(): string;
  66264. /**
  66265. * Gets the world position component
  66266. */
  66267. get worldPosition(): NodeMaterialConnectionPoint;
  66268. /**
  66269. * Gets the camera position component
  66270. */
  66271. get cameraPosition(): NodeMaterialConnectionPoint;
  66272. /**
  66273. * Gets the output component
  66274. */
  66275. get output(): NodeMaterialConnectionPoint;
  66276. autoConfigure(material: NodeMaterial): void;
  66277. protected _buildBlock(state: NodeMaterialBuildState): this;
  66278. }
  66279. }
  66280. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66284. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66285. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66286. /**
  66287. * Block used to compute fresnel value
  66288. */
  66289. export class FresnelBlock extends NodeMaterialBlock {
  66290. /**
  66291. * Create a new FresnelBlock
  66292. * @param name defines the block name
  66293. */
  66294. constructor(name: string);
  66295. /**
  66296. * Gets the current class name
  66297. * @returns the class name
  66298. */
  66299. getClassName(): string;
  66300. /**
  66301. * Gets the world normal input component
  66302. */
  66303. get worldNormal(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the view direction input component
  66306. */
  66307. get viewDirection(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the bias input component
  66310. */
  66311. get bias(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the camera (or eye) position component
  66314. */
  66315. get power(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the fresnel output component
  66318. */
  66319. get fresnel(): NodeMaterialConnectionPoint;
  66320. autoConfigure(material: NodeMaterial): void;
  66321. protected _buildBlock(state: NodeMaterialBuildState): this;
  66322. }
  66323. }
  66324. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66328. /**
  66329. * Block used to get the max of 2 values
  66330. */
  66331. export class MaxBlock extends NodeMaterialBlock {
  66332. /**
  66333. * Creates a new MaxBlock
  66334. * @param name defines the block name
  66335. */
  66336. constructor(name: string);
  66337. /**
  66338. * Gets the current class name
  66339. * @returns the class name
  66340. */
  66341. getClassName(): string;
  66342. /**
  66343. * Gets the left operand input component
  66344. */
  66345. get left(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the right operand input component
  66348. */
  66349. get right(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the output component
  66352. */
  66353. get output(): NodeMaterialConnectionPoint;
  66354. protected _buildBlock(state: NodeMaterialBuildState): this;
  66355. }
  66356. }
  66357. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66361. /**
  66362. * Block used to get the min of 2 values
  66363. */
  66364. export class MinBlock extends NodeMaterialBlock {
  66365. /**
  66366. * Creates a new MinBlock
  66367. * @param name defines the block name
  66368. */
  66369. constructor(name: string);
  66370. /**
  66371. * Gets the current class name
  66372. * @returns the class name
  66373. */
  66374. getClassName(): string;
  66375. /**
  66376. * Gets the left operand input component
  66377. */
  66378. get left(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the right operand input component
  66381. */
  66382. get right(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the output component
  66385. */
  66386. get output(): NodeMaterialConnectionPoint;
  66387. protected _buildBlock(state: NodeMaterialBuildState): this;
  66388. }
  66389. }
  66390. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66394. /**
  66395. * Block used to get the distance between 2 values
  66396. */
  66397. export class DistanceBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Creates a new DistanceBlock
  66400. * @param name defines the block name
  66401. */
  66402. constructor(name: string);
  66403. /**
  66404. * Gets the current class name
  66405. * @returns the class name
  66406. */
  66407. getClassName(): string;
  66408. /**
  66409. * Gets the left operand input component
  66410. */
  66411. get left(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the right operand input component
  66414. */
  66415. get right(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. protected _buildBlock(state: NodeMaterialBuildState): this;
  66421. }
  66422. }
  66423. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66427. /**
  66428. * Block used to get the length of a vector
  66429. */
  66430. export class LengthBlock extends NodeMaterialBlock {
  66431. /**
  66432. * Creates a new LengthBlock
  66433. * @param name defines the block name
  66434. */
  66435. constructor(name: string);
  66436. /**
  66437. * Gets the current class name
  66438. * @returns the class name
  66439. */
  66440. getClassName(): string;
  66441. /**
  66442. * Gets the value input component
  66443. */
  66444. get value(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the output component
  66447. */
  66448. get output(): NodeMaterialConnectionPoint;
  66449. protected _buildBlock(state: NodeMaterialBuildState): this;
  66450. }
  66451. }
  66452. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66456. /**
  66457. * Block used to get negative version of a value (i.e. x * -1)
  66458. */
  66459. export class NegateBlock extends NodeMaterialBlock {
  66460. /**
  66461. * Creates a new NegateBlock
  66462. * @param name defines the block name
  66463. */
  66464. constructor(name: string);
  66465. /**
  66466. * Gets the current class name
  66467. * @returns the class name
  66468. */
  66469. getClassName(): string;
  66470. /**
  66471. * Gets the value input component
  66472. */
  66473. get value(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the output component
  66476. */
  66477. get output(): NodeMaterialConnectionPoint;
  66478. protected _buildBlock(state: NodeMaterialBuildState): this;
  66479. }
  66480. }
  66481. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66485. /**
  66486. * Block used to get the value of the first parameter raised to the power of the second
  66487. */
  66488. export class PowBlock extends NodeMaterialBlock {
  66489. /**
  66490. * Creates a new PowBlock
  66491. * @param name defines the block name
  66492. */
  66493. constructor(name: string);
  66494. /**
  66495. * Gets the current class name
  66496. * @returns the class name
  66497. */
  66498. getClassName(): string;
  66499. /**
  66500. * Gets the value operand input component
  66501. */
  66502. get value(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the power operand input component
  66505. */
  66506. get power(): NodeMaterialConnectionPoint;
  66507. /**
  66508. * Gets the output component
  66509. */
  66510. get output(): NodeMaterialConnectionPoint;
  66511. protected _buildBlock(state: NodeMaterialBuildState): this;
  66512. }
  66513. }
  66514. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66519. /**
  66520. * Block used to get a random number
  66521. */
  66522. export class RandomNumberBlock extends NodeMaterialBlock {
  66523. /**
  66524. * Creates a new RandomNumberBlock
  66525. * @param name defines the block name
  66526. */
  66527. constructor(name: string);
  66528. /**
  66529. * Gets the current class name
  66530. * @returns the class name
  66531. */
  66532. getClassName(): string;
  66533. /**
  66534. * Gets the seed input component
  66535. */
  66536. get seed(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the output component
  66539. */
  66540. get output(): NodeMaterialConnectionPoint;
  66541. protected _buildBlock(state: NodeMaterialBuildState): this;
  66542. }
  66543. }
  66544. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66548. /**
  66549. * Block used to compute arc tangent of 2 values
  66550. */
  66551. export class ArcTan2Block extends NodeMaterialBlock {
  66552. /**
  66553. * Creates a new ArcTan2Block
  66554. * @param name defines the block name
  66555. */
  66556. constructor(name: string);
  66557. /**
  66558. * Gets the current class name
  66559. * @returns the class name
  66560. */
  66561. getClassName(): string;
  66562. /**
  66563. * Gets the x operand input component
  66564. */
  66565. get x(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the y operand input component
  66568. */
  66569. get y(): NodeMaterialConnectionPoint;
  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/smoothStepBlock" {
  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 smooth step a value
  66583. */
  66584. export class SmoothStepBlock extends NodeMaterialBlock {
  66585. /**
  66586. * Creates a new SmoothStepBlock
  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 value operand input component
  66597. */
  66598. get value(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the first edge operand input component
  66601. */
  66602. get edge0(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the second edge operand input component
  66605. */
  66606. get edge1(): NodeMaterialConnectionPoint;
  66607. /**
  66608. * Gets the output component
  66609. */
  66610. get output(): NodeMaterialConnectionPoint;
  66611. protected _buildBlock(state: NodeMaterialBuildState): this;
  66612. }
  66613. }
  66614. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66618. /**
  66619. * Block used to get the reciprocal (1 / x) of a value
  66620. */
  66621. export class ReciprocalBlock extends NodeMaterialBlock {
  66622. /**
  66623. * Creates a new ReciprocalBlock
  66624. * @param name defines the block name
  66625. */
  66626. constructor(name: string);
  66627. /**
  66628. * Gets the current class name
  66629. * @returns the class name
  66630. */
  66631. getClassName(): string;
  66632. /**
  66633. * Gets the input component
  66634. */
  66635. get input(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the output component
  66638. */
  66639. get output(): NodeMaterialConnectionPoint;
  66640. protected _buildBlock(state: NodeMaterialBuildState): this;
  66641. }
  66642. }
  66643. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66647. /**
  66648. * Block used to replace a color by another one
  66649. */
  66650. export class ReplaceColorBlock extends NodeMaterialBlock {
  66651. /**
  66652. * Creates a new ReplaceColorBlock
  66653. * @param name defines the block name
  66654. */
  66655. constructor(name: string);
  66656. /**
  66657. * Gets the current class name
  66658. * @returns the class name
  66659. */
  66660. getClassName(): string;
  66661. /**
  66662. * Gets the value input component
  66663. */
  66664. get value(): NodeMaterialConnectionPoint;
  66665. /**
  66666. * Gets the reference input component
  66667. */
  66668. get reference(): NodeMaterialConnectionPoint;
  66669. /**
  66670. * Gets the distance input component
  66671. */
  66672. get distance(): NodeMaterialConnectionPoint;
  66673. /**
  66674. * Gets the replacement input component
  66675. */
  66676. get replacement(): NodeMaterialConnectionPoint;
  66677. /**
  66678. * Gets the output component
  66679. */
  66680. get output(): NodeMaterialConnectionPoint;
  66681. protected _buildBlock(state: NodeMaterialBuildState): this;
  66682. }
  66683. }
  66684. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66688. /**
  66689. * Block used to posterize a value
  66690. * @see https://en.wikipedia.org/wiki/Posterization
  66691. */
  66692. export class PosterizeBlock extends NodeMaterialBlock {
  66693. /**
  66694. * Creates a new PosterizeBlock
  66695. * @param name defines the block name
  66696. */
  66697. constructor(name: string);
  66698. /**
  66699. * Gets the current class name
  66700. * @returns the class name
  66701. */
  66702. getClassName(): string;
  66703. /**
  66704. * Gets the value input component
  66705. */
  66706. get value(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the steps input component
  66709. */
  66710. get steps(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the output component
  66713. */
  66714. get output(): NodeMaterialConnectionPoint;
  66715. protected _buildBlock(state: NodeMaterialBuildState): this;
  66716. }
  66717. }
  66718. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66722. import { Scene } from "babylonjs/scene";
  66723. /**
  66724. * Operations supported by the Wave block
  66725. */
  66726. export enum WaveBlockKind {
  66727. /** SawTooth */
  66728. SawTooth = 0,
  66729. /** Square */
  66730. Square = 1,
  66731. /** Triangle */
  66732. Triangle = 2
  66733. }
  66734. /**
  66735. * Block used to apply wave operation to floats
  66736. */
  66737. export class WaveBlock extends NodeMaterialBlock {
  66738. /**
  66739. * Gets or sets the kibnd of wave to be applied by the block
  66740. */
  66741. kind: WaveBlockKind;
  66742. /**
  66743. * Creates a new WaveBlock
  66744. * @param name defines the block name
  66745. */
  66746. constructor(name: string);
  66747. /**
  66748. * Gets the current class name
  66749. * @returns the class name
  66750. */
  66751. getClassName(): string;
  66752. /**
  66753. * Gets the input component
  66754. */
  66755. get input(): NodeMaterialConnectionPoint;
  66756. /**
  66757. * Gets the output component
  66758. */
  66759. get output(): NodeMaterialConnectionPoint;
  66760. protected _buildBlock(state: NodeMaterialBuildState): this;
  66761. serialize(): any;
  66762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66763. }
  66764. }
  66765. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66769. import { Color3 } from "babylonjs/Maths/math.color";
  66770. import { Scene } from "babylonjs/scene";
  66771. /**
  66772. * Class used to store a color step for the GradientBlock
  66773. */
  66774. export class GradientBlockColorStep {
  66775. /**
  66776. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66777. */
  66778. step: number;
  66779. /**
  66780. * Gets or sets the color associated with this step
  66781. */
  66782. color: Color3;
  66783. /**
  66784. * Creates a new GradientBlockColorStep
  66785. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66786. * @param color defines the color associated with this step
  66787. */
  66788. constructor(
  66789. /**
  66790. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66791. */
  66792. step: number,
  66793. /**
  66794. * Gets or sets the color associated with this step
  66795. */
  66796. color: Color3);
  66797. }
  66798. /**
  66799. * Block used to return a color from a gradient based on an input value between 0 and 1
  66800. */
  66801. export class GradientBlock extends NodeMaterialBlock {
  66802. /**
  66803. * Gets or sets the list of color steps
  66804. */
  66805. colorSteps: GradientBlockColorStep[];
  66806. /**
  66807. * Creates a new GradientBlock
  66808. * @param name defines the block name
  66809. */
  66810. constructor(name: string);
  66811. /**
  66812. * Gets the current class name
  66813. * @returns the class name
  66814. */
  66815. getClassName(): string;
  66816. /**
  66817. * Gets the gradient input component
  66818. */
  66819. get gradient(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the output component
  66822. */
  66823. get output(): NodeMaterialConnectionPoint;
  66824. private _writeColorConstant;
  66825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66826. serialize(): any;
  66827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66828. protected _dumpPropertiesCode(): string;
  66829. }
  66830. }
  66831. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66835. /**
  66836. * Block used to normalize lerp between 2 values
  66837. */
  66838. export class NLerpBlock extends NodeMaterialBlock {
  66839. /**
  66840. * Creates a new NLerpBlock
  66841. * @param name defines the block name
  66842. */
  66843. constructor(name: string);
  66844. /**
  66845. * Gets the current class name
  66846. * @returns the class name
  66847. */
  66848. getClassName(): string;
  66849. /**
  66850. * Gets the left operand input component
  66851. */
  66852. get left(): NodeMaterialConnectionPoint;
  66853. /**
  66854. * Gets the right operand input component
  66855. */
  66856. get right(): NodeMaterialConnectionPoint;
  66857. /**
  66858. * Gets the gradient operand input component
  66859. */
  66860. get gradient(): NodeMaterialConnectionPoint;
  66861. /**
  66862. * Gets the output component
  66863. */
  66864. get output(): NodeMaterialConnectionPoint;
  66865. protected _buildBlock(state: NodeMaterialBuildState): this;
  66866. }
  66867. }
  66868. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66872. import { Scene } from "babylonjs/scene";
  66873. /**
  66874. * block used to Generate a Worley Noise 3D Noise Pattern
  66875. */
  66876. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66877. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66878. manhattanDistance: boolean;
  66879. /**
  66880. * Creates a new WorleyNoise3DBlock
  66881. * @param name defines the block name
  66882. */
  66883. constructor(name: string);
  66884. /**
  66885. * Gets the current class name
  66886. * @returns the class name
  66887. */
  66888. getClassName(): string;
  66889. /**
  66890. * Gets the seed input component
  66891. */
  66892. get seed(): NodeMaterialConnectionPoint;
  66893. /**
  66894. * Gets the jitter input component
  66895. */
  66896. get jitter(): NodeMaterialConnectionPoint;
  66897. /**
  66898. * Gets the output component
  66899. */
  66900. get output(): NodeMaterialConnectionPoint;
  66901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66902. /**
  66903. * Exposes the properties to the UI?
  66904. */
  66905. protected _dumpPropertiesCode(): string;
  66906. /**
  66907. * Exposes the properties to the Seralize?
  66908. */
  66909. serialize(): any;
  66910. /**
  66911. * Exposes the properties to the deseralize?
  66912. */
  66913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66914. }
  66915. }
  66916. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66920. /**
  66921. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66922. */
  66923. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66924. /**
  66925. * Creates a new SimplexPerlin3DBlock
  66926. * @param name defines the block name
  66927. */
  66928. constructor(name: string);
  66929. /**
  66930. * Gets the current class name
  66931. * @returns the class name
  66932. */
  66933. getClassName(): string;
  66934. /**
  66935. * Gets the seed operand input component
  66936. */
  66937. get seed(): NodeMaterialConnectionPoint;
  66938. /**
  66939. * Gets the output component
  66940. */
  66941. get output(): NodeMaterialConnectionPoint;
  66942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66943. }
  66944. }
  66945. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66949. /**
  66950. * Block used to blend normals
  66951. */
  66952. export class NormalBlendBlock extends NodeMaterialBlock {
  66953. /**
  66954. * Creates a new NormalBlendBlock
  66955. * @param name defines the block name
  66956. */
  66957. constructor(name: string);
  66958. /**
  66959. * Gets the current class name
  66960. * @returns the class name
  66961. */
  66962. getClassName(): string;
  66963. /**
  66964. * Gets the first input component
  66965. */
  66966. get normalMap0(): NodeMaterialConnectionPoint;
  66967. /**
  66968. * Gets the second input component
  66969. */
  66970. get normalMap1(): NodeMaterialConnectionPoint;
  66971. /**
  66972. * Gets the output component
  66973. */
  66974. get output(): NodeMaterialConnectionPoint;
  66975. protected _buildBlock(state: NodeMaterialBuildState): this;
  66976. }
  66977. }
  66978. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66982. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66983. /**
  66984. * Block used to rotate a 2d vector by a given angle
  66985. */
  66986. export class Rotate2dBlock extends NodeMaterialBlock {
  66987. /**
  66988. * Creates a new Rotate2dBlock
  66989. * @param name defines the block name
  66990. */
  66991. constructor(name: string);
  66992. /**
  66993. * Gets the current class name
  66994. * @returns the class name
  66995. */
  66996. getClassName(): string;
  66997. /**
  66998. * Gets the input vector
  66999. */
  67000. get input(): NodeMaterialConnectionPoint;
  67001. /**
  67002. * Gets the input angle
  67003. */
  67004. get angle(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the output component
  67007. */
  67008. get output(): NodeMaterialConnectionPoint;
  67009. autoConfigure(material: NodeMaterial): void;
  67010. protected _buildBlock(state: NodeMaterialBuildState): this;
  67011. }
  67012. }
  67013. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67017. /**
  67018. * Block used to get the reflected vector from a direction and a normal
  67019. */
  67020. export class ReflectBlock extends NodeMaterialBlock {
  67021. /**
  67022. * Creates a new ReflectBlock
  67023. * @param name defines the block name
  67024. */
  67025. constructor(name: string);
  67026. /**
  67027. * Gets the current class name
  67028. * @returns the class name
  67029. */
  67030. getClassName(): string;
  67031. /**
  67032. * Gets the incident component
  67033. */
  67034. get incident(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the normal component
  67037. */
  67038. get normal(): NodeMaterialConnectionPoint;
  67039. /**
  67040. * Gets the output component
  67041. */
  67042. get output(): NodeMaterialConnectionPoint;
  67043. protected _buildBlock(state: NodeMaterialBuildState): this;
  67044. }
  67045. }
  67046. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67050. /**
  67051. * Block used to get the refracted vector from a direction and a normal
  67052. */
  67053. export class RefractBlock extends NodeMaterialBlock {
  67054. /**
  67055. * Creates a new RefractBlock
  67056. * @param name defines the block name
  67057. */
  67058. constructor(name: string);
  67059. /**
  67060. * Gets the current class name
  67061. * @returns the class name
  67062. */
  67063. getClassName(): string;
  67064. /**
  67065. * Gets the incident component
  67066. */
  67067. get incident(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the normal component
  67070. */
  67071. get normal(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the index of refraction component
  67074. */
  67075. get ior(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the output component
  67078. */
  67079. get output(): NodeMaterialConnectionPoint;
  67080. protected _buildBlock(state: NodeMaterialBuildState): this;
  67081. }
  67082. }
  67083. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67087. /**
  67088. * Block used to desaturate a color
  67089. */
  67090. export class DesaturateBlock extends NodeMaterialBlock {
  67091. /**
  67092. * Creates a new DesaturateBlock
  67093. * @param name defines the block name
  67094. */
  67095. constructor(name: string);
  67096. /**
  67097. * Gets the current class name
  67098. * @returns the class name
  67099. */
  67100. getClassName(): string;
  67101. /**
  67102. * Gets the color operand input component
  67103. */
  67104. get color(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the level operand input component
  67107. */
  67108. get level(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the output component
  67111. */
  67112. get output(): NodeMaterialConnectionPoint;
  67113. protected _buildBlock(state: NodeMaterialBuildState): this;
  67114. }
  67115. }
  67116. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67120. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67121. import { Nullable } from "babylonjs/types";
  67122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67123. import { Scene } from "babylonjs/scene";
  67124. /**
  67125. * Block used to implement the ambient occlusion module of the PBR material
  67126. */
  67127. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67128. /**
  67129. * Create a new AmbientOcclusionBlock
  67130. * @param name defines the block name
  67131. */
  67132. constructor(name: string);
  67133. /**
  67134. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67135. */
  67136. useAmbientInGrayScale: boolean;
  67137. /**
  67138. * Initialize the block and prepare the context for build
  67139. * @param state defines the state that will be used for the build
  67140. */
  67141. initialize(state: NodeMaterialBuildState): void;
  67142. /**
  67143. * Gets the current class name
  67144. * @returns the class name
  67145. */
  67146. getClassName(): string;
  67147. /**
  67148. * Gets the texture input component
  67149. */
  67150. get texture(): NodeMaterialConnectionPoint;
  67151. /**
  67152. * Gets the texture intensity component
  67153. */
  67154. get intensity(): NodeMaterialConnectionPoint;
  67155. /**
  67156. * Gets the direct light intensity input component
  67157. */
  67158. get directLightIntensity(): NodeMaterialConnectionPoint;
  67159. /**
  67160. * Gets the ambient occlusion object output component
  67161. */
  67162. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67163. /**
  67164. * Gets the main code of the block (fragment side)
  67165. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67166. * @returns the shader code
  67167. */
  67168. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67170. protected _buildBlock(state: NodeMaterialBuildState): this;
  67171. protected _dumpPropertiesCode(): string;
  67172. serialize(): any;
  67173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67174. }
  67175. }
  67176. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67180. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67182. import { Nullable } from "babylonjs/types";
  67183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67184. import { Mesh } from "babylonjs/Meshes/mesh";
  67185. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67186. import { Effect } from "babylonjs/Materials/effect";
  67187. import { Scene } from "babylonjs/scene";
  67188. /**
  67189. * Block used to implement the reflection module of the PBR material
  67190. */
  67191. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67192. /** @hidden */
  67193. _defineLODReflectionAlpha: string;
  67194. /** @hidden */
  67195. _defineLinearSpecularReflection: string;
  67196. private _vEnvironmentIrradianceName;
  67197. /** @hidden */
  67198. _vReflectionMicrosurfaceInfosName: string;
  67199. /** @hidden */
  67200. _vReflectionInfosName: string;
  67201. /** @hidden */
  67202. _vReflectionFilteringInfoName: string;
  67203. private _scene;
  67204. /**
  67205. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67206. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67207. * It's less burden on the user side in the editor part.
  67208. */
  67209. /** @hidden */
  67210. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67211. /** @hidden */
  67212. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67213. /** @hidden */
  67214. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67215. /**
  67216. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67217. * diffuse part of the IBL.
  67218. */
  67219. useSphericalHarmonics: boolean;
  67220. /**
  67221. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67222. */
  67223. forceIrradianceInFragment: boolean;
  67224. /**
  67225. * Create a new ReflectionBlock
  67226. * @param name defines the block name
  67227. */
  67228. constructor(name: string);
  67229. /**
  67230. * Gets the current class name
  67231. * @returns the class name
  67232. */
  67233. getClassName(): string;
  67234. /**
  67235. * Gets the position input component
  67236. */
  67237. get position(): NodeMaterialConnectionPoint;
  67238. /**
  67239. * Gets the world position input component
  67240. */
  67241. get worldPosition(): NodeMaterialConnectionPoint;
  67242. /**
  67243. * Gets the world normal input component
  67244. */
  67245. get worldNormal(): NodeMaterialConnectionPoint;
  67246. /**
  67247. * Gets the world input component
  67248. */
  67249. get world(): NodeMaterialConnectionPoint;
  67250. /**
  67251. * Gets the camera (or eye) position component
  67252. */
  67253. get cameraPosition(): NodeMaterialConnectionPoint;
  67254. /**
  67255. * Gets the view input component
  67256. */
  67257. get view(): NodeMaterialConnectionPoint;
  67258. /**
  67259. * Gets the color input component
  67260. */
  67261. get color(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the reflection object output component
  67264. */
  67265. get reflection(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67268. */
  67269. get hasTexture(): boolean;
  67270. /**
  67271. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67272. */
  67273. get reflectionColor(): string;
  67274. protected _getTexture(): Nullable<BaseTexture>;
  67275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67277. /**
  67278. * Gets the code to inject in the vertex shader
  67279. * @param state current state of the node material building
  67280. * @returns the shader code
  67281. */
  67282. handleVertexSide(state: NodeMaterialBuildState): string;
  67283. /**
  67284. * Gets the main code of the block (fragment side)
  67285. * @param state current state of the node material building
  67286. * @param normalVarName name of the existing variable corresponding to the normal
  67287. * @returns the shader code
  67288. */
  67289. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67290. protected _buildBlock(state: NodeMaterialBuildState): this;
  67291. protected _dumpPropertiesCode(): string;
  67292. serialize(): any;
  67293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67294. }
  67295. }
  67296. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67300. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67302. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67303. import { Scene } from "babylonjs/scene";
  67304. import { Nullable } from "babylonjs/types";
  67305. /**
  67306. * Block used to implement the sheen module of the PBR material
  67307. */
  67308. export class SheenBlock extends NodeMaterialBlock {
  67309. /**
  67310. * Create a new SheenBlock
  67311. * @param name defines the block name
  67312. */
  67313. constructor(name: string);
  67314. /**
  67315. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67316. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67317. * making it easier to setup and tweak the effect
  67318. */
  67319. albedoScaling: boolean;
  67320. /**
  67321. * Defines if the sheen is linked to the sheen color.
  67322. */
  67323. linkSheenWithAlbedo: boolean;
  67324. /**
  67325. * Initialize the block and prepare the context for build
  67326. * @param state defines the state that will be used for the build
  67327. */
  67328. initialize(state: NodeMaterialBuildState): void;
  67329. /**
  67330. * Gets the current class name
  67331. * @returns the class name
  67332. */
  67333. getClassName(): string;
  67334. /**
  67335. * Gets the intensity input component
  67336. */
  67337. get intensity(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the color input component
  67340. */
  67341. get color(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the roughness input component
  67344. */
  67345. get roughness(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the sheen object output component
  67348. */
  67349. get sheen(): NodeMaterialConnectionPoint;
  67350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67351. /**
  67352. * Gets the main code of the block (fragment side)
  67353. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67354. * @returns the shader code
  67355. */
  67356. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67357. protected _buildBlock(state: NodeMaterialBuildState): this;
  67358. protected _dumpPropertiesCode(): string;
  67359. serialize(): any;
  67360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67361. }
  67362. }
  67363. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67364. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67369. import { Scene } from "babylonjs/scene";
  67370. import { Nullable } from "babylonjs/types";
  67371. import { Mesh } from "babylonjs/Meshes/mesh";
  67372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67373. import { Effect } from "babylonjs/Materials/effect";
  67374. /**
  67375. * Block used to implement the reflectivity module of the PBR material
  67376. */
  67377. export class ReflectivityBlock extends NodeMaterialBlock {
  67378. private _metallicReflectanceColor;
  67379. private _metallicF0Factor;
  67380. /** @hidden */
  67381. _vMetallicReflectanceFactorsName: string;
  67382. /**
  67383. * The property below is set by the main PBR block prior to calling methods of this class.
  67384. */
  67385. /** @hidden */
  67386. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67387. /**
  67388. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67389. */
  67390. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67391. /**
  67392. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67393. */
  67394. useMetallnessFromMetallicTextureBlue: boolean;
  67395. /**
  67396. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67397. */
  67398. useRoughnessFromMetallicTextureAlpha: boolean;
  67399. /**
  67400. * Specifies if the metallic texture contains the roughness information in its green channel.
  67401. */
  67402. useRoughnessFromMetallicTextureGreen: boolean;
  67403. /**
  67404. * Create a new ReflectivityBlock
  67405. * @param name defines the block name
  67406. */
  67407. constructor(name: string);
  67408. /**
  67409. * Initialize the block and prepare the context for build
  67410. * @param state defines the state that will be used for the build
  67411. */
  67412. initialize(state: NodeMaterialBuildState): void;
  67413. /**
  67414. * Gets the current class name
  67415. * @returns the class name
  67416. */
  67417. getClassName(): string;
  67418. /**
  67419. * Gets the metallic input component
  67420. */
  67421. get metallic(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the roughness input component
  67424. */
  67425. get roughness(): NodeMaterialConnectionPoint;
  67426. /**
  67427. * Gets the texture input component
  67428. */
  67429. get texture(): NodeMaterialConnectionPoint;
  67430. /**
  67431. * Gets the reflectivity object output component
  67432. */
  67433. get reflectivity(): NodeMaterialConnectionPoint;
  67434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67435. /**
  67436. * Gets the main code of the block (fragment side)
  67437. * @param state current state of the node material building
  67438. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67439. * @returns the shader code
  67440. */
  67441. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67443. protected _buildBlock(state: NodeMaterialBuildState): this;
  67444. protected _dumpPropertiesCode(): string;
  67445. serialize(): any;
  67446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67447. }
  67448. }
  67449. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67450. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67455. /**
  67456. * Block used to implement the anisotropy module of the PBR material
  67457. */
  67458. export class AnisotropyBlock extends NodeMaterialBlock {
  67459. /**
  67460. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67461. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67462. * It's less burden on the user side in the editor part.
  67463. */
  67464. /** @hidden */
  67465. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67466. /** @hidden */
  67467. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67468. /**
  67469. * Create a new AnisotropyBlock
  67470. * @param name defines the block name
  67471. */
  67472. constructor(name: string);
  67473. /**
  67474. * Initialize the block and prepare the context for build
  67475. * @param state defines the state that will be used for the build
  67476. */
  67477. initialize(state: NodeMaterialBuildState): void;
  67478. /**
  67479. * Gets the current class name
  67480. * @returns the class name
  67481. */
  67482. getClassName(): string;
  67483. /**
  67484. * Gets the intensity input component
  67485. */
  67486. get intensity(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the direction input component
  67489. */
  67490. get direction(): NodeMaterialConnectionPoint;
  67491. /**
  67492. * Gets the texture input component
  67493. */
  67494. get texture(): NodeMaterialConnectionPoint;
  67495. /**
  67496. * Gets the uv input component
  67497. */
  67498. get uv(): NodeMaterialConnectionPoint;
  67499. /**
  67500. * Gets the worldTangent input component
  67501. */
  67502. get worldTangent(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the anisotropy object output component
  67505. */
  67506. get anisotropy(): NodeMaterialConnectionPoint;
  67507. private _generateTBNSpace;
  67508. /**
  67509. * Gets the main code of the block (fragment side)
  67510. * @param state current state of the node material building
  67511. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67512. * @returns the shader code
  67513. */
  67514. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67516. protected _buildBlock(state: NodeMaterialBuildState): this;
  67517. }
  67518. }
  67519. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67523. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67525. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67526. import { Nullable } from "babylonjs/types";
  67527. import { Mesh } from "babylonjs/Meshes/mesh";
  67528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67529. import { Effect } from "babylonjs/Materials/effect";
  67530. /**
  67531. * Block used to implement the clear coat module of the PBR material
  67532. */
  67533. export class ClearCoatBlock extends NodeMaterialBlock {
  67534. private _scene;
  67535. /**
  67536. * Create a new ClearCoatBlock
  67537. * @param name defines the block name
  67538. */
  67539. constructor(name: string);
  67540. /**
  67541. * Initialize the block and prepare the context for build
  67542. * @param state defines the state that will be used for the build
  67543. */
  67544. initialize(state: NodeMaterialBuildState): void;
  67545. /**
  67546. * Gets the current class name
  67547. * @returns the class name
  67548. */
  67549. getClassName(): string;
  67550. /**
  67551. * Gets the intensity input component
  67552. */
  67553. get intensity(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the roughness input component
  67556. */
  67557. get roughness(): NodeMaterialConnectionPoint;
  67558. /**
  67559. * Gets the ior input component
  67560. */
  67561. get ior(): NodeMaterialConnectionPoint;
  67562. /**
  67563. * Gets the texture input component
  67564. */
  67565. get texture(): NodeMaterialConnectionPoint;
  67566. /**
  67567. * Gets the bump texture input component
  67568. */
  67569. get bumpTexture(): NodeMaterialConnectionPoint;
  67570. /**
  67571. * Gets the uv input component
  67572. */
  67573. get uv(): NodeMaterialConnectionPoint;
  67574. /**
  67575. * Gets the tint color input component
  67576. */
  67577. get tintColor(): NodeMaterialConnectionPoint;
  67578. /**
  67579. * Gets the tint "at distance" input component
  67580. */
  67581. get tintAtDistance(): NodeMaterialConnectionPoint;
  67582. /**
  67583. * Gets the tint thickness input component
  67584. */
  67585. get tintThickness(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the world tangent input component
  67588. */
  67589. get worldTangent(): NodeMaterialConnectionPoint;
  67590. /**
  67591. * Gets the clear coat object output component
  67592. */
  67593. get clearcoat(): NodeMaterialConnectionPoint;
  67594. autoConfigure(material: NodeMaterial): void;
  67595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67597. private _generateTBNSpace;
  67598. /**
  67599. * Gets the main code of the block (fragment side)
  67600. * @param state current state of the node material building
  67601. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67602. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67603. * @param worldPosVarName name of the variable holding the world position
  67604. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67605. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67606. * @param worldNormalVarName name of the variable holding the world normal
  67607. * @returns the shader code
  67608. */
  67609. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67610. protected _buildBlock(state: NodeMaterialBuildState): this;
  67611. }
  67612. }
  67613. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67617. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67619. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67620. import { Nullable } from "babylonjs/types";
  67621. /**
  67622. * Block used to implement the sub surface module of the PBR material
  67623. */
  67624. export class SubSurfaceBlock extends NodeMaterialBlock {
  67625. /**
  67626. * Create a new SubSurfaceBlock
  67627. * @param name defines the block name
  67628. */
  67629. constructor(name: string);
  67630. /**
  67631. * Stores the intensity of the different subsurface effects in the thickness texture.
  67632. * * the green channel is the translucency intensity.
  67633. * * the blue channel is the scattering intensity.
  67634. * * the alpha channel is the refraction intensity.
  67635. */
  67636. useMaskFromThicknessTexture: boolean;
  67637. /**
  67638. * Initialize the block and prepare the context for build
  67639. * @param state defines the state that will be used for the build
  67640. */
  67641. initialize(state: NodeMaterialBuildState): void;
  67642. /**
  67643. * Gets the current class name
  67644. * @returns the class name
  67645. */
  67646. getClassName(): string;
  67647. /**
  67648. * Gets the min thickness input component
  67649. */
  67650. get minThickness(): NodeMaterialConnectionPoint;
  67651. /**
  67652. * Gets the max thickness input component
  67653. */
  67654. get maxThickness(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the thickness texture component
  67657. */
  67658. get thicknessTexture(): NodeMaterialConnectionPoint;
  67659. /**
  67660. * Gets the tint color input component
  67661. */
  67662. get tintColor(): NodeMaterialConnectionPoint;
  67663. /**
  67664. * Gets the translucency intensity input component
  67665. */
  67666. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67667. /**
  67668. * Gets the translucency diffusion distance input component
  67669. */
  67670. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the refraction object parameters
  67673. */
  67674. get refraction(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the sub surface object output component
  67677. */
  67678. get subsurface(): NodeMaterialConnectionPoint;
  67679. autoConfigure(material: NodeMaterial): void;
  67680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67681. /**
  67682. * Gets the main code of the block (fragment side)
  67683. * @param state current state of the node material building
  67684. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67685. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67686. * @param worldPosVarName name of the variable holding the world position
  67687. * @returns the shader code
  67688. */
  67689. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67690. protected _buildBlock(state: NodeMaterialBuildState): this;
  67691. }
  67692. }
  67693. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67698. import { Light } from "babylonjs/Lights/light";
  67699. import { Nullable } from "babylonjs/types";
  67700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67701. import { Effect } from "babylonjs/Materials/effect";
  67702. import { Mesh } from "babylonjs/Meshes/mesh";
  67703. import { Scene } from "babylonjs/scene";
  67704. /**
  67705. * Block used to implement the PBR metallic/roughness model
  67706. */
  67707. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67708. /**
  67709. * Gets or sets the light associated with this block
  67710. */
  67711. light: Nullable<Light>;
  67712. private _lightId;
  67713. private _scene;
  67714. private _environmentBRDFTexture;
  67715. private _environmentBrdfSamplerName;
  67716. private _vNormalWName;
  67717. private _invertNormalName;
  67718. /**
  67719. * Create a new ReflectionBlock
  67720. * @param name defines the block name
  67721. */
  67722. constructor(name: string);
  67723. /**
  67724. * Intensity of the direct lights e.g. the four lights available in your scene.
  67725. * This impacts both the direct diffuse and specular highlights.
  67726. */
  67727. directIntensity: number;
  67728. /**
  67729. * Intensity of the environment e.g. how much the environment will light the object
  67730. * either through harmonics for rough material or through the refelction for shiny ones.
  67731. */
  67732. environmentIntensity: number;
  67733. /**
  67734. * This is a special control allowing the reduction of the specular highlights coming from the
  67735. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67736. */
  67737. specularIntensity: number;
  67738. /**
  67739. * Defines the falloff type used in this material.
  67740. * It by default is Physical.
  67741. */
  67742. lightFalloff: number;
  67743. /**
  67744. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67745. */
  67746. useAlphaFromAlbedoTexture: boolean;
  67747. /**
  67748. * Specifies that alpha test should be used
  67749. */
  67750. useAlphaTest: boolean;
  67751. /**
  67752. * Defines the alpha limits in alpha test mode.
  67753. */
  67754. alphaTestCutoff: number;
  67755. /**
  67756. * Specifies that alpha blending should be used
  67757. */
  67758. useAlphaBlending: boolean;
  67759. /**
  67760. * Defines if the alpha value should be determined via the rgb values.
  67761. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67762. */
  67763. opacityRGB: boolean;
  67764. /**
  67765. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67766. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67767. */
  67768. useRadianceOverAlpha: boolean;
  67769. /**
  67770. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67771. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67772. */
  67773. useSpecularOverAlpha: boolean;
  67774. /**
  67775. * Enables specular anti aliasing in the PBR shader.
  67776. * It will both interacts on the Geometry for analytical and IBL lighting.
  67777. * It also prefilter the roughness map based on the bump values.
  67778. */
  67779. enableSpecularAntiAliasing: boolean;
  67780. /**
  67781. * Enables realtime filtering on the texture.
  67782. */
  67783. realTimeFiltering: boolean;
  67784. /**
  67785. * Quality switch for realtime filtering
  67786. */
  67787. realTimeFilteringQuality: number;
  67788. /**
  67789. * Defines if the material uses energy conservation.
  67790. */
  67791. useEnergyConservation: boolean;
  67792. /**
  67793. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67794. * too much the area relying on ambient texture to define their ambient occlusion.
  67795. */
  67796. useRadianceOcclusion: boolean;
  67797. /**
  67798. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67799. * makes the reflect vector face the model (under horizon).
  67800. */
  67801. useHorizonOcclusion: boolean;
  67802. /**
  67803. * If set to true, no lighting calculations will be applied.
  67804. */
  67805. unlit: boolean;
  67806. /**
  67807. * Force normal to face away from face.
  67808. */
  67809. forceNormalForward: boolean;
  67810. /**
  67811. * Defines the material debug mode.
  67812. * It helps seeing only some components of the material while troubleshooting.
  67813. */
  67814. debugMode: number;
  67815. /**
  67816. * Specify from where on screen the debug mode should start.
  67817. * The value goes from -1 (full screen) to 1 (not visible)
  67818. * It helps with side by side comparison against the final render
  67819. * This defaults to 0
  67820. */
  67821. debugLimit: number;
  67822. /**
  67823. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67824. * You can use the factor to better multiply the final value.
  67825. */
  67826. debugFactor: number;
  67827. /**
  67828. * Initialize the block and prepare the context for build
  67829. * @param state defines the state that will be used for the build
  67830. */
  67831. initialize(state: NodeMaterialBuildState): void;
  67832. /**
  67833. * Gets the current class name
  67834. * @returns the class name
  67835. */
  67836. getClassName(): string;
  67837. /**
  67838. * Gets the world position input component
  67839. */
  67840. get worldPosition(): NodeMaterialConnectionPoint;
  67841. /**
  67842. * Gets the world normal input component
  67843. */
  67844. get worldNormal(): NodeMaterialConnectionPoint;
  67845. /**
  67846. * Gets the perturbed normal input component
  67847. */
  67848. get perturbedNormal(): NodeMaterialConnectionPoint;
  67849. /**
  67850. * Gets the camera position input component
  67851. */
  67852. get cameraPosition(): NodeMaterialConnectionPoint;
  67853. /**
  67854. * Gets the base color input component
  67855. */
  67856. get baseColor(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the opacity texture input component
  67859. */
  67860. get opacityTexture(): NodeMaterialConnectionPoint;
  67861. /**
  67862. * Gets the ambient color input component
  67863. */
  67864. get ambientColor(): NodeMaterialConnectionPoint;
  67865. /**
  67866. * Gets the reflectivity object parameters
  67867. */
  67868. get reflectivity(): NodeMaterialConnectionPoint;
  67869. /**
  67870. * Gets the ambient occlusion object parameters
  67871. */
  67872. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67873. /**
  67874. * Gets the reflection object parameters
  67875. */
  67876. get reflection(): NodeMaterialConnectionPoint;
  67877. /**
  67878. * Gets the sheen object parameters
  67879. */
  67880. get sheen(): NodeMaterialConnectionPoint;
  67881. /**
  67882. * Gets the clear coat object parameters
  67883. */
  67884. get clearcoat(): NodeMaterialConnectionPoint;
  67885. /**
  67886. * Gets the sub surface object parameters
  67887. */
  67888. get subsurface(): NodeMaterialConnectionPoint;
  67889. /**
  67890. * Gets the anisotropy object parameters
  67891. */
  67892. get anisotropy(): NodeMaterialConnectionPoint;
  67893. /**
  67894. * Gets the ambient output component
  67895. */
  67896. get ambient(): NodeMaterialConnectionPoint;
  67897. /**
  67898. * Gets the diffuse output component
  67899. */
  67900. get diffuse(): NodeMaterialConnectionPoint;
  67901. /**
  67902. * Gets the specular output component
  67903. */
  67904. get specular(): NodeMaterialConnectionPoint;
  67905. /**
  67906. * Gets the sheen output component
  67907. */
  67908. get sheenDir(): NodeMaterialConnectionPoint;
  67909. /**
  67910. * Gets the clear coat output component
  67911. */
  67912. get clearcoatDir(): NodeMaterialConnectionPoint;
  67913. /**
  67914. * Gets the indirect diffuse output component
  67915. */
  67916. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67917. /**
  67918. * Gets the indirect specular output component
  67919. */
  67920. get specularIndirect(): NodeMaterialConnectionPoint;
  67921. /**
  67922. * Gets the indirect sheen output component
  67923. */
  67924. get sheenIndirect(): NodeMaterialConnectionPoint;
  67925. /**
  67926. * Gets the indirect clear coat output component
  67927. */
  67928. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67929. /**
  67930. * Gets the refraction output component
  67931. */
  67932. get refraction(): NodeMaterialConnectionPoint;
  67933. /**
  67934. * Gets the global lighting output component
  67935. */
  67936. get lighting(): NodeMaterialConnectionPoint;
  67937. /**
  67938. * Gets the shadow output component
  67939. */
  67940. get shadow(): NodeMaterialConnectionPoint;
  67941. /**
  67942. * Gets the alpha output component
  67943. */
  67944. get alpha(): NodeMaterialConnectionPoint;
  67945. autoConfigure(material: NodeMaterial): void;
  67946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67947. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67949. private _injectVertexCode;
  67950. /**
  67951. * Gets the code corresponding to the albedo/opacity module
  67952. * @returns the shader code
  67953. */
  67954. getAlbedoOpacityCode(): string;
  67955. protected _buildBlock(state: NodeMaterialBuildState): this;
  67956. protected _dumpPropertiesCode(): string;
  67957. serialize(): any;
  67958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67959. }
  67960. }
  67961. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67962. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67963. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67964. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67965. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67966. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67967. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67968. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67969. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67970. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67971. }
  67972. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67973. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67974. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67975. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67976. }
  67977. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67981. /**
  67982. * Block used to compute value of one parameter modulo another
  67983. */
  67984. export class ModBlock extends NodeMaterialBlock {
  67985. /**
  67986. * Creates a new ModBlock
  67987. * @param name defines the block name
  67988. */
  67989. constructor(name: string);
  67990. /**
  67991. * Gets the current class name
  67992. * @returns the class name
  67993. */
  67994. getClassName(): string;
  67995. /**
  67996. * Gets the left operand input component
  67997. */
  67998. get left(): NodeMaterialConnectionPoint;
  67999. /**
  68000. * Gets the right operand input component
  68001. */
  68002. get right(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the output component
  68005. */
  68006. get output(): NodeMaterialConnectionPoint;
  68007. protected _buildBlock(state: NodeMaterialBuildState): this;
  68008. }
  68009. }
  68010. declare module "babylonjs/Materials/Node/Blocks/index" {
  68011. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68012. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68013. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68014. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68015. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68016. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68017. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68018. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68019. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68020. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68021. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68022. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68023. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68024. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68025. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68026. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68027. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68028. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68029. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68030. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68031. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68032. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68033. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68034. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68035. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68036. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68037. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68038. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68039. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68040. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68041. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68042. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68043. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68044. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68045. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68046. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68047. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68048. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68049. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68050. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68051. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68052. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68053. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68054. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68055. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68056. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68057. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68058. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68059. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68060. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68061. }
  68062. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68063. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68064. }
  68065. declare module "babylonjs/Materials/Node/index" {
  68066. export * from "babylonjs/Materials/Node/Enums/index";
  68067. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68068. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68069. export * from "babylonjs/Materials/Node/nodeMaterial";
  68070. export * from "babylonjs/Materials/Node/Blocks/index";
  68071. export * from "babylonjs/Materials/Node/Optimizers/index";
  68072. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68073. }
  68074. declare module "babylonjs/Materials/index" {
  68075. export * from "babylonjs/Materials/Background/index";
  68076. export * from "babylonjs/Materials/colorCurves";
  68077. export * from "babylonjs/Materials/iEffectFallbacks";
  68078. export * from "babylonjs/Materials/effectFallbacks";
  68079. export * from "babylonjs/Materials/effect";
  68080. export * from "babylonjs/Materials/fresnelParameters";
  68081. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68082. export * from "babylonjs/Materials/material";
  68083. export * from "babylonjs/Materials/materialDefines";
  68084. export * from "babylonjs/Materials/thinMaterialHelper";
  68085. export * from "babylonjs/Materials/materialHelper";
  68086. export * from "babylonjs/Materials/multiMaterial";
  68087. export * from "babylonjs/Materials/PBR/index";
  68088. export * from "babylonjs/Materials/pushMaterial";
  68089. export * from "babylonjs/Materials/shaderMaterial";
  68090. export * from "babylonjs/Materials/standardMaterial";
  68091. export * from "babylonjs/Materials/Textures/index";
  68092. export * from "babylonjs/Materials/uniformBuffer";
  68093. export * from "babylonjs/Materials/materialFlags";
  68094. export * from "babylonjs/Materials/Node/index";
  68095. export * from "babylonjs/Materials/effectRenderer";
  68096. export * from "babylonjs/Materials/shadowDepthWrapper";
  68097. }
  68098. declare module "babylonjs/Maths/index" {
  68099. export * from "babylonjs/Maths/math.scalar";
  68100. export * from "babylonjs/Maths/math";
  68101. export * from "babylonjs/Maths/sphericalPolynomial";
  68102. }
  68103. declare module "babylonjs/Misc/workerPool" {
  68104. import { IDisposable } from "babylonjs/scene";
  68105. /**
  68106. * Helper class to push actions to a pool of workers.
  68107. */
  68108. export class WorkerPool implements IDisposable {
  68109. private _workerInfos;
  68110. private _pendingActions;
  68111. /**
  68112. * Constructor
  68113. * @param workers Array of workers to use for actions
  68114. */
  68115. constructor(workers: Array<Worker>);
  68116. /**
  68117. * Terminates all workers and clears any pending actions.
  68118. */
  68119. dispose(): void;
  68120. /**
  68121. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68122. * pended until a worker has completed its action.
  68123. * @param action The action to perform. Call onComplete when the action is complete.
  68124. */
  68125. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68126. private _execute;
  68127. }
  68128. }
  68129. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68130. import { IDisposable } from "babylonjs/scene";
  68131. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68132. /**
  68133. * Configuration for Draco compression
  68134. */
  68135. export interface IDracoCompressionConfiguration {
  68136. /**
  68137. * Configuration for the decoder.
  68138. */
  68139. decoder: {
  68140. /**
  68141. * The url to the WebAssembly module.
  68142. */
  68143. wasmUrl?: string;
  68144. /**
  68145. * The url to the WebAssembly binary.
  68146. */
  68147. wasmBinaryUrl?: string;
  68148. /**
  68149. * The url to the fallback JavaScript module.
  68150. */
  68151. fallbackUrl?: string;
  68152. };
  68153. }
  68154. /**
  68155. * Draco compression (https://google.github.io/draco/)
  68156. *
  68157. * This class wraps the Draco module.
  68158. *
  68159. * **Encoder**
  68160. *
  68161. * The encoder is not currently implemented.
  68162. *
  68163. * **Decoder**
  68164. *
  68165. * 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.
  68166. *
  68167. * To update the configuration, use the following code:
  68168. * ```javascript
  68169. * DracoCompression.Configuration = {
  68170. * decoder: {
  68171. * wasmUrl: "<url to the WebAssembly library>",
  68172. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68173. * fallbackUrl: "<url to the fallback JavaScript library>",
  68174. * }
  68175. * };
  68176. * ```
  68177. *
  68178. * 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.
  68179. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68180. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68181. *
  68182. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68183. * ```javascript
  68184. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68185. * ```
  68186. *
  68187. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68188. */
  68189. export class DracoCompression implements IDisposable {
  68190. private _workerPoolPromise?;
  68191. private _decoderModulePromise?;
  68192. /**
  68193. * The configuration. Defaults to the following urls:
  68194. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68195. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68196. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68197. */
  68198. static Configuration: IDracoCompressionConfiguration;
  68199. /**
  68200. * Returns true if the decoder configuration is available.
  68201. */
  68202. static get DecoderAvailable(): boolean;
  68203. /**
  68204. * Default number of workers to create when creating the draco compression object.
  68205. */
  68206. static DefaultNumWorkers: number;
  68207. private static GetDefaultNumWorkers;
  68208. private static _Default;
  68209. /**
  68210. * Default instance for the draco compression object.
  68211. */
  68212. static get Default(): DracoCompression;
  68213. /**
  68214. * Constructor
  68215. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68216. */
  68217. constructor(numWorkers?: number);
  68218. /**
  68219. * Stop all async operations and release resources.
  68220. */
  68221. dispose(): void;
  68222. /**
  68223. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68224. * @returns a promise that resolves when ready
  68225. */
  68226. whenReadyAsync(): Promise<void>;
  68227. /**
  68228. * Decode Draco compressed mesh data to vertex data.
  68229. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68230. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68231. * @returns A promise that resolves with the decoded vertex data
  68232. */
  68233. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68234. [kind: string]: number;
  68235. }): Promise<VertexData>;
  68236. }
  68237. }
  68238. declare module "babylonjs/Meshes/Compression/index" {
  68239. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68240. }
  68241. declare module "babylonjs/Meshes/csg" {
  68242. import { Nullable } from "babylonjs/types";
  68243. import { Scene } from "babylonjs/scene";
  68244. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68245. import { Mesh } from "babylonjs/Meshes/mesh";
  68246. import { Material } from "babylonjs/Materials/material";
  68247. /**
  68248. * Class for building Constructive Solid Geometry
  68249. */
  68250. export class CSG {
  68251. private polygons;
  68252. /**
  68253. * The world matrix
  68254. */
  68255. matrix: Matrix;
  68256. /**
  68257. * Stores the position
  68258. */
  68259. position: Vector3;
  68260. /**
  68261. * Stores the rotation
  68262. */
  68263. rotation: Vector3;
  68264. /**
  68265. * Stores the rotation quaternion
  68266. */
  68267. rotationQuaternion: Nullable<Quaternion>;
  68268. /**
  68269. * Stores the scaling vector
  68270. */
  68271. scaling: Vector3;
  68272. /**
  68273. * Convert the Mesh to CSG
  68274. * @param mesh The Mesh to convert to CSG
  68275. * @returns A new CSG from the Mesh
  68276. */
  68277. static FromMesh(mesh: Mesh): CSG;
  68278. /**
  68279. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68280. * @param polygons Polygons used to construct a CSG solid
  68281. */
  68282. private static FromPolygons;
  68283. /**
  68284. * Clones, or makes a deep copy, of the CSG
  68285. * @returns A new CSG
  68286. */
  68287. clone(): CSG;
  68288. /**
  68289. * Unions this CSG with another CSG
  68290. * @param csg The CSG to union against this CSG
  68291. * @returns The unioned CSG
  68292. */
  68293. union(csg: CSG): CSG;
  68294. /**
  68295. * Unions this CSG with another CSG in place
  68296. * @param csg The CSG to union against this CSG
  68297. */
  68298. unionInPlace(csg: CSG): void;
  68299. /**
  68300. * Subtracts this CSG with another CSG
  68301. * @param csg The CSG to subtract against this CSG
  68302. * @returns A new CSG
  68303. */
  68304. subtract(csg: CSG): CSG;
  68305. /**
  68306. * Subtracts this CSG with another CSG in place
  68307. * @param csg The CSG to subtact against this CSG
  68308. */
  68309. subtractInPlace(csg: CSG): void;
  68310. /**
  68311. * Intersect this CSG with another CSG
  68312. * @param csg The CSG to intersect against this CSG
  68313. * @returns A new CSG
  68314. */
  68315. intersect(csg: CSG): CSG;
  68316. /**
  68317. * Intersects this CSG with another CSG in place
  68318. * @param csg The CSG to intersect against this CSG
  68319. */
  68320. intersectInPlace(csg: CSG): void;
  68321. /**
  68322. * Return a new CSG solid with solid and empty space switched. This solid is
  68323. * not modified.
  68324. * @returns A new CSG solid with solid and empty space switched
  68325. */
  68326. inverse(): CSG;
  68327. /**
  68328. * Inverses the CSG in place
  68329. */
  68330. inverseInPlace(): void;
  68331. /**
  68332. * This is used to keep meshes transformations so they can be restored
  68333. * when we build back a Babylon Mesh
  68334. * NB : All CSG operations are performed in world coordinates
  68335. * @param csg The CSG to copy the transform attributes from
  68336. * @returns This CSG
  68337. */
  68338. copyTransformAttributes(csg: CSG): CSG;
  68339. /**
  68340. * Build Raw mesh from CSG
  68341. * Coordinates here are in world space
  68342. * @param name The name of the mesh geometry
  68343. * @param scene The Scene
  68344. * @param keepSubMeshes Specifies if the submeshes should be kept
  68345. * @returns A new Mesh
  68346. */
  68347. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68348. /**
  68349. * Build Mesh from CSG taking material and transforms into account
  68350. * @param name The name of the Mesh
  68351. * @param material The material of the Mesh
  68352. * @param scene The Scene
  68353. * @param keepSubMeshes Specifies if submeshes should be kept
  68354. * @returns The new Mesh
  68355. */
  68356. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68357. }
  68358. }
  68359. declare module "babylonjs/Meshes/trailMesh" {
  68360. import { Mesh } from "babylonjs/Meshes/mesh";
  68361. import { Scene } from "babylonjs/scene";
  68362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68363. /**
  68364. * Class used to create a trail following a mesh
  68365. */
  68366. export class TrailMesh extends Mesh {
  68367. private _generator;
  68368. private _autoStart;
  68369. private _running;
  68370. private _diameter;
  68371. private _length;
  68372. private _sectionPolygonPointsCount;
  68373. private _sectionVectors;
  68374. private _sectionNormalVectors;
  68375. private _beforeRenderObserver;
  68376. /**
  68377. * @constructor
  68378. * @param name The value used by scene.getMeshByName() to do a lookup.
  68379. * @param generator The mesh or transform node to generate a trail.
  68380. * @param scene The scene to add this mesh to.
  68381. * @param diameter Diameter of trailing mesh. Default is 1.
  68382. * @param length Length of trailing mesh. Default is 60.
  68383. * @param autoStart Automatically start trailing mesh. Default true.
  68384. */
  68385. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68386. /**
  68387. * "TrailMesh"
  68388. * @returns "TrailMesh"
  68389. */
  68390. getClassName(): string;
  68391. private _createMesh;
  68392. /**
  68393. * Start trailing mesh.
  68394. */
  68395. start(): void;
  68396. /**
  68397. * Stop trailing mesh.
  68398. */
  68399. stop(): void;
  68400. /**
  68401. * Update trailing mesh geometry.
  68402. */
  68403. update(): void;
  68404. /**
  68405. * Returns a new TrailMesh object.
  68406. * @param name is a string, the name given to the new mesh
  68407. * @param newGenerator use new generator object for cloned trail mesh
  68408. * @returns a new mesh
  68409. */
  68410. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68411. /**
  68412. * Serializes this trail mesh
  68413. * @param serializationObject object to write serialization to
  68414. */
  68415. serialize(serializationObject: any): void;
  68416. /**
  68417. * Parses a serialized trail mesh
  68418. * @param parsedMesh the serialized mesh
  68419. * @param scene the scene to create the trail mesh in
  68420. * @returns the created trail mesh
  68421. */
  68422. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68423. }
  68424. }
  68425. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68426. import { Nullable } from "babylonjs/types";
  68427. import { Scene } from "babylonjs/scene";
  68428. import { Vector4 } from "babylonjs/Maths/math.vector";
  68429. import { Color4 } from "babylonjs/Maths/math.color";
  68430. import { Mesh } from "babylonjs/Meshes/mesh";
  68431. /**
  68432. * Class containing static functions to help procedurally build meshes
  68433. */
  68434. export class TiledBoxBuilder {
  68435. /**
  68436. * Creates a box mesh
  68437. * 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)
  68438. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68442. * @param name defines the name of the mesh
  68443. * @param options defines the options used to create the mesh
  68444. * @param scene defines the hosting scene
  68445. * @returns the box mesh
  68446. */
  68447. static CreateTiledBox(name: string, options: {
  68448. pattern?: number;
  68449. width?: number;
  68450. height?: number;
  68451. depth?: number;
  68452. tileSize?: number;
  68453. tileWidth?: number;
  68454. tileHeight?: number;
  68455. alignHorizontal?: number;
  68456. alignVertical?: number;
  68457. faceUV?: Vector4[];
  68458. faceColors?: Color4[];
  68459. sideOrientation?: number;
  68460. updatable?: boolean;
  68461. }, scene?: Nullable<Scene>): Mesh;
  68462. }
  68463. }
  68464. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68465. import { Vector4 } from "babylonjs/Maths/math.vector";
  68466. import { Mesh } from "babylonjs/Meshes/mesh";
  68467. /**
  68468. * Class containing static functions to help procedurally build meshes
  68469. */
  68470. export class TorusKnotBuilder {
  68471. /**
  68472. * Creates a torus knot mesh
  68473. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68474. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68475. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68476. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68480. * @param name defines the name of the mesh
  68481. * @param options defines the options used to create the mesh
  68482. * @param scene defines the hosting scene
  68483. * @returns the torus knot mesh
  68484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68485. */
  68486. static CreateTorusKnot(name: string, options: {
  68487. radius?: number;
  68488. tube?: number;
  68489. radialSegments?: number;
  68490. tubularSegments?: number;
  68491. p?: number;
  68492. q?: number;
  68493. updatable?: boolean;
  68494. sideOrientation?: number;
  68495. frontUVs?: Vector4;
  68496. backUVs?: Vector4;
  68497. }, scene: any): Mesh;
  68498. }
  68499. }
  68500. declare module "babylonjs/Meshes/polygonMesh" {
  68501. import { Scene } from "babylonjs/scene";
  68502. import { Vector2 } from "babylonjs/Maths/math.vector";
  68503. import { Mesh } from "babylonjs/Meshes/mesh";
  68504. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68505. import { Path2 } from "babylonjs/Maths/math.path";
  68506. /**
  68507. * Polygon
  68508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68509. */
  68510. export class Polygon {
  68511. /**
  68512. * Creates a rectangle
  68513. * @param xmin bottom X coord
  68514. * @param ymin bottom Y coord
  68515. * @param xmax top X coord
  68516. * @param ymax top Y coord
  68517. * @returns points that make the resulting rectation
  68518. */
  68519. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68520. /**
  68521. * Creates a circle
  68522. * @param radius radius of circle
  68523. * @param cx scale in x
  68524. * @param cy scale in y
  68525. * @param numberOfSides number of sides that make up the circle
  68526. * @returns points that make the resulting circle
  68527. */
  68528. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68529. /**
  68530. * Creates a polygon from input string
  68531. * @param input Input polygon data
  68532. * @returns the parsed points
  68533. */
  68534. static Parse(input: string): Vector2[];
  68535. /**
  68536. * Starts building a polygon from x and y coordinates
  68537. * @param x x coordinate
  68538. * @param y y coordinate
  68539. * @returns the started path2
  68540. */
  68541. static StartingAt(x: number, y: number): Path2;
  68542. }
  68543. /**
  68544. * Builds a polygon
  68545. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68546. */
  68547. export class PolygonMeshBuilder {
  68548. private _points;
  68549. private _outlinepoints;
  68550. private _holes;
  68551. private _name;
  68552. private _scene;
  68553. private _epoints;
  68554. private _eholes;
  68555. private _addToepoint;
  68556. /**
  68557. * Babylon reference to the earcut plugin.
  68558. */
  68559. bjsEarcut: any;
  68560. /**
  68561. * Creates a PolygonMeshBuilder
  68562. * @param name name of the builder
  68563. * @param contours Path of the polygon
  68564. * @param scene scene to add to when creating the mesh
  68565. * @param earcutInjection can be used to inject your own earcut reference
  68566. */
  68567. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68568. /**
  68569. * Adds a whole within the polygon
  68570. * @param hole Array of points defining the hole
  68571. * @returns this
  68572. */
  68573. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68574. /**
  68575. * Creates the polygon
  68576. * @param updatable If the mesh should be updatable
  68577. * @param depth The depth of the mesh created
  68578. * @returns the created mesh
  68579. */
  68580. build(updatable?: boolean, depth?: number): Mesh;
  68581. /**
  68582. * Creates the polygon
  68583. * @param depth The depth of the mesh created
  68584. * @returns the created VertexData
  68585. */
  68586. buildVertexData(depth?: number): VertexData;
  68587. /**
  68588. * Adds a side to the polygon
  68589. * @param positions points that make the polygon
  68590. * @param normals normals of the polygon
  68591. * @param uvs uvs of the polygon
  68592. * @param indices indices of the polygon
  68593. * @param bounds bounds of the polygon
  68594. * @param points points of the polygon
  68595. * @param depth depth of the polygon
  68596. * @param flip flip of the polygon
  68597. */
  68598. private addSide;
  68599. }
  68600. }
  68601. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68602. import { Scene } from "babylonjs/scene";
  68603. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68604. import { Color4 } from "babylonjs/Maths/math.color";
  68605. import { Mesh } from "babylonjs/Meshes/mesh";
  68606. import { Nullable } from "babylonjs/types";
  68607. /**
  68608. * Class containing static functions to help procedurally build meshes
  68609. */
  68610. export class PolygonBuilder {
  68611. /**
  68612. * Creates a polygon mesh
  68613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68614. * * 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
  68615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68618. * * Remember you can only change the shape positions, not their number when updating a polygon
  68619. * @param name defines the name of the mesh
  68620. * @param options defines the options used to create the mesh
  68621. * @param scene defines the hosting scene
  68622. * @param earcutInjection can be used to inject your own earcut reference
  68623. * @returns the polygon mesh
  68624. */
  68625. static CreatePolygon(name: string, options: {
  68626. shape: Vector3[];
  68627. holes?: Vector3[][];
  68628. depth?: number;
  68629. faceUV?: Vector4[];
  68630. faceColors?: Color4[];
  68631. updatable?: boolean;
  68632. sideOrientation?: number;
  68633. frontUVs?: Vector4;
  68634. backUVs?: Vector4;
  68635. wrap?: boolean;
  68636. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68637. /**
  68638. * Creates an extruded polygon mesh, with depth in the Y direction.
  68639. * * 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)
  68640. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68641. * @param name defines the name of the mesh
  68642. * @param options defines the options used to create the mesh
  68643. * @param scene defines the hosting scene
  68644. * @param earcutInjection can be used to inject your own earcut reference
  68645. * @returns the polygon mesh
  68646. */
  68647. static ExtrudePolygon(name: string, options: {
  68648. shape: Vector3[];
  68649. holes?: Vector3[][];
  68650. depth?: number;
  68651. faceUV?: Vector4[];
  68652. faceColors?: Color4[];
  68653. updatable?: boolean;
  68654. sideOrientation?: number;
  68655. frontUVs?: Vector4;
  68656. backUVs?: Vector4;
  68657. wrap?: boolean;
  68658. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68659. }
  68660. }
  68661. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68662. import { Scene } from "babylonjs/scene";
  68663. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68664. import { Mesh } from "babylonjs/Meshes/mesh";
  68665. import { Nullable } from "babylonjs/types";
  68666. /**
  68667. * Class containing static functions to help procedurally build meshes
  68668. */
  68669. export class LatheBuilder {
  68670. /**
  68671. * Creates lathe mesh.
  68672. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68673. * * 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
  68674. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68675. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68676. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68677. * * 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
  68678. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68679. * * 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
  68680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68684. * @param name defines the name of the mesh
  68685. * @param options defines the options used to create the mesh
  68686. * @param scene defines the hosting scene
  68687. * @returns the lathe mesh
  68688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68689. */
  68690. static CreateLathe(name: string, options: {
  68691. shape: Vector3[];
  68692. radius?: number;
  68693. tessellation?: number;
  68694. clip?: number;
  68695. arc?: number;
  68696. closed?: boolean;
  68697. updatable?: boolean;
  68698. sideOrientation?: number;
  68699. frontUVs?: Vector4;
  68700. backUVs?: Vector4;
  68701. cap?: number;
  68702. invertUV?: boolean;
  68703. }, scene?: Nullable<Scene>): Mesh;
  68704. }
  68705. }
  68706. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68707. import { Nullable } from "babylonjs/types";
  68708. import { Scene } from "babylonjs/scene";
  68709. import { Vector4 } from "babylonjs/Maths/math.vector";
  68710. import { Mesh } from "babylonjs/Meshes/mesh";
  68711. /**
  68712. * Class containing static functions to help procedurally build meshes
  68713. */
  68714. export class TiledPlaneBuilder {
  68715. /**
  68716. * Creates a tiled plane mesh
  68717. * * The parameter `pattern` will, depending on value, do nothing or
  68718. * * * flip (reflect about central vertical) alternate tiles across and up
  68719. * * * flip every tile on alternate rows
  68720. * * * rotate (180 degs) alternate tiles across and up
  68721. * * * rotate every tile on alternate rows
  68722. * * * flip and rotate alternate tiles across and up
  68723. * * * flip and rotate every tile on alternate rows
  68724. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68725. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68728. * * 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)
  68729. * * 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)
  68730. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68731. * @param name defines the name of the mesh
  68732. * @param options defines the options used to create the mesh
  68733. * @param scene defines the hosting scene
  68734. * @returns the box mesh
  68735. */
  68736. static CreateTiledPlane(name: string, options: {
  68737. pattern?: number;
  68738. tileSize?: number;
  68739. tileWidth?: number;
  68740. tileHeight?: number;
  68741. size?: number;
  68742. width?: number;
  68743. height?: number;
  68744. alignHorizontal?: number;
  68745. alignVertical?: number;
  68746. sideOrientation?: number;
  68747. frontUVs?: Vector4;
  68748. backUVs?: Vector4;
  68749. updatable?: boolean;
  68750. }, scene?: Nullable<Scene>): Mesh;
  68751. }
  68752. }
  68753. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68754. import { Nullable } from "babylonjs/types";
  68755. import { Scene } from "babylonjs/scene";
  68756. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68757. import { Mesh } from "babylonjs/Meshes/mesh";
  68758. /**
  68759. * Class containing static functions to help procedurally build meshes
  68760. */
  68761. export class TubeBuilder {
  68762. /**
  68763. * Creates a tube mesh.
  68764. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68765. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68766. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68767. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68768. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68769. * * 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)
  68770. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68771. * * 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
  68772. * * 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
  68773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68777. * @param name defines the name of the mesh
  68778. * @param options defines the options used to create the mesh
  68779. * @param scene defines the hosting scene
  68780. * @returns the tube mesh
  68781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68782. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68783. */
  68784. static CreateTube(name: string, options: {
  68785. path: Vector3[];
  68786. radius?: number;
  68787. tessellation?: number;
  68788. radiusFunction?: {
  68789. (i: number, distance: number): number;
  68790. };
  68791. cap?: number;
  68792. arc?: number;
  68793. updatable?: boolean;
  68794. sideOrientation?: number;
  68795. frontUVs?: Vector4;
  68796. backUVs?: Vector4;
  68797. instance?: Mesh;
  68798. invertUV?: boolean;
  68799. }, scene?: Nullable<Scene>): Mesh;
  68800. }
  68801. }
  68802. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68803. import { Scene } from "babylonjs/scene";
  68804. import { Vector4 } from "babylonjs/Maths/math.vector";
  68805. import { Mesh } from "babylonjs/Meshes/mesh";
  68806. import { Nullable } from "babylonjs/types";
  68807. /**
  68808. * Class containing static functions to help procedurally build meshes
  68809. */
  68810. export class IcoSphereBuilder {
  68811. /**
  68812. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68813. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68814. * * 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`)
  68815. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68816. * * 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
  68817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68820. * @param name defines the name of the mesh
  68821. * @param options defines the options used to create the mesh
  68822. * @param scene defines the hosting scene
  68823. * @returns the icosahedron mesh
  68824. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68825. */
  68826. static CreateIcoSphere(name: string, options: {
  68827. radius?: number;
  68828. radiusX?: number;
  68829. radiusY?: number;
  68830. radiusZ?: number;
  68831. flat?: boolean;
  68832. subdivisions?: number;
  68833. sideOrientation?: number;
  68834. frontUVs?: Vector4;
  68835. backUVs?: Vector4;
  68836. updatable?: boolean;
  68837. }, scene?: Nullable<Scene>): Mesh;
  68838. }
  68839. }
  68840. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68841. import { Vector3 } from "babylonjs/Maths/math.vector";
  68842. import { Mesh } from "babylonjs/Meshes/mesh";
  68843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68844. /**
  68845. * Class containing static functions to help procedurally build meshes
  68846. */
  68847. export class DecalBuilder {
  68848. /**
  68849. * Creates a decal mesh.
  68850. * 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
  68851. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68852. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68853. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68854. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68855. * @param name defines the name of the mesh
  68856. * @param sourceMesh defines the mesh where the decal must be applied
  68857. * @param options defines the options used to create the mesh
  68858. * @param scene defines the hosting scene
  68859. * @returns the decal mesh
  68860. * @see https://doc.babylonjs.com/how_to/decals
  68861. */
  68862. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68863. position?: Vector3;
  68864. normal?: Vector3;
  68865. size?: Vector3;
  68866. angle?: number;
  68867. }): Mesh;
  68868. }
  68869. }
  68870. declare module "babylonjs/Meshes/meshBuilder" {
  68871. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68872. import { Nullable } from "babylonjs/types";
  68873. import { Scene } from "babylonjs/scene";
  68874. import { Mesh } from "babylonjs/Meshes/mesh";
  68875. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68876. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68878. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68879. import { Plane } from "babylonjs/Maths/math.plane";
  68880. /**
  68881. * Class containing static functions to help procedurally build meshes
  68882. */
  68883. export class MeshBuilder {
  68884. /**
  68885. * Creates a box mesh
  68886. * * The parameter `size` sets the size (float) of each box side (default 1)
  68887. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68888. * * 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)
  68889. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68894. * @param name defines the name of the mesh
  68895. * @param options defines the options used to create the mesh
  68896. * @param scene defines the hosting scene
  68897. * @returns the box mesh
  68898. */
  68899. static CreateBox(name: string, options: {
  68900. size?: number;
  68901. width?: number;
  68902. height?: number;
  68903. depth?: number;
  68904. faceUV?: Vector4[];
  68905. faceColors?: Color4[];
  68906. sideOrientation?: number;
  68907. frontUVs?: Vector4;
  68908. backUVs?: Vector4;
  68909. wrap?: boolean;
  68910. topBaseAt?: number;
  68911. bottomBaseAt?: number;
  68912. updatable?: boolean;
  68913. }, scene?: Nullable<Scene>): Mesh;
  68914. /**
  68915. * Creates a tiled box mesh
  68916. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68918. * @param name defines the name of the mesh
  68919. * @param options defines the options used to create the mesh
  68920. * @param scene defines the hosting scene
  68921. * @returns the tiled box mesh
  68922. */
  68923. static CreateTiledBox(name: string, options: {
  68924. pattern?: number;
  68925. size?: number;
  68926. width?: number;
  68927. height?: number;
  68928. depth: number;
  68929. tileSize?: number;
  68930. tileWidth?: number;
  68931. tileHeight?: number;
  68932. faceUV?: Vector4[];
  68933. faceColors?: Color4[];
  68934. alignHorizontal?: number;
  68935. alignVertical?: number;
  68936. sideOrientation?: number;
  68937. updatable?: boolean;
  68938. }, scene?: Nullable<Scene>): Mesh;
  68939. /**
  68940. * Creates a sphere mesh
  68941. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68942. * * 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`)
  68943. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68944. * * 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
  68945. * * 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)
  68946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68949. * @param name defines the name of the mesh
  68950. * @param options defines the options used to create the mesh
  68951. * @param scene defines the hosting scene
  68952. * @returns the sphere mesh
  68953. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68954. */
  68955. static CreateSphere(name: string, options: {
  68956. segments?: number;
  68957. diameter?: number;
  68958. diameterX?: number;
  68959. diameterY?: number;
  68960. diameterZ?: number;
  68961. arc?: number;
  68962. slice?: number;
  68963. sideOrientation?: number;
  68964. frontUVs?: Vector4;
  68965. backUVs?: Vector4;
  68966. updatable?: boolean;
  68967. }, scene?: Nullable<Scene>): Mesh;
  68968. /**
  68969. * Creates a plane polygonal mesh. By default, this is a disc
  68970. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68971. * * 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
  68972. * * 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
  68973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68976. * @param name defines the name of the mesh
  68977. * @param options defines the options used to create the mesh
  68978. * @param scene defines the hosting scene
  68979. * @returns the plane polygonal mesh
  68980. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68981. */
  68982. static CreateDisc(name: string, options: {
  68983. radius?: number;
  68984. tessellation?: number;
  68985. arc?: number;
  68986. updatable?: boolean;
  68987. sideOrientation?: number;
  68988. frontUVs?: Vector4;
  68989. backUVs?: Vector4;
  68990. }, scene?: Nullable<Scene>): Mesh;
  68991. /**
  68992. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68993. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68994. * * 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`)
  68995. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68996. * * 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
  68997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69000. * @param name defines the name of the mesh
  69001. * @param options defines the options used to create the mesh
  69002. * @param scene defines the hosting scene
  69003. * @returns the icosahedron mesh
  69004. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69005. */
  69006. static CreateIcoSphere(name: string, options: {
  69007. radius?: number;
  69008. radiusX?: number;
  69009. radiusY?: number;
  69010. radiusZ?: number;
  69011. flat?: boolean;
  69012. subdivisions?: number;
  69013. sideOrientation?: number;
  69014. frontUVs?: Vector4;
  69015. backUVs?: Vector4;
  69016. updatable?: boolean;
  69017. }, scene?: Nullable<Scene>): Mesh;
  69018. /**
  69019. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69020. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69021. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69022. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69023. * * 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
  69024. * * 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
  69025. * * 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
  69026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69029. * * 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
  69030. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69031. * * 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
  69032. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69034. * @param name defines the name of the mesh
  69035. * @param options defines the options used to create the mesh
  69036. * @param scene defines the hosting scene
  69037. * @returns the ribbon mesh
  69038. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69040. */
  69041. static CreateRibbon(name: string, options: {
  69042. pathArray: Vector3[][];
  69043. closeArray?: boolean;
  69044. closePath?: boolean;
  69045. offset?: number;
  69046. updatable?: boolean;
  69047. sideOrientation?: number;
  69048. frontUVs?: Vector4;
  69049. backUVs?: Vector4;
  69050. instance?: Mesh;
  69051. invertUV?: boolean;
  69052. uvs?: Vector2[];
  69053. colors?: Color4[];
  69054. }, scene?: Nullable<Scene>): Mesh;
  69055. /**
  69056. * Creates a cylinder or a cone mesh
  69057. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69058. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69059. * * 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.
  69060. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69061. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69062. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69063. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69064. * * 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).
  69065. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69066. * * 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).
  69067. * * 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
  69068. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69069. * * 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
  69070. * * 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.
  69071. * * If `enclose` is false, a ring surface is one element.
  69072. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69073. * * 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
  69074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69077. * @param name defines the name of the mesh
  69078. * @param options defines the options used to create the mesh
  69079. * @param scene defines the hosting scene
  69080. * @returns the cylinder mesh
  69081. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69082. */
  69083. static CreateCylinder(name: string, options: {
  69084. height?: number;
  69085. diameterTop?: number;
  69086. diameterBottom?: number;
  69087. diameter?: number;
  69088. tessellation?: number;
  69089. subdivisions?: number;
  69090. arc?: number;
  69091. faceColors?: Color4[];
  69092. faceUV?: Vector4[];
  69093. updatable?: boolean;
  69094. hasRings?: boolean;
  69095. enclose?: boolean;
  69096. cap?: number;
  69097. sideOrientation?: number;
  69098. frontUVs?: Vector4;
  69099. backUVs?: Vector4;
  69100. }, scene?: Nullable<Scene>): Mesh;
  69101. /**
  69102. * Creates a torus mesh
  69103. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69104. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69105. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69109. * @param name defines the name of the mesh
  69110. * @param options defines the options used to create the mesh
  69111. * @param scene defines the hosting scene
  69112. * @returns the torus mesh
  69113. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69114. */
  69115. static CreateTorus(name: string, options: {
  69116. diameter?: number;
  69117. thickness?: number;
  69118. tessellation?: number;
  69119. updatable?: boolean;
  69120. sideOrientation?: number;
  69121. frontUVs?: Vector4;
  69122. backUVs?: Vector4;
  69123. }, scene?: Nullable<Scene>): Mesh;
  69124. /**
  69125. * Creates a torus knot mesh
  69126. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69127. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69128. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69129. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69133. * @param name defines the name of the mesh
  69134. * @param options defines the options used to create the mesh
  69135. * @param scene defines the hosting scene
  69136. * @returns the torus knot mesh
  69137. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69138. */
  69139. static CreateTorusKnot(name: string, options: {
  69140. radius?: number;
  69141. tube?: number;
  69142. radialSegments?: number;
  69143. tubularSegments?: number;
  69144. p?: number;
  69145. q?: number;
  69146. updatable?: boolean;
  69147. sideOrientation?: number;
  69148. frontUVs?: Vector4;
  69149. backUVs?: Vector4;
  69150. }, scene?: Nullable<Scene>): Mesh;
  69151. /**
  69152. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69153. * * 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
  69154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69155. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69156. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69157. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69158. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69159. * * 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
  69160. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69163. * @param name defines the name of the new line system
  69164. * @param options defines the options used to create the line system
  69165. * @param scene defines the hosting scene
  69166. * @returns a new line system mesh
  69167. */
  69168. static CreateLineSystem(name: string, options: {
  69169. lines: Vector3[][];
  69170. updatable?: boolean;
  69171. instance?: Nullable<LinesMesh>;
  69172. colors?: Nullable<Color4[][]>;
  69173. useVertexAlpha?: boolean;
  69174. }, scene: Nullable<Scene>): LinesMesh;
  69175. /**
  69176. * Creates a line mesh
  69177. * 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
  69178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69179. * * The parameter `points` is an array successive Vector3
  69180. * * 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
  69181. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69183. * * When updating an instance, remember that only point positions can change, not the number of points
  69184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69186. * @param name defines the name of the new line system
  69187. * @param options defines the options used to create the line system
  69188. * @param scene defines the hosting scene
  69189. * @returns a new line mesh
  69190. */
  69191. static CreateLines(name: string, options: {
  69192. points: Vector3[];
  69193. updatable?: boolean;
  69194. instance?: Nullable<LinesMesh>;
  69195. colors?: Color4[];
  69196. useVertexAlpha?: boolean;
  69197. }, scene?: Nullable<Scene>): LinesMesh;
  69198. /**
  69199. * Creates a dashed line mesh
  69200. * * 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
  69201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69202. * * The parameter `points` is an array successive Vector3
  69203. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69204. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69205. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69206. * * 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
  69207. * * When updating an instance, remember that only point positions can change, not the number of points
  69208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69209. * @param name defines the name of the mesh
  69210. * @param options defines the options used to create the mesh
  69211. * @param scene defines the hosting scene
  69212. * @returns the dashed line mesh
  69213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69214. */
  69215. static CreateDashedLines(name: string, options: {
  69216. points: Vector3[];
  69217. dashSize?: number;
  69218. gapSize?: number;
  69219. dashNb?: number;
  69220. updatable?: boolean;
  69221. instance?: LinesMesh;
  69222. }, scene?: Nullable<Scene>): LinesMesh;
  69223. /**
  69224. * 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.
  69225. * * 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.
  69226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69227. * * 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.
  69228. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69229. * * 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
  69230. * * 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
  69231. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69236. * @param name defines the name of the mesh
  69237. * @param options defines the options used to create the mesh
  69238. * @param scene defines the hosting scene
  69239. * @returns the extruded shape mesh
  69240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69242. */
  69243. static ExtrudeShape(name: string, options: {
  69244. shape: Vector3[];
  69245. path: Vector3[];
  69246. scale?: number;
  69247. rotation?: number;
  69248. cap?: number;
  69249. updatable?: boolean;
  69250. sideOrientation?: number;
  69251. frontUVs?: Vector4;
  69252. backUVs?: Vector4;
  69253. instance?: Mesh;
  69254. invertUV?: boolean;
  69255. }, scene?: Nullable<Scene>): Mesh;
  69256. /**
  69257. * Creates an custom extruded shape mesh.
  69258. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69259. * * 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.
  69260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69261. * * 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
  69262. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69263. * * 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
  69264. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69265. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69266. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69267. * * 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
  69268. * * 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
  69269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69274. * @param name defines the name of the mesh
  69275. * @param options defines the options used to create the mesh
  69276. * @param scene defines the hosting scene
  69277. * @returns the custom extruded shape mesh
  69278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69281. */
  69282. static ExtrudeShapeCustom(name: string, options: {
  69283. shape: Vector3[];
  69284. path: Vector3[];
  69285. scaleFunction?: any;
  69286. rotationFunction?: any;
  69287. ribbonCloseArray?: boolean;
  69288. ribbonClosePath?: boolean;
  69289. cap?: number;
  69290. updatable?: boolean;
  69291. sideOrientation?: number;
  69292. frontUVs?: Vector4;
  69293. backUVs?: Vector4;
  69294. instance?: Mesh;
  69295. invertUV?: boolean;
  69296. }, scene?: Nullable<Scene>): Mesh;
  69297. /**
  69298. * Creates lathe mesh.
  69299. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69300. * * 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
  69301. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69302. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69303. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69304. * * 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
  69305. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69306. * * 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
  69307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69311. * @param name defines the name of the mesh
  69312. * @param options defines the options used to create the mesh
  69313. * @param scene defines the hosting scene
  69314. * @returns the lathe mesh
  69315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69316. */
  69317. static CreateLathe(name: string, options: {
  69318. shape: Vector3[];
  69319. radius?: number;
  69320. tessellation?: number;
  69321. clip?: number;
  69322. arc?: number;
  69323. closed?: boolean;
  69324. updatable?: boolean;
  69325. sideOrientation?: number;
  69326. frontUVs?: Vector4;
  69327. backUVs?: Vector4;
  69328. cap?: number;
  69329. invertUV?: boolean;
  69330. }, scene?: Nullable<Scene>): Mesh;
  69331. /**
  69332. * Creates a tiled plane mesh
  69333. * * You can set a limited pattern arrangement with the tiles
  69334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69337. * @param name defines the name of the mesh
  69338. * @param options defines the options used to create the mesh
  69339. * @param scene defines the hosting scene
  69340. * @returns the plane mesh
  69341. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69342. */
  69343. static CreateTiledPlane(name: string, options: {
  69344. pattern?: number;
  69345. tileSize?: number;
  69346. tileWidth?: number;
  69347. tileHeight?: number;
  69348. size?: number;
  69349. width?: number;
  69350. height?: number;
  69351. alignHorizontal?: number;
  69352. alignVertical?: number;
  69353. sideOrientation?: number;
  69354. frontUVs?: Vector4;
  69355. backUVs?: Vector4;
  69356. updatable?: boolean;
  69357. }, scene?: Nullable<Scene>): Mesh;
  69358. /**
  69359. * Creates a plane mesh
  69360. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69361. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69362. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69366. * @param name defines the name of the mesh
  69367. * @param options defines the options used to create the mesh
  69368. * @param scene defines the hosting scene
  69369. * @returns the plane mesh
  69370. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69371. */
  69372. static CreatePlane(name: string, options: {
  69373. size?: number;
  69374. width?: number;
  69375. height?: number;
  69376. sideOrientation?: number;
  69377. frontUVs?: Vector4;
  69378. backUVs?: Vector4;
  69379. updatable?: boolean;
  69380. sourcePlane?: Plane;
  69381. }, scene?: Nullable<Scene>): Mesh;
  69382. /**
  69383. * Creates a ground mesh
  69384. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69385. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69387. * @param name defines the name of the mesh
  69388. * @param options defines the options used to create the mesh
  69389. * @param scene defines the hosting scene
  69390. * @returns the ground mesh
  69391. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69392. */
  69393. static CreateGround(name: string, options: {
  69394. width?: number;
  69395. height?: number;
  69396. subdivisions?: number;
  69397. subdivisionsX?: number;
  69398. subdivisionsY?: number;
  69399. updatable?: boolean;
  69400. }, scene?: Nullable<Scene>): Mesh;
  69401. /**
  69402. * Creates a tiled ground mesh
  69403. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69404. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69405. * * 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
  69406. * * 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
  69407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69408. * @param name defines the name of the mesh
  69409. * @param options defines the options used to create the mesh
  69410. * @param scene defines the hosting scene
  69411. * @returns the tiled ground mesh
  69412. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69413. */
  69414. static CreateTiledGround(name: string, options: {
  69415. xmin: number;
  69416. zmin: number;
  69417. xmax: number;
  69418. zmax: number;
  69419. subdivisions?: {
  69420. w: number;
  69421. h: number;
  69422. };
  69423. precision?: {
  69424. w: number;
  69425. h: number;
  69426. };
  69427. updatable?: boolean;
  69428. }, scene?: Nullable<Scene>): Mesh;
  69429. /**
  69430. * Creates a ground mesh from a height map
  69431. * * The parameter `url` sets the URL of the height map image resource.
  69432. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69433. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69434. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69435. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69436. * * 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.
  69437. * * 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).
  69438. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69440. * @param name defines the name of the mesh
  69441. * @param url defines the url to the height map
  69442. * @param options defines the options used to create the mesh
  69443. * @param scene defines the hosting scene
  69444. * @returns the ground mesh
  69445. * @see https://doc.babylonjs.com/babylon101/height_map
  69446. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69447. */
  69448. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69449. width?: number;
  69450. height?: number;
  69451. subdivisions?: number;
  69452. minHeight?: number;
  69453. maxHeight?: number;
  69454. colorFilter?: Color3;
  69455. alphaFilter?: number;
  69456. updatable?: boolean;
  69457. onReady?: (mesh: GroundMesh) => void;
  69458. }, scene?: Nullable<Scene>): GroundMesh;
  69459. /**
  69460. * Creates a polygon mesh
  69461. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69462. * * 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
  69463. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69466. * * Remember you can only change the shape positions, not their number when updating a polygon
  69467. * @param name defines the name of the mesh
  69468. * @param options defines the options used to create the mesh
  69469. * @param scene defines the hosting scene
  69470. * @param earcutInjection can be used to inject your own earcut reference
  69471. * @returns the polygon mesh
  69472. */
  69473. static CreatePolygon(name: string, options: {
  69474. shape: Vector3[];
  69475. holes?: Vector3[][];
  69476. depth?: number;
  69477. faceUV?: Vector4[];
  69478. faceColors?: Color4[];
  69479. updatable?: boolean;
  69480. sideOrientation?: number;
  69481. frontUVs?: Vector4;
  69482. backUVs?: Vector4;
  69483. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69484. /**
  69485. * Creates an extruded polygon mesh, with depth in the Y direction.
  69486. * * 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)
  69487. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69488. * @param name defines the name of the mesh
  69489. * @param options defines the options used to create the mesh
  69490. * @param scene defines the hosting scene
  69491. * @param earcutInjection can be used to inject your own earcut reference
  69492. * @returns the polygon mesh
  69493. */
  69494. static ExtrudePolygon(name: string, options: {
  69495. shape: Vector3[];
  69496. holes?: Vector3[][];
  69497. depth?: number;
  69498. faceUV?: Vector4[];
  69499. faceColors?: Color4[];
  69500. updatable?: boolean;
  69501. sideOrientation?: number;
  69502. frontUVs?: Vector4;
  69503. backUVs?: Vector4;
  69504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69505. /**
  69506. * Creates a tube mesh.
  69507. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69508. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69509. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69510. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69511. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69512. * * 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)
  69513. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69514. * * 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
  69515. * * 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
  69516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69520. * @param name defines the name of the mesh
  69521. * @param options defines the options used to create the mesh
  69522. * @param scene defines the hosting scene
  69523. * @returns the tube mesh
  69524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69525. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69526. */
  69527. static CreateTube(name: string, options: {
  69528. path: Vector3[];
  69529. radius?: number;
  69530. tessellation?: number;
  69531. radiusFunction?: {
  69532. (i: number, distance: number): number;
  69533. };
  69534. cap?: number;
  69535. arc?: number;
  69536. updatable?: boolean;
  69537. sideOrientation?: number;
  69538. frontUVs?: Vector4;
  69539. backUVs?: Vector4;
  69540. instance?: Mesh;
  69541. invertUV?: boolean;
  69542. }, scene?: Nullable<Scene>): Mesh;
  69543. /**
  69544. * Creates a polyhedron mesh
  69545. * * 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
  69546. * * The parameter `size` (positive float, default 1) sets the polygon size
  69547. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69548. * * 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`
  69549. * * 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
  69550. * * 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)`)
  69551. * * 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
  69552. * * 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
  69553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69556. * @param name defines the name of the mesh
  69557. * @param options defines the options used to create the mesh
  69558. * @param scene defines the hosting scene
  69559. * @returns the polyhedron mesh
  69560. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69561. */
  69562. static CreatePolyhedron(name: string, options: {
  69563. type?: number;
  69564. size?: number;
  69565. sizeX?: number;
  69566. sizeY?: number;
  69567. sizeZ?: number;
  69568. custom?: any;
  69569. faceUV?: Vector4[];
  69570. faceColors?: Color4[];
  69571. flat?: boolean;
  69572. updatable?: boolean;
  69573. sideOrientation?: number;
  69574. frontUVs?: Vector4;
  69575. backUVs?: Vector4;
  69576. }, scene?: Nullable<Scene>): Mesh;
  69577. /**
  69578. * Creates a decal mesh.
  69579. * 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
  69580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69584. * @param name defines the name of the mesh
  69585. * @param sourceMesh defines the mesh where the decal must be applied
  69586. * @param options defines the options used to create the mesh
  69587. * @param scene defines the hosting scene
  69588. * @returns the decal mesh
  69589. * @see https://doc.babylonjs.com/how_to/decals
  69590. */
  69591. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69592. position?: Vector3;
  69593. normal?: Vector3;
  69594. size?: Vector3;
  69595. angle?: number;
  69596. }): Mesh;
  69597. }
  69598. }
  69599. declare module "babylonjs/Meshes/meshSimplification" {
  69600. import { Mesh } from "babylonjs/Meshes/mesh";
  69601. /**
  69602. * A simplifier interface for future simplification implementations
  69603. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69604. */
  69605. export interface ISimplifier {
  69606. /**
  69607. * Simplification of a given mesh according to the given settings.
  69608. * Since this requires computation, it is assumed that the function runs async.
  69609. * @param settings The settings of the simplification, including quality and distance
  69610. * @param successCallback A callback that will be called after the mesh was simplified.
  69611. * @param errorCallback in case of an error, this callback will be called. optional.
  69612. */
  69613. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69614. }
  69615. /**
  69616. * Expected simplification settings.
  69617. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69618. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69619. */
  69620. export interface ISimplificationSettings {
  69621. /**
  69622. * Gets or sets the expected quality
  69623. */
  69624. quality: number;
  69625. /**
  69626. * Gets or sets the distance when this optimized version should be used
  69627. */
  69628. distance: number;
  69629. /**
  69630. * Gets an already optimized mesh
  69631. */
  69632. optimizeMesh?: boolean;
  69633. }
  69634. /**
  69635. * Class used to specify simplification options
  69636. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69637. */
  69638. export class SimplificationSettings implements ISimplificationSettings {
  69639. /** expected quality */
  69640. quality: number;
  69641. /** distance when this optimized version should be used */
  69642. distance: number;
  69643. /** already optimized mesh */
  69644. optimizeMesh?: boolean | undefined;
  69645. /**
  69646. * Creates a SimplificationSettings
  69647. * @param quality expected quality
  69648. * @param distance distance when this optimized version should be used
  69649. * @param optimizeMesh already optimized mesh
  69650. */
  69651. constructor(
  69652. /** expected quality */
  69653. quality: number,
  69654. /** distance when this optimized version should be used */
  69655. distance: number,
  69656. /** already optimized mesh */
  69657. optimizeMesh?: boolean | undefined);
  69658. }
  69659. /**
  69660. * Interface used to define a simplification task
  69661. */
  69662. export interface ISimplificationTask {
  69663. /**
  69664. * Array of settings
  69665. */
  69666. settings: Array<ISimplificationSettings>;
  69667. /**
  69668. * Simplification type
  69669. */
  69670. simplificationType: SimplificationType;
  69671. /**
  69672. * Mesh to simplify
  69673. */
  69674. mesh: Mesh;
  69675. /**
  69676. * Callback called on success
  69677. */
  69678. successCallback?: () => void;
  69679. /**
  69680. * Defines if parallel processing can be used
  69681. */
  69682. parallelProcessing: boolean;
  69683. }
  69684. /**
  69685. * Queue used to order the simplification tasks
  69686. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69687. */
  69688. export class SimplificationQueue {
  69689. private _simplificationArray;
  69690. /**
  69691. * Gets a boolean indicating that the process is still running
  69692. */
  69693. running: boolean;
  69694. /**
  69695. * Creates a new queue
  69696. */
  69697. constructor();
  69698. /**
  69699. * Adds a new simplification task
  69700. * @param task defines a task to add
  69701. */
  69702. addTask(task: ISimplificationTask): void;
  69703. /**
  69704. * Execute next task
  69705. */
  69706. executeNext(): void;
  69707. /**
  69708. * Execute a simplification task
  69709. * @param task defines the task to run
  69710. */
  69711. runSimplification(task: ISimplificationTask): void;
  69712. private getSimplifier;
  69713. }
  69714. /**
  69715. * The implemented types of simplification
  69716. * At the moment only Quadratic Error Decimation is implemented
  69717. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69718. */
  69719. export enum SimplificationType {
  69720. /** Quadratic error decimation */
  69721. QUADRATIC = 0
  69722. }
  69723. /**
  69724. * An implementation of the Quadratic Error simplification algorithm.
  69725. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69726. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69727. * @author RaananW
  69728. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69729. */
  69730. export class QuadraticErrorSimplification implements ISimplifier {
  69731. private _mesh;
  69732. private triangles;
  69733. private vertices;
  69734. private references;
  69735. private _reconstructedMesh;
  69736. /** Gets or sets the number pf sync interations */
  69737. syncIterations: number;
  69738. /** Gets or sets the aggressiveness of the simplifier */
  69739. aggressiveness: number;
  69740. /** Gets or sets the number of allowed iterations for decimation */
  69741. decimationIterations: number;
  69742. /** Gets or sets the espilon to use for bounding box computation */
  69743. boundingBoxEpsilon: number;
  69744. /**
  69745. * Creates a new QuadraticErrorSimplification
  69746. * @param _mesh defines the target mesh
  69747. */
  69748. constructor(_mesh: Mesh);
  69749. /**
  69750. * Simplification of a given mesh according to the given settings.
  69751. * Since this requires computation, it is assumed that the function runs async.
  69752. * @param settings The settings of the simplification, including quality and distance
  69753. * @param successCallback A callback that will be called after the mesh was simplified.
  69754. */
  69755. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69756. private runDecimation;
  69757. private initWithMesh;
  69758. private init;
  69759. private reconstructMesh;
  69760. private initDecimatedMesh;
  69761. private isFlipped;
  69762. private updateTriangles;
  69763. private identifyBorder;
  69764. private updateMesh;
  69765. private vertexError;
  69766. private calculateError;
  69767. }
  69768. }
  69769. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69770. import { Scene } from "babylonjs/scene";
  69771. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69772. import { ISceneComponent } from "babylonjs/sceneComponent";
  69773. module "babylonjs/scene" {
  69774. interface Scene {
  69775. /** @hidden (Backing field) */
  69776. _simplificationQueue: SimplificationQueue;
  69777. /**
  69778. * Gets or sets the simplification queue attached to the scene
  69779. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69780. */
  69781. simplificationQueue: SimplificationQueue;
  69782. }
  69783. }
  69784. module "babylonjs/Meshes/mesh" {
  69785. interface Mesh {
  69786. /**
  69787. * Simplify the mesh according to the given array of settings.
  69788. * Function will return immediately and will simplify async
  69789. * @param settings a collection of simplification settings
  69790. * @param parallelProcessing should all levels calculate parallel or one after the other
  69791. * @param simplificationType the type of simplification to run
  69792. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69793. * @returns the current mesh
  69794. */
  69795. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69796. }
  69797. }
  69798. /**
  69799. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69800. * created in a scene
  69801. */
  69802. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69803. /**
  69804. * The component name helpfull to identify the component in the list of scene components.
  69805. */
  69806. readonly name: string;
  69807. /**
  69808. * The scene the component belongs to.
  69809. */
  69810. scene: Scene;
  69811. /**
  69812. * Creates a new instance of the component for the given scene
  69813. * @param scene Defines the scene to register the component in
  69814. */
  69815. constructor(scene: Scene);
  69816. /**
  69817. * Registers the component in a given scene
  69818. */
  69819. register(): void;
  69820. /**
  69821. * Rebuilds the elements related to this component in case of
  69822. * context lost for instance.
  69823. */
  69824. rebuild(): void;
  69825. /**
  69826. * Disposes the component and the associated ressources
  69827. */
  69828. dispose(): void;
  69829. private _beforeCameraUpdate;
  69830. }
  69831. }
  69832. declare module "babylonjs/Meshes/Builders/index" {
  69833. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69834. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69835. export * from "babylonjs/Meshes/Builders/discBuilder";
  69836. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69837. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69838. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69839. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69840. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69841. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69842. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69843. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69844. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69845. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69846. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69847. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69848. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69849. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69850. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69851. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69852. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69853. }
  69854. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69855. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69856. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69857. import { Matrix } from "babylonjs/Maths/math.vector";
  69858. module "babylonjs/Meshes/mesh" {
  69859. interface Mesh {
  69860. /**
  69861. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69862. */
  69863. thinInstanceEnablePicking: boolean;
  69864. /**
  69865. * Creates a new thin instance
  69866. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69867. * @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
  69868. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69869. */
  69870. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69871. /**
  69872. * Adds the transformation (matrix) of the current mesh as a thin instance
  69873. * @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
  69874. * @returns the thin instance index number
  69875. */
  69876. thinInstanceAddSelf(refresh: boolean): number;
  69877. /**
  69878. * Registers a custom attribute to be used with thin instances
  69879. * @param kind name of the attribute
  69880. * @param stride size in floats of the attribute
  69881. */
  69882. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69883. /**
  69884. * Sets the matrix of a thin instance
  69885. * @param index index of the thin instance
  69886. * @param matrix matrix to set
  69887. * @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
  69888. */
  69889. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69890. /**
  69891. * Sets the value of a custom attribute for a thin instance
  69892. * @param kind name of the attribute
  69893. * @param index index of the thin instance
  69894. * @param value value to set
  69895. * @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
  69896. */
  69897. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69898. /**
  69899. * 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.
  69900. */
  69901. thinInstanceCount: number;
  69902. /**
  69903. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69904. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69905. * @param buffer buffer to set
  69906. * @param stride size in floats of each value of the buffer
  69907. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69908. */
  69909. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69910. /**
  69911. * Gets the list of world matrices
  69912. * @return an array containing all the world matrices from the thin instances
  69913. */
  69914. thinInstanceGetWorldMatrices(): Matrix[];
  69915. /**
  69916. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69917. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69918. */
  69919. thinInstanceBufferUpdated(kind: string): void;
  69920. /**
  69921. * Refreshes the bounding info, taking into account all the thin instances defined
  69922. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69923. */
  69924. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69925. /** @hidden */
  69926. _thinInstanceInitializeUserStorage(): void;
  69927. /** @hidden */
  69928. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69929. /** @hidden */
  69930. _userThinInstanceBuffersStorage: {
  69931. data: {
  69932. [key: string]: Float32Array;
  69933. };
  69934. sizes: {
  69935. [key: string]: number;
  69936. };
  69937. vertexBuffers: {
  69938. [key: string]: Nullable<VertexBuffer>;
  69939. };
  69940. strides: {
  69941. [key: string]: number;
  69942. };
  69943. };
  69944. }
  69945. }
  69946. }
  69947. declare module "babylonjs/Meshes/index" {
  69948. export * from "babylonjs/Meshes/abstractMesh";
  69949. export * from "babylonjs/Meshes/buffer";
  69950. export * from "babylonjs/Meshes/Compression/index";
  69951. export * from "babylonjs/Meshes/csg";
  69952. export * from "babylonjs/Meshes/geometry";
  69953. export * from "babylonjs/Meshes/groundMesh";
  69954. export * from "babylonjs/Meshes/trailMesh";
  69955. export * from "babylonjs/Meshes/instancedMesh";
  69956. export * from "babylonjs/Meshes/linesMesh";
  69957. export * from "babylonjs/Meshes/mesh";
  69958. export * from "babylonjs/Meshes/mesh.vertexData";
  69959. export * from "babylonjs/Meshes/meshBuilder";
  69960. export * from "babylonjs/Meshes/meshSimplification";
  69961. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69962. export * from "babylonjs/Meshes/polygonMesh";
  69963. export * from "babylonjs/Meshes/subMesh";
  69964. export * from "babylonjs/Meshes/meshLODLevel";
  69965. export * from "babylonjs/Meshes/transformNode";
  69966. export * from "babylonjs/Meshes/Builders/index";
  69967. export * from "babylonjs/Meshes/dataBuffer";
  69968. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69969. import "babylonjs/Meshes/thinInstanceMesh";
  69970. export * from "babylonjs/Meshes/thinInstanceMesh";
  69971. }
  69972. declare module "babylonjs/Morph/index" {
  69973. export * from "babylonjs/Morph/morphTarget";
  69974. export * from "babylonjs/Morph/morphTargetManager";
  69975. }
  69976. declare module "babylonjs/Navigation/INavigationEngine" {
  69977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69978. import { Vector3 } from "babylonjs/Maths/math";
  69979. import { Mesh } from "babylonjs/Meshes/mesh";
  69980. import { Scene } from "babylonjs/scene";
  69981. /**
  69982. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69983. */
  69984. export interface INavigationEnginePlugin {
  69985. /**
  69986. * plugin name
  69987. */
  69988. name: string;
  69989. /**
  69990. * Creates a navigation mesh
  69991. * @param meshes array of all the geometry used to compute the navigatio mesh
  69992. * @param parameters bunch of parameters used to filter geometry
  69993. */
  69994. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69995. /**
  69996. * Create a navigation mesh debug mesh
  69997. * @param scene is where the mesh will be added
  69998. * @returns debug display mesh
  69999. */
  70000. createDebugNavMesh(scene: Scene): Mesh;
  70001. /**
  70002. * Get a navigation mesh constrained position, closest to the parameter position
  70003. * @param position world position
  70004. * @returns the closest point to position constrained by the navigation mesh
  70005. */
  70006. getClosestPoint(position: Vector3): Vector3;
  70007. /**
  70008. * Get a navigation mesh constrained position, closest to the parameter position
  70009. * @param position world position
  70010. * @param result output the closest point to position constrained by the navigation mesh
  70011. */
  70012. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70013. /**
  70014. * Get a navigation mesh constrained position, within a particular radius
  70015. * @param position world position
  70016. * @param maxRadius the maximum distance to the constrained world position
  70017. * @returns the closest point to position constrained by the navigation mesh
  70018. */
  70019. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70020. /**
  70021. * Get a navigation mesh constrained position, within a particular radius
  70022. * @param position world position
  70023. * @param maxRadius the maximum distance to the constrained world position
  70024. * @param result output the closest point to position constrained by the navigation mesh
  70025. */
  70026. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70027. /**
  70028. * Compute the final position from a segment made of destination-position
  70029. * @param position world position
  70030. * @param destination world position
  70031. * @returns the resulting point along the navmesh
  70032. */
  70033. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70034. /**
  70035. * Compute the final position from a segment made of destination-position
  70036. * @param position world position
  70037. * @param destination world position
  70038. * @param result output the resulting point along the navmesh
  70039. */
  70040. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70041. /**
  70042. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70043. * @param start world position
  70044. * @param end world position
  70045. * @returns array containing world position composing the path
  70046. */
  70047. computePath(start: Vector3, end: Vector3): Vector3[];
  70048. /**
  70049. * If this plugin is supported
  70050. * @returns true if plugin is supported
  70051. */
  70052. isSupported(): boolean;
  70053. /**
  70054. * Create a new Crowd so you can add agents
  70055. * @param maxAgents the maximum agent count in the crowd
  70056. * @param maxAgentRadius the maximum radius an agent can have
  70057. * @param scene to attach the crowd to
  70058. * @returns the crowd you can add agents to
  70059. */
  70060. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70061. /**
  70062. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70063. * The queries will try to find a solution within those bounds
  70064. * default is (1,1,1)
  70065. * @param extent x,y,z value that define the extent around the queries point of reference
  70066. */
  70067. setDefaultQueryExtent(extent: Vector3): void;
  70068. /**
  70069. * Get the Bounding box extent specified by setDefaultQueryExtent
  70070. * @returns the box extent values
  70071. */
  70072. getDefaultQueryExtent(): Vector3;
  70073. /**
  70074. * build the navmesh from a previously saved state using getNavmeshData
  70075. * @param data the Uint8Array returned by getNavmeshData
  70076. */
  70077. buildFromNavmeshData(data: Uint8Array): void;
  70078. /**
  70079. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70080. * @returns data the Uint8Array that can be saved and reused
  70081. */
  70082. getNavmeshData(): Uint8Array;
  70083. /**
  70084. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70085. * @param result output the box extent values
  70086. */
  70087. getDefaultQueryExtentToRef(result: Vector3): void;
  70088. /**
  70089. * Release all resources
  70090. */
  70091. dispose(): void;
  70092. }
  70093. /**
  70094. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70095. */
  70096. export interface ICrowd {
  70097. /**
  70098. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70099. * You can attach anything to that node. The node position is updated in the scene update tick.
  70100. * @param pos world position that will be constrained by the navigation mesh
  70101. * @param parameters agent parameters
  70102. * @param transform hooked to the agent that will be update by the scene
  70103. * @returns agent index
  70104. */
  70105. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70106. /**
  70107. * Returns the agent position in world space
  70108. * @param index agent index returned by addAgent
  70109. * @returns world space position
  70110. */
  70111. getAgentPosition(index: number): Vector3;
  70112. /**
  70113. * Gets the agent position result in world space
  70114. * @param index agent index returned by addAgent
  70115. * @param result output world space position
  70116. */
  70117. getAgentPositionToRef(index: number, result: Vector3): void;
  70118. /**
  70119. * Gets the agent velocity in world space
  70120. * @param index agent index returned by addAgent
  70121. * @returns world space velocity
  70122. */
  70123. getAgentVelocity(index: number): Vector3;
  70124. /**
  70125. * Gets the agent velocity result in world space
  70126. * @param index agent index returned by addAgent
  70127. * @param result output world space velocity
  70128. */
  70129. getAgentVelocityToRef(index: number, result: Vector3): void;
  70130. /**
  70131. * remove a particular agent previously created
  70132. * @param index agent index returned by addAgent
  70133. */
  70134. removeAgent(index: number): void;
  70135. /**
  70136. * get the list of all agents attached to this crowd
  70137. * @returns list of agent indices
  70138. */
  70139. getAgents(): number[];
  70140. /**
  70141. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70142. * @param deltaTime in seconds
  70143. */
  70144. update(deltaTime: number): void;
  70145. /**
  70146. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70147. * @param index agent index returned by addAgent
  70148. * @param destination targeted world position
  70149. */
  70150. agentGoto(index: number, destination: Vector3): void;
  70151. /**
  70152. * Teleport the agent to a new position
  70153. * @param index agent index returned by addAgent
  70154. * @param destination targeted world position
  70155. */
  70156. agentTeleport(index: number, destination: Vector3): void;
  70157. /**
  70158. * Update agent parameters
  70159. * @param index agent index returned by addAgent
  70160. * @param parameters agent parameters
  70161. */
  70162. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70163. /**
  70164. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70165. * The queries will try to find a solution within those bounds
  70166. * default is (1,1,1)
  70167. * @param extent x,y,z value that define the extent around the queries point of reference
  70168. */
  70169. setDefaultQueryExtent(extent: Vector3): void;
  70170. /**
  70171. * Get the Bounding box extent specified by setDefaultQueryExtent
  70172. * @returns the box extent values
  70173. */
  70174. getDefaultQueryExtent(): Vector3;
  70175. /**
  70176. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70177. * @param result output the box extent values
  70178. */
  70179. getDefaultQueryExtentToRef(result: Vector3): void;
  70180. /**
  70181. * Release all resources
  70182. */
  70183. dispose(): void;
  70184. }
  70185. /**
  70186. * Configures an agent
  70187. */
  70188. export interface IAgentParameters {
  70189. /**
  70190. * Agent radius. [Limit: >= 0]
  70191. */
  70192. radius: number;
  70193. /**
  70194. * Agent height. [Limit: > 0]
  70195. */
  70196. height: number;
  70197. /**
  70198. * Maximum allowed acceleration. [Limit: >= 0]
  70199. */
  70200. maxAcceleration: number;
  70201. /**
  70202. * Maximum allowed speed. [Limit: >= 0]
  70203. */
  70204. maxSpeed: number;
  70205. /**
  70206. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70207. */
  70208. collisionQueryRange: number;
  70209. /**
  70210. * The path visibility optimization range. [Limit: > 0]
  70211. */
  70212. pathOptimizationRange: number;
  70213. /**
  70214. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70215. */
  70216. separationWeight: number;
  70217. }
  70218. /**
  70219. * Configures the navigation mesh creation
  70220. */
  70221. export interface INavMeshParameters {
  70222. /**
  70223. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70224. */
  70225. cs: number;
  70226. /**
  70227. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70228. */
  70229. ch: number;
  70230. /**
  70231. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70232. */
  70233. walkableSlopeAngle: number;
  70234. /**
  70235. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70236. * be considered walkable. [Limit: >= 3] [Units: vx]
  70237. */
  70238. walkableHeight: number;
  70239. /**
  70240. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70241. */
  70242. walkableClimb: number;
  70243. /**
  70244. * The distance to erode/shrink the walkable area of the heightfield away from
  70245. * obstructions. [Limit: >=0] [Units: vx]
  70246. */
  70247. walkableRadius: number;
  70248. /**
  70249. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70250. */
  70251. maxEdgeLen: number;
  70252. /**
  70253. * The maximum distance a simplfied contour's border edges should deviate
  70254. * the original raw contour. [Limit: >=0] [Units: vx]
  70255. */
  70256. maxSimplificationError: number;
  70257. /**
  70258. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70259. */
  70260. minRegionArea: number;
  70261. /**
  70262. * Any regions with a span count smaller than this value will, if possible,
  70263. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70264. */
  70265. mergeRegionArea: number;
  70266. /**
  70267. * The maximum number of vertices allowed for polygons generated during the
  70268. * contour to polygon conversion process. [Limit: >= 3]
  70269. */
  70270. maxVertsPerPoly: number;
  70271. /**
  70272. * Sets the sampling distance to use when generating the detail mesh.
  70273. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70274. */
  70275. detailSampleDist: number;
  70276. /**
  70277. * The maximum distance the detail mesh surface should deviate from heightfield
  70278. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70279. */
  70280. detailSampleMaxError: number;
  70281. }
  70282. }
  70283. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70284. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70285. import { Mesh } from "babylonjs/Meshes/mesh";
  70286. import { Scene } from "babylonjs/scene";
  70287. import { Vector3 } from "babylonjs/Maths/math";
  70288. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70289. /**
  70290. * RecastJS navigation plugin
  70291. */
  70292. export class RecastJSPlugin implements INavigationEnginePlugin {
  70293. /**
  70294. * Reference to the Recast library
  70295. */
  70296. bjsRECAST: any;
  70297. /**
  70298. * plugin name
  70299. */
  70300. name: string;
  70301. /**
  70302. * the first navmesh created. We might extend this to support multiple navmeshes
  70303. */
  70304. navMesh: any;
  70305. /**
  70306. * Initializes the recastJS plugin
  70307. * @param recastInjection can be used to inject your own recast reference
  70308. */
  70309. constructor(recastInjection?: any);
  70310. /**
  70311. * Creates a navigation mesh
  70312. * @param meshes array of all the geometry used to compute the navigatio mesh
  70313. * @param parameters bunch of parameters used to filter geometry
  70314. */
  70315. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70316. /**
  70317. * Create a navigation mesh debug mesh
  70318. * @param scene is where the mesh will be added
  70319. * @returns debug display mesh
  70320. */
  70321. createDebugNavMesh(scene: Scene): Mesh;
  70322. /**
  70323. * Get a navigation mesh constrained position, closest to the parameter position
  70324. * @param position world position
  70325. * @returns the closest point to position constrained by the navigation mesh
  70326. */
  70327. getClosestPoint(position: Vector3): Vector3;
  70328. /**
  70329. * Get a navigation mesh constrained position, closest to the parameter position
  70330. * @param position world position
  70331. * @param result output the closest point to position constrained by the navigation mesh
  70332. */
  70333. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70334. /**
  70335. * Get a navigation mesh constrained position, within a particular radius
  70336. * @param position world position
  70337. * @param maxRadius the maximum distance to the constrained world position
  70338. * @returns the closest point to position constrained by the navigation mesh
  70339. */
  70340. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70341. /**
  70342. * Get a navigation mesh constrained position, within a particular radius
  70343. * @param position world position
  70344. * @param maxRadius the maximum distance to the constrained world position
  70345. * @param result output the closest point to position constrained by the navigation mesh
  70346. */
  70347. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70348. /**
  70349. * Compute the final position from a segment made of destination-position
  70350. * @param position world position
  70351. * @param destination world position
  70352. * @returns the resulting point along the navmesh
  70353. */
  70354. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70355. /**
  70356. * Compute the final position from a segment made of destination-position
  70357. * @param position world position
  70358. * @param destination world position
  70359. * @param result output the resulting point along the navmesh
  70360. */
  70361. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70362. /**
  70363. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70364. * @param start world position
  70365. * @param end world position
  70366. * @returns array containing world position composing the path
  70367. */
  70368. computePath(start: Vector3, end: Vector3): Vector3[];
  70369. /**
  70370. * Create a new Crowd so you can add agents
  70371. * @param maxAgents the maximum agent count in the crowd
  70372. * @param maxAgentRadius the maximum radius an agent can have
  70373. * @param scene to attach the crowd to
  70374. * @returns the crowd you can add agents to
  70375. */
  70376. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70377. /**
  70378. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70379. * The queries will try to find a solution within those bounds
  70380. * default is (1,1,1)
  70381. * @param extent x,y,z value that define the extent around the queries point of reference
  70382. */
  70383. setDefaultQueryExtent(extent: Vector3): void;
  70384. /**
  70385. * Get the Bounding box extent specified by setDefaultQueryExtent
  70386. * @returns the box extent values
  70387. */
  70388. getDefaultQueryExtent(): Vector3;
  70389. /**
  70390. * build the navmesh from a previously saved state using getNavmeshData
  70391. * @param data the Uint8Array returned by getNavmeshData
  70392. */
  70393. buildFromNavmeshData(data: Uint8Array): void;
  70394. /**
  70395. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70396. * @returns data the Uint8Array that can be saved and reused
  70397. */
  70398. getNavmeshData(): Uint8Array;
  70399. /**
  70400. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70401. * @param result output the box extent values
  70402. */
  70403. getDefaultQueryExtentToRef(result: Vector3): void;
  70404. /**
  70405. * Disposes
  70406. */
  70407. dispose(): void;
  70408. /**
  70409. * If this plugin is supported
  70410. * @returns true if plugin is supported
  70411. */
  70412. isSupported(): boolean;
  70413. }
  70414. /**
  70415. * Recast detour crowd implementation
  70416. */
  70417. export class RecastJSCrowd implements ICrowd {
  70418. /**
  70419. * Recast/detour plugin
  70420. */
  70421. bjsRECASTPlugin: RecastJSPlugin;
  70422. /**
  70423. * Link to the detour crowd
  70424. */
  70425. recastCrowd: any;
  70426. /**
  70427. * One transform per agent
  70428. */
  70429. transforms: TransformNode[];
  70430. /**
  70431. * All agents created
  70432. */
  70433. agents: number[];
  70434. /**
  70435. * Link to the scene is kept to unregister the crowd from the scene
  70436. */
  70437. private _scene;
  70438. /**
  70439. * Observer for crowd updates
  70440. */
  70441. private _onBeforeAnimationsObserver;
  70442. /**
  70443. * Constructor
  70444. * @param plugin recastJS plugin
  70445. * @param maxAgents the maximum agent count in the crowd
  70446. * @param maxAgentRadius the maximum radius an agent can have
  70447. * @param scene to attach the crowd to
  70448. * @returns the crowd you can add agents to
  70449. */
  70450. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70451. /**
  70452. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70453. * You can attach anything to that node. The node position is updated in the scene update tick.
  70454. * @param pos world position that will be constrained by the navigation mesh
  70455. * @param parameters agent parameters
  70456. * @param transform hooked to the agent that will be update by the scene
  70457. * @returns agent index
  70458. */
  70459. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70460. /**
  70461. * Returns the agent position in world space
  70462. * @param index agent index returned by addAgent
  70463. * @returns world space position
  70464. */
  70465. getAgentPosition(index: number): Vector3;
  70466. /**
  70467. * Returns the agent position result in world space
  70468. * @param index agent index returned by addAgent
  70469. * @param result output world space position
  70470. */
  70471. getAgentPositionToRef(index: number, result: Vector3): void;
  70472. /**
  70473. * Returns the agent velocity in world space
  70474. * @param index agent index returned by addAgent
  70475. * @returns world space velocity
  70476. */
  70477. getAgentVelocity(index: number): Vector3;
  70478. /**
  70479. * Returns the agent velocity result in world space
  70480. * @param index agent index returned by addAgent
  70481. * @param result output world space velocity
  70482. */
  70483. getAgentVelocityToRef(index: number, result: Vector3): void;
  70484. /**
  70485. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70486. * @param index agent index returned by addAgent
  70487. * @param destination targeted world position
  70488. */
  70489. agentGoto(index: number, destination: Vector3): void;
  70490. /**
  70491. * Teleport the agent to a new position
  70492. * @param index agent index returned by addAgent
  70493. * @param destination targeted world position
  70494. */
  70495. agentTeleport(index: number, destination: Vector3): void;
  70496. /**
  70497. * Update agent parameters
  70498. * @param index agent index returned by addAgent
  70499. * @param parameters agent parameters
  70500. */
  70501. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70502. /**
  70503. * remove a particular agent previously created
  70504. * @param index agent index returned by addAgent
  70505. */
  70506. removeAgent(index: number): void;
  70507. /**
  70508. * get the list of all agents attached to this crowd
  70509. * @returns list of agent indices
  70510. */
  70511. getAgents(): number[];
  70512. /**
  70513. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70514. * @param deltaTime in seconds
  70515. */
  70516. update(deltaTime: number): void;
  70517. /**
  70518. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70519. * The queries will try to find a solution within those bounds
  70520. * default is (1,1,1)
  70521. * @param extent x,y,z value that define the extent around the queries point of reference
  70522. */
  70523. setDefaultQueryExtent(extent: Vector3): void;
  70524. /**
  70525. * Get the Bounding box extent specified by setDefaultQueryExtent
  70526. * @returns the box extent values
  70527. */
  70528. getDefaultQueryExtent(): Vector3;
  70529. /**
  70530. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70531. * @param result output the box extent values
  70532. */
  70533. getDefaultQueryExtentToRef(result: Vector3): void;
  70534. /**
  70535. * Release all resources
  70536. */
  70537. dispose(): void;
  70538. }
  70539. }
  70540. declare module "babylonjs/Navigation/Plugins/index" {
  70541. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70542. }
  70543. declare module "babylonjs/Navigation/index" {
  70544. export * from "babylonjs/Navigation/INavigationEngine";
  70545. export * from "babylonjs/Navigation/Plugins/index";
  70546. }
  70547. declare module "babylonjs/Offline/database" {
  70548. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70549. /**
  70550. * Class used to enable access to IndexedDB
  70551. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70552. */
  70553. export class Database implements IOfflineProvider {
  70554. private _callbackManifestChecked;
  70555. private _currentSceneUrl;
  70556. private _db;
  70557. private _enableSceneOffline;
  70558. private _enableTexturesOffline;
  70559. private _manifestVersionFound;
  70560. private _mustUpdateRessources;
  70561. private _hasReachedQuota;
  70562. private _isSupported;
  70563. private _idbFactory;
  70564. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70565. private static IsUASupportingBlobStorage;
  70566. /**
  70567. * Gets a boolean indicating if Database storate is enabled (off by default)
  70568. */
  70569. static IDBStorageEnabled: boolean;
  70570. /**
  70571. * Gets a boolean indicating if scene must be saved in the database
  70572. */
  70573. get enableSceneOffline(): boolean;
  70574. /**
  70575. * Gets a boolean indicating if textures must be saved in the database
  70576. */
  70577. get enableTexturesOffline(): boolean;
  70578. /**
  70579. * Creates a new Database
  70580. * @param urlToScene defines the url to load the scene
  70581. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70582. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70583. */
  70584. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70585. private static _ParseURL;
  70586. private static _ReturnFullUrlLocation;
  70587. private _checkManifestFile;
  70588. /**
  70589. * Open the database and make it available
  70590. * @param successCallback defines the callback to call on success
  70591. * @param errorCallback defines the callback to call on error
  70592. */
  70593. open(successCallback: () => void, errorCallback: () => void): void;
  70594. /**
  70595. * Loads an image from the database
  70596. * @param url defines the url to load from
  70597. * @param image defines the target DOM image
  70598. */
  70599. loadImage(url: string, image: HTMLImageElement): void;
  70600. private _loadImageFromDBAsync;
  70601. private _saveImageIntoDBAsync;
  70602. private _checkVersionFromDB;
  70603. private _loadVersionFromDBAsync;
  70604. private _saveVersionIntoDBAsync;
  70605. /**
  70606. * Loads a file from database
  70607. * @param url defines the URL to load from
  70608. * @param sceneLoaded defines a callback to call on success
  70609. * @param progressCallBack defines a callback to call when progress changed
  70610. * @param errorCallback defines a callback to call on error
  70611. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70612. */
  70613. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70614. private _loadFileAsync;
  70615. private _saveFileAsync;
  70616. /**
  70617. * Validates if xhr data is correct
  70618. * @param xhr defines the request to validate
  70619. * @param dataType defines the expected data type
  70620. * @returns true if data is correct
  70621. */
  70622. private static _ValidateXHRData;
  70623. }
  70624. }
  70625. declare module "babylonjs/Offline/index" {
  70626. export * from "babylonjs/Offline/database";
  70627. export * from "babylonjs/Offline/IOfflineProvider";
  70628. }
  70629. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70630. /** @hidden */
  70631. export var gpuUpdateParticlesPixelShader: {
  70632. name: string;
  70633. shader: string;
  70634. };
  70635. }
  70636. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70637. /** @hidden */
  70638. export var gpuUpdateParticlesVertexShader: {
  70639. name: string;
  70640. shader: string;
  70641. };
  70642. }
  70643. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70644. /** @hidden */
  70645. export var clipPlaneFragmentDeclaration2: {
  70646. name: string;
  70647. shader: string;
  70648. };
  70649. }
  70650. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70651. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70652. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70654. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70655. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70656. /** @hidden */
  70657. export var gpuRenderParticlesPixelShader: {
  70658. name: string;
  70659. shader: string;
  70660. };
  70661. }
  70662. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70663. /** @hidden */
  70664. export var clipPlaneVertexDeclaration2: {
  70665. name: string;
  70666. shader: string;
  70667. };
  70668. }
  70669. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70671. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70672. /** @hidden */
  70673. export var gpuRenderParticlesVertexShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module "babylonjs/Particles/gpuParticleSystem" {
  70679. import { Nullable } from "babylonjs/types";
  70680. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70681. import { Observable } from "babylonjs/Misc/observable";
  70682. import { Matrix } from "babylonjs/Maths/math.vector";
  70683. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70684. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70685. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70686. import { IDisposable } from "babylonjs/scene";
  70687. import { Effect } from "babylonjs/Materials/effect";
  70688. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70689. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70690. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70691. import { Scene } from "babylonjs/scene";
  70692. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70693. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70694. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70695. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70696. /**
  70697. * This represents a GPU particle system in Babylon
  70698. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70699. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70700. */
  70701. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70702. /**
  70703. * The layer mask we are rendering the particles through.
  70704. */
  70705. layerMask: number;
  70706. private _capacity;
  70707. private _activeCount;
  70708. private _currentActiveCount;
  70709. private _accumulatedCount;
  70710. private _renderEffect;
  70711. private _updateEffect;
  70712. private _buffer0;
  70713. private _buffer1;
  70714. private _spriteBuffer;
  70715. private _updateVAO;
  70716. private _renderVAO;
  70717. private _targetIndex;
  70718. private _sourceBuffer;
  70719. private _targetBuffer;
  70720. private _currentRenderId;
  70721. private _started;
  70722. private _stopped;
  70723. private _timeDelta;
  70724. private _randomTexture;
  70725. private _randomTexture2;
  70726. private _attributesStrideSize;
  70727. private _updateEffectOptions;
  70728. private _randomTextureSize;
  70729. private _actualFrame;
  70730. private _customEffect;
  70731. private readonly _rawTextureWidth;
  70732. /**
  70733. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70734. */
  70735. static get IsSupported(): boolean;
  70736. /**
  70737. * An event triggered when the system is disposed.
  70738. */
  70739. onDisposeObservable: Observable<IParticleSystem>;
  70740. /**
  70741. * Gets the maximum number of particles active at the same time.
  70742. * @returns The max number of active particles.
  70743. */
  70744. getCapacity(): number;
  70745. /**
  70746. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70747. * to override the particles.
  70748. */
  70749. forceDepthWrite: boolean;
  70750. /**
  70751. * Gets or set the number of active particles
  70752. */
  70753. get activeParticleCount(): number;
  70754. set activeParticleCount(value: number);
  70755. private _preWarmDone;
  70756. /**
  70757. * Specifies if the particles are updated in emitter local space or world space.
  70758. */
  70759. isLocal: boolean;
  70760. /** Gets or sets a matrix to use to compute projection */
  70761. defaultProjectionMatrix: Matrix;
  70762. /**
  70763. * Is this system ready to be used/rendered
  70764. * @return true if the system is ready
  70765. */
  70766. isReady(): boolean;
  70767. /**
  70768. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70769. * @returns True if it has been started, otherwise false.
  70770. */
  70771. isStarted(): boolean;
  70772. /**
  70773. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70774. * @returns True if it has been stopped, otherwise false.
  70775. */
  70776. isStopped(): boolean;
  70777. /**
  70778. * Gets a boolean indicating that the system is stopping
  70779. * @returns true if the system is currently stopping
  70780. */
  70781. isStopping(): boolean;
  70782. /**
  70783. * Gets the number of particles active at the same time.
  70784. * @returns The number of active particles.
  70785. */
  70786. getActiveCount(): number;
  70787. /**
  70788. * Starts the particle system and begins to emit
  70789. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70790. */
  70791. start(delay?: number): void;
  70792. /**
  70793. * Stops the particle system.
  70794. */
  70795. stop(): void;
  70796. /**
  70797. * Remove all active particles
  70798. */
  70799. reset(): void;
  70800. /**
  70801. * Returns the string "GPUParticleSystem"
  70802. * @returns a string containing the class name
  70803. */
  70804. getClassName(): string;
  70805. /**
  70806. * Gets the custom effect used to render the particles
  70807. * @param blendMode Blend mode for which the effect should be retrieved
  70808. * @returns The effect
  70809. */
  70810. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70811. /**
  70812. * Sets the custom effect used to render the particles
  70813. * @param effect The effect to set
  70814. * @param blendMode Blend mode for which the effect should be set
  70815. */
  70816. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70817. /** @hidden */
  70818. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70819. /**
  70820. * Observable that will be called just before the particles are drawn
  70821. */
  70822. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70823. /**
  70824. * Gets the name of the particle vertex shader
  70825. */
  70826. get vertexShaderName(): string;
  70827. private _colorGradientsTexture;
  70828. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70829. /**
  70830. * Adds a new color gradient
  70831. * @param gradient defines the gradient to use (between 0 and 1)
  70832. * @param color1 defines the color to affect to the specified gradient
  70833. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70834. * @returns the current particle system
  70835. */
  70836. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70837. private _refreshColorGradient;
  70838. /** Force the system to rebuild all gradients that need to be resync */
  70839. forceRefreshGradients(): void;
  70840. /**
  70841. * Remove a specific color gradient
  70842. * @param gradient defines the gradient to remove
  70843. * @returns the current particle system
  70844. */
  70845. removeColorGradient(gradient: number): GPUParticleSystem;
  70846. private _angularSpeedGradientsTexture;
  70847. private _sizeGradientsTexture;
  70848. private _velocityGradientsTexture;
  70849. private _limitVelocityGradientsTexture;
  70850. private _dragGradientsTexture;
  70851. private _addFactorGradient;
  70852. /**
  70853. * Adds a new size gradient
  70854. * @param gradient defines the gradient to use (between 0 and 1)
  70855. * @param factor defines the size factor to affect to the specified gradient
  70856. * @returns the current particle system
  70857. */
  70858. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70859. /**
  70860. * Remove a specific size gradient
  70861. * @param gradient defines the gradient to remove
  70862. * @returns the current particle system
  70863. */
  70864. removeSizeGradient(gradient: number): GPUParticleSystem;
  70865. private _refreshFactorGradient;
  70866. /**
  70867. * Adds a new angular speed gradient
  70868. * @param gradient defines the gradient to use (between 0 and 1)
  70869. * @param factor defines the angular speed to affect to the specified gradient
  70870. * @returns the current particle system
  70871. */
  70872. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70873. /**
  70874. * Remove a specific angular speed gradient
  70875. * @param gradient defines the gradient to remove
  70876. * @returns the current particle system
  70877. */
  70878. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70879. /**
  70880. * Adds a new velocity gradient
  70881. * @param gradient defines the gradient to use (between 0 and 1)
  70882. * @param factor defines the velocity to affect to the specified gradient
  70883. * @returns the current particle system
  70884. */
  70885. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70886. /**
  70887. * Remove a specific velocity gradient
  70888. * @param gradient defines the gradient to remove
  70889. * @returns the current particle system
  70890. */
  70891. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70892. /**
  70893. * Adds a new limit velocity gradient
  70894. * @param gradient defines the gradient to use (between 0 and 1)
  70895. * @param factor defines the limit velocity value to affect to the specified gradient
  70896. * @returns the current particle system
  70897. */
  70898. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70899. /**
  70900. * Remove a specific limit velocity gradient
  70901. * @param gradient defines the gradient to remove
  70902. * @returns the current particle system
  70903. */
  70904. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70905. /**
  70906. * Adds a new drag gradient
  70907. * @param gradient defines the gradient to use (between 0 and 1)
  70908. * @param factor defines the drag value to affect to the specified gradient
  70909. * @returns the current particle system
  70910. */
  70911. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70912. /**
  70913. * Remove a specific drag gradient
  70914. * @param gradient defines the gradient to remove
  70915. * @returns the current particle system
  70916. */
  70917. removeDragGradient(gradient: number): GPUParticleSystem;
  70918. /**
  70919. * Not supported by GPUParticleSystem
  70920. * @param gradient defines the gradient to use (between 0 and 1)
  70921. * @param factor defines the emit rate value to affect to the specified gradient
  70922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70923. * @returns the current particle system
  70924. */
  70925. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70926. /**
  70927. * Not supported by GPUParticleSystem
  70928. * @param gradient defines the gradient to remove
  70929. * @returns the current particle system
  70930. */
  70931. removeEmitRateGradient(gradient: number): IParticleSystem;
  70932. /**
  70933. * Not supported by GPUParticleSystem
  70934. * @param gradient defines the gradient to use (between 0 and 1)
  70935. * @param factor defines the start size value to affect to the specified gradient
  70936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70937. * @returns the current particle system
  70938. */
  70939. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70940. /**
  70941. * Not supported by GPUParticleSystem
  70942. * @param gradient defines the gradient to remove
  70943. * @returns the current particle system
  70944. */
  70945. removeStartSizeGradient(gradient: number): IParticleSystem;
  70946. /**
  70947. * Not supported by GPUParticleSystem
  70948. * @param gradient defines the gradient to use (between 0 and 1)
  70949. * @param min defines the color remap minimal range
  70950. * @param max defines the color remap maximal range
  70951. * @returns the current particle system
  70952. */
  70953. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70954. /**
  70955. * Not supported by GPUParticleSystem
  70956. * @param gradient defines the gradient to remove
  70957. * @returns the current particle system
  70958. */
  70959. removeColorRemapGradient(): IParticleSystem;
  70960. /**
  70961. * Not supported by GPUParticleSystem
  70962. * @param gradient defines the gradient to use (between 0 and 1)
  70963. * @param min defines the alpha remap minimal range
  70964. * @param max defines the alpha remap maximal range
  70965. * @returns the current particle system
  70966. */
  70967. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70968. /**
  70969. * Not supported by GPUParticleSystem
  70970. * @param gradient defines the gradient to remove
  70971. * @returns the current particle system
  70972. */
  70973. removeAlphaRemapGradient(): IParticleSystem;
  70974. /**
  70975. * Not supported by GPUParticleSystem
  70976. * @param gradient defines the gradient to use (between 0 and 1)
  70977. * @param color defines the color to affect to the specified gradient
  70978. * @returns the current particle system
  70979. */
  70980. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70981. /**
  70982. * Not supported by GPUParticleSystem
  70983. * @param gradient defines the gradient to remove
  70984. * @returns the current particle system
  70985. */
  70986. removeRampGradient(): IParticleSystem;
  70987. /**
  70988. * Not supported by GPUParticleSystem
  70989. * @returns the list of ramp gradients
  70990. */
  70991. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70992. /**
  70993. * Not supported by GPUParticleSystem
  70994. * Gets or sets a boolean indicating that ramp gradients must be used
  70995. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70996. */
  70997. get useRampGradients(): boolean;
  70998. set useRampGradients(value: boolean);
  70999. /**
  71000. * Not supported by GPUParticleSystem
  71001. * @param gradient defines the gradient to use (between 0 and 1)
  71002. * @param factor defines the life time factor to affect to the specified gradient
  71003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71004. * @returns the current particle system
  71005. */
  71006. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71007. /**
  71008. * Not supported by GPUParticleSystem
  71009. * @param gradient defines the gradient to remove
  71010. * @returns the current particle system
  71011. */
  71012. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71013. /**
  71014. * Instantiates a GPU particle system.
  71015. * 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.
  71016. * @param name The name of the particle system
  71017. * @param options The options used to create the system
  71018. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71019. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71020. * @param customEffect a custom effect used to change the way particles are rendered by default
  71021. */
  71022. constructor(name: string, options: Partial<{
  71023. capacity: number;
  71024. randomTextureSize: number;
  71025. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71026. protected _reset(): void;
  71027. private _createUpdateVAO;
  71028. private _createRenderVAO;
  71029. private _initialize;
  71030. /** @hidden */
  71031. _recreateUpdateEffect(): void;
  71032. private _getEffect;
  71033. /**
  71034. * Fill the defines array according to the current settings of the particle system
  71035. * @param defines Array to be updated
  71036. * @param blendMode blend mode to take into account when updating the array
  71037. */
  71038. fillDefines(defines: Array<string>, blendMode?: number): void;
  71039. /**
  71040. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71041. * @param uniforms Uniforms array to fill
  71042. * @param attributes Attributes array to fill
  71043. * @param samplers Samplers array to fill
  71044. */
  71045. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71046. /** @hidden */
  71047. _recreateRenderEffect(): Effect;
  71048. /**
  71049. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71050. * @param preWarm defines if we are in the pre-warmimg phase
  71051. */
  71052. animate(preWarm?: boolean): void;
  71053. private _createFactorGradientTexture;
  71054. private _createSizeGradientTexture;
  71055. private _createAngularSpeedGradientTexture;
  71056. private _createVelocityGradientTexture;
  71057. private _createLimitVelocityGradientTexture;
  71058. private _createDragGradientTexture;
  71059. private _createColorGradientTexture;
  71060. /**
  71061. * Renders the particle system in its current state
  71062. * @param preWarm defines if the system should only update the particles but not render them
  71063. * @returns the current number of particles
  71064. */
  71065. render(preWarm?: boolean): number;
  71066. /**
  71067. * Rebuilds the particle system
  71068. */
  71069. rebuild(): void;
  71070. private _releaseBuffers;
  71071. private _releaseVAOs;
  71072. /**
  71073. * Disposes the particle system and free the associated resources
  71074. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71075. */
  71076. dispose(disposeTexture?: boolean): void;
  71077. /**
  71078. * Clones the particle system.
  71079. * @param name The name of the cloned object
  71080. * @param newEmitter The new emitter to use
  71081. * @returns the cloned particle system
  71082. */
  71083. clone(name: string, newEmitter: any): GPUParticleSystem;
  71084. /**
  71085. * Serializes the particle system to a JSON object
  71086. * @param serializeTexture defines if the texture must be serialized as well
  71087. * @returns the JSON object
  71088. */
  71089. serialize(serializeTexture?: boolean): any;
  71090. /**
  71091. * Parses a JSON object to create a GPU particle system.
  71092. * @param parsedParticleSystem The JSON object to parse
  71093. * @param sceneOrEngine The scene or the engine to create the particle system in
  71094. * @param rootUrl The root url to use to load external dependencies like texture
  71095. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71096. * @returns the parsed GPU particle system
  71097. */
  71098. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71099. }
  71100. }
  71101. declare module "babylonjs/Particles/particleSystemSet" {
  71102. import { Nullable } from "babylonjs/types";
  71103. import { Color3 } from "babylonjs/Maths/math.color";
  71104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71106. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71107. import { Scene, IDisposable } from "babylonjs/scene";
  71108. /**
  71109. * Represents a set of particle systems working together to create a specific effect
  71110. */
  71111. export class ParticleSystemSet implements IDisposable {
  71112. /**
  71113. * Gets or sets base Assets URL
  71114. */
  71115. static BaseAssetsUrl: string;
  71116. private _emitterCreationOptions;
  71117. private _emitterNode;
  71118. /**
  71119. * Gets the particle system list
  71120. */
  71121. systems: IParticleSystem[];
  71122. /**
  71123. * Gets the emitter node used with this set
  71124. */
  71125. get emitterNode(): Nullable<TransformNode>;
  71126. /**
  71127. * Creates a new emitter mesh as a sphere
  71128. * @param options defines the options used to create the sphere
  71129. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71130. * @param scene defines the hosting scene
  71131. */
  71132. setEmitterAsSphere(options: {
  71133. diameter: number;
  71134. segments: number;
  71135. color: Color3;
  71136. }, renderingGroupId: number, scene: Scene): void;
  71137. /**
  71138. * Starts all particle systems of the set
  71139. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71140. */
  71141. start(emitter?: AbstractMesh): void;
  71142. /**
  71143. * Release all associated resources
  71144. */
  71145. dispose(): void;
  71146. /**
  71147. * Serialize the set into a JSON compatible object
  71148. * @param serializeTexture defines if the texture must be serialized as well
  71149. * @returns a JSON compatible representation of the set
  71150. */
  71151. serialize(serializeTexture?: boolean): any;
  71152. /**
  71153. * Parse a new ParticleSystemSet from a serialized source
  71154. * @param data defines a JSON compatible representation of the set
  71155. * @param scene defines the hosting scene
  71156. * @param gpu defines if we want GPU particles or CPU particles
  71157. * @returns a new ParticleSystemSet
  71158. */
  71159. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71160. }
  71161. }
  71162. declare module "babylonjs/Particles/particleHelper" {
  71163. import { Nullable } from "babylonjs/types";
  71164. import { Scene } from "babylonjs/scene";
  71165. import { Vector3 } from "babylonjs/Maths/math.vector";
  71166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71167. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71168. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71169. /**
  71170. * This class is made for on one-liner static method to help creating particle system set.
  71171. */
  71172. export class ParticleHelper {
  71173. /**
  71174. * Gets or sets base Assets URL
  71175. */
  71176. static BaseAssetsUrl: string;
  71177. /** Define the Url to load snippets */
  71178. static SnippetUrl: string;
  71179. /**
  71180. * Create a default particle system that you can tweak
  71181. * @param emitter defines the emitter to use
  71182. * @param capacity defines the system capacity (default is 500 particles)
  71183. * @param scene defines the hosting scene
  71184. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71185. * @returns the new Particle system
  71186. */
  71187. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71188. /**
  71189. * This is the main static method (one-liner) of this helper to create different particle systems
  71190. * @param type This string represents the type to the particle system to create
  71191. * @param scene The scene where the particle system should live
  71192. * @param gpu If the system will use gpu
  71193. * @returns the ParticleSystemSet created
  71194. */
  71195. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71196. /**
  71197. * Static function used to export a particle system to a ParticleSystemSet variable.
  71198. * Please note that the emitter shape is not exported
  71199. * @param systems defines the particle systems to export
  71200. * @returns the created particle system set
  71201. */
  71202. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71203. /**
  71204. * Creates a particle system from a snippet saved in a remote file
  71205. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71206. * @param url defines the url to load from
  71207. * @param scene defines the hosting scene
  71208. * @param gpu If the system will use gpu
  71209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71210. * @returns a promise that will resolve to the new particle system
  71211. */
  71212. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71213. /**
  71214. * Creates a particle system from a snippet saved by the particle system editor
  71215. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71216. * @param scene defines the hosting scene
  71217. * @param gpu If the system will use gpu
  71218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71219. * @returns a promise that will resolve to the new particle system
  71220. */
  71221. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71222. }
  71223. }
  71224. declare module "babylonjs/Particles/particleSystemComponent" {
  71225. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71226. import { Effect } from "babylonjs/Materials/effect";
  71227. import "babylonjs/Shaders/particles.vertex";
  71228. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71229. module "babylonjs/Engines/engine" {
  71230. interface Engine {
  71231. /**
  71232. * Create an effect to use with particle systems.
  71233. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71234. * the particle system for which you want to create a custom effect in the last parameter
  71235. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71236. * @param uniformsNames defines a list of attribute names
  71237. * @param samplers defines an array of string used to represent textures
  71238. * @param defines defines the string containing the defines to use to compile the shaders
  71239. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71240. * @param onCompiled defines a function to call when the effect creation is successful
  71241. * @param onError defines a function to call when the effect creation has failed
  71242. * @param particleSystem the particle system you want to create the effect for
  71243. * @returns the new Effect
  71244. */
  71245. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71246. }
  71247. }
  71248. module "babylonjs/Meshes/mesh" {
  71249. interface Mesh {
  71250. /**
  71251. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71252. * @returns an array of IParticleSystem
  71253. */
  71254. getEmittedParticleSystems(): IParticleSystem[];
  71255. /**
  71256. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71257. * @returns an array of IParticleSystem
  71258. */
  71259. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71260. }
  71261. }
  71262. }
  71263. declare module "babylonjs/Particles/pointsCloudSystem" {
  71264. import { Color4 } from "babylonjs/Maths/math";
  71265. import { Mesh } from "babylonjs/Meshes/mesh";
  71266. import { Scene, IDisposable } from "babylonjs/scene";
  71267. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71268. /** Defines the 4 color options */
  71269. export enum PointColor {
  71270. /** color value */
  71271. Color = 2,
  71272. /** uv value */
  71273. UV = 1,
  71274. /** random value */
  71275. Random = 0,
  71276. /** stated value */
  71277. Stated = 3
  71278. }
  71279. /**
  71280. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71281. * 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.
  71282. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71283. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71284. *
  71285. * Full documentation here : TO BE ENTERED
  71286. */
  71287. export class PointsCloudSystem implements IDisposable {
  71288. /**
  71289. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71290. * Example : var p = SPS.particles[i];
  71291. */
  71292. particles: CloudPoint[];
  71293. /**
  71294. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71295. */
  71296. nbParticles: number;
  71297. /**
  71298. * This a counter for your own usage. It's not set by any SPS functions.
  71299. */
  71300. counter: number;
  71301. /**
  71302. * The PCS name. This name is also given to the underlying mesh.
  71303. */
  71304. name: string;
  71305. /**
  71306. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71307. */
  71308. mesh: Mesh;
  71309. /**
  71310. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71311. * Please read :
  71312. */
  71313. vars: any;
  71314. /**
  71315. * @hidden
  71316. */
  71317. _size: number;
  71318. private _scene;
  71319. private _promises;
  71320. private _positions;
  71321. private _indices;
  71322. private _normals;
  71323. private _colors;
  71324. private _uvs;
  71325. private _indices32;
  71326. private _positions32;
  71327. private _colors32;
  71328. private _uvs32;
  71329. private _updatable;
  71330. private _isVisibilityBoxLocked;
  71331. private _alwaysVisible;
  71332. private _groups;
  71333. private _groupCounter;
  71334. private _computeParticleColor;
  71335. private _computeParticleTexture;
  71336. private _computeParticleRotation;
  71337. private _computeBoundingBox;
  71338. private _isReady;
  71339. /**
  71340. * Creates a PCS (Points Cloud System) object
  71341. * @param name (String) is the PCS name, this will be the underlying mesh name
  71342. * @param pointSize (number) is the size for each point
  71343. * @param scene (Scene) is the scene in which the PCS is added
  71344. * @param options defines the options of the PCS e.g.
  71345. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71346. */
  71347. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71348. updatable?: boolean;
  71349. });
  71350. /**
  71351. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71352. * If no points were added to the PCS, the returned mesh is just a single point.
  71353. * @returns a promise for the created mesh
  71354. */
  71355. buildMeshAsync(): Promise<Mesh>;
  71356. /**
  71357. * @hidden
  71358. */
  71359. private _buildMesh;
  71360. private _addParticle;
  71361. private _randomUnitVector;
  71362. private _getColorIndicesForCoord;
  71363. private _setPointsColorOrUV;
  71364. private _colorFromTexture;
  71365. private _calculateDensity;
  71366. /**
  71367. * Adds points to the PCS in random positions within a unit sphere
  71368. * @param nb (positive integer) the number of particles to be created from this model
  71369. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71370. * @returns the number of groups in the system
  71371. */
  71372. addPoints(nb: number, pointFunction?: any): number;
  71373. /**
  71374. * Adds points to the PCS from the surface of the model shape
  71375. * @param mesh is any Mesh object that will be used as a surface model for the points
  71376. * @param nb (positive integer) the number of particles to be created from this model
  71377. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71378. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71379. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71380. * @returns the number of groups in the system
  71381. */
  71382. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71383. /**
  71384. * Adds points to the PCS inside the model shape
  71385. * @param mesh is any Mesh object that will be used as a surface model for the points
  71386. * @param nb (positive integer) the number of particles to be created from this model
  71387. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71388. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71389. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71390. * @returns the number of groups in the system
  71391. */
  71392. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71393. /**
  71394. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71395. * This method calls `updateParticle()` for each particle of the SPS.
  71396. * For an animated SPS, it is usually called within the render loop.
  71397. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71398. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71399. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71400. * @returns the PCS.
  71401. */
  71402. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71403. /**
  71404. * Disposes the PCS.
  71405. */
  71406. dispose(): void;
  71407. /**
  71408. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71409. * doc :
  71410. * @returns the PCS.
  71411. */
  71412. refreshVisibleSize(): PointsCloudSystem;
  71413. /**
  71414. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71415. * @param size the size (float) of the visibility box
  71416. * note : this doesn't lock the PCS mesh bounding box.
  71417. * doc :
  71418. */
  71419. setVisibilityBox(size: number): void;
  71420. /**
  71421. * Gets whether the PCS is always visible or not
  71422. * doc :
  71423. */
  71424. get isAlwaysVisible(): boolean;
  71425. /**
  71426. * Sets the PCS as always visible or not
  71427. * doc :
  71428. */
  71429. set isAlwaysVisible(val: boolean);
  71430. /**
  71431. * Tells to `setParticles()` to compute the particle rotations or not
  71432. * Default value : false. The PCS is faster when it's set to false
  71433. * Note : particle rotations are only applied to parent particles
  71434. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71435. */
  71436. set computeParticleRotation(val: boolean);
  71437. /**
  71438. * Tells to `setParticles()` to compute the particle colors or not.
  71439. * Default value : true. The PCS is faster when it's set to false.
  71440. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71441. */
  71442. set computeParticleColor(val: boolean);
  71443. set computeParticleTexture(val: boolean);
  71444. /**
  71445. * Gets if `setParticles()` computes the particle colors or not.
  71446. * Default value : false. The PCS is faster when it's set to false.
  71447. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71448. */
  71449. get computeParticleColor(): boolean;
  71450. /**
  71451. * Gets if `setParticles()` computes the particle textures or not.
  71452. * Default value : false. The PCS is faster when it's set to false.
  71453. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71454. */
  71455. get computeParticleTexture(): boolean;
  71456. /**
  71457. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71458. */
  71459. set computeBoundingBox(val: boolean);
  71460. /**
  71461. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71462. */
  71463. get computeBoundingBox(): boolean;
  71464. /**
  71465. * This function does nothing. It may be overwritten to set all the particle first values.
  71466. * The PCS doesn't call this function, you may have to call it by your own.
  71467. * doc :
  71468. */
  71469. initParticles(): void;
  71470. /**
  71471. * This function does nothing. It may be overwritten to recycle a particle
  71472. * The PCS doesn't call this function, you can to call it
  71473. * doc :
  71474. * @param particle The particle to recycle
  71475. * @returns the recycled particle
  71476. */
  71477. recycleParticle(particle: CloudPoint): CloudPoint;
  71478. /**
  71479. * Updates a particle : this function should be overwritten by the user.
  71480. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71481. * doc :
  71482. * @example : just set a particle position or velocity and recycle conditions
  71483. * @param particle The particle to update
  71484. * @returns the updated particle
  71485. */
  71486. updateParticle(particle: CloudPoint): CloudPoint;
  71487. /**
  71488. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71489. * This does nothing and may be overwritten by the user.
  71490. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71491. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71492. * @param update the boolean update value actually passed to setParticles()
  71493. */
  71494. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71495. /**
  71496. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71497. * This will be passed three parameters.
  71498. * This does nothing and may be overwritten by the user.
  71499. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71500. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71501. * @param update the boolean update value actually passed to setParticles()
  71502. */
  71503. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71504. }
  71505. }
  71506. declare module "babylonjs/Particles/cloudPoint" {
  71507. import { Nullable } from "babylonjs/types";
  71508. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71509. import { Mesh } from "babylonjs/Meshes/mesh";
  71510. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71511. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71512. /**
  71513. * Represents one particle of a points cloud system.
  71514. */
  71515. export class CloudPoint {
  71516. /**
  71517. * particle global index
  71518. */
  71519. idx: number;
  71520. /**
  71521. * The color of the particle
  71522. */
  71523. color: Nullable<Color4>;
  71524. /**
  71525. * The world space position of the particle.
  71526. */
  71527. position: Vector3;
  71528. /**
  71529. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71530. */
  71531. rotation: Vector3;
  71532. /**
  71533. * The world space rotation quaternion of the particle.
  71534. */
  71535. rotationQuaternion: Nullable<Quaternion>;
  71536. /**
  71537. * The uv of the particle.
  71538. */
  71539. uv: Nullable<Vector2>;
  71540. /**
  71541. * The current speed of the particle.
  71542. */
  71543. velocity: Vector3;
  71544. /**
  71545. * The pivot point in the particle local space.
  71546. */
  71547. pivot: Vector3;
  71548. /**
  71549. * Must the particle be translated from its pivot point in its local space ?
  71550. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71551. * Default : false
  71552. */
  71553. translateFromPivot: boolean;
  71554. /**
  71555. * Index of this particle in the global "positions" array (Internal use)
  71556. * @hidden
  71557. */
  71558. _pos: number;
  71559. /**
  71560. * @hidden Index of this particle in the global "indices" array (Internal use)
  71561. */
  71562. _ind: number;
  71563. /**
  71564. * Group this particle belongs to
  71565. */
  71566. _group: PointsGroup;
  71567. /**
  71568. * Group id of this particle
  71569. */
  71570. groupId: number;
  71571. /**
  71572. * Index of the particle in its group id (Internal use)
  71573. */
  71574. idxInGroup: number;
  71575. /**
  71576. * @hidden Particle BoundingInfo object (Internal use)
  71577. */
  71578. _boundingInfo: BoundingInfo;
  71579. /**
  71580. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71581. */
  71582. _pcs: PointsCloudSystem;
  71583. /**
  71584. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71585. */
  71586. _stillInvisible: boolean;
  71587. /**
  71588. * @hidden Last computed particle rotation matrix
  71589. */
  71590. _rotationMatrix: number[];
  71591. /**
  71592. * Parent particle Id, if any.
  71593. * Default null.
  71594. */
  71595. parentId: Nullable<number>;
  71596. /**
  71597. * @hidden Internal global position in the PCS.
  71598. */
  71599. _globalPosition: Vector3;
  71600. /**
  71601. * Creates a Point Cloud object.
  71602. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71603. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71604. * @param group (PointsGroup) is the group the particle belongs to
  71605. * @param groupId (integer) is the group identifier in the PCS.
  71606. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71607. * @param pcs defines the PCS it is associated to
  71608. */
  71609. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71610. /**
  71611. * get point size
  71612. */
  71613. get size(): Vector3;
  71614. /**
  71615. * Set point size
  71616. */
  71617. set size(scale: Vector3);
  71618. /**
  71619. * Legacy support, changed quaternion to rotationQuaternion
  71620. */
  71621. get quaternion(): Nullable<Quaternion>;
  71622. /**
  71623. * Legacy support, changed quaternion to rotationQuaternion
  71624. */
  71625. set quaternion(q: Nullable<Quaternion>);
  71626. /**
  71627. * Returns a boolean. True if the particle intersects a mesh, else false
  71628. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71629. * @param target is the object (point or mesh) what the intersection is computed against
  71630. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71631. * @returns true if it intersects
  71632. */
  71633. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71634. /**
  71635. * get the rotation matrix of the particle
  71636. * @hidden
  71637. */
  71638. getRotationMatrix(m: Matrix): void;
  71639. }
  71640. /**
  71641. * Represents a group of points in a points cloud system
  71642. * * PCS internal tool, don't use it manually.
  71643. */
  71644. export class PointsGroup {
  71645. /**
  71646. * The group id
  71647. * @hidden
  71648. */
  71649. groupID: number;
  71650. /**
  71651. * image data for group (internal use)
  71652. * @hidden
  71653. */
  71654. _groupImageData: Nullable<ArrayBufferView>;
  71655. /**
  71656. * Image Width (internal use)
  71657. * @hidden
  71658. */
  71659. _groupImgWidth: number;
  71660. /**
  71661. * Image Height (internal use)
  71662. * @hidden
  71663. */
  71664. _groupImgHeight: number;
  71665. /**
  71666. * Custom position function (internal use)
  71667. * @hidden
  71668. */
  71669. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71670. /**
  71671. * density per facet for surface points
  71672. * @hidden
  71673. */
  71674. _groupDensity: number[];
  71675. /**
  71676. * Only when points are colored by texture carries pointer to texture list array
  71677. * @hidden
  71678. */
  71679. _textureNb: number;
  71680. /**
  71681. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71682. * PCS internal tool, don't use it manually.
  71683. * @hidden
  71684. */
  71685. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71686. }
  71687. }
  71688. declare module "babylonjs/Particles/index" {
  71689. export * from "babylonjs/Particles/baseParticleSystem";
  71690. export * from "babylonjs/Particles/EmitterTypes/index";
  71691. export * from "babylonjs/Particles/gpuParticleSystem";
  71692. export * from "babylonjs/Particles/IParticleSystem";
  71693. export * from "babylonjs/Particles/particle";
  71694. export * from "babylonjs/Particles/particleHelper";
  71695. export * from "babylonjs/Particles/particleSystem";
  71696. import "babylonjs/Particles/particleSystemComponent";
  71697. export * from "babylonjs/Particles/particleSystemComponent";
  71698. export * from "babylonjs/Particles/particleSystemSet";
  71699. export * from "babylonjs/Particles/solidParticle";
  71700. export * from "babylonjs/Particles/solidParticleSystem";
  71701. export * from "babylonjs/Particles/cloudPoint";
  71702. export * from "babylonjs/Particles/pointsCloudSystem";
  71703. export * from "babylonjs/Particles/subEmitter";
  71704. }
  71705. declare module "babylonjs/Physics/physicsEngineComponent" {
  71706. import { Nullable } from "babylonjs/types";
  71707. import { Observable, Observer } from "babylonjs/Misc/observable";
  71708. import { Vector3 } from "babylonjs/Maths/math.vector";
  71709. import { Mesh } from "babylonjs/Meshes/mesh";
  71710. import { ISceneComponent } from "babylonjs/sceneComponent";
  71711. import { Scene } from "babylonjs/scene";
  71712. import { Node } from "babylonjs/node";
  71713. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71714. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71715. module "babylonjs/scene" {
  71716. interface Scene {
  71717. /** @hidden (Backing field) */
  71718. _physicsEngine: Nullable<IPhysicsEngine>;
  71719. /** @hidden */
  71720. _physicsTimeAccumulator: number;
  71721. /**
  71722. * Gets the current physics engine
  71723. * @returns a IPhysicsEngine or null if none attached
  71724. */
  71725. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71726. /**
  71727. * Enables physics to the current scene
  71728. * @param gravity defines the scene's gravity for the physics engine
  71729. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71730. * @return a boolean indicating if the physics engine was initialized
  71731. */
  71732. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71733. /**
  71734. * Disables and disposes the physics engine associated with the scene
  71735. */
  71736. disablePhysicsEngine(): void;
  71737. /**
  71738. * Gets a boolean indicating if there is an active physics engine
  71739. * @returns a boolean indicating if there is an active physics engine
  71740. */
  71741. isPhysicsEnabled(): boolean;
  71742. /**
  71743. * Deletes a physics compound impostor
  71744. * @param compound defines the compound to delete
  71745. */
  71746. deleteCompoundImpostor(compound: any): void;
  71747. /**
  71748. * An event triggered when physic simulation is about to be run
  71749. */
  71750. onBeforePhysicsObservable: Observable<Scene>;
  71751. /**
  71752. * An event triggered when physic simulation has been done
  71753. */
  71754. onAfterPhysicsObservable: Observable<Scene>;
  71755. }
  71756. }
  71757. module "babylonjs/Meshes/abstractMesh" {
  71758. interface AbstractMesh {
  71759. /** @hidden */
  71760. _physicsImpostor: Nullable<PhysicsImpostor>;
  71761. /**
  71762. * Gets or sets impostor used for physic simulation
  71763. * @see https://doc.babylonjs.com/features/physics_engine
  71764. */
  71765. physicsImpostor: Nullable<PhysicsImpostor>;
  71766. /**
  71767. * Gets the current physics impostor
  71768. * @see https://doc.babylonjs.com/features/physics_engine
  71769. * @returns a physics impostor or null
  71770. */
  71771. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71772. /** Apply a physic impulse to the mesh
  71773. * @param force defines the force to apply
  71774. * @param contactPoint defines where to apply the force
  71775. * @returns the current mesh
  71776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71777. */
  71778. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71779. /**
  71780. * Creates a physic joint between two meshes
  71781. * @param otherMesh defines the other mesh to use
  71782. * @param pivot1 defines the pivot to use on this mesh
  71783. * @param pivot2 defines the pivot to use on the other mesh
  71784. * @param options defines additional options (can be plugin dependent)
  71785. * @returns the current mesh
  71786. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71787. */
  71788. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71789. /** @hidden */
  71790. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71791. }
  71792. }
  71793. /**
  71794. * Defines the physics engine scene component responsible to manage a physics engine
  71795. */
  71796. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71797. /**
  71798. * The component name helpful to identify the component in the list of scene components.
  71799. */
  71800. readonly name: string;
  71801. /**
  71802. * The scene the component belongs to.
  71803. */
  71804. scene: Scene;
  71805. /**
  71806. * Creates a new instance of the component for the given scene
  71807. * @param scene Defines the scene to register the component in
  71808. */
  71809. constructor(scene: Scene);
  71810. /**
  71811. * Registers the component in a given scene
  71812. */
  71813. register(): void;
  71814. /**
  71815. * Rebuilds the elements related to this component in case of
  71816. * context lost for instance.
  71817. */
  71818. rebuild(): void;
  71819. /**
  71820. * Disposes the component and the associated ressources
  71821. */
  71822. dispose(): void;
  71823. }
  71824. }
  71825. declare module "babylonjs/Physics/physicsHelper" {
  71826. import { Nullable } from "babylonjs/types";
  71827. import { Vector3 } from "babylonjs/Maths/math.vector";
  71828. import { Mesh } from "babylonjs/Meshes/mesh";
  71829. import { Scene } from "babylonjs/scene";
  71830. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71831. /**
  71832. * A helper for physics simulations
  71833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71834. */
  71835. export class PhysicsHelper {
  71836. private _scene;
  71837. private _physicsEngine;
  71838. /**
  71839. * Initializes the Physics helper
  71840. * @param scene Babylon.js scene
  71841. */
  71842. constructor(scene: Scene);
  71843. /**
  71844. * Applies a radial explosion impulse
  71845. * @param origin the origin of the explosion
  71846. * @param radiusOrEventOptions the radius or the options of radial explosion
  71847. * @param strength the explosion strength
  71848. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71849. * @returns A physics radial explosion event, or null
  71850. */
  71851. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71852. /**
  71853. * Applies a radial explosion force
  71854. * @param origin the origin of the explosion
  71855. * @param radiusOrEventOptions the radius or the options of radial explosion
  71856. * @param strength the explosion strength
  71857. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71858. * @returns A physics radial explosion event, or null
  71859. */
  71860. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71861. /**
  71862. * Creates a gravitational field
  71863. * @param origin the origin of the explosion
  71864. * @param radiusOrEventOptions the radius or the options of radial explosion
  71865. * @param strength the explosion strength
  71866. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71867. * @returns A physics gravitational field event, or null
  71868. */
  71869. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71870. /**
  71871. * Creates a physics updraft event
  71872. * @param origin the origin of the updraft
  71873. * @param radiusOrEventOptions the radius or the options of the updraft
  71874. * @param strength the strength of the updraft
  71875. * @param height the height of the updraft
  71876. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71877. * @returns A physics updraft event, or null
  71878. */
  71879. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71880. /**
  71881. * Creates a physics vortex event
  71882. * @param origin the of the vortex
  71883. * @param radiusOrEventOptions the radius or the options of the vortex
  71884. * @param strength the strength of the vortex
  71885. * @param height the height of the vortex
  71886. * @returns a Physics vortex event, or null
  71887. * A physics vortex event or null
  71888. */
  71889. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71890. }
  71891. /**
  71892. * Represents a physics radial explosion event
  71893. */
  71894. class PhysicsRadialExplosionEvent {
  71895. private _scene;
  71896. private _options;
  71897. private _sphere;
  71898. private _dataFetched;
  71899. /**
  71900. * Initializes a radial explosioin event
  71901. * @param _scene BabylonJS scene
  71902. * @param _options The options for the vortex event
  71903. */
  71904. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71905. /**
  71906. * Returns the data related to the radial explosion event (sphere).
  71907. * @returns The radial explosion event data
  71908. */
  71909. getData(): PhysicsRadialExplosionEventData;
  71910. /**
  71911. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71912. * @param impostor A physics imposter
  71913. * @param origin the origin of the explosion
  71914. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71915. */
  71916. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71917. /**
  71918. * Triggers affecterd impostors callbacks
  71919. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71920. */
  71921. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71922. /**
  71923. * Disposes the sphere.
  71924. * @param force Specifies if the sphere should be disposed by force
  71925. */
  71926. dispose(force?: boolean): void;
  71927. /*** Helpers ***/
  71928. private _prepareSphere;
  71929. private _intersectsWithSphere;
  71930. }
  71931. /**
  71932. * Represents a gravitational field event
  71933. */
  71934. class PhysicsGravitationalFieldEvent {
  71935. private _physicsHelper;
  71936. private _scene;
  71937. private _origin;
  71938. private _options;
  71939. private _tickCallback;
  71940. private _sphere;
  71941. private _dataFetched;
  71942. /**
  71943. * Initializes the physics gravitational field event
  71944. * @param _physicsHelper A physics helper
  71945. * @param _scene BabylonJS scene
  71946. * @param _origin The origin position of the gravitational field event
  71947. * @param _options The options for the vortex event
  71948. */
  71949. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71950. /**
  71951. * Returns the data related to the gravitational field event (sphere).
  71952. * @returns A gravitational field event
  71953. */
  71954. getData(): PhysicsGravitationalFieldEventData;
  71955. /**
  71956. * Enables the gravitational field.
  71957. */
  71958. enable(): void;
  71959. /**
  71960. * Disables the gravitational field.
  71961. */
  71962. disable(): void;
  71963. /**
  71964. * Disposes the sphere.
  71965. * @param force The force to dispose from the gravitational field event
  71966. */
  71967. dispose(force?: boolean): void;
  71968. private _tick;
  71969. }
  71970. /**
  71971. * Represents a physics updraft event
  71972. */
  71973. class PhysicsUpdraftEvent {
  71974. private _scene;
  71975. private _origin;
  71976. private _options;
  71977. private _physicsEngine;
  71978. private _originTop;
  71979. private _originDirection;
  71980. private _tickCallback;
  71981. private _cylinder;
  71982. private _cylinderPosition;
  71983. private _dataFetched;
  71984. /**
  71985. * Initializes the physics updraft event
  71986. * @param _scene BabylonJS scene
  71987. * @param _origin The origin position of the updraft
  71988. * @param _options The options for the updraft event
  71989. */
  71990. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71991. /**
  71992. * Returns the data related to the updraft event (cylinder).
  71993. * @returns A physics updraft event
  71994. */
  71995. getData(): PhysicsUpdraftEventData;
  71996. /**
  71997. * Enables the updraft.
  71998. */
  71999. enable(): void;
  72000. /**
  72001. * Disables the updraft.
  72002. */
  72003. disable(): void;
  72004. /**
  72005. * Disposes the cylinder.
  72006. * @param force Specifies if the updraft should be disposed by force
  72007. */
  72008. dispose(force?: boolean): void;
  72009. private getImpostorHitData;
  72010. private _tick;
  72011. /*** Helpers ***/
  72012. private _prepareCylinder;
  72013. private _intersectsWithCylinder;
  72014. }
  72015. /**
  72016. * Represents a physics vortex event
  72017. */
  72018. class PhysicsVortexEvent {
  72019. private _scene;
  72020. private _origin;
  72021. private _options;
  72022. private _physicsEngine;
  72023. private _originTop;
  72024. private _tickCallback;
  72025. private _cylinder;
  72026. private _cylinderPosition;
  72027. private _dataFetched;
  72028. /**
  72029. * Initializes the physics vortex event
  72030. * @param _scene The BabylonJS scene
  72031. * @param _origin The origin position of the vortex
  72032. * @param _options The options for the vortex event
  72033. */
  72034. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72035. /**
  72036. * Returns the data related to the vortex event (cylinder).
  72037. * @returns The physics vortex event data
  72038. */
  72039. getData(): PhysicsVortexEventData;
  72040. /**
  72041. * Enables the vortex.
  72042. */
  72043. enable(): void;
  72044. /**
  72045. * Disables the cortex.
  72046. */
  72047. disable(): void;
  72048. /**
  72049. * Disposes the sphere.
  72050. * @param force
  72051. */
  72052. dispose(force?: boolean): void;
  72053. private getImpostorHitData;
  72054. private _tick;
  72055. /*** Helpers ***/
  72056. private _prepareCylinder;
  72057. private _intersectsWithCylinder;
  72058. }
  72059. /**
  72060. * Options fot the radial explosion event
  72061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72062. */
  72063. export class PhysicsRadialExplosionEventOptions {
  72064. /**
  72065. * The radius of the sphere for the radial explosion.
  72066. */
  72067. radius: number;
  72068. /**
  72069. * The strenth of the explosion.
  72070. */
  72071. strength: number;
  72072. /**
  72073. * The strenght of the force in correspondence to the distance of the affected object
  72074. */
  72075. falloff: PhysicsRadialImpulseFalloff;
  72076. /**
  72077. * Sphere options for the radial explosion.
  72078. */
  72079. sphere: {
  72080. segments: number;
  72081. diameter: number;
  72082. };
  72083. /**
  72084. * Sphere options for the radial explosion.
  72085. */
  72086. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72087. }
  72088. /**
  72089. * Options fot the updraft event
  72090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72091. */
  72092. export class PhysicsUpdraftEventOptions {
  72093. /**
  72094. * The radius of the cylinder for the vortex
  72095. */
  72096. radius: number;
  72097. /**
  72098. * The strenth of the updraft.
  72099. */
  72100. strength: number;
  72101. /**
  72102. * The height of the cylinder for the updraft.
  72103. */
  72104. height: number;
  72105. /**
  72106. * The mode for the the updraft.
  72107. */
  72108. updraftMode: PhysicsUpdraftMode;
  72109. }
  72110. /**
  72111. * Options fot the vortex event
  72112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72113. */
  72114. export class PhysicsVortexEventOptions {
  72115. /**
  72116. * The radius of the cylinder for the vortex
  72117. */
  72118. radius: number;
  72119. /**
  72120. * The strenth of the vortex.
  72121. */
  72122. strength: number;
  72123. /**
  72124. * The height of the cylinder for the vortex.
  72125. */
  72126. height: number;
  72127. /**
  72128. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72129. */
  72130. centripetalForceThreshold: number;
  72131. /**
  72132. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72133. */
  72134. centripetalForceMultiplier: number;
  72135. /**
  72136. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72137. */
  72138. centrifugalForceMultiplier: number;
  72139. /**
  72140. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72141. */
  72142. updraftForceMultiplier: number;
  72143. }
  72144. /**
  72145. * The strenght of the force in correspondence to the distance of the affected object
  72146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72147. */
  72148. export enum PhysicsRadialImpulseFalloff {
  72149. /** Defines that impulse is constant in strength across it's whole radius */
  72150. Constant = 0,
  72151. /** Defines that impulse gets weaker if it's further from the origin */
  72152. Linear = 1
  72153. }
  72154. /**
  72155. * The strength of the force in correspondence to the distance of the affected object
  72156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72157. */
  72158. export enum PhysicsUpdraftMode {
  72159. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72160. Center = 0,
  72161. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72162. Perpendicular = 1
  72163. }
  72164. /**
  72165. * Interface for a physics hit data
  72166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72167. */
  72168. export interface PhysicsHitData {
  72169. /**
  72170. * The force applied at the contact point
  72171. */
  72172. force: Vector3;
  72173. /**
  72174. * The contact point
  72175. */
  72176. contactPoint: Vector3;
  72177. /**
  72178. * The distance from the origin to the contact point
  72179. */
  72180. distanceFromOrigin: number;
  72181. }
  72182. /**
  72183. * Interface for radial explosion event data
  72184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72185. */
  72186. export interface PhysicsRadialExplosionEventData {
  72187. /**
  72188. * A sphere used for the radial explosion event
  72189. */
  72190. sphere: Mesh;
  72191. }
  72192. /**
  72193. * Interface for gravitational field event data
  72194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72195. */
  72196. export interface PhysicsGravitationalFieldEventData {
  72197. /**
  72198. * A sphere mesh used for the gravitational field event
  72199. */
  72200. sphere: Mesh;
  72201. }
  72202. /**
  72203. * Interface for updraft event data
  72204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72205. */
  72206. export interface PhysicsUpdraftEventData {
  72207. /**
  72208. * A cylinder used for the updraft event
  72209. */
  72210. cylinder: Mesh;
  72211. }
  72212. /**
  72213. * Interface for vortex event data
  72214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72215. */
  72216. export interface PhysicsVortexEventData {
  72217. /**
  72218. * A cylinder used for the vortex event
  72219. */
  72220. cylinder: Mesh;
  72221. }
  72222. /**
  72223. * Interface for an affected physics impostor
  72224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72225. */
  72226. export interface PhysicsAffectedImpostorWithData {
  72227. /**
  72228. * The impostor affected by the effect
  72229. */
  72230. impostor: PhysicsImpostor;
  72231. /**
  72232. * The data about the hit/horce from the explosion
  72233. */
  72234. hitData: PhysicsHitData;
  72235. }
  72236. }
  72237. declare module "babylonjs/Physics/Plugins/index" {
  72238. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72239. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72240. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72241. }
  72242. declare module "babylonjs/Physics/index" {
  72243. export * from "babylonjs/Physics/IPhysicsEngine";
  72244. export * from "babylonjs/Physics/physicsEngine";
  72245. export * from "babylonjs/Physics/physicsEngineComponent";
  72246. export * from "babylonjs/Physics/physicsHelper";
  72247. export * from "babylonjs/Physics/physicsImpostor";
  72248. export * from "babylonjs/Physics/physicsJoint";
  72249. export * from "babylonjs/Physics/Plugins/index";
  72250. }
  72251. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72252. /** @hidden */
  72253. export var blackAndWhitePixelShader: {
  72254. name: string;
  72255. shader: string;
  72256. };
  72257. }
  72258. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72260. import { Camera } from "babylonjs/Cameras/camera";
  72261. import { Engine } from "babylonjs/Engines/engine";
  72262. import "babylonjs/Shaders/blackAndWhite.fragment";
  72263. /**
  72264. * Post process used to render in black and white
  72265. */
  72266. export class BlackAndWhitePostProcess extends PostProcess {
  72267. /**
  72268. * Linear about to convert he result to black and white (default: 1)
  72269. */
  72270. degree: number;
  72271. /**
  72272. * Creates a black and white post process
  72273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72274. * @param name The name of the effect.
  72275. * @param options The required width/height ratio to downsize to before computing the render pass.
  72276. * @param camera The camera to apply the render pass to.
  72277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72278. * @param engine The engine which the post process will be applied. (default: current engine)
  72279. * @param reusable If the post process can be reused on the same frame. (default: false)
  72280. */
  72281. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72282. }
  72283. }
  72284. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72285. import { Nullable } from "babylonjs/types";
  72286. import { Camera } from "babylonjs/Cameras/camera";
  72287. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72288. import { Engine } from "babylonjs/Engines/engine";
  72289. /**
  72290. * This represents a set of one or more post processes in Babylon.
  72291. * A post process can be used to apply a shader to a texture after it is rendered.
  72292. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72293. */
  72294. export class PostProcessRenderEffect {
  72295. private _postProcesses;
  72296. private _getPostProcesses;
  72297. private _singleInstance;
  72298. private _cameras;
  72299. private _indicesForCamera;
  72300. /**
  72301. * Name of the effect
  72302. * @hidden
  72303. */
  72304. _name: string;
  72305. /**
  72306. * Instantiates a post process render effect.
  72307. * A post process can be used to apply a shader to a texture after it is rendered.
  72308. * @param engine The engine the effect is tied to
  72309. * @param name The name of the effect
  72310. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72311. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72312. */
  72313. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72314. /**
  72315. * Checks if all the post processes in the effect are supported.
  72316. */
  72317. get isSupported(): boolean;
  72318. /**
  72319. * Updates the current state of the effect
  72320. * @hidden
  72321. */
  72322. _update(): void;
  72323. /**
  72324. * Attaches the effect on cameras
  72325. * @param cameras The camera to attach to.
  72326. * @hidden
  72327. */
  72328. _attachCameras(cameras: Camera): void;
  72329. /**
  72330. * Attaches the effect on cameras
  72331. * @param cameras The camera to attach to.
  72332. * @hidden
  72333. */
  72334. _attachCameras(cameras: Camera[]): void;
  72335. /**
  72336. * Detaches the effect on cameras
  72337. * @param cameras The camera to detatch from.
  72338. * @hidden
  72339. */
  72340. _detachCameras(cameras: Camera): void;
  72341. /**
  72342. * Detatches the effect on cameras
  72343. * @param cameras The camera to detatch from.
  72344. * @hidden
  72345. */
  72346. _detachCameras(cameras: Camera[]): void;
  72347. /**
  72348. * Enables the effect on given cameras
  72349. * @param cameras The camera to enable.
  72350. * @hidden
  72351. */
  72352. _enable(cameras: Camera): void;
  72353. /**
  72354. * Enables the effect on given cameras
  72355. * @param cameras The camera to enable.
  72356. * @hidden
  72357. */
  72358. _enable(cameras: Nullable<Camera[]>): void;
  72359. /**
  72360. * Disables the effect on the given cameras
  72361. * @param cameras The camera to disable.
  72362. * @hidden
  72363. */
  72364. _disable(cameras: Camera): void;
  72365. /**
  72366. * Disables the effect on the given cameras
  72367. * @param cameras The camera to disable.
  72368. * @hidden
  72369. */
  72370. _disable(cameras: Nullable<Camera[]>): void;
  72371. /**
  72372. * Gets a list of the post processes contained in the effect.
  72373. * @param camera The camera to get the post processes on.
  72374. * @returns The list of the post processes in the effect.
  72375. */
  72376. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72377. }
  72378. }
  72379. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72380. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72381. /** @hidden */
  72382. export var extractHighlightsPixelShader: {
  72383. name: string;
  72384. shader: string;
  72385. };
  72386. }
  72387. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72388. import { Nullable } from "babylonjs/types";
  72389. import { Camera } from "babylonjs/Cameras/camera";
  72390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72391. import { Engine } from "babylonjs/Engines/engine";
  72392. import "babylonjs/Shaders/extractHighlights.fragment";
  72393. /**
  72394. * 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.
  72395. */
  72396. export class ExtractHighlightsPostProcess extends PostProcess {
  72397. /**
  72398. * The luminance threshold, pixels below this value will be set to black.
  72399. */
  72400. threshold: number;
  72401. /** @hidden */
  72402. _exposure: number;
  72403. /**
  72404. * Post process which has the input texture to be used when performing highlight extraction
  72405. * @hidden
  72406. */
  72407. _inputPostProcess: Nullable<PostProcess>;
  72408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72409. }
  72410. }
  72411. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72412. /** @hidden */
  72413. export var bloomMergePixelShader: {
  72414. name: string;
  72415. shader: string;
  72416. };
  72417. }
  72418. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72419. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72420. import { Nullable } from "babylonjs/types";
  72421. import { Engine } from "babylonjs/Engines/engine";
  72422. import { Camera } from "babylonjs/Cameras/camera";
  72423. import "babylonjs/Shaders/bloomMerge.fragment";
  72424. /**
  72425. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72426. */
  72427. export class BloomMergePostProcess extends PostProcess {
  72428. /** Weight of the bloom to be added to the original input. */
  72429. weight: number;
  72430. /**
  72431. * Creates a new instance of @see BloomMergePostProcess
  72432. * @param name The name of the effect.
  72433. * @param originalFromInput Post process which's input will be used for the merge.
  72434. * @param blurred Blurred highlights post process which's output will be used.
  72435. * @param weight Weight of the bloom to be added to the original input.
  72436. * @param options The required width/height ratio to downsize to before computing the render pass.
  72437. * @param camera The camera to apply the render pass to.
  72438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72439. * @param engine The engine which the post process will be applied. (default: current engine)
  72440. * @param reusable If the post process can be reused on the same frame. (default: false)
  72441. * @param textureType Type of textures used when performing the post process. (default: 0)
  72442. * @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)
  72443. */
  72444. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72445. /** Weight of the bloom to be added to the original input. */
  72446. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72447. }
  72448. }
  72449. declare module "babylonjs/PostProcesses/bloomEffect" {
  72450. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72452. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72453. import { Camera } from "babylonjs/Cameras/camera";
  72454. import { Scene } from "babylonjs/scene";
  72455. /**
  72456. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72457. */
  72458. export class BloomEffect extends PostProcessRenderEffect {
  72459. private bloomScale;
  72460. /**
  72461. * @hidden Internal
  72462. */
  72463. _effects: Array<PostProcess>;
  72464. /**
  72465. * @hidden Internal
  72466. */
  72467. _downscale: ExtractHighlightsPostProcess;
  72468. private _blurX;
  72469. private _blurY;
  72470. private _merge;
  72471. /**
  72472. * The luminance threshold to find bright areas of the image to bloom.
  72473. */
  72474. get threshold(): number;
  72475. set threshold(value: number);
  72476. /**
  72477. * The strength of the bloom.
  72478. */
  72479. get weight(): number;
  72480. set weight(value: number);
  72481. /**
  72482. * Specifies the size of the bloom blur kernel, relative to the final output size
  72483. */
  72484. get kernel(): number;
  72485. set kernel(value: number);
  72486. /**
  72487. * Creates a new instance of @see BloomEffect
  72488. * @param scene The scene the effect belongs to.
  72489. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72490. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72491. * @param bloomWeight The the strength of bloom.
  72492. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72493. * @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)
  72494. */
  72495. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72496. /**
  72497. * Disposes each of the internal effects for a given camera.
  72498. * @param camera The camera to dispose the effect on.
  72499. */
  72500. disposeEffects(camera: Camera): void;
  72501. /**
  72502. * @hidden Internal
  72503. */
  72504. _updateEffects(): void;
  72505. /**
  72506. * Internal
  72507. * @returns if all the contained post processes are ready.
  72508. * @hidden
  72509. */
  72510. _isReady(): boolean;
  72511. }
  72512. }
  72513. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72514. /** @hidden */
  72515. export var chromaticAberrationPixelShader: {
  72516. name: string;
  72517. shader: string;
  72518. };
  72519. }
  72520. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72521. import { Vector2 } from "babylonjs/Maths/math.vector";
  72522. import { Nullable } from "babylonjs/types";
  72523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72524. import { Camera } from "babylonjs/Cameras/camera";
  72525. import { Engine } from "babylonjs/Engines/engine";
  72526. import "babylonjs/Shaders/chromaticAberration.fragment";
  72527. /**
  72528. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72529. */
  72530. export class ChromaticAberrationPostProcess extends PostProcess {
  72531. /**
  72532. * The amount of seperation of rgb channels (default: 30)
  72533. */
  72534. aberrationAmount: number;
  72535. /**
  72536. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72537. */
  72538. radialIntensity: number;
  72539. /**
  72540. * 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))
  72541. */
  72542. direction: Vector2;
  72543. /**
  72544. * 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))
  72545. */
  72546. centerPosition: Vector2;
  72547. /**
  72548. * Creates a new instance ChromaticAberrationPostProcess
  72549. * @param name The name of the effect.
  72550. * @param screenWidth The width of the screen to apply the effect on.
  72551. * @param screenHeight The height of the screen to apply the effect on.
  72552. * @param options The required width/height ratio to downsize to before computing the render pass.
  72553. * @param camera The camera to apply the render pass to.
  72554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72555. * @param engine The engine which the post process will be applied. (default: current engine)
  72556. * @param reusable If the post process can be reused on the same frame. (default: false)
  72557. * @param textureType Type of textures used when performing the post process. (default: 0)
  72558. * @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)
  72559. */
  72560. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72561. }
  72562. }
  72563. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72564. /** @hidden */
  72565. export var circleOfConfusionPixelShader: {
  72566. name: string;
  72567. shader: string;
  72568. };
  72569. }
  72570. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72571. import { Nullable } from "babylonjs/types";
  72572. import { Engine } from "babylonjs/Engines/engine";
  72573. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72575. import { Camera } from "babylonjs/Cameras/camera";
  72576. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72577. /**
  72578. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72579. */
  72580. export class CircleOfConfusionPostProcess extends PostProcess {
  72581. /**
  72582. * 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.
  72583. */
  72584. lensSize: number;
  72585. /**
  72586. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72587. */
  72588. fStop: number;
  72589. /**
  72590. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72591. */
  72592. focusDistance: number;
  72593. /**
  72594. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72595. */
  72596. focalLength: number;
  72597. private _depthTexture;
  72598. /**
  72599. * Creates a new instance CircleOfConfusionPostProcess
  72600. * @param name The name of the effect.
  72601. * @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.
  72602. * @param options The required width/height ratio to downsize to before computing the render pass.
  72603. * @param camera The camera to apply the render pass to.
  72604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72605. * @param engine The engine which the post process will be applied. (default: current engine)
  72606. * @param reusable If the post process can be reused on the same frame. (default: false)
  72607. * @param textureType Type of textures used when performing the post process. (default: 0)
  72608. * @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)
  72609. */
  72610. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72611. /**
  72612. * 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.
  72613. */
  72614. set depthTexture(value: RenderTargetTexture);
  72615. }
  72616. }
  72617. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72618. /** @hidden */
  72619. export var colorCorrectionPixelShader: {
  72620. name: string;
  72621. shader: string;
  72622. };
  72623. }
  72624. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72625. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72626. import { Engine } from "babylonjs/Engines/engine";
  72627. import { Camera } from "babylonjs/Cameras/camera";
  72628. import "babylonjs/Shaders/colorCorrection.fragment";
  72629. /**
  72630. *
  72631. * This post-process allows the modification of rendered colors by using
  72632. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72633. *
  72634. * The object needs to be provided an url to a texture containing the color
  72635. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72636. * Use an image editing software to tweak the LUT to match your needs.
  72637. *
  72638. * For an example of a color LUT, see here:
  72639. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72640. * For explanations on color grading, see here:
  72641. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72642. *
  72643. */
  72644. export class ColorCorrectionPostProcess extends PostProcess {
  72645. private _colorTableTexture;
  72646. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72647. }
  72648. }
  72649. declare module "babylonjs/Shaders/convolution.fragment" {
  72650. /** @hidden */
  72651. export var convolutionPixelShader: {
  72652. name: string;
  72653. shader: string;
  72654. };
  72655. }
  72656. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72658. import { Nullable } from "babylonjs/types";
  72659. import { Camera } from "babylonjs/Cameras/camera";
  72660. import { Engine } from "babylonjs/Engines/engine";
  72661. import "babylonjs/Shaders/convolution.fragment";
  72662. /**
  72663. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72664. * input texture to perform effects such as edge detection or sharpening
  72665. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72666. */
  72667. export class ConvolutionPostProcess extends PostProcess {
  72668. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72669. kernel: number[];
  72670. /**
  72671. * Creates a new instance ConvolutionPostProcess
  72672. * @param name The name of the effect.
  72673. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72674. * @param options The required width/height ratio to downsize to before computing the render pass.
  72675. * @param camera The camera to apply the render pass to.
  72676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72677. * @param engine The engine which the post process will be applied. (default: current engine)
  72678. * @param reusable If the post process can be reused on the same frame. (default: false)
  72679. * @param textureType Type of textures used when performing the post process. (default: 0)
  72680. */
  72681. constructor(name: string,
  72682. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72683. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72684. /**
  72685. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72686. */
  72687. static EdgeDetect0Kernel: number[];
  72688. /**
  72689. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72690. */
  72691. static EdgeDetect1Kernel: number[];
  72692. /**
  72693. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72694. */
  72695. static EdgeDetect2Kernel: number[];
  72696. /**
  72697. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72698. */
  72699. static SharpenKernel: number[];
  72700. /**
  72701. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72702. */
  72703. static EmbossKernel: number[];
  72704. /**
  72705. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72706. */
  72707. static GaussianKernel: number[];
  72708. }
  72709. }
  72710. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72711. import { Nullable } from "babylonjs/types";
  72712. import { Vector2 } from "babylonjs/Maths/math.vector";
  72713. import { Camera } from "babylonjs/Cameras/camera";
  72714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72715. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72716. import { Engine } from "babylonjs/Engines/engine";
  72717. import { Scene } from "babylonjs/scene";
  72718. /**
  72719. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72720. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72721. * based on samples that have a large difference in distance than the center pixel.
  72722. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72723. */
  72724. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72725. direction: Vector2;
  72726. /**
  72727. * Creates a new instance CircleOfConfusionPostProcess
  72728. * @param name The name of the effect.
  72729. * @param scene The scene the effect belongs to.
  72730. * @param direction The direction the blur should be applied.
  72731. * @param kernel The size of the kernel used to blur.
  72732. * @param options The required width/height ratio to downsize to before computing the render pass.
  72733. * @param camera The camera to apply the render pass to.
  72734. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72735. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72737. * @param engine The engine which the post process will be applied. (default: current engine)
  72738. * @param reusable If the post process can be reused on the same frame. (default: false)
  72739. * @param textureType Type of textures used when performing the post process. (default: 0)
  72740. * @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)
  72741. */
  72742. 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);
  72743. }
  72744. }
  72745. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72746. /** @hidden */
  72747. export var depthOfFieldMergePixelShader: {
  72748. name: string;
  72749. shader: string;
  72750. };
  72751. }
  72752. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72753. import { Nullable } from "babylonjs/types";
  72754. import { Camera } from "babylonjs/Cameras/camera";
  72755. import { Effect } from "babylonjs/Materials/effect";
  72756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72757. import { Engine } from "babylonjs/Engines/engine";
  72758. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72759. /**
  72760. * Options to be set when merging outputs from the default pipeline.
  72761. */
  72762. export class DepthOfFieldMergePostProcessOptions {
  72763. /**
  72764. * The original image to merge on top of
  72765. */
  72766. originalFromInput: PostProcess;
  72767. /**
  72768. * Parameters to perform the merge of the depth of field effect
  72769. */
  72770. depthOfField?: {
  72771. circleOfConfusion: PostProcess;
  72772. blurSteps: Array<PostProcess>;
  72773. };
  72774. /**
  72775. * Parameters to perform the merge of bloom effect
  72776. */
  72777. bloom?: {
  72778. blurred: PostProcess;
  72779. weight: number;
  72780. };
  72781. }
  72782. /**
  72783. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72784. */
  72785. export class DepthOfFieldMergePostProcess extends PostProcess {
  72786. private blurSteps;
  72787. /**
  72788. * Creates a new instance of DepthOfFieldMergePostProcess
  72789. * @param name The name of the effect.
  72790. * @param originalFromInput Post process which's input will be used for the merge.
  72791. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72792. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72793. * @param options The required width/height ratio to downsize to before computing the render pass.
  72794. * @param camera The camera to apply the render pass to.
  72795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72796. * @param engine The engine which the post process will be applied. (default: current engine)
  72797. * @param reusable If the post process can be reused on the same frame. (default: false)
  72798. * @param textureType Type of textures used when performing the post process. (default: 0)
  72799. * @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)
  72800. */
  72801. 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);
  72802. /**
  72803. * Updates the effect with the current post process compile time values and recompiles the shader.
  72804. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72805. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72806. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72807. * @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
  72808. * @param onCompiled Called when the shader has been compiled.
  72809. * @param onError Called if there is an error when compiling a shader.
  72810. */
  72811. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72812. }
  72813. }
  72814. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72815. import { Nullable } from "babylonjs/types";
  72816. import { Camera } from "babylonjs/Cameras/camera";
  72817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72819. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72820. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72821. import { Scene } from "babylonjs/scene";
  72822. /**
  72823. * Specifies the level of max blur that should be applied when using the depth of field effect
  72824. */
  72825. export enum DepthOfFieldEffectBlurLevel {
  72826. /**
  72827. * Subtle blur
  72828. */
  72829. Low = 0,
  72830. /**
  72831. * Medium blur
  72832. */
  72833. Medium = 1,
  72834. /**
  72835. * Large blur
  72836. */
  72837. High = 2
  72838. }
  72839. /**
  72840. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72841. */
  72842. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72843. private _circleOfConfusion;
  72844. /**
  72845. * @hidden Internal, blurs from high to low
  72846. */
  72847. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72848. private _depthOfFieldBlurY;
  72849. private _dofMerge;
  72850. /**
  72851. * @hidden Internal post processes in depth of field effect
  72852. */
  72853. _effects: Array<PostProcess>;
  72854. /**
  72855. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72856. */
  72857. set focalLength(value: number);
  72858. get focalLength(): number;
  72859. /**
  72860. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72861. */
  72862. set fStop(value: number);
  72863. get fStop(): number;
  72864. /**
  72865. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72866. */
  72867. set focusDistance(value: number);
  72868. get focusDistance(): number;
  72869. /**
  72870. * 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.
  72871. */
  72872. set lensSize(value: number);
  72873. get lensSize(): number;
  72874. /**
  72875. * Creates a new instance DepthOfFieldEffect
  72876. * @param scene The scene the effect belongs to.
  72877. * @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.
  72878. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72879. * @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)
  72880. */
  72881. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72882. /**
  72883. * Get the current class name of the current effet
  72884. * @returns "DepthOfFieldEffect"
  72885. */
  72886. getClassName(): string;
  72887. /**
  72888. * 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.
  72889. */
  72890. set depthTexture(value: RenderTargetTexture);
  72891. /**
  72892. * Disposes each of the internal effects for a given camera.
  72893. * @param camera The camera to dispose the effect on.
  72894. */
  72895. disposeEffects(camera: Camera): void;
  72896. /**
  72897. * @hidden Internal
  72898. */
  72899. _updateEffects(): void;
  72900. /**
  72901. * Internal
  72902. * @returns if all the contained post processes are ready.
  72903. * @hidden
  72904. */
  72905. _isReady(): boolean;
  72906. }
  72907. }
  72908. declare module "babylonjs/Shaders/displayPass.fragment" {
  72909. /** @hidden */
  72910. export var displayPassPixelShader: {
  72911. name: string;
  72912. shader: string;
  72913. };
  72914. }
  72915. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72916. import { Nullable } from "babylonjs/types";
  72917. import { Camera } from "babylonjs/Cameras/camera";
  72918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72919. import { Engine } from "babylonjs/Engines/engine";
  72920. import "babylonjs/Shaders/displayPass.fragment";
  72921. /**
  72922. * DisplayPassPostProcess which produces an output the same as it's input
  72923. */
  72924. export class DisplayPassPostProcess extends PostProcess {
  72925. /**
  72926. * Creates the DisplayPassPostProcess
  72927. * @param name The name of the effect.
  72928. * @param options The required width/height ratio to downsize to before computing the render pass.
  72929. * @param camera The camera to apply the render pass to.
  72930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72931. * @param engine The engine which the post process will be applied. (default: current engine)
  72932. * @param reusable If the post process can be reused on the same frame. (default: false)
  72933. */
  72934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72935. }
  72936. }
  72937. declare module "babylonjs/Shaders/filter.fragment" {
  72938. /** @hidden */
  72939. export var filterPixelShader: {
  72940. name: string;
  72941. shader: string;
  72942. };
  72943. }
  72944. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72945. import { Nullable } from "babylonjs/types";
  72946. import { Matrix } from "babylonjs/Maths/math.vector";
  72947. import { Camera } from "babylonjs/Cameras/camera";
  72948. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72949. import { Engine } from "babylonjs/Engines/engine";
  72950. import "babylonjs/Shaders/filter.fragment";
  72951. /**
  72952. * Applies a kernel filter to the image
  72953. */
  72954. export class FilterPostProcess extends PostProcess {
  72955. /** The matrix to be applied to the image */
  72956. kernelMatrix: Matrix;
  72957. /**
  72958. *
  72959. * @param name The name of the effect.
  72960. * @param kernelMatrix The matrix to be applied to the image
  72961. * @param options The required width/height ratio to downsize to before computing the render pass.
  72962. * @param camera The camera to apply the render pass to.
  72963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72964. * @param engine The engine which the post process will be applied. (default: current engine)
  72965. * @param reusable If the post process can be reused on the same frame. (default: false)
  72966. */
  72967. constructor(name: string,
  72968. /** The matrix to be applied to the image */
  72969. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72970. }
  72971. }
  72972. declare module "babylonjs/Shaders/fxaa.fragment" {
  72973. /** @hidden */
  72974. export var fxaaPixelShader: {
  72975. name: string;
  72976. shader: string;
  72977. };
  72978. }
  72979. declare module "babylonjs/Shaders/fxaa.vertex" {
  72980. /** @hidden */
  72981. export var fxaaVertexShader: {
  72982. name: string;
  72983. shader: string;
  72984. };
  72985. }
  72986. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72987. import { Nullable } from "babylonjs/types";
  72988. import { Camera } from "babylonjs/Cameras/camera";
  72989. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72990. import { Engine } from "babylonjs/Engines/engine";
  72991. import "babylonjs/Shaders/fxaa.fragment";
  72992. import "babylonjs/Shaders/fxaa.vertex";
  72993. /**
  72994. * Fxaa post process
  72995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72996. */
  72997. export class FxaaPostProcess extends PostProcess {
  72998. /** @hidden */
  72999. texelWidth: number;
  73000. /** @hidden */
  73001. texelHeight: number;
  73002. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73003. private _getDefines;
  73004. }
  73005. }
  73006. declare module "babylonjs/Shaders/grain.fragment" {
  73007. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73008. /** @hidden */
  73009. export var grainPixelShader: {
  73010. name: string;
  73011. shader: string;
  73012. };
  73013. }
  73014. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73015. import { Nullable } from "babylonjs/types";
  73016. import { Camera } from "babylonjs/Cameras/camera";
  73017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73018. import { Engine } from "babylonjs/Engines/engine";
  73019. import "babylonjs/Shaders/grain.fragment";
  73020. /**
  73021. * The GrainPostProcess adds noise to the image at mid luminance levels
  73022. */
  73023. export class GrainPostProcess extends PostProcess {
  73024. /**
  73025. * The intensity of the grain added (default: 30)
  73026. */
  73027. intensity: number;
  73028. /**
  73029. * If the grain should be randomized on every frame
  73030. */
  73031. animated: boolean;
  73032. /**
  73033. * Creates a new instance of @see GrainPostProcess
  73034. * @param name The name of the effect.
  73035. * @param options The required width/height ratio to downsize to before computing the render pass.
  73036. * @param camera The camera to apply the render pass to.
  73037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73038. * @param engine The engine which the post process will be applied. (default: current engine)
  73039. * @param reusable If the post process can be reused on the same frame. (default: false)
  73040. * @param textureType Type of textures used when performing the post process. (default: 0)
  73041. * @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)
  73042. */
  73043. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73044. }
  73045. }
  73046. declare module "babylonjs/Shaders/highlights.fragment" {
  73047. /** @hidden */
  73048. export var highlightsPixelShader: {
  73049. name: string;
  73050. shader: string;
  73051. };
  73052. }
  73053. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73054. import { Nullable } from "babylonjs/types";
  73055. import { Camera } from "babylonjs/Cameras/camera";
  73056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73057. import { Engine } from "babylonjs/Engines/engine";
  73058. import "babylonjs/Shaders/highlights.fragment";
  73059. /**
  73060. * Extracts highlights from the image
  73061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73062. */
  73063. export class HighlightsPostProcess extends PostProcess {
  73064. /**
  73065. * Extracts highlights from the image
  73066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73067. * @param name The name of the effect.
  73068. * @param options The required width/height ratio to downsize to before computing the render pass.
  73069. * @param camera The camera to apply the render pass to.
  73070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73071. * @param engine The engine which the post process will be applied. (default: current engine)
  73072. * @param reusable If the post process can be reused on the same frame. (default: false)
  73073. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73074. */
  73075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73076. }
  73077. }
  73078. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73079. /** @hidden */
  73080. export var mrtFragmentDeclaration: {
  73081. name: string;
  73082. shader: string;
  73083. };
  73084. }
  73085. declare module "babylonjs/Shaders/geometry.fragment" {
  73086. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73087. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73088. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73089. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73090. /** @hidden */
  73091. export var geometryPixelShader: {
  73092. name: string;
  73093. shader: string;
  73094. };
  73095. }
  73096. declare module "babylonjs/Shaders/geometry.vertex" {
  73097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73098. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73100. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73102. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73103. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73104. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73105. /** @hidden */
  73106. export var geometryVertexShader: {
  73107. name: string;
  73108. shader: string;
  73109. };
  73110. }
  73111. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73112. import { Matrix } from "babylonjs/Maths/math.vector";
  73113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73114. import { Mesh } from "babylonjs/Meshes/mesh";
  73115. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73116. import { Effect } from "babylonjs/Materials/effect";
  73117. import { Scene } from "babylonjs/scene";
  73118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73119. import "babylonjs/Shaders/geometry.fragment";
  73120. import "babylonjs/Shaders/geometry.vertex";
  73121. /** @hidden */
  73122. interface ISavedTransformationMatrix {
  73123. world: Matrix;
  73124. viewProjection: Matrix;
  73125. }
  73126. /**
  73127. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73128. */
  73129. export class GeometryBufferRenderer {
  73130. /**
  73131. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73132. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73133. */
  73134. static readonly POSITION_TEXTURE_TYPE: number;
  73135. /**
  73136. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73137. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73138. */
  73139. static readonly VELOCITY_TEXTURE_TYPE: number;
  73140. /**
  73141. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73142. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73143. */
  73144. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73145. /**
  73146. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73147. * in order to compute objects velocities when enableVelocity is set to "true"
  73148. * @hidden
  73149. */
  73150. _previousTransformationMatrices: {
  73151. [index: number]: ISavedTransformationMatrix;
  73152. };
  73153. /**
  73154. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73155. * in order to compute objects velocities when enableVelocity is set to "true"
  73156. * @hidden
  73157. */
  73158. _previousBonesTransformationMatrices: {
  73159. [index: number]: Float32Array;
  73160. };
  73161. /**
  73162. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73163. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73164. */
  73165. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73166. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73167. renderTransparentMeshes: boolean;
  73168. private _scene;
  73169. private _resizeObserver;
  73170. private _multiRenderTarget;
  73171. private _ratio;
  73172. private _enablePosition;
  73173. private _enableVelocity;
  73174. private _enableReflectivity;
  73175. private _positionIndex;
  73176. private _velocityIndex;
  73177. private _reflectivityIndex;
  73178. protected _effect: Effect;
  73179. protected _cachedDefines: string;
  73180. /**
  73181. * Set the render list (meshes to be rendered) used in the G buffer.
  73182. */
  73183. set renderList(meshes: Mesh[]);
  73184. /**
  73185. * Gets wether or not G buffer are supported by the running hardware.
  73186. * This requires draw buffer supports
  73187. */
  73188. get isSupported(): boolean;
  73189. /**
  73190. * Returns the index of the given texture type in the G-Buffer textures array
  73191. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73192. * @returns the index of the given texture type in the G-Buffer textures array
  73193. */
  73194. getTextureIndex(textureType: number): number;
  73195. /**
  73196. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73197. */
  73198. get enablePosition(): boolean;
  73199. /**
  73200. * Sets whether or not objects positions are enabled for the G buffer.
  73201. */
  73202. set enablePosition(enable: boolean);
  73203. /**
  73204. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73205. */
  73206. get enableVelocity(): boolean;
  73207. /**
  73208. * Sets wether or not objects velocities are enabled for the G buffer.
  73209. */
  73210. set enableVelocity(enable: boolean);
  73211. /**
  73212. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73213. */
  73214. get enableReflectivity(): boolean;
  73215. /**
  73216. * Sets wether or not objects roughness are enabled for the G buffer.
  73217. */
  73218. set enableReflectivity(enable: boolean);
  73219. /**
  73220. * Gets the scene associated with the buffer.
  73221. */
  73222. get scene(): Scene;
  73223. /**
  73224. * Gets the ratio used by the buffer during its creation.
  73225. * How big is the buffer related to the main canvas.
  73226. */
  73227. get ratio(): number;
  73228. /** @hidden */
  73229. static _SceneComponentInitialization: (scene: Scene) => void;
  73230. /**
  73231. * Creates a new G Buffer for the scene
  73232. * @param scene The scene the buffer belongs to
  73233. * @param ratio How big is the buffer related to the main canvas.
  73234. */
  73235. constructor(scene: Scene, ratio?: number);
  73236. /**
  73237. * Checks wether everything is ready to render a submesh to the G buffer.
  73238. * @param subMesh the submesh to check readiness for
  73239. * @param useInstances is the mesh drawn using instance or not
  73240. * @returns true if ready otherwise false
  73241. */
  73242. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73243. /**
  73244. * Gets the current underlying G Buffer.
  73245. * @returns the buffer
  73246. */
  73247. getGBuffer(): MultiRenderTarget;
  73248. /**
  73249. * Gets the number of samples used to render the buffer (anti aliasing).
  73250. */
  73251. get samples(): number;
  73252. /**
  73253. * Sets the number of samples used to render the buffer (anti aliasing).
  73254. */
  73255. set samples(value: number);
  73256. /**
  73257. * Disposes the renderer and frees up associated resources.
  73258. */
  73259. dispose(): void;
  73260. protected _createRenderTargets(): void;
  73261. private _copyBonesTransformationMatrices;
  73262. }
  73263. }
  73264. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73265. import { Nullable } from "babylonjs/types";
  73266. import { Scene } from "babylonjs/scene";
  73267. import { ISceneComponent } from "babylonjs/sceneComponent";
  73268. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73269. module "babylonjs/scene" {
  73270. interface Scene {
  73271. /** @hidden (Backing field) */
  73272. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73273. /**
  73274. * Gets or Sets the current geometry buffer associated to the scene.
  73275. */
  73276. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73277. /**
  73278. * Enables a GeometryBufferRender and associates it with the scene
  73279. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73280. * @returns the GeometryBufferRenderer
  73281. */
  73282. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73283. /**
  73284. * Disables the GeometryBufferRender associated with the scene
  73285. */
  73286. disableGeometryBufferRenderer(): void;
  73287. }
  73288. }
  73289. /**
  73290. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73291. * in several rendering techniques.
  73292. */
  73293. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73294. /**
  73295. * The component name helpful to identify the component in the list of scene components.
  73296. */
  73297. readonly name: string;
  73298. /**
  73299. * The scene the component belongs to.
  73300. */
  73301. scene: Scene;
  73302. /**
  73303. * Creates a new instance of the component for the given scene
  73304. * @param scene Defines the scene to register the component in
  73305. */
  73306. constructor(scene: Scene);
  73307. /**
  73308. * Registers the component in a given scene
  73309. */
  73310. register(): void;
  73311. /**
  73312. * Rebuilds the elements related to this component in case of
  73313. * context lost for instance.
  73314. */
  73315. rebuild(): void;
  73316. /**
  73317. * Disposes the component and the associated ressources
  73318. */
  73319. dispose(): void;
  73320. private _gatherRenderTargets;
  73321. }
  73322. }
  73323. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73324. /** @hidden */
  73325. export var motionBlurPixelShader: {
  73326. name: string;
  73327. shader: string;
  73328. };
  73329. }
  73330. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73331. import { Nullable } from "babylonjs/types";
  73332. import { Camera } from "babylonjs/Cameras/camera";
  73333. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73334. import { Scene } from "babylonjs/scene";
  73335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73336. import "babylonjs/Animations/animatable";
  73337. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73338. import "babylonjs/Shaders/motionBlur.fragment";
  73339. import { Engine } from "babylonjs/Engines/engine";
  73340. /**
  73341. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73342. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73343. * As an example, all you have to do is to create the post-process:
  73344. * var mb = new BABYLON.MotionBlurPostProcess(
  73345. * 'mb', // The name of the effect.
  73346. * scene, // The scene containing the objects to blur according to their velocity.
  73347. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73348. * camera // The camera to apply the render pass to.
  73349. * );
  73350. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73351. */
  73352. export class MotionBlurPostProcess extends PostProcess {
  73353. /**
  73354. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73355. */
  73356. motionStrength: number;
  73357. /**
  73358. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73359. */
  73360. get motionBlurSamples(): number;
  73361. /**
  73362. * Sets the number of iterations to be used for motion blur quality
  73363. */
  73364. set motionBlurSamples(samples: number);
  73365. private _motionBlurSamples;
  73366. private _geometryBufferRenderer;
  73367. /**
  73368. * Creates a new instance MotionBlurPostProcess
  73369. * @param name The name of the effect.
  73370. * @param scene The scene containing the objects to blur according to their velocity.
  73371. * @param options The required width/height ratio to downsize to before computing the render pass.
  73372. * @param camera The camera to apply the render pass to.
  73373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73374. * @param engine The engine which the post process will be applied. (default: current engine)
  73375. * @param reusable If the post process can be reused on the same frame. (default: false)
  73376. * @param textureType Type of textures used when performing the post process. (default: 0)
  73377. * @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)
  73378. */
  73379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73380. /**
  73381. * Excludes the given skinned mesh from computing bones velocities.
  73382. * 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.
  73383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73384. */
  73385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73386. /**
  73387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73390. */
  73391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73392. /**
  73393. * Disposes the post process.
  73394. * @param camera The camera to dispose the post process on.
  73395. */
  73396. dispose(camera?: Camera): void;
  73397. }
  73398. }
  73399. declare module "babylonjs/Shaders/refraction.fragment" {
  73400. /** @hidden */
  73401. export var refractionPixelShader: {
  73402. name: string;
  73403. shader: string;
  73404. };
  73405. }
  73406. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73407. import { Color3 } from "babylonjs/Maths/math.color";
  73408. import { Camera } from "babylonjs/Cameras/camera";
  73409. import { Texture } from "babylonjs/Materials/Textures/texture";
  73410. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73411. import { Engine } from "babylonjs/Engines/engine";
  73412. import "babylonjs/Shaders/refraction.fragment";
  73413. /**
  73414. * Post process which applies a refractin texture
  73415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73416. */
  73417. export class RefractionPostProcess extends PostProcess {
  73418. /** the base color of the refraction (used to taint the rendering) */
  73419. color: Color3;
  73420. /** simulated refraction depth */
  73421. depth: number;
  73422. /** the coefficient of the base color (0 to remove base color tainting) */
  73423. colorLevel: number;
  73424. private _refTexture;
  73425. private _ownRefractionTexture;
  73426. /**
  73427. * Gets or sets the refraction texture
  73428. * Please note that you are responsible for disposing the texture if you set it manually
  73429. */
  73430. get refractionTexture(): Texture;
  73431. set refractionTexture(value: Texture);
  73432. /**
  73433. * Initializes the RefractionPostProcess
  73434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73435. * @param name The name of the effect.
  73436. * @param refractionTextureUrl Url of the refraction texture to use
  73437. * @param color the base color of the refraction (used to taint the rendering)
  73438. * @param depth simulated refraction depth
  73439. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73440. * @param camera The camera to apply the render pass to.
  73441. * @param options The required width/height ratio to downsize to before computing the render pass.
  73442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73443. * @param engine The engine which the post process will be applied. (default: current engine)
  73444. * @param reusable If the post process can be reused on the same frame. (default: false)
  73445. */
  73446. constructor(name: string, refractionTextureUrl: string,
  73447. /** the base color of the refraction (used to taint the rendering) */
  73448. color: Color3,
  73449. /** simulated refraction depth */
  73450. depth: number,
  73451. /** the coefficient of the base color (0 to remove base color tainting) */
  73452. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73453. /**
  73454. * Disposes of the post process
  73455. * @param camera Camera to dispose post process on
  73456. */
  73457. dispose(camera: Camera): void;
  73458. }
  73459. }
  73460. declare module "babylonjs/Shaders/sharpen.fragment" {
  73461. /** @hidden */
  73462. export var sharpenPixelShader: {
  73463. name: string;
  73464. shader: string;
  73465. };
  73466. }
  73467. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73468. import { Nullable } from "babylonjs/types";
  73469. import { Camera } from "babylonjs/Cameras/camera";
  73470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73471. import "babylonjs/Shaders/sharpen.fragment";
  73472. import { Engine } from "babylonjs/Engines/engine";
  73473. /**
  73474. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73475. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73476. */
  73477. export class SharpenPostProcess extends PostProcess {
  73478. /**
  73479. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73480. */
  73481. colorAmount: number;
  73482. /**
  73483. * How much sharpness should be applied (default: 0.3)
  73484. */
  73485. edgeAmount: number;
  73486. /**
  73487. * Creates a new instance ConvolutionPostProcess
  73488. * @param name The name of the effect.
  73489. * @param options The required width/height ratio to downsize to before computing the render pass.
  73490. * @param camera The camera to apply the render pass to.
  73491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73492. * @param engine The engine which the post process will be applied. (default: current engine)
  73493. * @param reusable If the post process can be reused on the same frame. (default: false)
  73494. * @param textureType Type of textures used when performing the post process. (default: 0)
  73495. * @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)
  73496. */
  73497. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73498. }
  73499. }
  73500. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73501. import { Nullable } from "babylonjs/types";
  73502. import { Camera } from "babylonjs/Cameras/camera";
  73503. import { Engine } from "babylonjs/Engines/engine";
  73504. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73505. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73506. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73507. /**
  73508. * PostProcessRenderPipeline
  73509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73510. */
  73511. export class PostProcessRenderPipeline {
  73512. private engine;
  73513. private _renderEffects;
  73514. private _renderEffectsForIsolatedPass;
  73515. /**
  73516. * List of inspectable custom properties (used by the Inspector)
  73517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73518. */
  73519. inspectableCustomProperties: IInspectable[];
  73520. /**
  73521. * @hidden
  73522. */
  73523. protected _cameras: Camera[];
  73524. /** @hidden */
  73525. _name: string;
  73526. /**
  73527. * Gets pipeline name
  73528. */
  73529. get name(): string;
  73530. /** Gets the list of attached cameras */
  73531. get cameras(): Camera[];
  73532. /**
  73533. * Initializes a PostProcessRenderPipeline
  73534. * @param engine engine to add the pipeline to
  73535. * @param name name of the pipeline
  73536. */
  73537. constructor(engine: Engine, name: string);
  73538. /**
  73539. * Gets the class name
  73540. * @returns "PostProcessRenderPipeline"
  73541. */
  73542. getClassName(): string;
  73543. /**
  73544. * If all the render effects in the pipeline are supported
  73545. */
  73546. get isSupported(): boolean;
  73547. /**
  73548. * Adds an effect to the pipeline
  73549. * @param renderEffect the effect to add
  73550. */
  73551. addEffect(renderEffect: PostProcessRenderEffect): void;
  73552. /** @hidden */
  73553. _rebuild(): void;
  73554. /** @hidden */
  73555. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73556. /** @hidden */
  73557. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73558. /** @hidden */
  73559. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73560. /** @hidden */
  73561. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73562. /** @hidden */
  73563. _attachCameras(cameras: Camera, unique: boolean): void;
  73564. /** @hidden */
  73565. _attachCameras(cameras: Camera[], unique: boolean): void;
  73566. /** @hidden */
  73567. _detachCameras(cameras: Camera): void;
  73568. /** @hidden */
  73569. _detachCameras(cameras: Nullable<Camera[]>): void;
  73570. /** @hidden */
  73571. _update(): void;
  73572. /** @hidden */
  73573. _reset(): void;
  73574. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73575. /**
  73576. * Sets the required values to the prepass renderer.
  73577. * @param prePassRenderer defines the prepass renderer to setup.
  73578. * @returns true if the pre pass is needed.
  73579. */
  73580. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73581. /**
  73582. * Disposes of the pipeline
  73583. */
  73584. dispose(): void;
  73585. }
  73586. }
  73587. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73588. import { Camera } from "babylonjs/Cameras/camera";
  73589. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73590. /**
  73591. * PostProcessRenderPipelineManager class
  73592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73593. */
  73594. export class PostProcessRenderPipelineManager {
  73595. private _renderPipelines;
  73596. /**
  73597. * Initializes a PostProcessRenderPipelineManager
  73598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73599. */
  73600. constructor();
  73601. /**
  73602. * Gets the list of supported render pipelines
  73603. */
  73604. get supportedPipelines(): PostProcessRenderPipeline[];
  73605. /**
  73606. * Adds a pipeline to the manager
  73607. * @param renderPipeline The pipeline to add
  73608. */
  73609. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73610. /**
  73611. * Attaches a camera to the pipeline
  73612. * @param renderPipelineName The name of the pipeline to attach to
  73613. * @param cameras the camera to attach
  73614. * @param unique if the camera can be attached multiple times to the pipeline
  73615. */
  73616. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73617. /**
  73618. * Detaches a camera from the pipeline
  73619. * @param renderPipelineName The name of the pipeline to detach from
  73620. * @param cameras the camera to detach
  73621. */
  73622. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73623. /**
  73624. * Enables an effect by name on a pipeline
  73625. * @param renderPipelineName the name of the pipeline to enable the effect in
  73626. * @param renderEffectName the name of the effect to enable
  73627. * @param cameras the cameras that the effect should be enabled on
  73628. */
  73629. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73630. /**
  73631. * Disables an effect by name on a pipeline
  73632. * @param renderPipelineName the name of the pipeline to disable the effect in
  73633. * @param renderEffectName the name of the effect to disable
  73634. * @param cameras the cameras that the effect should be disabled on
  73635. */
  73636. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73637. /**
  73638. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73639. */
  73640. update(): void;
  73641. /** @hidden */
  73642. _rebuild(): void;
  73643. /**
  73644. * Disposes of the manager and pipelines
  73645. */
  73646. dispose(): void;
  73647. }
  73648. }
  73649. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73650. import { ISceneComponent } from "babylonjs/sceneComponent";
  73651. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73652. import { Scene } from "babylonjs/scene";
  73653. module "babylonjs/scene" {
  73654. interface Scene {
  73655. /** @hidden (Backing field) */
  73656. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73657. /**
  73658. * Gets the postprocess render pipeline manager
  73659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73660. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73661. */
  73662. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73663. }
  73664. }
  73665. /**
  73666. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73667. */
  73668. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73669. /**
  73670. * The component name helpfull to identify the component in the list of scene components.
  73671. */
  73672. readonly name: string;
  73673. /**
  73674. * The scene the component belongs to.
  73675. */
  73676. scene: Scene;
  73677. /**
  73678. * Creates a new instance of the component for the given scene
  73679. * @param scene Defines the scene to register the component in
  73680. */
  73681. constructor(scene: Scene);
  73682. /**
  73683. * Registers the component in a given scene
  73684. */
  73685. register(): void;
  73686. /**
  73687. * Rebuilds the elements related to this component in case of
  73688. * context lost for instance.
  73689. */
  73690. rebuild(): void;
  73691. /**
  73692. * Disposes the component and the associated ressources
  73693. */
  73694. dispose(): void;
  73695. private _gatherRenderTargets;
  73696. }
  73697. }
  73698. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73699. import { Nullable } from "babylonjs/types";
  73700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73701. import { Camera } from "babylonjs/Cameras/camera";
  73702. import { IDisposable } from "babylonjs/scene";
  73703. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73704. import { Scene } from "babylonjs/scene";
  73705. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73706. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73707. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73708. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73709. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73710. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73711. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73712. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73713. import { Animation } from "babylonjs/Animations/animation";
  73714. /**
  73715. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73716. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73717. */
  73718. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73719. private _scene;
  73720. private _camerasToBeAttached;
  73721. /**
  73722. * ID of the sharpen post process,
  73723. */
  73724. private readonly SharpenPostProcessId;
  73725. /**
  73726. * @ignore
  73727. * ID of the image processing post process;
  73728. */
  73729. readonly ImageProcessingPostProcessId: string;
  73730. /**
  73731. * @ignore
  73732. * ID of the Fast Approximate Anti-Aliasing post process;
  73733. */
  73734. readonly FxaaPostProcessId: string;
  73735. /**
  73736. * ID of the chromatic aberration post process,
  73737. */
  73738. private readonly ChromaticAberrationPostProcessId;
  73739. /**
  73740. * ID of the grain post process
  73741. */
  73742. private readonly GrainPostProcessId;
  73743. /**
  73744. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73745. */
  73746. sharpen: SharpenPostProcess;
  73747. private _sharpenEffect;
  73748. private bloom;
  73749. /**
  73750. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73751. */
  73752. depthOfField: DepthOfFieldEffect;
  73753. /**
  73754. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73755. */
  73756. fxaa: FxaaPostProcess;
  73757. /**
  73758. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73759. */
  73760. imageProcessing: ImageProcessingPostProcess;
  73761. /**
  73762. * Chromatic aberration post process which will shift rgb colors in the image
  73763. */
  73764. chromaticAberration: ChromaticAberrationPostProcess;
  73765. private _chromaticAberrationEffect;
  73766. /**
  73767. * Grain post process which add noise to the image
  73768. */
  73769. grain: GrainPostProcess;
  73770. private _grainEffect;
  73771. /**
  73772. * Glow post process which adds a glow to emissive areas of the image
  73773. */
  73774. private _glowLayer;
  73775. /**
  73776. * Animations which can be used to tweak settings over a period of time
  73777. */
  73778. animations: Animation[];
  73779. private _imageProcessingConfigurationObserver;
  73780. private _sharpenEnabled;
  73781. private _bloomEnabled;
  73782. private _depthOfFieldEnabled;
  73783. private _depthOfFieldBlurLevel;
  73784. private _fxaaEnabled;
  73785. private _imageProcessingEnabled;
  73786. private _defaultPipelineTextureType;
  73787. private _bloomScale;
  73788. private _chromaticAberrationEnabled;
  73789. private _grainEnabled;
  73790. private _buildAllowed;
  73791. /**
  73792. * Gets active scene
  73793. */
  73794. get scene(): Scene;
  73795. /**
  73796. * Enable or disable the sharpen process from the pipeline
  73797. */
  73798. set sharpenEnabled(enabled: boolean);
  73799. get sharpenEnabled(): boolean;
  73800. private _resizeObserver;
  73801. private _hardwareScaleLevel;
  73802. private _bloomKernel;
  73803. /**
  73804. * Specifies the size of the bloom blur kernel, relative to the final output size
  73805. */
  73806. get bloomKernel(): number;
  73807. set bloomKernel(value: number);
  73808. /**
  73809. * Specifies the weight of the bloom in the final rendering
  73810. */
  73811. private _bloomWeight;
  73812. /**
  73813. * Specifies the luma threshold for the area that will be blurred by the bloom
  73814. */
  73815. private _bloomThreshold;
  73816. private _hdr;
  73817. /**
  73818. * The strength of the bloom.
  73819. */
  73820. set bloomWeight(value: number);
  73821. get bloomWeight(): number;
  73822. /**
  73823. * The strength of the bloom.
  73824. */
  73825. set bloomThreshold(value: number);
  73826. get bloomThreshold(): number;
  73827. /**
  73828. * The scale of the bloom, lower value will provide better performance.
  73829. */
  73830. set bloomScale(value: number);
  73831. get bloomScale(): number;
  73832. /**
  73833. * Enable or disable the bloom from the pipeline
  73834. */
  73835. set bloomEnabled(enabled: boolean);
  73836. get bloomEnabled(): boolean;
  73837. private _rebuildBloom;
  73838. /**
  73839. * If the depth of field is enabled.
  73840. */
  73841. get depthOfFieldEnabled(): boolean;
  73842. set depthOfFieldEnabled(enabled: boolean);
  73843. /**
  73844. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73845. */
  73846. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73847. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73848. /**
  73849. * If the anti aliasing is enabled.
  73850. */
  73851. set fxaaEnabled(enabled: boolean);
  73852. get fxaaEnabled(): boolean;
  73853. private _samples;
  73854. /**
  73855. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73856. */
  73857. set samples(sampleCount: number);
  73858. get samples(): number;
  73859. /**
  73860. * If image processing is enabled.
  73861. */
  73862. set imageProcessingEnabled(enabled: boolean);
  73863. get imageProcessingEnabled(): boolean;
  73864. /**
  73865. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73866. */
  73867. set glowLayerEnabled(enabled: boolean);
  73868. get glowLayerEnabled(): boolean;
  73869. /**
  73870. * Gets the glow layer (or null if not defined)
  73871. */
  73872. get glowLayer(): Nullable<GlowLayer>;
  73873. /**
  73874. * Enable or disable the chromaticAberration process from the pipeline
  73875. */
  73876. set chromaticAberrationEnabled(enabled: boolean);
  73877. get chromaticAberrationEnabled(): boolean;
  73878. /**
  73879. * Enable or disable the grain process from the pipeline
  73880. */
  73881. set grainEnabled(enabled: boolean);
  73882. get grainEnabled(): boolean;
  73883. /**
  73884. * @constructor
  73885. * @param name - The rendering pipeline name (default: "")
  73886. * @param hdr - If high dynamic range textures should be used (default: true)
  73887. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73888. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73889. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73890. */
  73891. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73892. /**
  73893. * Get the class name
  73894. * @returns "DefaultRenderingPipeline"
  73895. */
  73896. getClassName(): string;
  73897. /**
  73898. * Force the compilation of the entire pipeline.
  73899. */
  73900. prepare(): void;
  73901. private _hasCleared;
  73902. private _prevPostProcess;
  73903. private _prevPrevPostProcess;
  73904. private _setAutoClearAndTextureSharing;
  73905. private _depthOfFieldSceneObserver;
  73906. private _buildPipeline;
  73907. private _disposePostProcesses;
  73908. /**
  73909. * Adds a camera to the pipeline
  73910. * @param camera the camera to be added
  73911. */
  73912. addCamera(camera: Camera): void;
  73913. /**
  73914. * Removes a camera from the pipeline
  73915. * @param camera the camera to remove
  73916. */
  73917. removeCamera(camera: Camera): void;
  73918. /**
  73919. * Dispose of the pipeline and stop all post processes
  73920. */
  73921. dispose(): void;
  73922. /**
  73923. * Serialize the rendering pipeline (Used when exporting)
  73924. * @returns the serialized object
  73925. */
  73926. serialize(): any;
  73927. /**
  73928. * Parse the serialized pipeline
  73929. * @param source Source pipeline.
  73930. * @param scene The scene to load the pipeline to.
  73931. * @param rootUrl The URL of the serialized pipeline.
  73932. * @returns An instantiated pipeline from the serialized object.
  73933. */
  73934. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73935. }
  73936. }
  73937. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73938. /** @hidden */
  73939. export var lensHighlightsPixelShader: {
  73940. name: string;
  73941. shader: string;
  73942. };
  73943. }
  73944. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73945. /** @hidden */
  73946. export var depthOfFieldPixelShader: {
  73947. name: string;
  73948. shader: string;
  73949. };
  73950. }
  73951. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73952. import { Camera } from "babylonjs/Cameras/camera";
  73953. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73954. import { Scene } from "babylonjs/scene";
  73955. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73956. import "babylonjs/Shaders/chromaticAberration.fragment";
  73957. import "babylonjs/Shaders/lensHighlights.fragment";
  73958. import "babylonjs/Shaders/depthOfField.fragment";
  73959. /**
  73960. * BABYLON.JS Chromatic Aberration GLSL Shader
  73961. * Author: Olivier Guyot
  73962. * Separates very slightly R, G and B colors on the edges of the screen
  73963. * Inspired by Francois Tarlier & Martins Upitis
  73964. */
  73965. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73966. /**
  73967. * @ignore
  73968. * The chromatic aberration PostProcess id in the pipeline
  73969. */
  73970. LensChromaticAberrationEffect: string;
  73971. /**
  73972. * @ignore
  73973. * The highlights enhancing PostProcess id in the pipeline
  73974. */
  73975. HighlightsEnhancingEffect: string;
  73976. /**
  73977. * @ignore
  73978. * The depth-of-field PostProcess id in the pipeline
  73979. */
  73980. LensDepthOfFieldEffect: string;
  73981. private _scene;
  73982. private _depthTexture;
  73983. private _grainTexture;
  73984. private _chromaticAberrationPostProcess;
  73985. private _highlightsPostProcess;
  73986. private _depthOfFieldPostProcess;
  73987. private _edgeBlur;
  73988. private _grainAmount;
  73989. private _chromaticAberration;
  73990. private _distortion;
  73991. private _highlightsGain;
  73992. private _highlightsThreshold;
  73993. private _dofDistance;
  73994. private _dofAperture;
  73995. private _dofDarken;
  73996. private _dofPentagon;
  73997. private _blurNoise;
  73998. /**
  73999. * @constructor
  74000. *
  74001. * Effect parameters are as follow:
  74002. * {
  74003. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74004. * edge_blur: number; // from 0 to x (1 for realism)
  74005. * distortion: number; // from 0 to x (1 for realism)
  74006. * grain_amount: number; // from 0 to 1
  74007. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74008. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74009. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74010. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74011. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74012. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74013. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74014. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74015. * }
  74016. * Note: if an effect parameter is unset, effect is disabled
  74017. *
  74018. * @param name The rendering pipeline name
  74019. * @param parameters - An object containing all parameters (see above)
  74020. * @param scene The scene linked to this pipeline
  74021. * @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)
  74022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74023. */
  74024. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74025. /**
  74026. * Get the class name
  74027. * @returns "LensRenderingPipeline"
  74028. */
  74029. getClassName(): string;
  74030. /**
  74031. * Gets associated scene
  74032. */
  74033. get scene(): Scene;
  74034. /**
  74035. * Gets or sets the edge blur
  74036. */
  74037. get edgeBlur(): number;
  74038. set edgeBlur(value: number);
  74039. /**
  74040. * Gets or sets the grain amount
  74041. */
  74042. get grainAmount(): number;
  74043. set grainAmount(value: number);
  74044. /**
  74045. * Gets or sets the chromatic aberration amount
  74046. */
  74047. get chromaticAberration(): number;
  74048. set chromaticAberration(value: number);
  74049. /**
  74050. * Gets or sets the depth of field aperture
  74051. */
  74052. get dofAperture(): number;
  74053. set dofAperture(value: number);
  74054. /**
  74055. * Gets or sets the edge distortion
  74056. */
  74057. get edgeDistortion(): number;
  74058. set edgeDistortion(value: number);
  74059. /**
  74060. * Gets or sets the depth of field distortion
  74061. */
  74062. get dofDistortion(): number;
  74063. set dofDistortion(value: number);
  74064. /**
  74065. * Gets or sets the darken out of focus amount
  74066. */
  74067. get darkenOutOfFocus(): number;
  74068. set darkenOutOfFocus(value: number);
  74069. /**
  74070. * Gets or sets a boolean indicating if blur noise is enabled
  74071. */
  74072. get blurNoise(): boolean;
  74073. set blurNoise(value: boolean);
  74074. /**
  74075. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74076. */
  74077. get pentagonBokeh(): boolean;
  74078. set pentagonBokeh(value: boolean);
  74079. /**
  74080. * Gets or sets the highlight grain amount
  74081. */
  74082. get highlightsGain(): number;
  74083. set highlightsGain(value: number);
  74084. /**
  74085. * Gets or sets the highlight threshold
  74086. */
  74087. get highlightsThreshold(): number;
  74088. set highlightsThreshold(value: number);
  74089. /**
  74090. * Sets the amount of blur at the edges
  74091. * @param amount blur amount
  74092. */
  74093. setEdgeBlur(amount: number): void;
  74094. /**
  74095. * Sets edge blur to 0
  74096. */
  74097. disableEdgeBlur(): void;
  74098. /**
  74099. * Sets the amout of grain
  74100. * @param amount Amount of grain
  74101. */
  74102. setGrainAmount(amount: number): void;
  74103. /**
  74104. * Set grain amount to 0
  74105. */
  74106. disableGrain(): void;
  74107. /**
  74108. * Sets the chromatic aberration amount
  74109. * @param amount amount of chromatic aberration
  74110. */
  74111. setChromaticAberration(amount: number): void;
  74112. /**
  74113. * Sets chromatic aberration amount to 0
  74114. */
  74115. disableChromaticAberration(): void;
  74116. /**
  74117. * Sets the EdgeDistortion amount
  74118. * @param amount amount of EdgeDistortion
  74119. */
  74120. setEdgeDistortion(amount: number): void;
  74121. /**
  74122. * Sets edge distortion to 0
  74123. */
  74124. disableEdgeDistortion(): void;
  74125. /**
  74126. * Sets the FocusDistance amount
  74127. * @param amount amount of FocusDistance
  74128. */
  74129. setFocusDistance(amount: number): void;
  74130. /**
  74131. * Disables depth of field
  74132. */
  74133. disableDepthOfField(): void;
  74134. /**
  74135. * Sets the Aperture amount
  74136. * @param amount amount of Aperture
  74137. */
  74138. setAperture(amount: number): void;
  74139. /**
  74140. * Sets the DarkenOutOfFocus amount
  74141. * @param amount amount of DarkenOutOfFocus
  74142. */
  74143. setDarkenOutOfFocus(amount: number): void;
  74144. private _pentagonBokehIsEnabled;
  74145. /**
  74146. * Creates a pentagon bokeh effect
  74147. */
  74148. enablePentagonBokeh(): void;
  74149. /**
  74150. * Disables the pentagon bokeh effect
  74151. */
  74152. disablePentagonBokeh(): void;
  74153. /**
  74154. * Enables noise blur
  74155. */
  74156. enableNoiseBlur(): void;
  74157. /**
  74158. * Disables noise blur
  74159. */
  74160. disableNoiseBlur(): void;
  74161. /**
  74162. * Sets the HighlightsGain amount
  74163. * @param amount amount of HighlightsGain
  74164. */
  74165. setHighlightsGain(amount: number): void;
  74166. /**
  74167. * Sets the HighlightsThreshold amount
  74168. * @param amount amount of HighlightsThreshold
  74169. */
  74170. setHighlightsThreshold(amount: number): void;
  74171. /**
  74172. * Disables highlights
  74173. */
  74174. disableHighlights(): void;
  74175. /**
  74176. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74177. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74178. */
  74179. dispose(disableDepthRender?: boolean): void;
  74180. private _createChromaticAberrationPostProcess;
  74181. private _createHighlightsPostProcess;
  74182. private _createDepthOfFieldPostProcess;
  74183. private _createGrainTexture;
  74184. }
  74185. }
  74186. declare module "babylonjs/Shaders/ssao2.fragment" {
  74187. /** @hidden */
  74188. export var ssao2PixelShader: {
  74189. name: string;
  74190. shader: string;
  74191. };
  74192. }
  74193. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74194. /** @hidden */
  74195. export var ssaoCombinePixelShader: {
  74196. name: string;
  74197. shader: string;
  74198. };
  74199. }
  74200. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74201. import { Camera } from "babylonjs/Cameras/camera";
  74202. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74203. import { Scene } from "babylonjs/scene";
  74204. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74205. import "babylonjs/Shaders/ssao2.fragment";
  74206. import "babylonjs/Shaders/ssaoCombine.fragment";
  74207. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74208. /**
  74209. * Render pipeline to produce ssao effect
  74210. */
  74211. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74212. /**
  74213. * @ignore
  74214. * The PassPostProcess id in the pipeline that contains the original scene color
  74215. */
  74216. SSAOOriginalSceneColorEffect: string;
  74217. /**
  74218. * @ignore
  74219. * The SSAO PostProcess id in the pipeline
  74220. */
  74221. SSAORenderEffect: string;
  74222. /**
  74223. * @ignore
  74224. * The horizontal blur PostProcess id in the pipeline
  74225. */
  74226. SSAOBlurHRenderEffect: string;
  74227. /**
  74228. * @ignore
  74229. * The vertical blur PostProcess id in the pipeline
  74230. */
  74231. SSAOBlurVRenderEffect: string;
  74232. /**
  74233. * @ignore
  74234. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74235. */
  74236. SSAOCombineRenderEffect: string;
  74237. /**
  74238. * The output strength of the SSAO post-process. Default value is 1.0.
  74239. */
  74240. totalStrength: number;
  74241. /**
  74242. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74243. */
  74244. maxZ: number;
  74245. /**
  74246. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74247. */
  74248. minZAspect: number;
  74249. private _samples;
  74250. /**
  74251. * Number of samples used for the SSAO calculations. Default value is 8
  74252. */
  74253. set samples(n: number);
  74254. get samples(): number;
  74255. private _textureSamples;
  74256. /**
  74257. * Number of samples to use for antialiasing
  74258. */
  74259. set textureSamples(n: number);
  74260. get textureSamples(): number;
  74261. /**
  74262. * Force rendering the geometry through geometry buffer
  74263. */
  74264. private _forceGeometryBuffer;
  74265. /**
  74266. * Ratio object used for SSAO ratio and blur ratio
  74267. */
  74268. private _ratio;
  74269. /**
  74270. * Dynamically generated sphere sampler.
  74271. */
  74272. private _sampleSphere;
  74273. /**
  74274. * Blur filter offsets
  74275. */
  74276. private _samplerOffsets;
  74277. private _expensiveBlur;
  74278. /**
  74279. * If bilateral blur should be used
  74280. */
  74281. set expensiveBlur(b: boolean);
  74282. get expensiveBlur(): boolean;
  74283. /**
  74284. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74285. */
  74286. radius: number;
  74287. /**
  74288. * The base color of the SSAO post-process
  74289. * The final result is "base + ssao" between [0, 1]
  74290. */
  74291. base: number;
  74292. /**
  74293. * Support test.
  74294. */
  74295. static get IsSupported(): boolean;
  74296. private _scene;
  74297. private _randomTexture;
  74298. private _originalColorPostProcess;
  74299. private _ssaoPostProcess;
  74300. private _blurHPostProcess;
  74301. private _blurVPostProcess;
  74302. private _ssaoCombinePostProcess;
  74303. private _prePassRenderer;
  74304. /**
  74305. * Gets active scene
  74306. */
  74307. get scene(): Scene;
  74308. /**
  74309. * @constructor
  74310. * @param name The rendering pipeline name
  74311. * @param scene The scene linked to this pipeline
  74312. * @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 }
  74313. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74314. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74315. */
  74316. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74317. /**
  74318. * Get the class name
  74319. * @returns "SSAO2RenderingPipeline"
  74320. */
  74321. getClassName(): string;
  74322. /**
  74323. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74324. */
  74325. dispose(disableGeometryBufferRenderer?: boolean): void;
  74326. private _createBlurPostProcess;
  74327. /** @hidden */
  74328. _rebuild(): void;
  74329. private _bits;
  74330. private _radicalInverse_VdC;
  74331. private _hammersley;
  74332. private _hemisphereSample_uniform;
  74333. private _generateHemisphere;
  74334. private _getDefinesForSSAO;
  74335. private _createSSAOPostProcess;
  74336. private _createSSAOCombinePostProcess;
  74337. private _createRandomTexture;
  74338. /**
  74339. * Serialize the rendering pipeline (Used when exporting)
  74340. * @returns the serialized object
  74341. */
  74342. serialize(): any;
  74343. /**
  74344. * Parse the serialized pipeline
  74345. * @param source Source pipeline.
  74346. * @param scene The scene to load the pipeline to.
  74347. * @param rootUrl The URL of the serialized pipeline.
  74348. * @returns An instantiated pipeline from the serialized object.
  74349. */
  74350. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74351. /**
  74352. * Sets the required values to the prepass renderer.
  74353. * @param prePassRenderer defines the prepass renderer to setup
  74354. * @returns true if the pre pass is needed.
  74355. */
  74356. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74357. }
  74358. }
  74359. declare module "babylonjs/Shaders/ssao.fragment" {
  74360. /** @hidden */
  74361. export var ssaoPixelShader: {
  74362. name: string;
  74363. shader: string;
  74364. };
  74365. }
  74366. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74367. import { Camera } from "babylonjs/Cameras/camera";
  74368. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74369. import { Scene } from "babylonjs/scene";
  74370. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74371. import "babylonjs/Shaders/ssao.fragment";
  74372. import "babylonjs/Shaders/ssaoCombine.fragment";
  74373. /**
  74374. * Render pipeline to produce ssao effect
  74375. */
  74376. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74377. /**
  74378. * @ignore
  74379. * The PassPostProcess id in the pipeline that contains the original scene color
  74380. */
  74381. SSAOOriginalSceneColorEffect: string;
  74382. /**
  74383. * @ignore
  74384. * The SSAO PostProcess id in the pipeline
  74385. */
  74386. SSAORenderEffect: string;
  74387. /**
  74388. * @ignore
  74389. * The horizontal blur PostProcess id in the pipeline
  74390. */
  74391. SSAOBlurHRenderEffect: string;
  74392. /**
  74393. * @ignore
  74394. * The vertical blur PostProcess id in the pipeline
  74395. */
  74396. SSAOBlurVRenderEffect: string;
  74397. /**
  74398. * @ignore
  74399. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74400. */
  74401. SSAOCombineRenderEffect: string;
  74402. /**
  74403. * The output strength of the SSAO post-process. Default value is 1.0.
  74404. */
  74405. totalStrength: number;
  74406. /**
  74407. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74408. */
  74409. radius: number;
  74410. /**
  74411. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74412. * Must not be equal to fallOff and superior to fallOff.
  74413. * Default value is 0.0075
  74414. */
  74415. area: number;
  74416. /**
  74417. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74418. * Must not be equal to area and inferior to area.
  74419. * Default value is 0.000001
  74420. */
  74421. fallOff: number;
  74422. /**
  74423. * The base color of the SSAO post-process
  74424. * The final result is "base + ssao" between [0, 1]
  74425. */
  74426. base: number;
  74427. private _scene;
  74428. private _depthTexture;
  74429. private _randomTexture;
  74430. private _originalColorPostProcess;
  74431. private _ssaoPostProcess;
  74432. private _blurHPostProcess;
  74433. private _blurVPostProcess;
  74434. private _ssaoCombinePostProcess;
  74435. private _firstUpdate;
  74436. /**
  74437. * Gets active scene
  74438. */
  74439. get scene(): Scene;
  74440. /**
  74441. * @constructor
  74442. * @param name - The rendering pipeline name
  74443. * @param scene - The scene linked to this pipeline
  74444. * @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 }
  74445. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74446. */
  74447. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74448. /**
  74449. * Get the class name
  74450. * @returns "SSAORenderingPipeline"
  74451. */
  74452. getClassName(): string;
  74453. /**
  74454. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74455. */
  74456. dispose(disableDepthRender?: boolean): void;
  74457. private _createBlurPostProcess;
  74458. /** @hidden */
  74459. _rebuild(): void;
  74460. private _createSSAOPostProcess;
  74461. private _createSSAOCombinePostProcess;
  74462. private _createRandomTexture;
  74463. }
  74464. }
  74465. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74466. /** @hidden */
  74467. export var screenSpaceReflectionPixelShader: {
  74468. name: string;
  74469. shader: string;
  74470. };
  74471. }
  74472. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74473. import { Nullable } from "babylonjs/types";
  74474. import { Camera } from "babylonjs/Cameras/camera";
  74475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74476. import { Scene } from "babylonjs/scene";
  74477. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74478. import { Engine } from "babylonjs/Engines/engine";
  74479. /**
  74480. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74481. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74482. */
  74483. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74484. /**
  74485. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74486. */
  74487. threshold: number;
  74488. /**
  74489. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74490. */
  74491. strength: number;
  74492. /**
  74493. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74494. */
  74495. reflectionSpecularFalloffExponent: number;
  74496. /**
  74497. * 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]
  74498. */
  74499. step: number;
  74500. /**
  74501. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74502. */
  74503. roughnessFactor: number;
  74504. private _geometryBufferRenderer;
  74505. private _enableSmoothReflections;
  74506. private _reflectionSamples;
  74507. private _smoothSteps;
  74508. /**
  74509. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74510. * @param name The name of the effect.
  74511. * @param scene The scene containing the objects to calculate reflections.
  74512. * @param options The required width/height ratio to downsize to before computing the render pass.
  74513. * @param camera The camera to apply the render pass to.
  74514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74515. * @param engine The engine which the post process will be applied. (default: current engine)
  74516. * @param reusable If the post process can be reused on the same frame. (default: false)
  74517. * @param textureType Type of textures used when performing the post process. (default: 0)
  74518. * @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)
  74519. */
  74520. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74521. /**
  74522. * Gets wether or not smoothing reflections is enabled.
  74523. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74524. */
  74525. get enableSmoothReflections(): boolean;
  74526. /**
  74527. * Sets wether or not smoothing reflections is enabled.
  74528. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74529. */
  74530. set enableSmoothReflections(enabled: boolean);
  74531. /**
  74532. * Gets the number of samples taken while computing reflections. More samples count is high,
  74533. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74534. */
  74535. get reflectionSamples(): number;
  74536. /**
  74537. * Sets the number of samples taken while computing reflections. More samples count is high,
  74538. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74539. */
  74540. set reflectionSamples(samples: number);
  74541. /**
  74542. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74543. * more the post-process will require GPU power and can generate a drop in FPS.
  74544. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74545. */
  74546. get smoothSteps(): number;
  74547. set smoothSteps(steps: number);
  74548. private _updateEffectDefines;
  74549. }
  74550. }
  74551. declare module "babylonjs/Shaders/standard.fragment" {
  74552. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74553. /** @hidden */
  74554. export var standardPixelShader: {
  74555. name: string;
  74556. shader: string;
  74557. };
  74558. }
  74559. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74560. import { Nullable } from "babylonjs/types";
  74561. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74562. import { Camera } from "babylonjs/Cameras/camera";
  74563. import { Texture } from "babylonjs/Materials/Textures/texture";
  74564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74565. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74566. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74567. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74568. import { IDisposable } from "babylonjs/scene";
  74569. import { SpotLight } from "babylonjs/Lights/spotLight";
  74570. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74571. import { Scene } from "babylonjs/scene";
  74572. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74573. import { Animation } from "babylonjs/Animations/animation";
  74574. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74575. import "babylonjs/Shaders/standard.fragment";
  74576. /**
  74577. * Standard rendering pipeline
  74578. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74579. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74580. */
  74581. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74582. /**
  74583. * Public members
  74584. */
  74585. /**
  74586. * Post-process which contains the original scene color before the pipeline applies all the effects
  74587. */
  74588. originalPostProcess: Nullable<PostProcess>;
  74589. /**
  74590. * Post-process used to down scale an image x4
  74591. */
  74592. downSampleX4PostProcess: Nullable<PostProcess>;
  74593. /**
  74594. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74595. */
  74596. brightPassPostProcess: Nullable<PostProcess>;
  74597. /**
  74598. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74599. */
  74600. blurHPostProcesses: PostProcess[];
  74601. /**
  74602. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74603. */
  74604. blurVPostProcesses: PostProcess[];
  74605. /**
  74606. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74607. */
  74608. textureAdderPostProcess: Nullable<PostProcess>;
  74609. /**
  74610. * Post-process used to create volumetric lighting effect
  74611. */
  74612. volumetricLightPostProcess: Nullable<PostProcess>;
  74613. /**
  74614. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74615. */
  74616. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74617. /**
  74618. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74619. */
  74620. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74621. /**
  74622. * Post-process used to merge the volumetric light effect and the real scene color
  74623. */
  74624. volumetricLightMergePostProces: Nullable<PostProcess>;
  74625. /**
  74626. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74627. */
  74628. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74629. /**
  74630. * Base post-process used to calculate the average luminance of the final image for HDR
  74631. */
  74632. luminancePostProcess: Nullable<PostProcess>;
  74633. /**
  74634. * Post-processes used to create down sample post-processes in order to get
  74635. * the average luminance of the final image for HDR
  74636. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74637. */
  74638. luminanceDownSamplePostProcesses: PostProcess[];
  74639. /**
  74640. * Post-process used to create a HDR effect (light adaptation)
  74641. */
  74642. hdrPostProcess: Nullable<PostProcess>;
  74643. /**
  74644. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74645. */
  74646. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74647. /**
  74648. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74649. */
  74650. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74651. /**
  74652. * Post-process used to merge the final HDR post-process and the real scene color
  74653. */
  74654. hdrFinalPostProcess: Nullable<PostProcess>;
  74655. /**
  74656. * Post-process used to create a lens flare effect
  74657. */
  74658. lensFlarePostProcess: Nullable<PostProcess>;
  74659. /**
  74660. * Post-process that merges the result of the lens flare post-process and the real scene color
  74661. */
  74662. lensFlareComposePostProcess: Nullable<PostProcess>;
  74663. /**
  74664. * Post-process used to create a motion blur effect
  74665. */
  74666. motionBlurPostProcess: Nullable<PostProcess>;
  74667. /**
  74668. * Post-process used to create a depth of field effect
  74669. */
  74670. depthOfFieldPostProcess: Nullable<PostProcess>;
  74671. /**
  74672. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74673. */
  74674. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74675. /**
  74676. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74677. */
  74678. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74679. /**
  74680. * Represents the brightness threshold in order to configure the illuminated surfaces
  74681. */
  74682. brightThreshold: number;
  74683. /**
  74684. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74685. */
  74686. blurWidth: number;
  74687. /**
  74688. * Sets if the blur for highlighted surfaces must be only horizontal
  74689. */
  74690. horizontalBlur: boolean;
  74691. /**
  74692. * Gets the overall exposure used by the pipeline
  74693. */
  74694. get exposure(): number;
  74695. /**
  74696. * Sets the overall exposure used by the pipeline
  74697. */
  74698. set exposure(value: number);
  74699. /**
  74700. * Texture used typically to simulate "dirty" on camera lens
  74701. */
  74702. lensTexture: Nullable<Texture>;
  74703. /**
  74704. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74705. */
  74706. volumetricLightCoefficient: number;
  74707. /**
  74708. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74709. */
  74710. volumetricLightPower: number;
  74711. /**
  74712. * Used the set the blur intensity to smooth the volumetric lights
  74713. */
  74714. volumetricLightBlurScale: number;
  74715. /**
  74716. * Light (spot or directional) used to generate the volumetric lights rays
  74717. * The source light must have a shadow generate so the pipeline can get its
  74718. * depth map
  74719. */
  74720. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74721. /**
  74722. * For eye adaptation, represents the minimum luminance the eye can see
  74723. */
  74724. hdrMinimumLuminance: number;
  74725. /**
  74726. * For eye adaptation, represents the decrease luminance speed
  74727. */
  74728. hdrDecreaseRate: number;
  74729. /**
  74730. * For eye adaptation, represents the increase luminance speed
  74731. */
  74732. hdrIncreaseRate: number;
  74733. /**
  74734. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74735. */
  74736. get hdrAutoExposure(): boolean;
  74737. /**
  74738. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74739. */
  74740. set hdrAutoExposure(value: boolean);
  74741. /**
  74742. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74743. */
  74744. lensColorTexture: Nullable<Texture>;
  74745. /**
  74746. * The overall strengh for the lens flare effect
  74747. */
  74748. lensFlareStrength: number;
  74749. /**
  74750. * Dispersion coefficient for lens flare ghosts
  74751. */
  74752. lensFlareGhostDispersal: number;
  74753. /**
  74754. * Main lens flare halo width
  74755. */
  74756. lensFlareHaloWidth: number;
  74757. /**
  74758. * Based on the lens distortion effect, defines how much the lens flare result
  74759. * is distorted
  74760. */
  74761. lensFlareDistortionStrength: number;
  74762. /**
  74763. * Configures the blur intensity used for for lens flare (halo)
  74764. */
  74765. lensFlareBlurWidth: number;
  74766. /**
  74767. * Lens star texture must be used to simulate rays on the flares and is available
  74768. * in the documentation
  74769. */
  74770. lensStarTexture: Nullable<Texture>;
  74771. /**
  74772. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74773. * flare effect by taking account of the dirt texture
  74774. */
  74775. lensFlareDirtTexture: Nullable<Texture>;
  74776. /**
  74777. * Represents the focal length for the depth of field effect
  74778. */
  74779. depthOfFieldDistance: number;
  74780. /**
  74781. * Represents the blur intensity for the blurred part of the depth of field effect
  74782. */
  74783. depthOfFieldBlurWidth: number;
  74784. /**
  74785. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74786. */
  74787. get motionStrength(): number;
  74788. /**
  74789. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74790. */
  74791. set motionStrength(strength: number);
  74792. /**
  74793. * Gets wether or not the motion blur post-process is object based or screen based.
  74794. */
  74795. get objectBasedMotionBlur(): boolean;
  74796. /**
  74797. * Sets wether or not the motion blur post-process should be object based or screen based
  74798. */
  74799. set objectBasedMotionBlur(value: boolean);
  74800. /**
  74801. * List of animations for the pipeline (IAnimatable implementation)
  74802. */
  74803. animations: Animation[];
  74804. /**
  74805. * Private members
  74806. */
  74807. private _scene;
  74808. private _currentDepthOfFieldSource;
  74809. private _basePostProcess;
  74810. private _fixedExposure;
  74811. private _currentExposure;
  74812. private _hdrAutoExposure;
  74813. private _hdrCurrentLuminance;
  74814. private _motionStrength;
  74815. private _isObjectBasedMotionBlur;
  74816. private _floatTextureType;
  74817. private _camerasToBeAttached;
  74818. private _ratio;
  74819. private _bloomEnabled;
  74820. private _depthOfFieldEnabled;
  74821. private _vlsEnabled;
  74822. private _lensFlareEnabled;
  74823. private _hdrEnabled;
  74824. private _motionBlurEnabled;
  74825. private _fxaaEnabled;
  74826. private _screenSpaceReflectionsEnabled;
  74827. private _motionBlurSamples;
  74828. private _volumetricLightStepsCount;
  74829. private _samples;
  74830. /**
  74831. * @ignore
  74832. * Specifies if the bloom pipeline is enabled
  74833. */
  74834. get BloomEnabled(): boolean;
  74835. set BloomEnabled(enabled: boolean);
  74836. /**
  74837. * @ignore
  74838. * Specifies if the depth of field pipeline is enabed
  74839. */
  74840. get DepthOfFieldEnabled(): boolean;
  74841. set DepthOfFieldEnabled(enabled: boolean);
  74842. /**
  74843. * @ignore
  74844. * Specifies if the lens flare pipeline is enabed
  74845. */
  74846. get LensFlareEnabled(): boolean;
  74847. set LensFlareEnabled(enabled: boolean);
  74848. /**
  74849. * @ignore
  74850. * Specifies if the HDR pipeline is enabled
  74851. */
  74852. get HDREnabled(): boolean;
  74853. set HDREnabled(enabled: boolean);
  74854. /**
  74855. * @ignore
  74856. * Specifies if the volumetric lights scattering effect is enabled
  74857. */
  74858. get VLSEnabled(): boolean;
  74859. set VLSEnabled(enabled: boolean);
  74860. /**
  74861. * @ignore
  74862. * Specifies if the motion blur effect is enabled
  74863. */
  74864. get MotionBlurEnabled(): boolean;
  74865. set MotionBlurEnabled(enabled: boolean);
  74866. /**
  74867. * Specifies if anti-aliasing is enabled
  74868. */
  74869. get fxaaEnabled(): boolean;
  74870. set fxaaEnabled(enabled: boolean);
  74871. /**
  74872. * Specifies if screen space reflections are enabled.
  74873. */
  74874. get screenSpaceReflectionsEnabled(): boolean;
  74875. set screenSpaceReflectionsEnabled(enabled: boolean);
  74876. /**
  74877. * Specifies the number of steps used to calculate the volumetric lights
  74878. * Typically in interval [50, 200]
  74879. */
  74880. get volumetricLightStepsCount(): number;
  74881. set volumetricLightStepsCount(count: number);
  74882. /**
  74883. * Specifies the number of samples used for the motion blur effect
  74884. * Typically in interval [16, 64]
  74885. */
  74886. get motionBlurSamples(): number;
  74887. set motionBlurSamples(samples: number);
  74888. /**
  74889. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74890. */
  74891. get samples(): number;
  74892. set samples(sampleCount: number);
  74893. /**
  74894. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74895. * @constructor
  74896. * @param name The rendering pipeline name
  74897. * @param scene The scene linked to this pipeline
  74898. * @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)
  74899. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74900. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74901. */
  74902. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74903. private _buildPipeline;
  74904. private _createDownSampleX4PostProcess;
  74905. private _createBrightPassPostProcess;
  74906. private _createBlurPostProcesses;
  74907. private _createTextureAdderPostProcess;
  74908. private _createVolumetricLightPostProcess;
  74909. private _createLuminancePostProcesses;
  74910. private _createHdrPostProcess;
  74911. private _createLensFlarePostProcess;
  74912. private _createDepthOfFieldPostProcess;
  74913. private _createMotionBlurPostProcess;
  74914. private _getDepthTexture;
  74915. private _disposePostProcesses;
  74916. /**
  74917. * Dispose of the pipeline and stop all post processes
  74918. */
  74919. dispose(): void;
  74920. /**
  74921. * Serialize the rendering pipeline (Used when exporting)
  74922. * @returns the serialized object
  74923. */
  74924. serialize(): any;
  74925. /**
  74926. * Parse the serialized pipeline
  74927. * @param source Source pipeline.
  74928. * @param scene The scene to load the pipeline to.
  74929. * @param rootUrl The URL of the serialized pipeline.
  74930. * @returns An instantiated pipeline from the serialized object.
  74931. */
  74932. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74933. /**
  74934. * Luminance steps
  74935. */
  74936. static LuminanceSteps: number;
  74937. }
  74938. }
  74939. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74940. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74941. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74942. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74943. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74944. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74945. }
  74946. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74947. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74948. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74949. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74950. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74951. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74952. }
  74953. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74954. /** @hidden */
  74955. export var stereoscopicInterlacePixelShader: {
  74956. name: string;
  74957. shader: string;
  74958. };
  74959. }
  74960. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74961. import { Camera } from "babylonjs/Cameras/camera";
  74962. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74963. import { Engine } from "babylonjs/Engines/engine";
  74964. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74965. /**
  74966. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74967. */
  74968. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74969. private _stepSize;
  74970. private _passedProcess;
  74971. /**
  74972. * Initializes a StereoscopicInterlacePostProcessI
  74973. * @param name The name of the effect.
  74974. * @param rigCameras The rig cameras to be appled to the post process
  74975. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74976. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74978. * @param engine The engine which the post process will be applied. (default: current engine)
  74979. * @param reusable If the post process can be reused on the same frame. (default: false)
  74980. */
  74981. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74982. }
  74983. /**
  74984. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74985. */
  74986. export class StereoscopicInterlacePostProcess extends PostProcess {
  74987. private _stepSize;
  74988. private _passedProcess;
  74989. /**
  74990. * Initializes a StereoscopicInterlacePostProcess
  74991. * @param name The name of the effect.
  74992. * @param rigCameras The rig cameras to be appled to the post process
  74993. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74995. * @param engine The engine which the post process will be applied. (default: current engine)
  74996. * @param reusable If the post process can be reused on the same frame. (default: false)
  74997. */
  74998. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74999. }
  75000. }
  75001. declare module "babylonjs/Shaders/tonemap.fragment" {
  75002. /** @hidden */
  75003. export var tonemapPixelShader: {
  75004. name: string;
  75005. shader: string;
  75006. };
  75007. }
  75008. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75009. import { Camera } from "babylonjs/Cameras/camera";
  75010. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75011. import "babylonjs/Shaders/tonemap.fragment";
  75012. import { Engine } from "babylonjs/Engines/engine";
  75013. /** Defines operator used for tonemapping */
  75014. export enum TonemappingOperator {
  75015. /** Hable */
  75016. Hable = 0,
  75017. /** Reinhard */
  75018. Reinhard = 1,
  75019. /** HejiDawson */
  75020. HejiDawson = 2,
  75021. /** Photographic */
  75022. Photographic = 3
  75023. }
  75024. /**
  75025. * Defines a post process to apply tone mapping
  75026. */
  75027. export class TonemapPostProcess extends PostProcess {
  75028. private _operator;
  75029. /** Defines the required exposure adjustement */
  75030. exposureAdjustment: number;
  75031. /**
  75032. * Creates a new TonemapPostProcess
  75033. * @param name defines the name of the postprocess
  75034. * @param _operator defines the operator to use
  75035. * @param exposureAdjustment defines the required exposure adjustement
  75036. * @param camera defines the camera to use (can be null)
  75037. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75038. * @param engine defines the hosting engine (can be ignore if camera is set)
  75039. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75040. */
  75041. constructor(name: string, _operator: TonemappingOperator,
  75042. /** Defines the required exposure adjustement */
  75043. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75044. }
  75045. }
  75046. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75047. /** @hidden */
  75048. export var volumetricLightScatteringPixelShader: {
  75049. name: string;
  75050. shader: string;
  75051. };
  75052. }
  75053. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75054. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75055. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75056. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75057. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75058. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75059. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75060. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75061. /** @hidden */
  75062. export var volumetricLightScatteringPassVertexShader: {
  75063. name: string;
  75064. shader: string;
  75065. };
  75066. }
  75067. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75068. /** @hidden */
  75069. export var volumetricLightScatteringPassPixelShader: {
  75070. name: string;
  75071. shader: string;
  75072. };
  75073. }
  75074. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75075. import { Vector3 } from "babylonjs/Maths/math.vector";
  75076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75077. import { Mesh } from "babylonjs/Meshes/mesh";
  75078. import { Camera } from "babylonjs/Cameras/camera";
  75079. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75080. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75081. import { Scene } from "babylonjs/scene";
  75082. import "babylonjs/Meshes/Builders/planeBuilder";
  75083. import "babylonjs/Shaders/depth.vertex";
  75084. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75085. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75086. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75087. import { Engine } from "babylonjs/Engines/engine";
  75088. /**
  75089. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75090. */
  75091. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75092. private _volumetricLightScatteringPass;
  75093. private _volumetricLightScatteringRTT;
  75094. private _viewPort;
  75095. private _screenCoordinates;
  75096. private _cachedDefines;
  75097. /**
  75098. * If not undefined, the mesh position is computed from the attached node position
  75099. */
  75100. attachedNode: {
  75101. position: Vector3;
  75102. };
  75103. /**
  75104. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75105. */
  75106. customMeshPosition: Vector3;
  75107. /**
  75108. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75109. */
  75110. useCustomMeshPosition: boolean;
  75111. /**
  75112. * If the post-process should inverse the light scattering direction
  75113. */
  75114. invert: boolean;
  75115. /**
  75116. * The internal mesh used by the post-process
  75117. */
  75118. mesh: Mesh;
  75119. /**
  75120. * @hidden
  75121. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75122. */
  75123. get useDiffuseColor(): boolean;
  75124. set useDiffuseColor(useDiffuseColor: boolean);
  75125. /**
  75126. * Array containing the excluded meshes not rendered in the internal pass
  75127. */
  75128. excludedMeshes: AbstractMesh[];
  75129. /**
  75130. * Controls the overall intensity of the post-process
  75131. */
  75132. exposure: number;
  75133. /**
  75134. * Dissipates each sample's contribution in range [0, 1]
  75135. */
  75136. decay: number;
  75137. /**
  75138. * Controls the overall intensity of each sample
  75139. */
  75140. weight: number;
  75141. /**
  75142. * Controls the density of each sample
  75143. */
  75144. density: number;
  75145. /**
  75146. * @constructor
  75147. * @param name The post-process name
  75148. * @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)
  75149. * @param camera The camera that the post-process will be attached to
  75150. * @param mesh The mesh used to create the light scattering
  75151. * @param samples The post-process quality, default 100
  75152. * @param samplingModeThe post-process filtering mode
  75153. * @param engine The babylon engine
  75154. * @param reusable If the post-process is reusable
  75155. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75156. */
  75157. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75158. /**
  75159. * Returns the string "VolumetricLightScatteringPostProcess"
  75160. * @returns "VolumetricLightScatteringPostProcess"
  75161. */
  75162. getClassName(): string;
  75163. private _isReady;
  75164. /**
  75165. * Sets the new light position for light scattering effect
  75166. * @param position The new custom light position
  75167. */
  75168. setCustomMeshPosition(position: Vector3): void;
  75169. /**
  75170. * Returns the light position for light scattering effect
  75171. * @return Vector3 The custom light position
  75172. */
  75173. getCustomMeshPosition(): Vector3;
  75174. /**
  75175. * Disposes the internal assets and detaches the post-process from the camera
  75176. */
  75177. dispose(camera: Camera): void;
  75178. /**
  75179. * Returns the render target texture used by the post-process
  75180. * @return the render target texture used by the post-process
  75181. */
  75182. getPass(): RenderTargetTexture;
  75183. private _meshExcluded;
  75184. private _createPass;
  75185. private _updateMeshScreenCoordinates;
  75186. /**
  75187. * Creates a default mesh for the Volumeric Light Scattering post-process
  75188. * @param name The mesh name
  75189. * @param scene The scene where to create the mesh
  75190. * @return the default mesh
  75191. */
  75192. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75193. }
  75194. }
  75195. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75196. /** @hidden */
  75197. export var screenSpaceCurvaturePixelShader: {
  75198. name: string;
  75199. shader: string;
  75200. };
  75201. }
  75202. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75203. import { Nullable } from "babylonjs/types";
  75204. import { Camera } from "babylonjs/Cameras/camera";
  75205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75206. import { Scene } from "babylonjs/scene";
  75207. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75208. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75209. import { Engine } from "babylonjs/Engines/engine";
  75210. /**
  75211. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75212. */
  75213. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75214. /**
  75215. * Defines how much ridge the curvature effect displays.
  75216. */
  75217. ridge: number;
  75218. /**
  75219. * Defines how much valley the curvature effect displays.
  75220. */
  75221. valley: number;
  75222. private _geometryBufferRenderer;
  75223. /**
  75224. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75225. * @param name The name of the effect.
  75226. * @param scene The scene containing the objects to blur according to their velocity.
  75227. * @param options The required width/height ratio to downsize to before computing the render pass.
  75228. * @param camera The camera to apply the render pass to.
  75229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75230. * @param engine The engine which the post process will be applied. (default: current engine)
  75231. * @param reusable If the post process can be reused on the same frame. (default: false)
  75232. * @param textureType Type of textures used when performing the post process. (default: 0)
  75233. * @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)
  75234. */
  75235. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75236. /**
  75237. * Support test.
  75238. */
  75239. static get IsSupported(): boolean;
  75240. }
  75241. }
  75242. declare module "babylonjs/PostProcesses/index" {
  75243. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75244. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75245. export * from "babylonjs/PostProcesses/bloomEffect";
  75246. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75247. export * from "babylonjs/PostProcesses/blurPostProcess";
  75248. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75249. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75250. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75251. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75252. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75253. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75254. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75255. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75256. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75257. export * from "babylonjs/PostProcesses/filterPostProcess";
  75258. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75259. export * from "babylonjs/PostProcesses/grainPostProcess";
  75260. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75261. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75262. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75263. export * from "babylonjs/PostProcesses/passPostProcess";
  75264. export * from "babylonjs/PostProcesses/postProcess";
  75265. export * from "babylonjs/PostProcesses/postProcessManager";
  75266. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75267. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75268. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75269. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75270. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75271. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75272. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75273. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75274. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75275. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75276. }
  75277. declare module "babylonjs/Probes/index" {
  75278. export * from "babylonjs/Probes/reflectionProbe";
  75279. }
  75280. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75281. import { Scene } from "babylonjs/scene";
  75282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75283. import { SmartArray } from "babylonjs/Misc/smartArray";
  75284. import { ISceneComponent } from "babylonjs/sceneComponent";
  75285. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75286. import "babylonjs/Meshes/Builders/boxBuilder";
  75287. import "babylonjs/Shaders/color.fragment";
  75288. import "babylonjs/Shaders/color.vertex";
  75289. import { Color3 } from "babylonjs/Maths/math.color";
  75290. import { Observable } from "babylonjs/Misc/observable";
  75291. module "babylonjs/scene" {
  75292. interface Scene {
  75293. /** @hidden (Backing field) */
  75294. _boundingBoxRenderer: BoundingBoxRenderer;
  75295. /** @hidden (Backing field) */
  75296. _forceShowBoundingBoxes: boolean;
  75297. /**
  75298. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75299. */
  75300. forceShowBoundingBoxes: boolean;
  75301. /**
  75302. * Gets the bounding box renderer associated with the scene
  75303. * @returns a BoundingBoxRenderer
  75304. */
  75305. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75306. }
  75307. }
  75308. module "babylonjs/Meshes/abstractMesh" {
  75309. interface AbstractMesh {
  75310. /** @hidden (Backing field) */
  75311. _showBoundingBox: boolean;
  75312. /**
  75313. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75314. */
  75315. showBoundingBox: boolean;
  75316. }
  75317. }
  75318. /**
  75319. * Component responsible of rendering the bounding box of the meshes in a scene.
  75320. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75321. */
  75322. export class BoundingBoxRenderer implements ISceneComponent {
  75323. /**
  75324. * The component name helpfull to identify the component in the list of scene components.
  75325. */
  75326. readonly name: string;
  75327. /**
  75328. * The scene the component belongs to.
  75329. */
  75330. scene: Scene;
  75331. /**
  75332. * Color of the bounding box lines placed in front of an object
  75333. */
  75334. frontColor: Color3;
  75335. /**
  75336. * Color of the bounding box lines placed behind an object
  75337. */
  75338. backColor: Color3;
  75339. /**
  75340. * Defines if the renderer should show the back lines or not
  75341. */
  75342. showBackLines: boolean;
  75343. /**
  75344. * Observable raised before rendering a bounding box
  75345. */
  75346. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75347. /**
  75348. * Observable raised after rendering a bounding box
  75349. */
  75350. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75351. /**
  75352. * @hidden
  75353. */
  75354. renderList: SmartArray<BoundingBox>;
  75355. private _colorShader;
  75356. private _vertexBuffers;
  75357. private _indexBuffer;
  75358. private _fillIndexBuffer;
  75359. private _fillIndexData;
  75360. /**
  75361. * Instantiates a new bounding box renderer in a scene.
  75362. * @param scene the scene the renderer renders in
  75363. */
  75364. constructor(scene: Scene);
  75365. /**
  75366. * Registers the component in a given scene
  75367. */
  75368. register(): void;
  75369. private _evaluateSubMesh;
  75370. private _activeMesh;
  75371. private _prepareRessources;
  75372. private _createIndexBuffer;
  75373. /**
  75374. * Rebuilds the elements related to this component in case of
  75375. * context lost for instance.
  75376. */
  75377. rebuild(): void;
  75378. /**
  75379. * @hidden
  75380. */
  75381. reset(): void;
  75382. /**
  75383. * Render the bounding boxes of a specific rendering group
  75384. * @param renderingGroupId defines the rendering group to render
  75385. */
  75386. render(renderingGroupId: number): void;
  75387. /**
  75388. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75389. * @param mesh Define the mesh to render the occlusion bounding box for
  75390. */
  75391. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75392. /**
  75393. * Dispose and release the resources attached to this renderer.
  75394. */
  75395. dispose(): void;
  75396. }
  75397. }
  75398. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75399. import { Nullable } from "babylonjs/types";
  75400. import { Scene } from "babylonjs/scene";
  75401. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75402. import { Camera } from "babylonjs/Cameras/camera";
  75403. import { ISceneComponent } from "babylonjs/sceneComponent";
  75404. module "babylonjs/scene" {
  75405. interface Scene {
  75406. /** @hidden (Backing field) */
  75407. _depthRenderer: {
  75408. [id: string]: DepthRenderer;
  75409. };
  75410. /**
  75411. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75412. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75413. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75414. * @returns the created depth renderer
  75415. */
  75416. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75417. /**
  75418. * Disables a depth renderer for a given camera
  75419. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75420. */
  75421. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75422. }
  75423. }
  75424. /**
  75425. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75426. * in several rendering techniques.
  75427. */
  75428. export class DepthRendererSceneComponent implements ISceneComponent {
  75429. /**
  75430. * The component name helpfull to identify the component in the list of scene components.
  75431. */
  75432. readonly name: string;
  75433. /**
  75434. * The scene the component belongs to.
  75435. */
  75436. scene: Scene;
  75437. /**
  75438. * Creates a new instance of the component for the given scene
  75439. * @param scene Defines the scene to register the component in
  75440. */
  75441. constructor(scene: Scene);
  75442. /**
  75443. * Registers the component in a given scene
  75444. */
  75445. register(): void;
  75446. /**
  75447. * Rebuilds the elements related to this component in case of
  75448. * context lost for instance.
  75449. */
  75450. rebuild(): void;
  75451. /**
  75452. * Disposes the component and the associated ressources
  75453. */
  75454. dispose(): void;
  75455. private _gatherRenderTargets;
  75456. private _gatherActiveCameraRenderTargets;
  75457. }
  75458. }
  75459. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75460. import { Nullable } from "babylonjs/types";
  75461. import { Scene } from "babylonjs/scene";
  75462. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75463. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75464. import { AbstractScene } from "babylonjs/abstractScene";
  75465. module "babylonjs/abstractScene" {
  75466. interface AbstractScene {
  75467. /** @hidden (Backing field) */
  75468. _prePassRenderer: Nullable<PrePassRenderer>;
  75469. /**
  75470. * Gets or Sets the current prepass renderer associated to the scene.
  75471. */
  75472. prePassRenderer: Nullable<PrePassRenderer>;
  75473. /**
  75474. * Enables the prepass and associates it with the scene
  75475. * @returns the PrePassRenderer
  75476. */
  75477. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75478. /**
  75479. * Disables the prepass associated with the scene
  75480. */
  75481. disablePrePassRenderer(): void;
  75482. }
  75483. }
  75484. /**
  75485. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75486. * in several rendering techniques.
  75487. */
  75488. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75489. /**
  75490. * The component name helpful to identify the component in the list of scene components.
  75491. */
  75492. readonly name: string;
  75493. /**
  75494. * The scene the component belongs to.
  75495. */
  75496. scene: Scene;
  75497. /**
  75498. * Creates a new instance of the component for the given scene
  75499. * @param scene Defines the scene to register the component in
  75500. */
  75501. constructor(scene: Scene);
  75502. /**
  75503. * Registers the component in a given scene
  75504. */
  75505. register(): void;
  75506. private _beforeCameraDraw;
  75507. private _afterCameraDraw;
  75508. private _beforeClearStage;
  75509. /**
  75510. * Serializes the component data to the specified json object
  75511. * @param serializationObject The object to serialize to
  75512. */
  75513. serialize(serializationObject: any): void;
  75514. /**
  75515. * Adds all the elements from the container to the scene
  75516. * @param container the container holding the elements
  75517. */
  75518. addFromContainer(container: AbstractScene): void;
  75519. /**
  75520. * Removes all the elements in the container from the scene
  75521. * @param container contains the elements to remove
  75522. * @param dispose if the removed element should be disposed (default: false)
  75523. */
  75524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75525. /**
  75526. * Rebuilds the elements related to this component in case of
  75527. * context lost for instance.
  75528. */
  75529. rebuild(): void;
  75530. /**
  75531. * Disposes the component and the associated ressources
  75532. */
  75533. dispose(): void;
  75534. }
  75535. }
  75536. declare module "babylonjs/Shaders/outline.fragment" {
  75537. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75538. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75539. /** @hidden */
  75540. export var outlinePixelShader: {
  75541. name: string;
  75542. shader: string;
  75543. };
  75544. }
  75545. declare module "babylonjs/Shaders/outline.vertex" {
  75546. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75549. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75550. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75554. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75555. /** @hidden */
  75556. export var outlineVertexShader: {
  75557. name: string;
  75558. shader: string;
  75559. };
  75560. }
  75561. declare module "babylonjs/Rendering/outlineRenderer" {
  75562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75563. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75564. import { Scene } from "babylonjs/scene";
  75565. import { ISceneComponent } from "babylonjs/sceneComponent";
  75566. import "babylonjs/Shaders/outline.fragment";
  75567. import "babylonjs/Shaders/outline.vertex";
  75568. module "babylonjs/scene" {
  75569. interface Scene {
  75570. /** @hidden */
  75571. _outlineRenderer: OutlineRenderer;
  75572. /**
  75573. * Gets the outline renderer associated with the scene
  75574. * @returns a OutlineRenderer
  75575. */
  75576. getOutlineRenderer(): OutlineRenderer;
  75577. }
  75578. }
  75579. module "babylonjs/Meshes/abstractMesh" {
  75580. interface AbstractMesh {
  75581. /** @hidden (Backing field) */
  75582. _renderOutline: boolean;
  75583. /**
  75584. * Gets or sets a boolean indicating if the outline must be rendered as well
  75585. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75586. */
  75587. renderOutline: boolean;
  75588. /** @hidden (Backing field) */
  75589. _renderOverlay: boolean;
  75590. /**
  75591. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75592. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75593. */
  75594. renderOverlay: boolean;
  75595. }
  75596. }
  75597. /**
  75598. * This class is responsible to draw bothe outline/overlay of meshes.
  75599. * It should not be used directly but through the available method on mesh.
  75600. */
  75601. export class OutlineRenderer implements ISceneComponent {
  75602. /**
  75603. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75604. */
  75605. private static _StencilReference;
  75606. /**
  75607. * The name of the component. Each component must have a unique name.
  75608. */
  75609. name: string;
  75610. /**
  75611. * The scene the component belongs to.
  75612. */
  75613. scene: Scene;
  75614. /**
  75615. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75616. */
  75617. zOffset: number;
  75618. private _engine;
  75619. private _effect;
  75620. private _cachedDefines;
  75621. private _savedDepthWrite;
  75622. /**
  75623. * Instantiates a new outline renderer. (There could be only one per scene).
  75624. * @param scene Defines the scene it belongs to
  75625. */
  75626. constructor(scene: Scene);
  75627. /**
  75628. * Register the component to one instance of a scene.
  75629. */
  75630. register(): void;
  75631. /**
  75632. * Rebuilds the elements related to this component in case of
  75633. * context lost for instance.
  75634. */
  75635. rebuild(): void;
  75636. /**
  75637. * Disposes the component and the associated ressources.
  75638. */
  75639. dispose(): void;
  75640. /**
  75641. * Renders the outline in the canvas.
  75642. * @param subMesh Defines the sumesh to render
  75643. * @param batch Defines the batch of meshes in case of instances
  75644. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75645. */
  75646. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75647. /**
  75648. * Returns whether or not the outline renderer is ready for a given submesh.
  75649. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75650. * @param subMesh Defines the submesh to check readyness for
  75651. * @param useInstances Defines wheter wee are trying to render instances or not
  75652. * @returns true if ready otherwise false
  75653. */
  75654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75655. private _beforeRenderingMesh;
  75656. private _afterRenderingMesh;
  75657. }
  75658. }
  75659. declare module "babylonjs/Rendering/index" {
  75660. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75661. export * from "babylonjs/Rendering/depthRenderer";
  75662. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75663. export * from "babylonjs/Rendering/edgesRenderer";
  75664. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75665. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75666. export * from "babylonjs/Rendering/prePassRenderer";
  75667. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75668. export * from "babylonjs/Rendering/outlineRenderer";
  75669. export * from "babylonjs/Rendering/renderingGroup";
  75670. export * from "babylonjs/Rendering/renderingManager";
  75671. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75672. }
  75673. declare module "babylonjs/Sprites/ISprites" {
  75674. /**
  75675. * Defines the basic options interface of a Sprite Frame Source Size.
  75676. */
  75677. export interface ISpriteJSONSpriteSourceSize {
  75678. /**
  75679. * number of the original width of the Frame
  75680. */
  75681. w: number;
  75682. /**
  75683. * number of the original height of the Frame
  75684. */
  75685. h: number;
  75686. }
  75687. /**
  75688. * Defines the basic options interface of a Sprite Frame Data.
  75689. */
  75690. export interface ISpriteJSONSpriteFrameData {
  75691. /**
  75692. * number of the x offset of the Frame
  75693. */
  75694. x: number;
  75695. /**
  75696. * number of the y offset of the Frame
  75697. */
  75698. y: number;
  75699. /**
  75700. * number of the width of the Frame
  75701. */
  75702. w: number;
  75703. /**
  75704. * number of the height of the Frame
  75705. */
  75706. h: number;
  75707. }
  75708. /**
  75709. * Defines the basic options interface of a JSON Sprite.
  75710. */
  75711. export interface ISpriteJSONSprite {
  75712. /**
  75713. * string name of the Frame
  75714. */
  75715. filename: string;
  75716. /**
  75717. * ISpriteJSONSpriteFrame basic object of the frame data
  75718. */
  75719. frame: ISpriteJSONSpriteFrameData;
  75720. /**
  75721. * boolean to flag is the frame was rotated.
  75722. */
  75723. rotated: boolean;
  75724. /**
  75725. * boolean to flag is the frame was trimmed.
  75726. */
  75727. trimmed: boolean;
  75728. /**
  75729. * ISpriteJSONSpriteFrame basic object of the source data
  75730. */
  75731. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75732. /**
  75733. * ISpriteJSONSpriteFrame basic object of the source data
  75734. */
  75735. sourceSize: ISpriteJSONSpriteSourceSize;
  75736. }
  75737. /**
  75738. * Defines the basic options interface of a JSON atlas.
  75739. */
  75740. export interface ISpriteJSONAtlas {
  75741. /**
  75742. * Array of objects that contain the frame data.
  75743. */
  75744. frames: Array<ISpriteJSONSprite>;
  75745. /**
  75746. * object basic object containing the sprite meta data.
  75747. */
  75748. meta?: object;
  75749. }
  75750. }
  75751. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75752. /** @hidden */
  75753. export var spriteMapPixelShader: {
  75754. name: string;
  75755. shader: string;
  75756. };
  75757. }
  75758. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75759. /** @hidden */
  75760. export var spriteMapVertexShader: {
  75761. name: string;
  75762. shader: string;
  75763. };
  75764. }
  75765. declare module "babylonjs/Sprites/spriteMap" {
  75766. import { IDisposable, Scene } from "babylonjs/scene";
  75767. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75768. import { Texture } from "babylonjs/Materials/Textures/texture";
  75769. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75770. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75771. import "babylonjs/Meshes/Builders/planeBuilder";
  75772. import "babylonjs/Shaders/spriteMap.fragment";
  75773. import "babylonjs/Shaders/spriteMap.vertex";
  75774. /**
  75775. * Defines the basic options interface of a SpriteMap
  75776. */
  75777. export interface ISpriteMapOptions {
  75778. /**
  75779. * Vector2 of the number of cells in the grid.
  75780. */
  75781. stageSize?: Vector2;
  75782. /**
  75783. * Vector2 of the size of the output plane in World Units.
  75784. */
  75785. outputSize?: Vector2;
  75786. /**
  75787. * Vector3 of the position of the output plane in World Units.
  75788. */
  75789. outputPosition?: Vector3;
  75790. /**
  75791. * Vector3 of the rotation of the output plane.
  75792. */
  75793. outputRotation?: Vector3;
  75794. /**
  75795. * number of layers that the system will reserve in resources.
  75796. */
  75797. layerCount?: number;
  75798. /**
  75799. * number of max animation frames a single cell will reserve in resources.
  75800. */
  75801. maxAnimationFrames?: number;
  75802. /**
  75803. * number cell index of the base tile when the system compiles.
  75804. */
  75805. baseTile?: number;
  75806. /**
  75807. * boolean flip the sprite after its been repositioned by the framing data.
  75808. */
  75809. flipU?: boolean;
  75810. /**
  75811. * Vector3 scalar of the global RGB values of the SpriteMap.
  75812. */
  75813. colorMultiply?: Vector3;
  75814. }
  75815. /**
  75816. * Defines the IDisposable interface in order to be cleanable from resources.
  75817. */
  75818. export interface ISpriteMap extends IDisposable {
  75819. /**
  75820. * String name of the SpriteMap.
  75821. */
  75822. name: string;
  75823. /**
  75824. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75825. */
  75826. atlasJSON: ISpriteJSONAtlas;
  75827. /**
  75828. * Texture of the SpriteMap.
  75829. */
  75830. spriteSheet: Texture;
  75831. /**
  75832. * The parameters to initialize the SpriteMap with.
  75833. */
  75834. options: ISpriteMapOptions;
  75835. }
  75836. /**
  75837. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75838. */
  75839. export class SpriteMap implements ISpriteMap {
  75840. /** The Name of the spriteMap */
  75841. name: string;
  75842. /** The JSON file with the frame and meta data */
  75843. atlasJSON: ISpriteJSONAtlas;
  75844. /** The systems Sprite Sheet Texture */
  75845. spriteSheet: Texture;
  75846. /** Arguments passed with the Constructor */
  75847. options: ISpriteMapOptions;
  75848. /** Public Sprite Storage array, parsed from atlasJSON */
  75849. sprites: Array<ISpriteJSONSprite>;
  75850. /** Returns the Number of Sprites in the System */
  75851. get spriteCount(): number;
  75852. /** Returns the Position of Output Plane*/
  75853. get position(): Vector3;
  75854. /** Returns the Position of Output Plane*/
  75855. set position(v: Vector3);
  75856. /** Returns the Rotation of Output Plane*/
  75857. get rotation(): Vector3;
  75858. /** Returns the Rotation of Output Plane*/
  75859. set rotation(v: Vector3);
  75860. /** Sets the AnimationMap*/
  75861. get animationMap(): RawTexture;
  75862. /** Sets the AnimationMap*/
  75863. set animationMap(v: RawTexture);
  75864. /** Scene that the SpriteMap was created in */
  75865. private _scene;
  75866. /** Texture Buffer of Float32 that holds tile frame data*/
  75867. private _frameMap;
  75868. /** Texture Buffers of Float32 that holds tileMap data*/
  75869. private _tileMaps;
  75870. /** Texture Buffer of Float32 that holds Animation Data*/
  75871. private _animationMap;
  75872. /** Custom ShaderMaterial Central to the System*/
  75873. private _material;
  75874. /** Custom ShaderMaterial Central to the System*/
  75875. private _output;
  75876. /** Systems Time Ticker*/
  75877. private _time;
  75878. /**
  75879. * Creates a new SpriteMap
  75880. * @param name defines the SpriteMaps Name
  75881. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75882. * @param spriteSheet is the Texture that the Sprites are on.
  75883. * @param options a basic deployment configuration
  75884. * @param scene The Scene that the map is deployed on
  75885. */
  75886. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75887. /**
  75888. * Returns tileID location
  75889. * @returns Vector2 the cell position ID
  75890. */
  75891. getTileID(): Vector2;
  75892. /**
  75893. * Gets the UV location of the mouse over the SpriteMap.
  75894. * @returns Vector2 the UV position of the mouse interaction
  75895. */
  75896. getMousePosition(): Vector2;
  75897. /**
  75898. * Creates the "frame" texture Buffer
  75899. * -------------------------------------
  75900. * Structure of frames
  75901. * "filename": "Falling-Water-2.png",
  75902. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75903. * "rotated": true,
  75904. * "trimmed": true,
  75905. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75906. * "sourceSize": {"w":32,"h":32}
  75907. * @returns RawTexture of the frameMap
  75908. */
  75909. private _createFrameBuffer;
  75910. /**
  75911. * Creates the tileMap texture Buffer
  75912. * @param buffer normally and array of numbers, or a false to generate from scratch
  75913. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75914. * @returns RawTexture of the tileMap
  75915. */
  75916. private _createTileBuffer;
  75917. /**
  75918. * Modifies the data of the tileMaps
  75919. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75920. * @param pos is the iVector2 Coordinates of the Tile
  75921. * @param tile The SpriteIndex of the new Tile
  75922. */
  75923. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75924. /**
  75925. * Creates the animationMap texture Buffer
  75926. * @param buffer normally and array of numbers, or a false to generate from scratch
  75927. * @returns RawTexture of the animationMap
  75928. */
  75929. private _createTileAnimationBuffer;
  75930. /**
  75931. * Modifies the data of the animationMap
  75932. * @param cellID is the Index of the Sprite
  75933. * @param _frame is the target Animation frame
  75934. * @param toCell is the Target Index of the next frame of the animation
  75935. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75936. * @param speed is a global scalar of the time variable on the map.
  75937. */
  75938. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75939. /**
  75940. * Exports the .tilemaps file
  75941. */
  75942. saveTileMaps(): void;
  75943. /**
  75944. * Imports the .tilemaps file
  75945. * @param url of the .tilemaps file
  75946. */
  75947. loadTileMaps(url: string): void;
  75948. /**
  75949. * Release associated resources
  75950. */
  75951. dispose(): void;
  75952. }
  75953. }
  75954. declare module "babylonjs/Sprites/spritePackedManager" {
  75955. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75956. import { Scene } from "babylonjs/scene";
  75957. /**
  75958. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75959. * @see https://doc.babylonjs.com/babylon101/sprites
  75960. */
  75961. export class SpritePackedManager extends SpriteManager {
  75962. /** defines the packed manager's name */
  75963. name: string;
  75964. /**
  75965. * Creates a new sprite manager from a packed sprite sheet
  75966. * @param name defines the manager's name
  75967. * @param imgUrl defines the sprite sheet url
  75968. * @param capacity defines the maximum allowed number of sprites
  75969. * @param scene defines the hosting scene
  75970. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75971. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75972. * @param samplingMode defines the smapling mode to use with spritesheet
  75973. * @param fromPacked set to true; do not alter
  75974. */
  75975. constructor(
  75976. /** defines the packed manager's name */
  75977. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75978. }
  75979. }
  75980. declare module "babylonjs/Sprites/index" {
  75981. export * from "babylonjs/Sprites/sprite";
  75982. export * from "babylonjs/Sprites/ISprites";
  75983. export * from "babylonjs/Sprites/spriteManager";
  75984. export * from "babylonjs/Sprites/spriteMap";
  75985. export * from "babylonjs/Sprites/spritePackedManager";
  75986. export * from "babylonjs/Sprites/spriteSceneComponent";
  75987. }
  75988. declare module "babylonjs/States/index" {
  75989. export * from "babylonjs/States/alphaCullingState";
  75990. export * from "babylonjs/States/depthCullingState";
  75991. export * from "babylonjs/States/stencilState";
  75992. }
  75993. declare module "babylonjs/Misc/assetsManager" {
  75994. import { Scene } from "babylonjs/scene";
  75995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75996. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75997. import { Skeleton } from "babylonjs/Bones/skeleton";
  75998. import { Observable } from "babylonjs/Misc/observable";
  75999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76000. import { Texture } from "babylonjs/Materials/Textures/texture";
  76001. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76002. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76003. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76004. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76005. import { AssetContainer } from "babylonjs/assetContainer";
  76006. /**
  76007. * Defines the list of states available for a task inside a AssetsManager
  76008. */
  76009. export enum AssetTaskState {
  76010. /**
  76011. * Initialization
  76012. */
  76013. INIT = 0,
  76014. /**
  76015. * Running
  76016. */
  76017. RUNNING = 1,
  76018. /**
  76019. * Done
  76020. */
  76021. DONE = 2,
  76022. /**
  76023. * Error
  76024. */
  76025. ERROR = 3
  76026. }
  76027. /**
  76028. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76029. */
  76030. export abstract class AbstractAssetTask {
  76031. /**
  76032. * Task name
  76033. */ name: string;
  76034. /**
  76035. * Callback called when the task is successful
  76036. */
  76037. onSuccess: (task: any) => void;
  76038. /**
  76039. * Callback called when the task is not successful
  76040. */
  76041. onError: (task: any, message?: string, exception?: any) => void;
  76042. /**
  76043. * Creates a new AssetsManager
  76044. * @param name defines the name of the task
  76045. */
  76046. constructor(
  76047. /**
  76048. * Task name
  76049. */ name: string);
  76050. private _isCompleted;
  76051. private _taskState;
  76052. private _errorObject;
  76053. /**
  76054. * Get if the task is completed
  76055. */
  76056. get isCompleted(): boolean;
  76057. /**
  76058. * Gets the current state of the task
  76059. */
  76060. get taskState(): AssetTaskState;
  76061. /**
  76062. * Gets the current error object (if task is in error)
  76063. */
  76064. get errorObject(): {
  76065. message?: string;
  76066. exception?: any;
  76067. };
  76068. /**
  76069. * Internal only
  76070. * @hidden
  76071. */
  76072. _setErrorObject(message?: string, exception?: any): void;
  76073. /**
  76074. * Execute the current task
  76075. * @param scene defines the scene where you want your assets to be loaded
  76076. * @param onSuccess is a callback called when the task is successfully executed
  76077. * @param onError is a callback called if an error occurs
  76078. */
  76079. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76080. /**
  76081. * Execute the current task
  76082. * @param scene defines the scene where you want your assets to be loaded
  76083. * @param onSuccess is a callback called when the task is successfully executed
  76084. * @param onError is a callback called if an error occurs
  76085. */
  76086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76087. /**
  76088. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76089. * This can be used with failed tasks that have the reason for failure fixed.
  76090. */
  76091. reset(): void;
  76092. private onErrorCallback;
  76093. private onDoneCallback;
  76094. }
  76095. /**
  76096. * Define the interface used by progress events raised during assets loading
  76097. */
  76098. export interface IAssetsProgressEvent {
  76099. /**
  76100. * Defines the number of remaining tasks to process
  76101. */
  76102. remainingCount: number;
  76103. /**
  76104. * Defines the total number of tasks
  76105. */
  76106. totalCount: number;
  76107. /**
  76108. * Defines the task that was just processed
  76109. */
  76110. task: AbstractAssetTask;
  76111. }
  76112. /**
  76113. * Class used to share progress information about assets loading
  76114. */
  76115. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76116. /**
  76117. * Defines the number of remaining tasks to process
  76118. */
  76119. remainingCount: number;
  76120. /**
  76121. * Defines the total number of tasks
  76122. */
  76123. totalCount: number;
  76124. /**
  76125. * Defines the task that was just processed
  76126. */
  76127. task: AbstractAssetTask;
  76128. /**
  76129. * Creates a AssetsProgressEvent
  76130. * @param remainingCount defines the number of remaining tasks to process
  76131. * @param totalCount defines the total number of tasks
  76132. * @param task defines the task that was just processed
  76133. */
  76134. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76135. }
  76136. /**
  76137. * Define a task used by AssetsManager to load assets into a container
  76138. */
  76139. export class ContainerAssetTask extends AbstractAssetTask {
  76140. /**
  76141. * Defines the name of the task
  76142. */
  76143. name: string;
  76144. /**
  76145. * Defines the list of mesh's names you want to load
  76146. */
  76147. meshesNames: any;
  76148. /**
  76149. * Defines the root url to use as a base to load your meshes and associated resources
  76150. */
  76151. rootUrl: string;
  76152. /**
  76153. * Defines the filename or File of the scene to load from
  76154. */
  76155. sceneFilename: string | File;
  76156. /**
  76157. * Get the loaded asset container
  76158. */
  76159. loadedContainer: AssetContainer;
  76160. /**
  76161. * Gets the list of loaded meshes
  76162. */
  76163. loadedMeshes: Array<AbstractMesh>;
  76164. /**
  76165. * Gets the list of loaded particle systems
  76166. */
  76167. loadedParticleSystems: Array<IParticleSystem>;
  76168. /**
  76169. * Gets the list of loaded skeletons
  76170. */
  76171. loadedSkeletons: Array<Skeleton>;
  76172. /**
  76173. * Gets the list of loaded animation groups
  76174. */
  76175. loadedAnimationGroups: Array<AnimationGroup>;
  76176. /**
  76177. * Callback called when the task is successful
  76178. */
  76179. onSuccess: (task: ContainerAssetTask) => void;
  76180. /**
  76181. * Callback called when the task is successful
  76182. */
  76183. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76184. /**
  76185. * Creates a new ContainerAssetTask
  76186. * @param name defines the name of the task
  76187. * @param meshesNames defines the list of mesh's names you want to load
  76188. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76189. * @param sceneFilename defines the filename or File of the scene to load from
  76190. */
  76191. constructor(
  76192. /**
  76193. * Defines the name of the task
  76194. */
  76195. name: string,
  76196. /**
  76197. * Defines the list of mesh's names you want to load
  76198. */
  76199. meshesNames: any,
  76200. /**
  76201. * Defines the root url to use as a base to load your meshes and associated resources
  76202. */
  76203. rootUrl: string,
  76204. /**
  76205. * Defines the filename or File of the scene to load from
  76206. */
  76207. sceneFilename: string | File);
  76208. /**
  76209. * Execute the current task
  76210. * @param scene defines the scene where you want your assets to be loaded
  76211. * @param onSuccess is a callback called when the task is successfully executed
  76212. * @param onError is a callback called if an error occurs
  76213. */
  76214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76215. }
  76216. /**
  76217. * Define a task used by AssetsManager to load meshes
  76218. */
  76219. export class MeshAssetTask extends AbstractAssetTask {
  76220. /**
  76221. * Defines the name of the task
  76222. */
  76223. name: string;
  76224. /**
  76225. * Defines the list of mesh's names you want to load
  76226. */
  76227. meshesNames: any;
  76228. /**
  76229. * Defines the root url to use as a base to load your meshes and associated resources
  76230. */
  76231. rootUrl: string;
  76232. /**
  76233. * Defines the filename or File of the scene to load from
  76234. */
  76235. sceneFilename: string | File;
  76236. /**
  76237. * Gets the list of loaded meshes
  76238. */
  76239. loadedMeshes: Array<AbstractMesh>;
  76240. /**
  76241. * Gets the list of loaded particle systems
  76242. */
  76243. loadedParticleSystems: Array<IParticleSystem>;
  76244. /**
  76245. * Gets the list of loaded skeletons
  76246. */
  76247. loadedSkeletons: Array<Skeleton>;
  76248. /**
  76249. * Gets the list of loaded animation groups
  76250. */
  76251. loadedAnimationGroups: Array<AnimationGroup>;
  76252. /**
  76253. * Callback called when the task is successful
  76254. */
  76255. onSuccess: (task: MeshAssetTask) => void;
  76256. /**
  76257. * Callback called when the task is successful
  76258. */
  76259. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76260. /**
  76261. * Creates a new MeshAssetTask
  76262. * @param name defines the name of the task
  76263. * @param meshesNames defines the list of mesh's names you want to load
  76264. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76265. * @param sceneFilename defines the filename or File of the scene to load from
  76266. */
  76267. constructor(
  76268. /**
  76269. * Defines the name of the task
  76270. */
  76271. name: string,
  76272. /**
  76273. * Defines the list of mesh's names you want to load
  76274. */
  76275. meshesNames: any,
  76276. /**
  76277. * Defines the root url to use as a base to load your meshes and associated resources
  76278. */
  76279. rootUrl: string,
  76280. /**
  76281. * Defines the filename or File of the scene to load from
  76282. */
  76283. sceneFilename: string | File);
  76284. /**
  76285. * Execute the current task
  76286. * @param scene defines the scene where you want your assets to be loaded
  76287. * @param onSuccess is a callback called when the task is successfully executed
  76288. * @param onError is a callback called if an error occurs
  76289. */
  76290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76291. }
  76292. /**
  76293. * Define a task used by AssetsManager to load text content
  76294. */
  76295. export class TextFileAssetTask extends AbstractAssetTask {
  76296. /**
  76297. * Defines the name of the task
  76298. */
  76299. name: string;
  76300. /**
  76301. * Defines the location of the file to load
  76302. */
  76303. url: string;
  76304. /**
  76305. * Gets the loaded text string
  76306. */
  76307. text: string;
  76308. /**
  76309. * Callback called when the task is successful
  76310. */
  76311. onSuccess: (task: TextFileAssetTask) => void;
  76312. /**
  76313. * Callback called when the task is successful
  76314. */
  76315. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76316. /**
  76317. * Creates a new TextFileAssetTask object
  76318. * @param name defines the name of the task
  76319. * @param url defines the location of the file to load
  76320. */
  76321. constructor(
  76322. /**
  76323. * Defines the name of the task
  76324. */
  76325. name: string,
  76326. /**
  76327. * Defines the location of the file to load
  76328. */
  76329. url: string);
  76330. /**
  76331. * Execute the current task
  76332. * @param scene defines the scene where you want your assets to be loaded
  76333. * @param onSuccess is a callback called when the task is successfully executed
  76334. * @param onError is a callback called if an error occurs
  76335. */
  76336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76337. }
  76338. /**
  76339. * Define a task used by AssetsManager to load binary data
  76340. */
  76341. export class BinaryFileAssetTask extends AbstractAssetTask {
  76342. /**
  76343. * Defines the name of the task
  76344. */
  76345. name: string;
  76346. /**
  76347. * Defines the location of the file to load
  76348. */
  76349. url: string;
  76350. /**
  76351. * Gets the lodaded data (as an array buffer)
  76352. */
  76353. data: ArrayBuffer;
  76354. /**
  76355. * Callback called when the task is successful
  76356. */
  76357. onSuccess: (task: BinaryFileAssetTask) => void;
  76358. /**
  76359. * Callback called when the task is successful
  76360. */
  76361. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76362. /**
  76363. * Creates a new BinaryFileAssetTask object
  76364. * @param name defines the name of the new task
  76365. * @param url defines the location of the file to load
  76366. */
  76367. constructor(
  76368. /**
  76369. * Defines the name of the task
  76370. */
  76371. name: string,
  76372. /**
  76373. * Defines the location of the file to load
  76374. */
  76375. url: string);
  76376. /**
  76377. * Execute the current task
  76378. * @param scene defines the scene where you want your assets to be loaded
  76379. * @param onSuccess is a callback called when the task is successfully executed
  76380. * @param onError is a callback called if an error occurs
  76381. */
  76382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76383. }
  76384. /**
  76385. * Define a task used by AssetsManager to load images
  76386. */
  76387. export class ImageAssetTask extends AbstractAssetTask {
  76388. /**
  76389. * Defines the name of the task
  76390. */
  76391. name: string;
  76392. /**
  76393. * Defines the location of the image to load
  76394. */
  76395. url: string;
  76396. /**
  76397. * Gets the loaded images
  76398. */
  76399. image: HTMLImageElement;
  76400. /**
  76401. * Callback called when the task is successful
  76402. */
  76403. onSuccess: (task: ImageAssetTask) => void;
  76404. /**
  76405. * Callback called when the task is successful
  76406. */
  76407. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76408. /**
  76409. * Creates a new ImageAssetTask
  76410. * @param name defines the name of the task
  76411. * @param url defines the location of the image to load
  76412. */
  76413. constructor(
  76414. /**
  76415. * Defines the name of the task
  76416. */
  76417. name: string,
  76418. /**
  76419. * Defines the location of the image to load
  76420. */
  76421. url: string);
  76422. /**
  76423. * Execute the current task
  76424. * @param scene defines the scene where you want your assets to be loaded
  76425. * @param onSuccess is a callback called when the task is successfully executed
  76426. * @param onError is a callback called if an error occurs
  76427. */
  76428. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76429. }
  76430. /**
  76431. * Defines the interface used by texture loading tasks
  76432. */
  76433. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76434. /**
  76435. * Gets the loaded texture
  76436. */
  76437. texture: TEX;
  76438. }
  76439. /**
  76440. * Define a task used by AssetsManager to load 2D textures
  76441. */
  76442. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76443. /**
  76444. * Defines the name of the task
  76445. */
  76446. name: string;
  76447. /**
  76448. * Defines the location of the file to load
  76449. */
  76450. url: string;
  76451. /**
  76452. * Defines if mipmap should not be generated (default is false)
  76453. */
  76454. noMipmap?: boolean | undefined;
  76455. /**
  76456. * Defines if texture must be inverted on Y axis (default is true)
  76457. */
  76458. invertY: boolean;
  76459. /**
  76460. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76461. */
  76462. samplingMode: number;
  76463. /**
  76464. * Gets the loaded texture
  76465. */
  76466. texture: Texture;
  76467. /**
  76468. * Callback called when the task is successful
  76469. */
  76470. onSuccess: (task: TextureAssetTask) => void;
  76471. /**
  76472. * Callback called when the task is successful
  76473. */
  76474. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76475. /**
  76476. * Creates a new TextureAssetTask object
  76477. * @param name defines the name of the task
  76478. * @param url defines the location of the file to load
  76479. * @param noMipmap defines if mipmap should not be generated (default is false)
  76480. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76481. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76482. */
  76483. constructor(
  76484. /**
  76485. * Defines the name of the task
  76486. */
  76487. name: string,
  76488. /**
  76489. * Defines the location of the file to load
  76490. */
  76491. url: string,
  76492. /**
  76493. * Defines if mipmap should not be generated (default is false)
  76494. */
  76495. noMipmap?: boolean | undefined,
  76496. /**
  76497. * Defines if texture must be inverted on Y axis (default is true)
  76498. */
  76499. invertY?: boolean,
  76500. /**
  76501. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76502. */
  76503. samplingMode?: number);
  76504. /**
  76505. * Execute the current task
  76506. * @param scene defines the scene where you want your assets to be loaded
  76507. * @param onSuccess is a callback called when the task is successfully executed
  76508. * @param onError is a callback called if an error occurs
  76509. */
  76510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76511. }
  76512. /**
  76513. * Define a task used by AssetsManager to load cube textures
  76514. */
  76515. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76516. /**
  76517. * Defines the name of the task
  76518. */
  76519. name: string;
  76520. /**
  76521. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76522. */
  76523. url: string;
  76524. /**
  76525. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76526. */
  76527. extensions?: string[] | undefined;
  76528. /**
  76529. * Defines if mipmaps should not be generated (default is false)
  76530. */
  76531. noMipmap?: boolean | undefined;
  76532. /**
  76533. * Defines the explicit list of files (undefined by default)
  76534. */
  76535. files?: string[] | undefined;
  76536. /**
  76537. * Gets the loaded texture
  76538. */
  76539. texture: CubeTexture;
  76540. /**
  76541. * Callback called when the task is successful
  76542. */
  76543. onSuccess: (task: CubeTextureAssetTask) => void;
  76544. /**
  76545. * Callback called when the task is successful
  76546. */
  76547. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76548. /**
  76549. * Creates a new CubeTextureAssetTask
  76550. * @param name defines the name of the task
  76551. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76552. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76553. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76554. * @param files defines the explicit list of files (undefined by default)
  76555. */
  76556. constructor(
  76557. /**
  76558. * Defines the name of the task
  76559. */
  76560. name: string,
  76561. /**
  76562. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76563. */
  76564. url: string,
  76565. /**
  76566. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76567. */
  76568. extensions?: string[] | undefined,
  76569. /**
  76570. * Defines if mipmaps should not be generated (default is false)
  76571. */
  76572. noMipmap?: boolean | undefined,
  76573. /**
  76574. * Defines the explicit list of files (undefined by default)
  76575. */
  76576. files?: string[] | undefined);
  76577. /**
  76578. * Execute the current task
  76579. * @param scene defines the scene where you want your assets to be loaded
  76580. * @param onSuccess is a callback called when the task is successfully executed
  76581. * @param onError is a callback called if an error occurs
  76582. */
  76583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76584. }
  76585. /**
  76586. * Define a task used by AssetsManager to load HDR cube textures
  76587. */
  76588. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76589. /**
  76590. * Defines the name of the task
  76591. */
  76592. name: string;
  76593. /**
  76594. * Defines the location of the file to load
  76595. */
  76596. url: string;
  76597. /**
  76598. * Defines the desired size (the more it increases the longer the generation will be)
  76599. */
  76600. size: number;
  76601. /**
  76602. * Defines if mipmaps should not be generated (default is false)
  76603. */
  76604. noMipmap: boolean;
  76605. /**
  76606. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76607. */
  76608. generateHarmonics: boolean;
  76609. /**
  76610. * 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)
  76611. */
  76612. gammaSpace: boolean;
  76613. /**
  76614. * Internal Use Only
  76615. */
  76616. reserved: boolean;
  76617. /**
  76618. * Gets the loaded texture
  76619. */
  76620. texture: HDRCubeTexture;
  76621. /**
  76622. * Callback called when the task is successful
  76623. */
  76624. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76625. /**
  76626. * Callback called when the task is successful
  76627. */
  76628. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76629. /**
  76630. * Creates a new HDRCubeTextureAssetTask object
  76631. * @param name defines the name of the task
  76632. * @param url defines the location of the file to load
  76633. * @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.
  76634. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76635. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76636. * @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)
  76637. * @param reserved Internal use only
  76638. */
  76639. constructor(
  76640. /**
  76641. * Defines the name of the task
  76642. */
  76643. name: string,
  76644. /**
  76645. * Defines the location of the file to load
  76646. */
  76647. url: string,
  76648. /**
  76649. * Defines the desired size (the more it increases the longer the generation will be)
  76650. */
  76651. size: number,
  76652. /**
  76653. * Defines if mipmaps should not be generated (default is false)
  76654. */
  76655. noMipmap?: boolean,
  76656. /**
  76657. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76658. */
  76659. generateHarmonics?: boolean,
  76660. /**
  76661. * 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)
  76662. */
  76663. gammaSpace?: boolean,
  76664. /**
  76665. * Internal Use Only
  76666. */
  76667. reserved?: boolean);
  76668. /**
  76669. * Execute the current task
  76670. * @param scene defines the scene where you want your assets to be loaded
  76671. * @param onSuccess is a callback called when the task is successfully executed
  76672. * @param onError is a callback called if an error occurs
  76673. */
  76674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76675. }
  76676. /**
  76677. * Define a task used by AssetsManager to load Equirectangular cube textures
  76678. */
  76679. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76680. /**
  76681. * Defines the name of the task
  76682. */
  76683. name: string;
  76684. /**
  76685. * Defines the location of the file to load
  76686. */
  76687. url: string;
  76688. /**
  76689. * Defines the desired size (the more it increases the longer the generation will be)
  76690. */
  76691. size: number;
  76692. /**
  76693. * Defines if mipmaps should not be generated (default is false)
  76694. */
  76695. noMipmap: boolean;
  76696. /**
  76697. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76698. * but the standard material would require them in Gamma space) (default is true)
  76699. */
  76700. gammaSpace: boolean;
  76701. /**
  76702. * Gets the loaded texture
  76703. */
  76704. texture: EquiRectangularCubeTexture;
  76705. /**
  76706. * Callback called when the task is successful
  76707. */
  76708. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76709. /**
  76710. * Callback called when the task is successful
  76711. */
  76712. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76713. /**
  76714. * Creates a new EquiRectangularCubeTextureAssetTask object
  76715. * @param name defines the name of the task
  76716. * @param url defines the location of the file to load
  76717. * @param size defines the desired size (the more it increases the longer the generation will be)
  76718. * If the size is omitted this implies you are using a preprocessed cubemap.
  76719. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76720. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76721. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76722. * (default is true)
  76723. */
  76724. constructor(
  76725. /**
  76726. * Defines the name of the task
  76727. */
  76728. name: string,
  76729. /**
  76730. * Defines the location of the file to load
  76731. */
  76732. url: string,
  76733. /**
  76734. * Defines the desired size (the more it increases the longer the generation will be)
  76735. */
  76736. size: number,
  76737. /**
  76738. * Defines if mipmaps should not be generated (default is false)
  76739. */
  76740. noMipmap?: boolean,
  76741. /**
  76742. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76743. * but the standard material would require them in Gamma space) (default is true)
  76744. */
  76745. gammaSpace?: boolean);
  76746. /**
  76747. * Execute the current task
  76748. * @param scene defines the scene where you want your assets to be loaded
  76749. * @param onSuccess is a callback called when the task is successfully executed
  76750. * @param onError is a callback called if an error occurs
  76751. */
  76752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76753. }
  76754. /**
  76755. * This class can be used to easily import assets into a scene
  76756. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76757. */
  76758. export class AssetsManager {
  76759. private _scene;
  76760. private _isLoading;
  76761. protected _tasks: AbstractAssetTask[];
  76762. protected _waitingTasksCount: number;
  76763. protected _totalTasksCount: number;
  76764. /**
  76765. * Callback called when all tasks are processed
  76766. */
  76767. onFinish: (tasks: AbstractAssetTask[]) => void;
  76768. /**
  76769. * Callback called when a task is successful
  76770. */
  76771. onTaskSuccess: (task: AbstractAssetTask) => void;
  76772. /**
  76773. * Callback called when a task had an error
  76774. */
  76775. onTaskError: (task: AbstractAssetTask) => void;
  76776. /**
  76777. * Callback called when a task is done (whatever the result is)
  76778. */
  76779. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76780. /**
  76781. * Observable called when all tasks are processed
  76782. */
  76783. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76784. /**
  76785. * Observable called when a task had an error
  76786. */
  76787. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76788. /**
  76789. * Observable called when all tasks were executed
  76790. */
  76791. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76792. /**
  76793. * Observable called when a task is done (whatever the result is)
  76794. */
  76795. onProgressObservable: Observable<IAssetsProgressEvent>;
  76796. /**
  76797. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76798. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76799. */
  76800. useDefaultLoadingScreen: boolean;
  76801. /**
  76802. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76803. * when all assets have been downloaded.
  76804. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76805. */
  76806. autoHideLoadingUI: boolean;
  76807. /**
  76808. * Creates a new AssetsManager
  76809. * @param scene defines the scene to work on
  76810. */
  76811. constructor(scene: Scene);
  76812. /**
  76813. * Add a ContainerAssetTask to the list of active tasks
  76814. * @param taskName defines the name of the new task
  76815. * @param meshesNames defines the name of meshes to load
  76816. * @param rootUrl defines the root url to use to locate files
  76817. * @param sceneFilename defines the filename of the scene file
  76818. * @returns a new ContainerAssetTask object
  76819. */
  76820. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76821. /**
  76822. * Add a MeshAssetTask to the list of active tasks
  76823. * @param taskName defines the name of the new task
  76824. * @param meshesNames defines the name of meshes to load
  76825. * @param rootUrl defines the root url to use to locate files
  76826. * @param sceneFilename defines the filename of the scene file
  76827. * @returns a new MeshAssetTask object
  76828. */
  76829. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76830. /**
  76831. * Add a TextFileAssetTask to the list of active tasks
  76832. * @param taskName defines the name of the new task
  76833. * @param url defines the url of the file to load
  76834. * @returns a new TextFileAssetTask object
  76835. */
  76836. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76837. /**
  76838. * Add a BinaryFileAssetTask to the list of active tasks
  76839. * @param taskName defines the name of the new task
  76840. * @param url defines the url of the file to load
  76841. * @returns a new BinaryFileAssetTask object
  76842. */
  76843. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76844. /**
  76845. * Add a ImageAssetTask to the list of active tasks
  76846. * @param taskName defines the name of the new task
  76847. * @param url defines the url of the file to load
  76848. * @returns a new ImageAssetTask object
  76849. */
  76850. addImageTask(taskName: string, url: string): ImageAssetTask;
  76851. /**
  76852. * Add a TextureAssetTask to the list of active tasks
  76853. * @param taskName defines the name of the new task
  76854. * @param url defines the url of the file to load
  76855. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76856. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76857. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76858. * @returns a new TextureAssetTask object
  76859. */
  76860. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76861. /**
  76862. * Add a CubeTextureAssetTask to the list of active tasks
  76863. * @param taskName defines the name of the new task
  76864. * @param url defines the url of the file to load
  76865. * @param extensions defines the extension to use to load the cube map (can be null)
  76866. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76867. * @param files defines the list of files to load (can be null)
  76868. * @returns a new CubeTextureAssetTask object
  76869. */
  76870. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76871. /**
  76872. *
  76873. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76874. * @param taskName defines the name of the new task
  76875. * @param url defines the url of the file to load
  76876. * @param size defines the size you want for the cubemap (can be null)
  76877. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76878. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76879. * @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)
  76880. * @param reserved Internal use only
  76881. * @returns a new HDRCubeTextureAssetTask object
  76882. */
  76883. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76884. /**
  76885. *
  76886. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76887. * @param taskName defines the name of the new task
  76888. * @param url defines the url of the file to load
  76889. * @param size defines the size you want for the cubemap (can be null)
  76890. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76891. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76892. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76893. * @returns a new EquiRectangularCubeTextureAssetTask object
  76894. */
  76895. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76896. /**
  76897. * Remove a task from the assets manager.
  76898. * @param task the task to remove
  76899. */
  76900. removeTask(task: AbstractAssetTask): void;
  76901. private _decreaseWaitingTasksCount;
  76902. private _runTask;
  76903. /**
  76904. * Reset the AssetsManager and remove all tasks
  76905. * @return the current instance of the AssetsManager
  76906. */
  76907. reset(): AssetsManager;
  76908. /**
  76909. * Start the loading process
  76910. * @return the current instance of the AssetsManager
  76911. */
  76912. load(): AssetsManager;
  76913. /**
  76914. * Start the loading process as an async operation
  76915. * @return a promise returning the list of failed tasks
  76916. */
  76917. loadAsync(): Promise<void>;
  76918. }
  76919. }
  76920. declare module "babylonjs/Misc/deferred" {
  76921. /**
  76922. * Wrapper class for promise with external resolve and reject.
  76923. */
  76924. export class Deferred<T> {
  76925. /**
  76926. * The promise associated with this deferred object.
  76927. */
  76928. readonly promise: Promise<T>;
  76929. private _resolve;
  76930. private _reject;
  76931. /**
  76932. * The resolve method of the promise associated with this deferred object.
  76933. */
  76934. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76935. /**
  76936. * The reject method of the promise associated with this deferred object.
  76937. */
  76938. get reject(): (reason?: any) => void;
  76939. /**
  76940. * Constructor for this deferred object.
  76941. */
  76942. constructor();
  76943. }
  76944. }
  76945. declare module "babylonjs/Misc/meshExploder" {
  76946. import { Mesh } from "babylonjs/Meshes/mesh";
  76947. /**
  76948. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76949. */
  76950. export class MeshExploder {
  76951. private _centerMesh;
  76952. private _meshes;
  76953. private _meshesOrigins;
  76954. private _toCenterVectors;
  76955. private _scaledDirection;
  76956. private _newPosition;
  76957. private _centerPosition;
  76958. /**
  76959. * Explodes meshes from a center mesh.
  76960. * @param meshes The meshes to explode.
  76961. * @param centerMesh The mesh to be center of explosion.
  76962. */
  76963. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76964. private _setCenterMesh;
  76965. /**
  76966. * Get class name
  76967. * @returns "MeshExploder"
  76968. */
  76969. getClassName(): string;
  76970. /**
  76971. * "Exploded meshes"
  76972. * @returns Array of meshes with the centerMesh at index 0.
  76973. */
  76974. getMeshes(): Array<Mesh>;
  76975. /**
  76976. * Explodes meshes giving a specific direction
  76977. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76978. */
  76979. explode(direction?: number): void;
  76980. }
  76981. }
  76982. declare module "babylonjs/Misc/filesInput" {
  76983. import { Engine } from "babylonjs/Engines/engine";
  76984. import { Scene } from "babylonjs/scene";
  76985. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76986. import { Nullable } from "babylonjs/types";
  76987. /**
  76988. * Class used to help managing file picking and drag'n'drop
  76989. */
  76990. export class FilesInput {
  76991. /**
  76992. * List of files ready to be loaded
  76993. */
  76994. static get FilesToLoad(): {
  76995. [key: string]: File;
  76996. };
  76997. /**
  76998. * Callback called when a file is processed
  76999. */
  77000. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77001. private _engine;
  77002. private _currentScene;
  77003. private _sceneLoadedCallback;
  77004. private _progressCallback;
  77005. private _additionalRenderLoopLogicCallback;
  77006. private _textureLoadingCallback;
  77007. private _startingProcessingFilesCallback;
  77008. private _onReloadCallback;
  77009. private _errorCallback;
  77010. private _elementToMonitor;
  77011. private _sceneFileToLoad;
  77012. private _filesToLoad;
  77013. /**
  77014. * Creates a new FilesInput
  77015. * @param engine defines the rendering engine
  77016. * @param scene defines the hosting scene
  77017. * @param sceneLoadedCallback callback called when scene is loaded
  77018. * @param progressCallback callback called to track progress
  77019. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77020. * @param textureLoadingCallback callback called when a texture is loading
  77021. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77022. * @param onReloadCallback callback called when a reload is requested
  77023. * @param errorCallback callback call if an error occurs
  77024. */
  77025. 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>);
  77026. private _dragEnterHandler;
  77027. private _dragOverHandler;
  77028. private _dropHandler;
  77029. /**
  77030. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77031. * @param elementToMonitor defines the DOM element to track
  77032. */
  77033. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77034. /** Gets the current list of files to load */
  77035. get filesToLoad(): File[];
  77036. /**
  77037. * Release all associated resources
  77038. */
  77039. dispose(): void;
  77040. private renderFunction;
  77041. private drag;
  77042. private drop;
  77043. private _traverseFolder;
  77044. private _processFiles;
  77045. /**
  77046. * Load files from a drop event
  77047. * @param event defines the drop event to use as source
  77048. */
  77049. loadFiles(event: any): void;
  77050. private _processReload;
  77051. /**
  77052. * Reload the current scene from the loaded files
  77053. */
  77054. reload(): void;
  77055. }
  77056. }
  77057. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77058. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77059. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77060. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77061. }
  77062. declare module "babylonjs/Misc/sceneOptimizer" {
  77063. import { Scene, IDisposable } from "babylonjs/scene";
  77064. import { Observable } from "babylonjs/Misc/observable";
  77065. /**
  77066. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77067. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77068. */
  77069. export class SceneOptimization {
  77070. /**
  77071. * Defines the priority of this optimization (0 by default which means first in the list)
  77072. */
  77073. priority: number;
  77074. /**
  77075. * Gets a string describing the action executed by the current optimization
  77076. * @returns description string
  77077. */
  77078. getDescription(): string;
  77079. /**
  77080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77081. * @param scene defines the current scene where to apply this optimization
  77082. * @param optimizer defines the current optimizer
  77083. * @returns true if everything that can be done was applied
  77084. */
  77085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77086. /**
  77087. * Creates the SceneOptimization object
  77088. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77089. * @param desc defines the description associated with the optimization
  77090. */
  77091. constructor(
  77092. /**
  77093. * Defines the priority of this optimization (0 by default which means first in the list)
  77094. */
  77095. priority?: number);
  77096. }
  77097. /**
  77098. * Defines an optimization used to reduce the size of render target textures
  77099. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77100. */
  77101. export class TextureOptimization extends SceneOptimization {
  77102. /**
  77103. * Defines the priority of this optimization (0 by default which means first in the list)
  77104. */
  77105. priority: number;
  77106. /**
  77107. * 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
  77108. */
  77109. maximumSize: number;
  77110. /**
  77111. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77112. */
  77113. step: number;
  77114. /**
  77115. * Gets a string describing the action executed by the current optimization
  77116. * @returns description string
  77117. */
  77118. getDescription(): string;
  77119. /**
  77120. * Creates the TextureOptimization object
  77121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77122. * @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
  77123. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77124. */
  77125. constructor(
  77126. /**
  77127. * Defines the priority of this optimization (0 by default which means first in the list)
  77128. */
  77129. priority?: number,
  77130. /**
  77131. * 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
  77132. */
  77133. maximumSize?: number,
  77134. /**
  77135. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77136. */
  77137. step?: number);
  77138. /**
  77139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77140. * @param scene defines the current scene where to apply this optimization
  77141. * @param optimizer defines the current optimizer
  77142. * @returns true if everything that can be done was applied
  77143. */
  77144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77145. }
  77146. /**
  77147. * Defines an optimization used to increase or decrease the rendering resolution
  77148. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77149. */
  77150. export class HardwareScalingOptimization extends SceneOptimization {
  77151. /**
  77152. * Defines the priority of this optimization (0 by default which means first in the list)
  77153. */
  77154. priority: number;
  77155. /**
  77156. * Defines the maximum scale to use (2 by default)
  77157. */
  77158. maximumScale: number;
  77159. /**
  77160. * Defines the step to use between two passes (0.5 by default)
  77161. */
  77162. step: number;
  77163. private _currentScale;
  77164. private _directionOffset;
  77165. /**
  77166. * Gets a string describing the action executed by the current optimization
  77167. * @return description string
  77168. */
  77169. getDescription(): string;
  77170. /**
  77171. * Creates the HardwareScalingOptimization object
  77172. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77173. * @param maximumScale defines the maximum scale to use (2 by default)
  77174. * @param step defines the step to use between two passes (0.5 by default)
  77175. */
  77176. constructor(
  77177. /**
  77178. * Defines the priority of this optimization (0 by default which means first in the list)
  77179. */
  77180. priority?: number,
  77181. /**
  77182. * Defines the maximum scale to use (2 by default)
  77183. */
  77184. maximumScale?: number,
  77185. /**
  77186. * Defines the step to use between two passes (0.5 by default)
  77187. */
  77188. step?: number);
  77189. /**
  77190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77191. * @param scene defines the current scene where to apply this optimization
  77192. * @param optimizer defines the current optimizer
  77193. * @returns true if everything that can be done was applied
  77194. */
  77195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77196. }
  77197. /**
  77198. * Defines an optimization used to remove shadows
  77199. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77200. */
  77201. export class ShadowsOptimization extends SceneOptimization {
  77202. /**
  77203. * Gets a string describing the action executed by the current optimization
  77204. * @return description string
  77205. */
  77206. getDescription(): string;
  77207. /**
  77208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77209. * @param scene defines the current scene where to apply this optimization
  77210. * @param optimizer defines the current optimizer
  77211. * @returns true if everything that can be done was applied
  77212. */
  77213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77214. }
  77215. /**
  77216. * Defines an optimization used to turn post-processes off
  77217. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77218. */
  77219. export class PostProcessesOptimization extends SceneOptimization {
  77220. /**
  77221. * Gets a string describing the action executed by the current optimization
  77222. * @return description string
  77223. */
  77224. getDescription(): string;
  77225. /**
  77226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77227. * @param scene defines the current scene where to apply this optimization
  77228. * @param optimizer defines the current optimizer
  77229. * @returns true if everything that can be done was applied
  77230. */
  77231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77232. }
  77233. /**
  77234. * Defines an optimization used to turn lens flares off
  77235. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77236. */
  77237. export class LensFlaresOptimization extends SceneOptimization {
  77238. /**
  77239. * Gets a string describing the action executed by the current optimization
  77240. * @return description string
  77241. */
  77242. getDescription(): string;
  77243. /**
  77244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77245. * @param scene defines the current scene where to apply this optimization
  77246. * @param optimizer defines the current optimizer
  77247. * @returns true if everything that can be done was applied
  77248. */
  77249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77250. }
  77251. /**
  77252. * Defines an optimization based on user defined callback.
  77253. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77254. */
  77255. export class CustomOptimization extends SceneOptimization {
  77256. /**
  77257. * Callback called to apply the custom optimization.
  77258. */
  77259. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77260. /**
  77261. * Callback called to get custom description
  77262. */
  77263. onGetDescription: () => string;
  77264. /**
  77265. * Gets a string describing the action executed by the current optimization
  77266. * @returns description string
  77267. */
  77268. getDescription(): string;
  77269. /**
  77270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77271. * @param scene defines the current scene where to apply this optimization
  77272. * @param optimizer defines the current optimizer
  77273. * @returns true if everything that can be done was applied
  77274. */
  77275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77276. }
  77277. /**
  77278. * Defines an optimization used to turn particles off
  77279. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77280. */
  77281. export class ParticlesOptimization extends SceneOptimization {
  77282. /**
  77283. * Gets a string describing the action executed by the current optimization
  77284. * @return description string
  77285. */
  77286. getDescription(): string;
  77287. /**
  77288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77289. * @param scene defines the current scene where to apply this optimization
  77290. * @param optimizer defines the current optimizer
  77291. * @returns true if everything that can be done was applied
  77292. */
  77293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77294. }
  77295. /**
  77296. * Defines an optimization used to turn render targets off
  77297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77298. */
  77299. export class RenderTargetsOptimization extends SceneOptimization {
  77300. /**
  77301. * Gets a string describing the action executed by the current optimization
  77302. * @return description string
  77303. */
  77304. getDescription(): string;
  77305. /**
  77306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77307. * @param scene defines the current scene where to apply this optimization
  77308. * @param optimizer defines the current optimizer
  77309. * @returns true if everything that can be done was applied
  77310. */
  77311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77312. }
  77313. /**
  77314. * Defines an optimization used to merge meshes with compatible materials
  77315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77316. */
  77317. export class MergeMeshesOptimization extends SceneOptimization {
  77318. private static _UpdateSelectionTree;
  77319. /**
  77320. * Gets or sets a boolean which defines if optimization octree has to be updated
  77321. */
  77322. static get UpdateSelectionTree(): boolean;
  77323. /**
  77324. * Gets or sets a boolean which defines if optimization octree has to be updated
  77325. */
  77326. static set UpdateSelectionTree(value: boolean);
  77327. /**
  77328. * Gets a string describing the action executed by the current optimization
  77329. * @return description string
  77330. */
  77331. getDescription(): string;
  77332. private _canBeMerged;
  77333. /**
  77334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77335. * @param scene defines the current scene where to apply this optimization
  77336. * @param optimizer defines the current optimizer
  77337. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77338. * @returns true if everything that can be done was applied
  77339. */
  77340. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77341. }
  77342. /**
  77343. * Defines a list of options used by SceneOptimizer
  77344. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77345. */
  77346. export class SceneOptimizerOptions {
  77347. /**
  77348. * Defines the target frame rate to reach (60 by default)
  77349. */
  77350. targetFrameRate: number;
  77351. /**
  77352. * Defines the interval between two checkes (2000ms by default)
  77353. */
  77354. trackerDuration: number;
  77355. /**
  77356. * Gets the list of optimizations to apply
  77357. */
  77358. optimizations: SceneOptimization[];
  77359. /**
  77360. * Creates a new list of options used by SceneOptimizer
  77361. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77362. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77363. */
  77364. constructor(
  77365. /**
  77366. * Defines the target frame rate to reach (60 by default)
  77367. */
  77368. targetFrameRate?: number,
  77369. /**
  77370. * Defines the interval between two checkes (2000ms by default)
  77371. */
  77372. trackerDuration?: number);
  77373. /**
  77374. * Add a new optimization
  77375. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77376. * @returns the current SceneOptimizerOptions
  77377. */
  77378. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77379. /**
  77380. * Add a new custom optimization
  77381. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77382. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77383. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77384. * @returns the current SceneOptimizerOptions
  77385. */
  77386. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77387. /**
  77388. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77389. * @param targetFrameRate defines the target frame rate (60 by default)
  77390. * @returns a SceneOptimizerOptions object
  77391. */
  77392. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77393. /**
  77394. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77395. * @param targetFrameRate defines the target frame rate (60 by default)
  77396. * @returns a SceneOptimizerOptions object
  77397. */
  77398. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77399. /**
  77400. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77401. * @param targetFrameRate defines the target frame rate (60 by default)
  77402. * @returns a SceneOptimizerOptions object
  77403. */
  77404. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77405. }
  77406. /**
  77407. * Class used to run optimizations in order to reach a target frame rate
  77408. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77409. */
  77410. export class SceneOptimizer implements IDisposable {
  77411. private _isRunning;
  77412. private _options;
  77413. private _scene;
  77414. private _currentPriorityLevel;
  77415. private _targetFrameRate;
  77416. private _trackerDuration;
  77417. private _currentFrameRate;
  77418. private _sceneDisposeObserver;
  77419. private _improvementMode;
  77420. /**
  77421. * Defines an observable called when the optimizer reaches the target frame rate
  77422. */
  77423. onSuccessObservable: Observable<SceneOptimizer>;
  77424. /**
  77425. * Defines an observable called when the optimizer enables an optimization
  77426. */
  77427. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77428. /**
  77429. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77430. */
  77431. onFailureObservable: Observable<SceneOptimizer>;
  77432. /**
  77433. * Gets a boolean indicating if the optimizer is in improvement mode
  77434. */
  77435. get isInImprovementMode(): boolean;
  77436. /**
  77437. * Gets the current priority level (0 at start)
  77438. */
  77439. get currentPriorityLevel(): number;
  77440. /**
  77441. * Gets the current frame rate checked by the SceneOptimizer
  77442. */
  77443. get currentFrameRate(): number;
  77444. /**
  77445. * Gets or sets the current target frame rate (60 by default)
  77446. */
  77447. get targetFrameRate(): number;
  77448. /**
  77449. * Gets or sets the current target frame rate (60 by default)
  77450. */
  77451. set targetFrameRate(value: number);
  77452. /**
  77453. * Gets or sets the current interval between two checks (every 2000ms by default)
  77454. */
  77455. get trackerDuration(): number;
  77456. /**
  77457. * Gets or sets the current interval between two checks (every 2000ms by default)
  77458. */
  77459. set trackerDuration(value: number);
  77460. /**
  77461. * Gets the list of active optimizations
  77462. */
  77463. get optimizations(): SceneOptimization[];
  77464. /**
  77465. * Creates a new SceneOptimizer
  77466. * @param scene defines the scene to work on
  77467. * @param options defines the options to use with the SceneOptimizer
  77468. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77469. * @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)
  77470. */
  77471. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77472. /**
  77473. * Stops the current optimizer
  77474. */
  77475. stop(): void;
  77476. /**
  77477. * Reset the optimizer to initial step (current priority level = 0)
  77478. */
  77479. reset(): void;
  77480. /**
  77481. * Start the optimizer. By default it will try to reach a specific framerate
  77482. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77483. */
  77484. start(): void;
  77485. private _checkCurrentState;
  77486. /**
  77487. * Release all resources
  77488. */
  77489. dispose(): void;
  77490. /**
  77491. * Helper function to create a SceneOptimizer with one single line of code
  77492. * @param scene defines the scene to work on
  77493. * @param options defines the options to use with the SceneOptimizer
  77494. * @param onSuccess defines a callback to call on success
  77495. * @param onFailure defines a callback to call on failure
  77496. * @returns the new SceneOptimizer object
  77497. */
  77498. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77499. }
  77500. }
  77501. declare module "babylonjs/Misc/sceneSerializer" {
  77502. import { Scene } from "babylonjs/scene";
  77503. /**
  77504. * Class used to serialize a scene into a string
  77505. */
  77506. export class SceneSerializer {
  77507. /**
  77508. * Clear cache used by a previous serialization
  77509. */
  77510. static ClearCache(): void;
  77511. /**
  77512. * Serialize a scene into a JSON compatible object
  77513. * @param scene defines the scene to serialize
  77514. * @returns a JSON compatible object
  77515. */
  77516. static Serialize(scene: Scene): any;
  77517. /**
  77518. * Serialize a mesh into a JSON compatible object
  77519. * @param toSerialize defines the mesh to serialize
  77520. * @param withParents defines if parents must be serialized as well
  77521. * @param withChildren defines if children must be serialized as well
  77522. * @returns a JSON compatible object
  77523. */
  77524. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77525. }
  77526. }
  77527. declare module "babylonjs/Misc/textureTools" {
  77528. import { Texture } from "babylonjs/Materials/Textures/texture";
  77529. /**
  77530. * Class used to host texture specific utilities
  77531. */
  77532. export class TextureTools {
  77533. /**
  77534. * Uses the GPU to create a copy texture rescaled at a given size
  77535. * @param texture Texture to copy from
  77536. * @param width defines the desired width
  77537. * @param height defines the desired height
  77538. * @param useBilinearMode defines if bilinear mode has to be used
  77539. * @return the generated texture
  77540. */
  77541. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77542. }
  77543. }
  77544. declare module "babylonjs/Misc/videoRecorder" {
  77545. import { Nullable } from "babylonjs/types";
  77546. import { Engine } from "babylonjs/Engines/engine";
  77547. /**
  77548. * This represents the different options available for the video capture.
  77549. */
  77550. export interface VideoRecorderOptions {
  77551. /** Defines the mime type of the video. */
  77552. mimeType: string;
  77553. /** Defines the FPS the video should be recorded at. */
  77554. fps: number;
  77555. /** Defines the chunk size for the recording data. */
  77556. recordChunckSize: number;
  77557. /** The audio tracks to attach to the recording. */
  77558. audioTracks?: MediaStreamTrack[];
  77559. }
  77560. /**
  77561. * This can help with recording videos from BabylonJS.
  77562. * This is based on the available WebRTC functionalities of the browser.
  77563. *
  77564. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77565. */
  77566. export class VideoRecorder {
  77567. private static readonly _defaultOptions;
  77568. /**
  77569. * Returns whether or not the VideoRecorder is available in your browser.
  77570. * @param engine Defines the Babylon Engine.
  77571. * @returns true if supported otherwise false.
  77572. */
  77573. static IsSupported(engine: Engine): boolean;
  77574. private readonly _options;
  77575. private _canvas;
  77576. private _mediaRecorder;
  77577. private _recordedChunks;
  77578. private _fileName;
  77579. private _resolve;
  77580. private _reject;
  77581. /**
  77582. * True when a recording is already in progress.
  77583. */
  77584. get isRecording(): boolean;
  77585. /**
  77586. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77587. * @param engine Defines the BabylonJS Engine you wish to record.
  77588. * @param options Defines options that can be used to customize the capture.
  77589. */
  77590. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77591. /**
  77592. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77593. */
  77594. stopRecording(): void;
  77595. /**
  77596. * Starts recording the canvas for a max duration specified in parameters.
  77597. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77598. * If null no automatic download will start and you can rely on the promise to get the data back.
  77599. * @param maxDuration Defines the maximum recording time in seconds.
  77600. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77601. * @return A promise callback at the end of the recording with the video data in Blob.
  77602. */
  77603. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77604. /**
  77605. * Releases internal resources used during the recording.
  77606. */
  77607. dispose(): void;
  77608. private _handleDataAvailable;
  77609. private _handleError;
  77610. private _handleStop;
  77611. }
  77612. }
  77613. declare module "babylonjs/Misc/screenshotTools" {
  77614. import { Camera } from "babylonjs/Cameras/camera";
  77615. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77616. import { Engine } from "babylonjs/Engines/engine";
  77617. /**
  77618. * Class containing a set of static utilities functions for screenshots
  77619. */
  77620. export class ScreenshotTools {
  77621. /**
  77622. * Captures a screenshot of the current rendering
  77623. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77624. * @param engine defines the rendering engine
  77625. * @param camera defines the source camera
  77626. * @param size This parameter can be set to a single number or to an object with the
  77627. * following (optional) properties: precision, width, height. If a single number is passed,
  77628. * it will be used for both width and height. If an object is passed, the screenshot size
  77629. * will be derived from the parameters. The precision property is a multiplier allowing
  77630. * rendering at a higher or lower resolution
  77631. * @param successCallback defines the callback receives a single parameter which contains the
  77632. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77633. * src parameter of an <img> to display it
  77634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77635. * Check your browser for supported MIME types
  77636. */
  77637. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77638. /**
  77639. * Captures a screenshot of the current rendering
  77640. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77641. * @param engine defines the rendering engine
  77642. * @param camera defines the source camera
  77643. * @param size This parameter can be set to a single number or to an object with the
  77644. * following (optional) properties: precision, width, height. If a single number is passed,
  77645. * it will be used for both width and height. If an object is passed, the screenshot size
  77646. * will be derived from the parameters. The precision property is a multiplier allowing
  77647. * rendering at a higher or lower resolution
  77648. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77649. * Check your browser for supported MIME types
  77650. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77651. * to the src parameter of an <img> to display it
  77652. */
  77653. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77654. /**
  77655. * Generates an image screenshot from the specified camera.
  77656. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77657. * @param engine The engine to use for rendering
  77658. * @param camera The camera to use for rendering
  77659. * @param size This parameter can be set to a single number or to an object with the
  77660. * following (optional) properties: precision, width, height. If a single number is passed,
  77661. * it will be used for both width and height. If an object is passed, the screenshot size
  77662. * will be derived from the parameters. The precision property is a multiplier allowing
  77663. * rendering at a higher or lower resolution
  77664. * @param successCallback The callback receives a single parameter which contains the
  77665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77666. * src parameter of an <img> to display it
  77667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77668. * Check your browser for supported MIME types
  77669. * @param samples Texture samples (default: 1)
  77670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77671. * @param fileName A name for for the downloaded file.
  77672. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77673. */
  77674. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77675. /**
  77676. * Generates an image screenshot from the specified camera.
  77677. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77678. * @param engine The engine to use for rendering
  77679. * @param camera The camera to use for rendering
  77680. * @param size This parameter can be set to a single number or to an object with the
  77681. * following (optional) properties: precision, width, height. If a single number is passed,
  77682. * it will be used for both width and height. If an object is passed, the screenshot size
  77683. * will be derived from the parameters. The precision property is a multiplier allowing
  77684. * rendering at a higher or lower resolution
  77685. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77686. * Check your browser for supported MIME types
  77687. * @param samples Texture samples (default: 1)
  77688. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77689. * @param fileName A name for for the downloaded file.
  77690. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77691. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77692. * to the src parameter of an <img> to display it
  77693. */
  77694. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77695. /**
  77696. * Gets height and width for screenshot size
  77697. * @private
  77698. */
  77699. private static _getScreenshotSize;
  77700. }
  77701. }
  77702. declare module "babylonjs/Misc/dataReader" {
  77703. /**
  77704. * Interface for a data buffer
  77705. */
  77706. export interface IDataBuffer {
  77707. /**
  77708. * Reads bytes from the data buffer.
  77709. * @param byteOffset The byte offset to read
  77710. * @param byteLength The byte length to read
  77711. * @returns A promise that resolves when the bytes are read
  77712. */
  77713. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77714. /**
  77715. * The byte length of the buffer.
  77716. */
  77717. readonly byteLength: number;
  77718. }
  77719. /**
  77720. * Utility class for reading from a data buffer
  77721. */
  77722. export class DataReader {
  77723. /**
  77724. * The data buffer associated with this data reader.
  77725. */
  77726. readonly buffer: IDataBuffer;
  77727. /**
  77728. * The current byte offset from the beginning of the data buffer.
  77729. */
  77730. byteOffset: number;
  77731. private _dataView;
  77732. private _dataByteOffset;
  77733. /**
  77734. * Constructor
  77735. * @param buffer The buffer to read
  77736. */
  77737. constructor(buffer: IDataBuffer);
  77738. /**
  77739. * Loads the given byte length.
  77740. * @param byteLength The byte length to load
  77741. * @returns A promise that resolves when the load is complete
  77742. */
  77743. loadAsync(byteLength: number): Promise<void>;
  77744. /**
  77745. * Read a unsigned 32-bit integer from the currently loaded data range.
  77746. * @returns The 32-bit integer read
  77747. */
  77748. readUint32(): number;
  77749. /**
  77750. * Read a byte array from the currently loaded data range.
  77751. * @param byteLength The byte length to read
  77752. * @returns The byte array read
  77753. */
  77754. readUint8Array(byteLength: number): Uint8Array;
  77755. /**
  77756. * Read a string from the currently loaded data range.
  77757. * @param byteLength The byte length to read
  77758. * @returns The string read
  77759. */
  77760. readString(byteLength: number): string;
  77761. /**
  77762. * Skips the given byte length the currently loaded data range.
  77763. * @param byteLength The byte length to skip
  77764. */
  77765. skipBytes(byteLength: number): void;
  77766. }
  77767. }
  77768. declare module "babylonjs/Misc/dataStorage" {
  77769. /**
  77770. * Class for storing data to local storage if available or in-memory storage otherwise
  77771. */
  77772. export class DataStorage {
  77773. private static _Storage;
  77774. private static _GetStorage;
  77775. /**
  77776. * Reads a string from the data storage
  77777. * @param key The key to read
  77778. * @param defaultValue The value if the key doesn't exist
  77779. * @returns The string value
  77780. */
  77781. static ReadString(key: string, defaultValue: string): string;
  77782. /**
  77783. * Writes a string to the data storage
  77784. * @param key The key to write
  77785. * @param value The value to write
  77786. */
  77787. static WriteString(key: string, value: string): void;
  77788. /**
  77789. * Reads a boolean from the data storage
  77790. * @param key The key to read
  77791. * @param defaultValue The value if the key doesn't exist
  77792. * @returns The boolean value
  77793. */
  77794. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77795. /**
  77796. * Writes a boolean to the data storage
  77797. * @param key The key to write
  77798. * @param value The value to write
  77799. */
  77800. static WriteBoolean(key: string, value: boolean): void;
  77801. /**
  77802. * Reads a number from the data storage
  77803. * @param key The key to read
  77804. * @param defaultValue The value if the key doesn't exist
  77805. * @returns The number value
  77806. */
  77807. static ReadNumber(key: string, defaultValue: number): number;
  77808. /**
  77809. * Writes a number to the data storage
  77810. * @param key The key to write
  77811. * @param value The value to write
  77812. */
  77813. static WriteNumber(key: string, value: number): void;
  77814. }
  77815. }
  77816. declare module "babylonjs/Misc/sceneRecorder" {
  77817. import { Scene } from "babylonjs/scene";
  77818. /**
  77819. * Class used to record delta files between 2 scene states
  77820. */
  77821. export class SceneRecorder {
  77822. private _trackedScene;
  77823. private _savedJSON;
  77824. /**
  77825. * Track a given scene. This means the current scene state will be considered the original state
  77826. * @param scene defines the scene to track
  77827. */
  77828. track(scene: Scene): void;
  77829. /**
  77830. * Get the delta between current state and original state
  77831. * @returns a string containing the delta
  77832. */
  77833. getDelta(): any;
  77834. private _compareArray;
  77835. private _compareObjects;
  77836. private _compareCollections;
  77837. private static GetShadowGeneratorById;
  77838. /**
  77839. * Apply a given delta to a given scene
  77840. * @param deltaJSON defines the JSON containing the delta
  77841. * @param scene defines the scene to apply the delta to
  77842. */
  77843. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77844. private static _ApplyPropertiesToEntity;
  77845. private static _ApplyDeltaForEntity;
  77846. }
  77847. }
  77848. declare module "babylonjs/Misc/index" {
  77849. export * from "babylonjs/Misc/andOrNotEvaluator";
  77850. export * from "babylonjs/Misc/assetsManager";
  77851. export * from "babylonjs/Misc/basis";
  77852. export * from "babylonjs/Misc/dds";
  77853. export * from "babylonjs/Misc/decorators";
  77854. export * from "babylonjs/Misc/deferred";
  77855. export * from "babylonjs/Misc/environmentTextureTools";
  77856. export * from "babylonjs/Misc/meshExploder";
  77857. export * from "babylonjs/Misc/filesInput";
  77858. export * from "babylonjs/Misc/HighDynamicRange/index";
  77859. export * from "babylonjs/Misc/khronosTextureContainer";
  77860. export * from "babylonjs/Misc/observable";
  77861. export * from "babylonjs/Misc/performanceMonitor";
  77862. export * from "babylonjs/Misc/promise";
  77863. export * from "babylonjs/Misc/sceneOptimizer";
  77864. export * from "babylonjs/Misc/sceneSerializer";
  77865. export * from "babylonjs/Misc/smartArray";
  77866. export * from "babylonjs/Misc/stringDictionary";
  77867. export * from "babylonjs/Misc/tags";
  77868. export * from "babylonjs/Misc/textureTools";
  77869. export * from "babylonjs/Misc/tga";
  77870. export * from "babylonjs/Misc/tools";
  77871. export * from "babylonjs/Misc/videoRecorder";
  77872. export * from "babylonjs/Misc/virtualJoystick";
  77873. export * from "babylonjs/Misc/workerPool";
  77874. export * from "babylonjs/Misc/logger";
  77875. export * from "babylonjs/Misc/typeStore";
  77876. export * from "babylonjs/Misc/filesInputStore";
  77877. export * from "babylonjs/Misc/deepCopier";
  77878. export * from "babylonjs/Misc/pivotTools";
  77879. export * from "babylonjs/Misc/precisionDate";
  77880. export * from "babylonjs/Misc/screenshotTools";
  77881. export * from "babylonjs/Misc/typeStore";
  77882. export * from "babylonjs/Misc/webRequest";
  77883. export * from "babylonjs/Misc/iInspectable";
  77884. export * from "babylonjs/Misc/brdfTextureTools";
  77885. export * from "babylonjs/Misc/rgbdTextureTools";
  77886. export * from "babylonjs/Misc/gradients";
  77887. export * from "babylonjs/Misc/perfCounter";
  77888. export * from "babylonjs/Misc/fileRequest";
  77889. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77890. export * from "babylonjs/Misc/retryStrategy";
  77891. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77892. export * from "babylonjs/Misc/canvasGenerator";
  77893. export * from "babylonjs/Misc/fileTools";
  77894. export * from "babylonjs/Misc/stringTools";
  77895. export * from "babylonjs/Misc/dataReader";
  77896. export * from "babylonjs/Misc/minMaxReducer";
  77897. export * from "babylonjs/Misc/depthReducer";
  77898. export * from "babylonjs/Misc/dataStorage";
  77899. export * from "babylonjs/Misc/sceneRecorder";
  77900. }
  77901. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77902. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77903. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77904. import { Observable } from "babylonjs/Misc/observable";
  77905. import { Matrix } from "babylonjs/Maths/math.vector";
  77906. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77907. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77908. /**
  77909. * An interface for all Hit test features
  77910. */
  77911. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77912. /**
  77913. * Triggered when new babylon (transformed) hit test results are available
  77914. */
  77915. onHitTestResultObservable: Observable<T[]>;
  77916. }
  77917. /**
  77918. * Options used for hit testing
  77919. */
  77920. export interface IWebXRLegacyHitTestOptions {
  77921. /**
  77922. * Only test when user interacted with the scene. Default - hit test every frame
  77923. */
  77924. testOnPointerDownOnly?: boolean;
  77925. /**
  77926. * The node to use to transform the local results to world coordinates
  77927. */
  77928. worldParentNode?: TransformNode;
  77929. }
  77930. /**
  77931. * Interface defining the babylon result of raycasting/hit-test
  77932. */
  77933. export interface IWebXRLegacyHitResult {
  77934. /**
  77935. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77936. */
  77937. transformationMatrix: Matrix;
  77938. /**
  77939. * The native hit test result
  77940. */
  77941. xrHitResult: XRHitResult | XRHitTestResult;
  77942. }
  77943. /**
  77944. * The currently-working hit-test module.
  77945. * Hit test (or Ray-casting) is used to interact with the real world.
  77946. * For further information read here - https://github.com/immersive-web/hit-test
  77947. */
  77948. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77949. /**
  77950. * options to use when constructing this feature
  77951. */
  77952. readonly options: IWebXRLegacyHitTestOptions;
  77953. private _direction;
  77954. private _mat;
  77955. private _onSelectEnabled;
  77956. private _origin;
  77957. /**
  77958. * The module's name
  77959. */
  77960. static readonly Name: string;
  77961. /**
  77962. * The (Babylon) version of this module.
  77963. * This is an integer representing the implementation version.
  77964. * This number does not correspond to the WebXR specs version
  77965. */
  77966. static readonly Version: number;
  77967. /**
  77968. * Populated with the last native XR Hit Results
  77969. */
  77970. lastNativeXRHitResults: XRHitResult[];
  77971. /**
  77972. * Triggered when new babylon (transformed) hit test results are available
  77973. */
  77974. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77975. /**
  77976. * Creates a new instance of the (legacy version) hit test feature
  77977. * @param _xrSessionManager an instance of WebXRSessionManager
  77978. * @param options options to use when constructing this feature
  77979. */
  77980. constructor(_xrSessionManager: WebXRSessionManager,
  77981. /**
  77982. * options to use when constructing this feature
  77983. */
  77984. options?: IWebXRLegacyHitTestOptions);
  77985. /**
  77986. * execute a hit test with an XR Ray
  77987. *
  77988. * @param xrSession a native xrSession that will execute this hit test
  77989. * @param xrRay the ray (position and direction) to use for ray-casting
  77990. * @param referenceSpace native XR reference space to use for the hit-test
  77991. * @param filter filter function that will filter the results
  77992. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77993. */
  77994. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77995. /**
  77996. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77997. * @param event the (select) event to use to select with
  77998. * @param referenceSpace the reference space to use for this hit test
  77999. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78000. */
  78001. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78002. /**
  78003. * attach this feature
  78004. * Will usually be called by the features manager
  78005. *
  78006. * @returns true if successful.
  78007. */
  78008. attach(): boolean;
  78009. /**
  78010. * detach this feature.
  78011. * Will usually be called by the features manager
  78012. *
  78013. * @returns true if successful.
  78014. */
  78015. detach(): boolean;
  78016. /**
  78017. * Dispose this feature and all of the resources attached
  78018. */
  78019. dispose(): void;
  78020. protected _onXRFrame(frame: XRFrame): void;
  78021. private _onHitTestResults;
  78022. private _onSelect;
  78023. }
  78024. }
  78025. declare module "babylonjs/XR/features/WebXRHitTest" {
  78026. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78027. import { Observable } from "babylonjs/Misc/observable";
  78028. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78029. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78030. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78031. /**
  78032. * Options used for hit testing (version 2)
  78033. */
  78034. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78035. /**
  78036. * Do not create a permanent hit test. Will usually be used when only
  78037. * transient inputs are needed.
  78038. */
  78039. disablePermanentHitTest?: boolean;
  78040. /**
  78041. * Enable transient (for example touch-based) hit test inspections
  78042. */
  78043. enableTransientHitTest?: boolean;
  78044. /**
  78045. * Offset ray for the permanent hit test
  78046. */
  78047. offsetRay?: Vector3;
  78048. /**
  78049. * Offset ray for the transient hit test
  78050. */
  78051. transientOffsetRay?: Vector3;
  78052. /**
  78053. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78054. */
  78055. useReferenceSpace?: boolean;
  78056. }
  78057. /**
  78058. * Interface defining the babylon result of hit-test
  78059. */
  78060. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78061. /**
  78062. * The input source that generated this hit test (if transient)
  78063. */
  78064. inputSource?: XRInputSource;
  78065. /**
  78066. * Is this a transient hit test
  78067. */
  78068. isTransient?: boolean;
  78069. /**
  78070. * Position of the hit test result
  78071. */
  78072. position: Vector3;
  78073. /**
  78074. * Rotation of the hit test result
  78075. */
  78076. rotationQuaternion: Quaternion;
  78077. /**
  78078. * The native hit test result
  78079. */
  78080. xrHitResult: XRHitTestResult;
  78081. }
  78082. /**
  78083. * The currently-working hit-test module.
  78084. * Hit test (or Ray-casting) is used to interact with the real world.
  78085. * For further information read here - https://github.com/immersive-web/hit-test
  78086. *
  78087. * Tested on chrome (mobile) 80.
  78088. */
  78089. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78090. /**
  78091. * options to use when constructing this feature
  78092. */
  78093. readonly options: IWebXRHitTestOptions;
  78094. private _tmpMat;
  78095. private _tmpPos;
  78096. private _tmpQuat;
  78097. private _transientXrHitTestSource;
  78098. private _xrHitTestSource;
  78099. private initHitTestSource;
  78100. /**
  78101. * The module's name
  78102. */
  78103. static readonly Name: string;
  78104. /**
  78105. * The (Babylon) version of this module.
  78106. * This is an integer representing the implementation version.
  78107. * This number does not correspond to the WebXR specs version
  78108. */
  78109. static readonly Version: number;
  78110. /**
  78111. * When set to true, each hit test will have its own position/rotation objects
  78112. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78113. * the developers will clone them or copy them as they see fit.
  78114. */
  78115. autoCloneTransformation: boolean;
  78116. /**
  78117. * Triggered when new babylon (transformed) hit test results are available
  78118. */
  78119. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78120. /**
  78121. * Use this to temporarily pause hit test checks.
  78122. */
  78123. paused: boolean;
  78124. /**
  78125. * Creates a new instance of the hit test feature
  78126. * @param _xrSessionManager an instance of WebXRSessionManager
  78127. * @param options options to use when constructing this feature
  78128. */
  78129. constructor(_xrSessionManager: WebXRSessionManager,
  78130. /**
  78131. * options to use when constructing this feature
  78132. */
  78133. options?: IWebXRHitTestOptions);
  78134. /**
  78135. * attach this feature
  78136. * Will usually be called by the features manager
  78137. *
  78138. * @returns true if successful.
  78139. */
  78140. attach(): boolean;
  78141. /**
  78142. * detach this feature.
  78143. * Will usually be called by the features manager
  78144. *
  78145. * @returns true if successful.
  78146. */
  78147. detach(): boolean;
  78148. /**
  78149. * Dispose this feature and all of the resources attached
  78150. */
  78151. dispose(): void;
  78152. protected _onXRFrame(frame: XRFrame): void;
  78153. private _processWebXRHitTestResult;
  78154. }
  78155. }
  78156. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78157. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78158. import { Observable } from "babylonjs/Misc/observable";
  78159. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78160. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78161. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78162. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78163. /**
  78164. * Configuration options of the anchor system
  78165. */
  78166. export interface IWebXRAnchorSystemOptions {
  78167. /**
  78168. * a node that will be used to convert local to world coordinates
  78169. */
  78170. worldParentNode?: TransformNode;
  78171. /**
  78172. * If set to true a reference of the created anchors will be kept until the next session starts
  78173. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78174. */
  78175. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78176. }
  78177. /**
  78178. * A babylon container for an XR Anchor
  78179. */
  78180. export interface IWebXRAnchor {
  78181. /**
  78182. * A babylon-assigned ID for this anchor
  78183. */
  78184. id: number;
  78185. /**
  78186. * Transformation matrix to apply to an object attached to this anchor
  78187. */
  78188. transformationMatrix: Matrix;
  78189. /**
  78190. * The native anchor object
  78191. */
  78192. xrAnchor: XRAnchor;
  78193. /**
  78194. * if defined, this object will be constantly updated by the anchor's position and rotation
  78195. */
  78196. attachedNode?: TransformNode;
  78197. }
  78198. /**
  78199. * An implementation of the anchor system for WebXR.
  78200. * For further information see https://github.com/immersive-web/anchors/
  78201. */
  78202. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78203. private _options;
  78204. private _lastFrameDetected;
  78205. private _trackedAnchors;
  78206. private _referenceSpaceForFrameAnchors;
  78207. private _futureAnchors;
  78208. /**
  78209. * The module's name
  78210. */
  78211. static readonly Name: string;
  78212. /**
  78213. * The (Babylon) version of this module.
  78214. * This is an integer representing the implementation version.
  78215. * This number does not correspond to the WebXR specs version
  78216. */
  78217. static readonly Version: number;
  78218. /**
  78219. * Observers registered here will be executed when a new anchor was added to the session
  78220. */
  78221. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78222. /**
  78223. * Observers registered here will be executed when an anchor was removed from the session
  78224. */
  78225. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78226. /**
  78227. * Observers registered here will be executed when an existing anchor updates
  78228. * This can execute N times every frame
  78229. */
  78230. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78231. /**
  78232. * Set the reference space to use for anchor creation, when not using a hit test.
  78233. * Will default to the session's reference space if not defined
  78234. */
  78235. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78236. /**
  78237. * constructs a new anchor system
  78238. * @param _xrSessionManager an instance of WebXRSessionManager
  78239. * @param _options configuration object for this feature
  78240. */
  78241. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78242. private _tmpVector;
  78243. private _tmpQuaternion;
  78244. private _populateTmpTransformation;
  78245. /**
  78246. * Create a new anchor point using a hit test result at a specific point in the scene
  78247. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78248. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78249. *
  78250. * @param hitTestResult The hit test result to use for this anchor creation
  78251. * @param position an optional position offset for this anchor
  78252. * @param rotationQuaternion an optional rotation offset for this anchor
  78253. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78254. */
  78255. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78256. /**
  78257. * Add a new anchor at a specific position and rotation
  78258. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78259. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78260. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78261. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78262. *
  78263. * @param position the position in which to add an anchor
  78264. * @param rotationQuaternion an optional rotation for the anchor transformation
  78265. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78266. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78267. */
  78268. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78269. /**
  78270. * detach this feature.
  78271. * Will usually be called by the features manager
  78272. *
  78273. * @returns true if successful.
  78274. */
  78275. detach(): boolean;
  78276. /**
  78277. * Dispose this feature and all of the resources attached
  78278. */
  78279. dispose(): void;
  78280. protected _onXRFrame(frame: XRFrame): void;
  78281. /**
  78282. * avoiding using Array.find for global support.
  78283. * @param xrAnchor the plane to find in the array
  78284. */
  78285. private _findIndexInAnchorArray;
  78286. private _updateAnchorWithXRFrame;
  78287. private _createAnchorAtTransformation;
  78288. }
  78289. }
  78290. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78292. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78293. import { Observable } from "babylonjs/Misc/observable";
  78294. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78295. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78296. /**
  78297. * Options used in the plane detector module
  78298. */
  78299. export interface IWebXRPlaneDetectorOptions {
  78300. /**
  78301. * The node to use to transform the local results to world coordinates
  78302. */
  78303. worldParentNode?: TransformNode;
  78304. /**
  78305. * If set to true a reference of the created planes will be kept until the next session starts
  78306. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78307. */
  78308. doNotRemovePlanesOnSessionEnded?: boolean;
  78309. }
  78310. /**
  78311. * A babylon interface for a WebXR plane.
  78312. * A Plane is actually a polygon, built from N points in space
  78313. *
  78314. * Supported in chrome 79, not supported in canary 81 ATM
  78315. */
  78316. export interface IWebXRPlane {
  78317. /**
  78318. * a babylon-assigned ID for this polygon
  78319. */
  78320. id: number;
  78321. /**
  78322. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78323. */
  78324. polygonDefinition: Array<Vector3>;
  78325. /**
  78326. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78327. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78328. */
  78329. transformationMatrix: Matrix;
  78330. /**
  78331. * the native xr-plane object
  78332. */
  78333. xrPlane: XRPlane;
  78334. }
  78335. /**
  78336. * The plane detector is used to detect planes in the real world when in AR
  78337. * For more information see https://github.com/immersive-web/real-world-geometry/
  78338. */
  78339. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78340. private _options;
  78341. private _detectedPlanes;
  78342. private _enabled;
  78343. private _lastFrameDetected;
  78344. /**
  78345. * The module's name
  78346. */
  78347. static readonly Name: string;
  78348. /**
  78349. * The (Babylon) version of this module.
  78350. * This is an integer representing the implementation version.
  78351. * This number does not correspond to the WebXR specs version
  78352. */
  78353. static readonly Version: number;
  78354. /**
  78355. * Observers registered here will be executed when a new plane was added to the session
  78356. */
  78357. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78358. /**
  78359. * Observers registered here will be executed when a plane is no longer detected in the session
  78360. */
  78361. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78362. /**
  78363. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78364. * This can execute N times every frame
  78365. */
  78366. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78367. /**
  78368. * construct a new Plane Detector
  78369. * @param _xrSessionManager an instance of xr Session manager
  78370. * @param _options configuration to use when constructing this feature
  78371. */
  78372. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78373. /**
  78374. * detach this feature.
  78375. * Will usually be called by the features manager
  78376. *
  78377. * @returns true if successful.
  78378. */
  78379. detach(): boolean;
  78380. /**
  78381. * Dispose this feature and all of the resources attached
  78382. */
  78383. dispose(): void;
  78384. protected _onXRFrame(frame: XRFrame): void;
  78385. private _init;
  78386. private _updatePlaneWithXRPlane;
  78387. /**
  78388. * avoiding using Array.find for global support.
  78389. * @param xrPlane the plane to find in the array
  78390. */
  78391. private findIndexInPlaneArray;
  78392. }
  78393. }
  78394. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78395. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78397. import { Observable } from "babylonjs/Misc/observable";
  78398. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78399. /**
  78400. * Options interface for the background remover plugin
  78401. */
  78402. export interface IWebXRBackgroundRemoverOptions {
  78403. /**
  78404. * Further background meshes to disable when entering AR
  78405. */
  78406. backgroundMeshes?: AbstractMesh[];
  78407. /**
  78408. * flags to configure the removal of the environment helper.
  78409. * If not set, the entire background will be removed. If set, flags should be set as well.
  78410. */
  78411. environmentHelperRemovalFlags?: {
  78412. /**
  78413. * Should the skybox be removed (default false)
  78414. */
  78415. skyBox?: boolean;
  78416. /**
  78417. * Should the ground be removed (default false)
  78418. */
  78419. ground?: boolean;
  78420. };
  78421. /**
  78422. * don't disable the environment helper
  78423. */
  78424. ignoreEnvironmentHelper?: boolean;
  78425. }
  78426. /**
  78427. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78428. */
  78429. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78430. /**
  78431. * read-only options to be used in this module
  78432. */
  78433. readonly options: IWebXRBackgroundRemoverOptions;
  78434. /**
  78435. * The module's name
  78436. */
  78437. static readonly Name: string;
  78438. /**
  78439. * The (Babylon) version of this module.
  78440. * This is an integer representing the implementation version.
  78441. * This number does not correspond to the WebXR specs version
  78442. */
  78443. static readonly Version: number;
  78444. /**
  78445. * registered observers will be triggered when the background state changes
  78446. */
  78447. onBackgroundStateChangedObservable: Observable<boolean>;
  78448. /**
  78449. * constructs a new background remover module
  78450. * @param _xrSessionManager the session manager for this module
  78451. * @param options read-only options to be used in this module
  78452. */
  78453. constructor(_xrSessionManager: WebXRSessionManager,
  78454. /**
  78455. * read-only options to be used in this module
  78456. */
  78457. options?: IWebXRBackgroundRemoverOptions);
  78458. /**
  78459. * attach this feature
  78460. * Will usually be called by the features manager
  78461. *
  78462. * @returns true if successful.
  78463. */
  78464. attach(): boolean;
  78465. /**
  78466. * detach this feature.
  78467. * Will usually be called by the features manager
  78468. *
  78469. * @returns true if successful.
  78470. */
  78471. detach(): boolean;
  78472. /**
  78473. * Dispose this feature and all of the resources attached
  78474. */
  78475. dispose(): void;
  78476. protected _onXRFrame(_xrFrame: XRFrame): void;
  78477. private _setBackgroundState;
  78478. }
  78479. }
  78480. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78481. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78482. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78483. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78484. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78485. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78486. import { Nullable } from "babylonjs/types";
  78487. /**
  78488. * Options for the controller physics feature
  78489. */
  78490. export class IWebXRControllerPhysicsOptions {
  78491. /**
  78492. * Should the headset get its own impostor
  78493. */
  78494. enableHeadsetImpostor?: boolean;
  78495. /**
  78496. * Optional parameters for the headset impostor
  78497. */
  78498. headsetImpostorParams?: {
  78499. /**
  78500. * The type of impostor to create. Default is sphere
  78501. */
  78502. impostorType: number;
  78503. /**
  78504. * the size of the impostor. Defaults to 10cm
  78505. */
  78506. impostorSize?: number | {
  78507. width: number;
  78508. height: number;
  78509. depth: number;
  78510. };
  78511. /**
  78512. * Friction definitions
  78513. */
  78514. friction?: number;
  78515. /**
  78516. * Restitution
  78517. */
  78518. restitution?: number;
  78519. };
  78520. /**
  78521. * The physics properties of the future impostors
  78522. */
  78523. physicsProperties?: {
  78524. /**
  78525. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78526. * Note that this requires a physics engine that supports mesh impostors!
  78527. */
  78528. useControllerMesh?: boolean;
  78529. /**
  78530. * The type of impostor to create. Default is sphere
  78531. */
  78532. impostorType?: number;
  78533. /**
  78534. * the size of the impostor. Defaults to 10cm
  78535. */
  78536. impostorSize?: number | {
  78537. width: number;
  78538. height: number;
  78539. depth: number;
  78540. };
  78541. /**
  78542. * Friction definitions
  78543. */
  78544. friction?: number;
  78545. /**
  78546. * Restitution
  78547. */
  78548. restitution?: number;
  78549. };
  78550. /**
  78551. * the xr input to use with this pointer selection
  78552. */
  78553. xrInput: WebXRInput;
  78554. }
  78555. /**
  78556. * Add physics impostor to your webxr controllers,
  78557. * including naive calculation of their linear and angular velocity
  78558. */
  78559. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78560. private readonly _options;
  78561. private _attachController;
  78562. private _controllers;
  78563. private _debugMode;
  78564. private _delta;
  78565. private _headsetImpostor?;
  78566. private _headsetMesh?;
  78567. private _lastTimestamp;
  78568. private _tmpQuaternion;
  78569. private _tmpVector;
  78570. /**
  78571. * The module's name
  78572. */
  78573. static readonly Name: string;
  78574. /**
  78575. * The (Babylon) version of this module.
  78576. * This is an integer representing the implementation version.
  78577. * This number does not correspond to the webxr specs version
  78578. */
  78579. static readonly Version: number;
  78580. /**
  78581. * Construct a new Controller Physics Feature
  78582. * @param _xrSessionManager the corresponding xr session manager
  78583. * @param _options options to create this feature with
  78584. */
  78585. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78586. /**
  78587. * @hidden
  78588. * enable debugging - will show console outputs and the impostor mesh
  78589. */
  78590. _enablePhysicsDebug(): void;
  78591. /**
  78592. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78593. * @param xrController the controller to add
  78594. */
  78595. addController(xrController: WebXRInputSource): void;
  78596. /**
  78597. * attach this feature
  78598. * Will usually be called by the features manager
  78599. *
  78600. * @returns true if successful.
  78601. */
  78602. attach(): boolean;
  78603. /**
  78604. * detach this feature.
  78605. * Will usually be called by the features manager
  78606. *
  78607. * @returns true if successful.
  78608. */
  78609. detach(): boolean;
  78610. /**
  78611. * Get the headset impostor, if enabled
  78612. * @returns the impostor
  78613. */
  78614. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78615. /**
  78616. * Get the physics impostor of a specific controller.
  78617. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78618. * @param controller the controller or the controller id of which to get the impostor
  78619. * @returns the impostor or null
  78620. */
  78621. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78622. /**
  78623. * Update the physics properties provided in the constructor
  78624. * @param newProperties the new properties object
  78625. */
  78626. setPhysicsProperties(newProperties: {
  78627. impostorType?: number;
  78628. impostorSize?: number | {
  78629. width: number;
  78630. height: number;
  78631. depth: number;
  78632. };
  78633. friction?: number;
  78634. restitution?: number;
  78635. }): void;
  78636. protected _onXRFrame(_xrFrame: any): void;
  78637. private _detachController;
  78638. }
  78639. }
  78640. declare module "babylonjs/XR/features/index" {
  78641. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78642. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78643. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78644. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78645. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78646. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78647. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78648. export * from "babylonjs/XR/features/WebXRHitTest";
  78649. }
  78650. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78651. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78653. import { Scene } from "babylonjs/scene";
  78654. /**
  78655. * The motion controller class for all microsoft mixed reality controllers
  78656. */
  78657. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78658. protected readonly _mapping: {
  78659. defaultButton: {
  78660. valueNodeName: string;
  78661. unpressedNodeName: string;
  78662. pressedNodeName: string;
  78663. };
  78664. defaultAxis: {
  78665. valueNodeName: string;
  78666. minNodeName: string;
  78667. maxNodeName: string;
  78668. };
  78669. buttons: {
  78670. "xr-standard-trigger": {
  78671. rootNodeName: string;
  78672. componentProperty: string;
  78673. states: string[];
  78674. };
  78675. "xr-standard-squeeze": {
  78676. rootNodeName: string;
  78677. componentProperty: string;
  78678. states: string[];
  78679. };
  78680. "xr-standard-touchpad": {
  78681. rootNodeName: string;
  78682. labelAnchorNodeName: string;
  78683. touchPointNodeName: string;
  78684. };
  78685. "xr-standard-thumbstick": {
  78686. rootNodeName: string;
  78687. componentProperty: string;
  78688. states: string[];
  78689. };
  78690. };
  78691. axes: {
  78692. "xr-standard-touchpad": {
  78693. "x-axis": {
  78694. rootNodeName: string;
  78695. };
  78696. "y-axis": {
  78697. rootNodeName: string;
  78698. };
  78699. };
  78700. "xr-standard-thumbstick": {
  78701. "x-axis": {
  78702. rootNodeName: string;
  78703. };
  78704. "y-axis": {
  78705. rootNodeName: string;
  78706. };
  78707. };
  78708. };
  78709. };
  78710. /**
  78711. * The base url used to load the left and right controller models
  78712. */
  78713. static MODEL_BASE_URL: string;
  78714. /**
  78715. * The name of the left controller model file
  78716. */
  78717. static MODEL_LEFT_FILENAME: string;
  78718. /**
  78719. * The name of the right controller model file
  78720. */
  78721. static MODEL_RIGHT_FILENAME: string;
  78722. profileId: string;
  78723. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78724. protected _getFilenameAndPath(): {
  78725. filename: string;
  78726. path: string;
  78727. };
  78728. protected _getModelLoadingConstraints(): boolean;
  78729. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78730. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78731. protected _updateModel(): void;
  78732. }
  78733. }
  78734. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78735. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78737. import { Scene } from "babylonjs/scene";
  78738. /**
  78739. * The motion controller class for oculus touch (quest, rift).
  78740. * This class supports legacy mapping as well the standard xr mapping
  78741. */
  78742. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78743. private _forceLegacyControllers;
  78744. private _modelRootNode;
  78745. /**
  78746. * The base url used to load the left and right controller models
  78747. */
  78748. static MODEL_BASE_URL: string;
  78749. /**
  78750. * The name of the left controller model file
  78751. */
  78752. static MODEL_LEFT_FILENAME: string;
  78753. /**
  78754. * The name of the right controller model file
  78755. */
  78756. static MODEL_RIGHT_FILENAME: string;
  78757. /**
  78758. * Base Url for the Quest controller model.
  78759. */
  78760. static QUEST_MODEL_BASE_URL: string;
  78761. profileId: string;
  78762. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78763. protected _getFilenameAndPath(): {
  78764. filename: string;
  78765. path: string;
  78766. };
  78767. protected _getModelLoadingConstraints(): boolean;
  78768. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78769. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78770. protected _updateModel(): void;
  78771. /**
  78772. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78773. * between the touch and touch 2.
  78774. */
  78775. private _isQuest;
  78776. }
  78777. }
  78778. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78779. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78780. import { Scene } from "babylonjs/scene";
  78781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78782. /**
  78783. * The motion controller class for the standard HTC-Vive controllers
  78784. */
  78785. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78786. private _modelRootNode;
  78787. /**
  78788. * The base url used to load the left and right controller models
  78789. */
  78790. static MODEL_BASE_URL: string;
  78791. /**
  78792. * File name for the controller model.
  78793. */
  78794. static MODEL_FILENAME: string;
  78795. profileId: string;
  78796. /**
  78797. * Create a new Vive motion controller object
  78798. * @param scene the scene to use to create this controller
  78799. * @param gamepadObject the corresponding gamepad object
  78800. * @param handedness the handedness of the controller
  78801. */
  78802. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78803. protected _getFilenameAndPath(): {
  78804. filename: string;
  78805. path: string;
  78806. };
  78807. protected _getModelLoadingConstraints(): boolean;
  78808. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78809. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78810. protected _updateModel(): void;
  78811. }
  78812. }
  78813. declare module "babylonjs/XR/motionController/index" {
  78814. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78815. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78816. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78817. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78818. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78819. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78820. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78821. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78822. }
  78823. declare module "babylonjs/XR/index" {
  78824. export * from "babylonjs/XR/webXRCamera";
  78825. export * from "babylonjs/XR/webXREnterExitUI";
  78826. export * from "babylonjs/XR/webXRExperienceHelper";
  78827. export * from "babylonjs/XR/webXRInput";
  78828. export * from "babylonjs/XR/webXRInputSource";
  78829. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78830. export * from "babylonjs/XR/webXRTypes";
  78831. export * from "babylonjs/XR/webXRSessionManager";
  78832. export * from "babylonjs/XR/webXRDefaultExperience";
  78833. export * from "babylonjs/XR/webXRFeaturesManager";
  78834. export * from "babylonjs/XR/features/index";
  78835. export * from "babylonjs/XR/motionController/index";
  78836. }
  78837. declare module "babylonjs/index" {
  78838. export * from "babylonjs/abstractScene";
  78839. export * from "babylonjs/Actions/index";
  78840. export * from "babylonjs/Animations/index";
  78841. export * from "babylonjs/assetContainer";
  78842. export * from "babylonjs/Audio/index";
  78843. export * from "babylonjs/Behaviors/index";
  78844. export * from "babylonjs/Bones/index";
  78845. export * from "babylonjs/Cameras/index";
  78846. export * from "babylonjs/Collisions/index";
  78847. export * from "babylonjs/Culling/index";
  78848. export * from "babylonjs/Debug/index";
  78849. export * from "babylonjs/DeviceInput/index";
  78850. export * from "babylonjs/Engines/index";
  78851. export * from "babylonjs/Events/index";
  78852. export * from "babylonjs/Gamepads/index";
  78853. export * from "babylonjs/Gizmos/index";
  78854. export * from "babylonjs/Helpers/index";
  78855. export * from "babylonjs/Instrumentation/index";
  78856. export * from "babylonjs/Layers/index";
  78857. export * from "babylonjs/LensFlares/index";
  78858. export * from "babylonjs/Lights/index";
  78859. export * from "babylonjs/Loading/index";
  78860. export * from "babylonjs/Materials/index";
  78861. export * from "babylonjs/Maths/index";
  78862. export * from "babylonjs/Meshes/index";
  78863. export * from "babylonjs/Morph/index";
  78864. export * from "babylonjs/Navigation/index";
  78865. export * from "babylonjs/node";
  78866. export * from "babylonjs/Offline/index";
  78867. export * from "babylonjs/Particles/index";
  78868. export * from "babylonjs/Physics/index";
  78869. export * from "babylonjs/PostProcesses/index";
  78870. export * from "babylonjs/Probes/index";
  78871. export * from "babylonjs/Rendering/index";
  78872. export * from "babylonjs/scene";
  78873. export * from "babylonjs/sceneComponent";
  78874. export * from "babylonjs/Sprites/index";
  78875. export * from "babylonjs/States/index";
  78876. export * from "babylonjs/Misc/index";
  78877. export * from "babylonjs/XR/index";
  78878. export * from "babylonjs/types";
  78879. }
  78880. declare module "babylonjs/Animations/pathCursor" {
  78881. import { Vector3 } from "babylonjs/Maths/math.vector";
  78882. import { Path2 } from "babylonjs/Maths/math.path";
  78883. /**
  78884. * A cursor which tracks a point on a path
  78885. */
  78886. export class PathCursor {
  78887. private path;
  78888. /**
  78889. * Stores path cursor callbacks for when an onchange event is triggered
  78890. */
  78891. private _onchange;
  78892. /**
  78893. * The value of the path cursor
  78894. */
  78895. value: number;
  78896. /**
  78897. * The animation array of the path cursor
  78898. */
  78899. animations: Animation[];
  78900. /**
  78901. * Initializes the path cursor
  78902. * @param path The path to track
  78903. */
  78904. constructor(path: Path2);
  78905. /**
  78906. * Gets the cursor point on the path
  78907. * @returns A point on the path cursor at the cursor location
  78908. */
  78909. getPoint(): Vector3;
  78910. /**
  78911. * Moves the cursor ahead by the step amount
  78912. * @param step The amount to move the cursor forward
  78913. * @returns This path cursor
  78914. */
  78915. moveAhead(step?: number): PathCursor;
  78916. /**
  78917. * Moves the cursor behind by the step amount
  78918. * @param step The amount to move the cursor back
  78919. * @returns This path cursor
  78920. */
  78921. moveBack(step?: number): PathCursor;
  78922. /**
  78923. * Moves the cursor by the step amount
  78924. * If the step amount is greater than one, an exception is thrown
  78925. * @param step The amount to move the cursor
  78926. * @returns This path cursor
  78927. */
  78928. move(step: number): PathCursor;
  78929. /**
  78930. * Ensures that the value is limited between zero and one
  78931. * @returns This path cursor
  78932. */
  78933. private ensureLimits;
  78934. /**
  78935. * Runs onchange callbacks on change (used by the animation engine)
  78936. * @returns This path cursor
  78937. */
  78938. private raiseOnChange;
  78939. /**
  78940. * Executes a function on change
  78941. * @param f A path cursor onchange callback
  78942. * @returns This path cursor
  78943. */
  78944. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78945. }
  78946. }
  78947. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78948. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78949. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78950. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78951. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78952. }
  78953. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78954. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78955. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78956. }
  78957. declare module "babylonjs/Engines/Processors/index" {
  78958. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78959. export * from "babylonjs/Engines/Processors/Expressions/index";
  78960. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78961. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78962. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78963. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78964. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78965. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78966. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78967. }
  78968. declare module "babylonjs/Legacy/legacy" {
  78969. import * as Babylon from "babylonjs/index";
  78970. export * from "babylonjs/index";
  78971. }
  78972. declare module "babylonjs/Shaders/blur.fragment" {
  78973. /** @hidden */
  78974. export var blurPixelShader: {
  78975. name: string;
  78976. shader: string;
  78977. };
  78978. }
  78979. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78980. /** @hidden */
  78981. export var pointCloudVertexDeclaration: {
  78982. name: string;
  78983. shader: string;
  78984. };
  78985. }
  78986. declare module "babylonjs" {
  78987. export * from "babylonjs/Legacy/legacy";
  78988. }
  78989. declare module BABYLON {
  78990. /** Alias type for value that can be null */
  78991. export type Nullable<T> = T | null;
  78992. /**
  78993. * Alias type for number that are floats
  78994. * @ignorenaming
  78995. */
  78996. export type float = number;
  78997. /**
  78998. * Alias type for number that are doubles.
  78999. * @ignorenaming
  79000. */
  79001. export type double = number;
  79002. /**
  79003. * Alias type for number that are integer
  79004. * @ignorenaming
  79005. */
  79006. export type int = number;
  79007. /** Alias type for number array or Float32Array */
  79008. export type FloatArray = number[] | Float32Array;
  79009. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79010. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79011. /**
  79012. * Alias for types that can be used by a Buffer or VertexBuffer.
  79013. */
  79014. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79015. /**
  79016. * Alias type for primitive types
  79017. * @ignorenaming
  79018. */
  79019. type Primitive = undefined | null | boolean | string | number | Function;
  79020. /**
  79021. * Type modifier to make all the properties of an object Readonly
  79022. */
  79023. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79024. /**
  79025. * Type modifier to make all the properties of an object Readonly recursively
  79026. */
  79027. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79028. /**
  79029. * Type modifier to make object properties readonly.
  79030. */
  79031. export type DeepImmutableObject<T> = {
  79032. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79033. };
  79034. /** @hidden */
  79035. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79036. }
  79037. }
  79038. declare module BABYLON {
  79039. /**
  79040. * A class serves as a medium between the observable and its observers
  79041. */
  79042. export class EventState {
  79043. /**
  79044. * Create a new EventState
  79045. * @param mask defines the mask associated with this state
  79046. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79047. * @param target defines the original target of the state
  79048. * @param currentTarget defines the current target of the state
  79049. */
  79050. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79051. /**
  79052. * Initialize the current event state
  79053. * @param mask defines the mask associated with this state
  79054. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79055. * @param target defines the original target of the state
  79056. * @param currentTarget defines the current target of the state
  79057. * @returns the current event state
  79058. */
  79059. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79060. /**
  79061. * An Observer can set this property to true to prevent subsequent observers of being notified
  79062. */
  79063. skipNextObservers: boolean;
  79064. /**
  79065. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79066. */
  79067. mask: number;
  79068. /**
  79069. * The object that originally notified the event
  79070. */
  79071. target?: any;
  79072. /**
  79073. * The current object in the bubbling phase
  79074. */
  79075. currentTarget?: any;
  79076. /**
  79077. * This will be populated with the return value of the last function that was executed.
  79078. * If it is the first function in the callback chain it will be the event data.
  79079. */
  79080. lastReturnValue?: any;
  79081. }
  79082. /**
  79083. * Represent an Observer registered to a given Observable object.
  79084. */
  79085. export class Observer<T> {
  79086. /**
  79087. * Defines the callback to call when the observer is notified
  79088. */
  79089. callback: (eventData: T, eventState: EventState) => void;
  79090. /**
  79091. * Defines the mask of the observer (used to filter notifications)
  79092. */
  79093. mask: number;
  79094. /**
  79095. * Defines the current scope used to restore the JS context
  79096. */
  79097. scope: any;
  79098. /** @hidden */
  79099. _willBeUnregistered: boolean;
  79100. /**
  79101. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79102. */
  79103. unregisterOnNextCall: boolean;
  79104. /**
  79105. * Creates a new observer
  79106. * @param callback defines the callback to call when the observer is notified
  79107. * @param mask defines the mask of the observer (used to filter notifications)
  79108. * @param scope defines the current scope used to restore the JS context
  79109. */
  79110. constructor(
  79111. /**
  79112. * Defines the callback to call when the observer is notified
  79113. */
  79114. callback: (eventData: T, eventState: EventState) => void,
  79115. /**
  79116. * Defines the mask of the observer (used to filter notifications)
  79117. */
  79118. mask: number,
  79119. /**
  79120. * Defines the current scope used to restore the JS context
  79121. */
  79122. scope?: any);
  79123. }
  79124. /**
  79125. * Represent a list of observers registered to multiple Observables object.
  79126. */
  79127. export class MultiObserver<T> {
  79128. private _observers;
  79129. private _observables;
  79130. /**
  79131. * Release associated resources
  79132. */
  79133. dispose(): void;
  79134. /**
  79135. * Raise a callback when one of the observable will notify
  79136. * @param observables defines a list of observables to watch
  79137. * @param callback defines the callback to call on notification
  79138. * @param mask defines the mask used to filter notifications
  79139. * @param scope defines the current scope used to restore the JS context
  79140. * @returns the new MultiObserver
  79141. */
  79142. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79143. }
  79144. /**
  79145. * The Observable class is a simple implementation of the Observable pattern.
  79146. *
  79147. * 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.
  79148. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79149. * 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).
  79150. * 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.
  79151. */
  79152. export class Observable<T> {
  79153. private _observers;
  79154. private _eventState;
  79155. private _onObserverAdded;
  79156. /**
  79157. * Gets the list of observers
  79158. */
  79159. get observers(): Array<Observer<T>>;
  79160. /**
  79161. * Creates a new observable
  79162. * @param onObserverAdded defines a callback to call when a new observer is added
  79163. */
  79164. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79165. /**
  79166. * Create a new Observer with the specified callback
  79167. * @param callback the callback that will be executed for that Observer
  79168. * @param mask the mask used to filter observers
  79169. * @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.
  79170. * @param scope optional scope for the callback to be called from
  79171. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79172. * @returns the new observer created for the callback
  79173. */
  79174. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79175. /**
  79176. * Create a new Observer with the specified callback and unregisters after the next notification
  79177. * @param callback the callback that will be executed for that Observer
  79178. * @returns the new observer created for the callback
  79179. */
  79180. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79181. /**
  79182. * Remove an Observer from the Observable object
  79183. * @param observer the instance of the Observer to remove
  79184. * @returns false if it doesn't belong to this Observable
  79185. */
  79186. remove(observer: Nullable<Observer<T>>): boolean;
  79187. /**
  79188. * Remove a callback from the Observable object
  79189. * @param callback the callback to remove
  79190. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79191. * @returns false if it doesn't belong to this Observable
  79192. */
  79193. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79194. private _deferUnregister;
  79195. private _remove;
  79196. /**
  79197. * Moves the observable to the top of the observer list making it get called first when notified
  79198. * @param observer the observer to move
  79199. */
  79200. makeObserverTopPriority(observer: Observer<T>): void;
  79201. /**
  79202. * Moves the observable to the bottom of the observer list making it get called last when notified
  79203. * @param observer the observer to move
  79204. */
  79205. makeObserverBottomPriority(observer: Observer<T>): void;
  79206. /**
  79207. * Notify all Observers by calling their respective callback with the given data
  79208. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79209. * @param eventData defines the data to send to all observers
  79210. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79211. * @param target defines the original target of the state
  79212. * @param currentTarget defines the current target of the state
  79213. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79214. */
  79215. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79216. /**
  79217. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79218. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79219. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79220. * and it is crucial that all callbacks will be executed.
  79221. * The order of the callbacks is kept, callbacks are not executed parallel.
  79222. *
  79223. * @param eventData The data to be sent to each callback
  79224. * @param mask is used to filter observers defaults to -1
  79225. * @param target defines the callback target (see EventState)
  79226. * @param currentTarget defines he current object in the bubbling phase
  79227. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79228. */
  79229. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79230. /**
  79231. * Notify a specific observer
  79232. * @param observer defines the observer to notify
  79233. * @param eventData defines the data to be sent to each callback
  79234. * @param mask is used to filter observers defaults to -1
  79235. */
  79236. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79237. /**
  79238. * Gets a boolean indicating if the observable has at least one observer
  79239. * @returns true is the Observable has at least one Observer registered
  79240. */
  79241. hasObservers(): boolean;
  79242. /**
  79243. * Clear the list of observers
  79244. */
  79245. clear(): void;
  79246. /**
  79247. * Clone the current observable
  79248. * @returns a new observable
  79249. */
  79250. clone(): Observable<T>;
  79251. /**
  79252. * Does this observable handles observer registered with a given mask
  79253. * @param mask defines the mask to be tested
  79254. * @return whether or not one observer registered with the given mask is handeled
  79255. **/
  79256. hasSpecificMask(mask?: number): boolean;
  79257. }
  79258. }
  79259. declare module BABYLON {
  79260. /**
  79261. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79262. * Babylon.js
  79263. */
  79264. export class DomManagement {
  79265. /**
  79266. * Checks if the window object exists
  79267. * @returns true if the window object exists
  79268. */
  79269. static IsWindowObjectExist(): boolean;
  79270. /**
  79271. * Checks if the navigator object exists
  79272. * @returns true if the navigator object exists
  79273. */
  79274. static IsNavigatorAvailable(): boolean;
  79275. /**
  79276. * Check if the document object exists
  79277. * @returns true if the document object exists
  79278. */
  79279. static IsDocumentAvailable(): boolean;
  79280. /**
  79281. * Extracts text content from a DOM element hierarchy
  79282. * @param element defines the root element
  79283. * @returns a string
  79284. */
  79285. static GetDOMTextContent(element: HTMLElement): string;
  79286. }
  79287. }
  79288. declare module BABYLON {
  79289. /**
  79290. * Logger used througouht the application to allow configuration of
  79291. * the log level required for the messages.
  79292. */
  79293. export class Logger {
  79294. /**
  79295. * No log
  79296. */
  79297. static readonly NoneLogLevel: number;
  79298. /**
  79299. * Only message logs
  79300. */
  79301. static readonly MessageLogLevel: number;
  79302. /**
  79303. * Only warning logs
  79304. */
  79305. static readonly WarningLogLevel: number;
  79306. /**
  79307. * Only error logs
  79308. */
  79309. static readonly ErrorLogLevel: number;
  79310. /**
  79311. * All logs
  79312. */
  79313. static readonly AllLogLevel: number;
  79314. private static _LogCache;
  79315. /**
  79316. * Gets a value indicating the number of loading errors
  79317. * @ignorenaming
  79318. */
  79319. static errorsCount: number;
  79320. /**
  79321. * Callback called when a new log is added
  79322. */
  79323. static OnNewCacheEntry: (entry: string) => void;
  79324. private static _AddLogEntry;
  79325. private static _FormatMessage;
  79326. private static _LogDisabled;
  79327. private static _LogEnabled;
  79328. private static _WarnDisabled;
  79329. private static _WarnEnabled;
  79330. private static _ErrorDisabled;
  79331. private static _ErrorEnabled;
  79332. /**
  79333. * Log a message to the console
  79334. */
  79335. static Log: (message: string) => void;
  79336. /**
  79337. * Write a warning message to the console
  79338. */
  79339. static Warn: (message: string) => void;
  79340. /**
  79341. * Write an error message to the console
  79342. */
  79343. static Error: (message: string) => void;
  79344. /**
  79345. * Gets current log cache (list of logs)
  79346. */
  79347. static get LogCache(): string;
  79348. /**
  79349. * Clears the log cache
  79350. */
  79351. static ClearLogCache(): void;
  79352. /**
  79353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79354. */
  79355. static set LogLevels(level: number);
  79356. }
  79357. }
  79358. declare module BABYLON {
  79359. /** @hidden */
  79360. export class _TypeStore {
  79361. /** @hidden */
  79362. static RegisteredTypes: {
  79363. [key: string]: Object;
  79364. };
  79365. /** @hidden */
  79366. static GetClass(fqdn: string): any;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * Helper to manipulate strings
  79372. */
  79373. export class StringTools {
  79374. /**
  79375. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79376. * @param str Source string
  79377. * @param suffix Suffix to search for in the source string
  79378. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79379. */
  79380. static EndsWith(str: string, suffix: string): boolean;
  79381. /**
  79382. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79383. * @param str Source string
  79384. * @param suffix Suffix to search for in the source string
  79385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79386. */
  79387. static StartsWith(str: string, suffix: string): boolean;
  79388. /**
  79389. * Decodes a buffer into a string
  79390. * @param buffer The buffer to decode
  79391. * @returns The decoded string
  79392. */
  79393. static Decode(buffer: Uint8Array | Uint16Array): string;
  79394. /**
  79395. * Encode a buffer to a base64 string
  79396. * @param buffer defines the buffer to encode
  79397. * @returns the encoded string
  79398. */
  79399. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79400. /**
  79401. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79402. * @param num the number to convert and pad
  79403. * @param length the expected length of the string
  79404. * @returns the padded string
  79405. */
  79406. static PadNumber(num: number, length: number): string;
  79407. }
  79408. }
  79409. declare module BABYLON {
  79410. /**
  79411. * Class containing a set of static utilities functions for deep copy.
  79412. */
  79413. export class DeepCopier {
  79414. /**
  79415. * Tries to copy an object by duplicating every property
  79416. * @param source defines the source object
  79417. * @param destination defines the target object
  79418. * @param doNotCopyList defines a list of properties to avoid
  79419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79420. */
  79421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. /**
  79426. * Class containing a set of static utilities functions for precision date
  79427. */
  79428. export class PrecisionDate {
  79429. /**
  79430. * Gets either window.performance.now() if supported or Date.now() else
  79431. */
  79432. static get Now(): number;
  79433. }
  79434. }
  79435. declare module BABYLON {
  79436. /** @hidden */
  79437. export class _DevTools {
  79438. static WarnImport(name: string): string;
  79439. }
  79440. }
  79441. declare module BABYLON {
  79442. /**
  79443. * Interface used to define the mechanism to get data from the network
  79444. */
  79445. export interface IWebRequest {
  79446. /**
  79447. * Returns client's response url
  79448. */
  79449. responseURL: string;
  79450. /**
  79451. * Returns client's status
  79452. */
  79453. status: number;
  79454. /**
  79455. * Returns client's status as a text
  79456. */
  79457. statusText: string;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /**
  79462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79463. */
  79464. export class WebRequest implements IWebRequest {
  79465. private _xhr;
  79466. /**
  79467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79468. * i.e. when loading files, where the server/service expects an Authorization header
  79469. */
  79470. static CustomRequestHeaders: {
  79471. [key: string]: string;
  79472. };
  79473. /**
  79474. * Add callback functions in this array to update all the requests before they get sent to the network
  79475. */
  79476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79477. private _injectCustomRequestHeaders;
  79478. /**
  79479. * Gets or sets a function to be called when loading progress changes
  79480. */
  79481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79483. /**
  79484. * Returns client's state
  79485. */
  79486. get readyState(): number;
  79487. /**
  79488. * Returns client's status
  79489. */
  79490. get status(): number;
  79491. /**
  79492. * Returns client's status as a text
  79493. */
  79494. get statusText(): string;
  79495. /**
  79496. * Returns client's response
  79497. */
  79498. get response(): any;
  79499. /**
  79500. * Returns client's response url
  79501. */
  79502. get responseURL(): string;
  79503. /**
  79504. * Returns client's response as text
  79505. */
  79506. get responseText(): string;
  79507. /**
  79508. * Gets or sets the expected response type
  79509. */
  79510. get responseType(): XMLHttpRequestResponseType;
  79511. set responseType(value: XMLHttpRequestResponseType);
  79512. /** @hidden */
  79513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79514. /** @hidden */
  79515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79516. /**
  79517. * Cancels any network activity
  79518. */
  79519. abort(): void;
  79520. /**
  79521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79522. * @param body defines an optional request body
  79523. */
  79524. send(body?: Document | BodyInit | null): void;
  79525. /**
  79526. * Sets the request method, request URL
  79527. * @param method defines the method to use (GET, POST, etc..)
  79528. * @param url defines the url to connect with
  79529. */
  79530. open(method: string, url: string): void;
  79531. /**
  79532. * Sets the value of a request header.
  79533. * @param name The name of the header whose value is to be set
  79534. * @param value The value to set as the body of the header
  79535. */
  79536. setRequestHeader(name: string, value: string): void;
  79537. /**
  79538. * Get the string containing the text of a particular header's value.
  79539. * @param name The name of the header
  79540. * @returns The string containing the text of the given header name
  79541. */
  79542. getResponseHeader(name: string): Nullable<string>;
  79543. }
  79544. }
  79545. declare module BABYLON {
  79546. /**
  79547. * File request interface
  79548. */
  79549. export interface IFileRequest {
  79550. /**
  79551. * Raised when the request is complete (success or error).
  79552. */
  79553. onCompleteObservable: Observable<IFileRequest>;
  79554. /**
  79555. * Aborts the request for a file.
  79556. */
  79557. abort: () => void;
  79558. }
  79559. }
  79560. declare module BABYLON {
  79561. /**
  79562. * Define options used to create a render target texture
  79563. */
  79564. export class RenderTargetCreationOptions {
  79565. /**
  79566. * Specifies is mipmaps must be generated
  79567. */
  79568. generateMipMaps?: boolean;
  79569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79570. generateDepthBuffer?: boolean;
  79571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79572. generateStencilBuffer?: boolean;
  79573. /** Defines texture type (int by default) */
  79574. type?: number;
  79575. /** Defines sampling mode (trilinear by default) */
  79576. samplingMode?: number;
  79577. /** Defines format (RGBA by default) */
  79578. format?: number;
  79579. }
  79580. }
  79581. declare module BABYLON {
  79582. /** Defines the cross module used constants to avoid circular dependncies */
  79583. export class Constants {
  79584. /** Defines that alpha blending is disabled */
  79585. static readonly ALPHA_DISABLE: number;
  79586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79587. static readonly ALPHA_ADD: number;
  79588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79589. static readonly ALPHA_COMBINE: number;
  79590. /** Defines that alpha blending is DEST - SRC * DEST */
  79591. static readonly ALPHA_SUBTRACT: number;
  79592. /** Defines that alpha blending is SRC * DEST */
  79593. static readonly ALPHA_MULTIPLY: number;
  79594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79595. static readonly ALPHA_MAXIMIZED: number;
  79596. /** Defines that alpha blending is SRC + DEST */
  79597. static readonly ALPHA_ONEONE: number;
  79598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79599. static readonly ALPHA_PREMULTIPLIED: number;
  79600. /**
  79601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79603. */
  79604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79606. static readonly ALPHA_INTERPOLATE: number;
  79607. /**
  79608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79610. */
  79611. static readonly ALPHA_SCREENMODE: number;
  79612. /**
  79613. * Defines that alpha blending is SRC + DST
  79614. * Alpha will be set to SRC ALPHA + DST ALPHA
  79615. */
  79616. static readonly ALPHA_ONEONE_ONEONE: number;
  79617. /**
  79618. * Defines that alpha blending is SRC * DST ALPHA + DST
  79619. * Alpha will be set to 0
  79620. */
  79621. static readonly ALPHA_ALPHATOCOLOR: number;
  79622. /**
  79623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79624. */
  79625. static readonly ALPHA_REVERSEONEMINUS: number;
  79626. /**
  79627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79629. */
  79630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79631. /**
  79632. * Defines that alpha blending is SRC + DST
  79633. * Alpha will be set to SRC ALPHA
  79634. */
  79635. static readonly ALPHA_ONEONE_ONEZERO: number;
  79636. /**
  79637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79638. * Alpha will be set to DST ALPHA
  79639. */
  79640. static readonly ALPHA_EXCLUSION: number;
  79641. /** Defines that alpha blending equation a SUM */
  79642. static readonly ALPHA_EQUATION_ADD: number;
  79643. /** Defines that alpha blending equation a SUBSTRACTION */
  79644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79647. /** Defines that alpha blending equation a MAX operation */
  79648. static readonly ALPHA_EQUATION_MAX: number;
  79649. /** Defines that alpha blending equation a MIN operation */
  79650. static readonly ALPHA_EQUATION_MIN: number;
  79651. /**
  79652. * Defines that alpha blending equation a DARKEN operation:
  79653. * It takes the min of the src and sums the alpha channels.
  79654. */
  79655. static readonly ALPHA_EQUATION_DARKEN: number;
  79656. /** Defines that the ressource is not delayed*/
  79657. static readonly DELAYLOADSTATE_NONE: number;
  79658. /** Defines that the ressource was successfully delay loaded */
  79659. static readonly DELAYLOADSTATE_LOADED: number;
  79660. /** Defines that the ressource is currently delay loading */
  79661. static readonly DELAYLOADSTATE_LOADING: number;
  79662. /** Defines that the ressource is delayed and has not started loading */
  79663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79665. static readonly NEVER: number;
  79666. /** 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 */
  79667. static readonly ALWAYS: number;
  79668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79669. static readonly LESS: number;
  79670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79671. static readonly EQUAL: number;
  79672. /** 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 */
  79673. static readonly LEQUAL: number;
  79674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79675. static readonly GREATER: number;
  79676. /** 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 */
  79677. static readonly GEQUAL: number;
  79678. /** 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 */
  79679. static readonly NOTEQUAL: number;
  79680. /** Passed to stencilOperation to specify that stencil value must be kept */
  79681. static readonly KEEP: number;
  79682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79683. static readonly REPLACE: number;
  79684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79685. static readonly INCR: number;
  79686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79687. static readonly DECR: number;
  79688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79689. static readonly INVERT: number;
  79690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79691. static readonly INCR_WRAP: number;
  79692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79693. static readonly DECR_WRAP: number;
  79694. /** Texture is not repeating outside of 0..1 UVs */
  79695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79696. /** Texture is repeating outside of 0..1 UVs */
  79697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79698. /** Texture is repeating and mirrored */
  79699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79700. /** ALPHA */
  79701. static readonly TEXTUREFORMAT_ALPHA: number;
  79702. /** LUMINANCE */
  79703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79704. /** LUMINANCE_ALPHA */
  79705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79706. /** RGB */
  79707. static readonly TEXTUREFORMAT_RGB: number;
  79708. /** RGBA */
  79709. static readonly TEXTUREFORMAT_RGBA: number;
  79710. /** RED */
  79711. static readonly TEXTUREFORMAT_RED: number;
  79712. /** RED (2nd reference) */
  79713. static readonly TEXTUREFORMAT_R: number;
  79714. /** RG */
  79715. static readonly TEXTUREFORMAT_RG: number;
  79716. /** RED_INTEGER */
  79717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79718. /** RED_INTEGER (2nd reference) */
  79719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79720. /** RG_INTEGER */
  79721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79722. /** RGB_INTEGER */
  79723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79724. /** RGBA_INTEGER */
  79725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79726. /** UNSIGNED_BYTE */
  79727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79728. /** UNSIGNED_BYTE (2nd reference) */
  79729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79730. /** FLOAT */
  79731. static readonly TEXTURETYPE_FLOAT: number;
  79732. /** HALF_FLOAT */
  79733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79734. /** BYTE */
  79735. static readonly TEXTURETYPE_BYTE: number;
  79736. /** SHORT */
  79737. static readonly TEXTURETYPE_SHORT: number;
  79738. /** UNSIGNED_SHORT */
  79739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79740. /** INT */
  79741. static readonly TEXTURETYPE_INT: number;
  79742. /** UNSIGNED_INT */
  79743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79744. /** UNSIGNED_SHORT_4_4_4_4 */
  79745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79746. /** UNSIGNED_SHORT_5_5_5_1 */
  79747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79748. /** UNSIGNED_SHORT_5_6_5 */
  79749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79750. /** UNSIGNED_INT_2_10_10_10_REV */
  79751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79752. /** UNSIGNED_INT_24_8 */
  79753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79754. /** UNSIGNED_INT_10F_11F_11F_REV */
  79755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79756. /** UNSIGNED_INT_5_9_9_9_REV */
  79757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79760. /** nearest is mag = nearest and min = nearest and no mip */
  79761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79762. /** mag = nearest and min = nearest and mip = none */
  79763. static readonly TEXTURE_NEAREST_NEAREST: number;
  79764. /** Bilinear is mag = linear and min = linear and no mip */
  79765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79766. /** mag = linear and min = linear and mip = none */
  79767. static readonly TEXTURE_LINEAR_LINEAR: number;
  79768. /** Trilinear is mag = linear and min = linear and mip = linear */
  79769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79770. /** Trilinear is mag = linear and min = linear and mip = linear */
  79771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79772. /** mag = nearest and min = nearest and mip = nearest */
  79773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79774. /** mag = nearest and min = linear and mip = nearest */
  79775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79776. /** mag = nearest and min = linear and mip = linear */
  79777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79778. /** mag = nearest and min = linear and mip = none */
  79779. static readonly TEXTURE_NEAREST_LINEAR: number;
  79780. /** nearest is mag = nearest and min = nearest and mip = linear */
  79781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79782. /** mag = linear and min = nearest and mip = nearest */
  79783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79784. /** mag = linear and min = nearest and mip = linear */
  79785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79788. /** mag = linear and min = nearest and mip = none */
  79789. static readonly TEXTURE_LINEAR_NEAREST: number;
  79790. /** Explicit coordinates mode */
  79791. static readonly TEXTURE_EXPLICIT_MODE: number;
  79792. /** Spherical coordinates mode */
  79793. static readonly TEXTURE_SPHERICAL_MODE: number;
  79794. /** Planar coordinates mode */
  79795. static readonly TEXTURE_PLANAR_MODE: number;
  79796. /** Cubic coordinates mode */
  79797. static readonly TEXTURE_CUBIC_MODE: number;
  79798. /** Projection coordinates mode */
  79799. static readonly TEXTURE_PROJECTION_MODE: number;
  79800. /** Skybox coordinates mode */
  79801. static readonly TEXTURE_SKYBOX_MODE: number;
  79802. /** Inverse Cubic coordinates mode */
  79803. static readonly TEXTURE_INVCUBIC_MODE: number;
  79804. /** Equirectangular coordinates mode */
  79805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79806. /** Equirectangular Fixed coordinates mode */
  79807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79808. /** Equirectangular Fixed Mirrored coordinates mode */
  79809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79810. /** Offline (baking) quality for texture filtering */
  79811. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79812. /** High quality for texture filtering */
  79813. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79814. /** Medium quality for texture filtering */
  79815. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79816. /** Low quality for texture filtering */
  79817. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79818. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79819. static readonly SCALEMODE_FLOOR: number;
  79820. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79821. static readonly SCALEMODE_NEAREST: number;
  79822. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79823. static readonly SCALEMODE_CEILING: number;
  79824. /**
  79825. * The dirty texture flag value
  79826. */
  79827. static readonly MATERIAL_TextureDirtyFlag: number;
  79828. /**
  79829. * The dirty light flag value
  79830. */
  79831. static readonly MATERIAL_LightDirtyFlag: number;
  79832. /**
  79833. * The dirty fresnel flag value
  79834. */
  79835. static readonly MATERIAL_FresnelDirtyFlag: number;
  79836. /**
  79837. * The dirty attribute flag value
  79838. */
  79839. static readonly MATERIAL_AttributesDirtyFlag: number;
  79840. /**
  79841. * The dirty misc flag value
  79842. */
  79843. static readonly MATERIAL_MiscDirtyFlag: number;
  79844. /**
  79845. * The all dirty flag value
  79846. */
  79847. static readonly MATERIAL_AllDirtyFlag: number;
  79848. /**
  79849. * Returns the triangle fill mode
  79850. */
  79851. static readonly MATERIAL_TriangleFillMode: number;
  79852. /**
  79853. * Returns the wireframe mode
  79854. */
  79855. static readonly MATERIAL_WireFrameFillMode: number;
  79856. /**
  79857. * Returns the point fill mode
  79858. */
  79859. static readonly MATERIAL_PointFillMode: number;
  79860. /**
  79861. * Returns the point list draw mode
  79862. */
  79863. static readonly MATERIAL_PointListDrawMode: number;
  79864. /**
  79865. * Returns the line list draw mode
  79866. */
  79867. static readonly MATERIAL_LineListDrawMode: number;
  79868. /**
  79869. * Returns the line loop draw mode
  79870. */
  79871. static readonly MATERIAL_LineLoopDrawMode: number;
  79872. /**
  79873. * Returns the line strip draw mode
  79874. */
  79875. static readonly MATERIAL_LineStripDrawMode: number;
  79876. /**
  79877. * Returns the triangle strip draw mode
  79878. */
  79879. static readonly MATERIAL_TriangleStripDrawMode: number;
  79880. /**
  79881. * Returns the triangle fan draw mode
  79882. */
  79883. static readonly MATERIAL_TriangleFanDrawMode: number;
  79884. /**
  79885. * Stores the clock-wise side orientation
  79886. */
  79887. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79888. /**
  79889. * Stores the counter clock-wise side orientation
  79890. */
  79891. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79892. /**
  79893. * Nothing
  79894. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79895. */
  79896. static readonly ACTION_NothingTrigger: number;
  79897. /**
  79898. * On pick
  79899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79900. */
  79901. static readonly ACTION_OnPickTrigger: number;
  79902. /**
  79903. * On left pick
  79904. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79905. */
  79906. static readonly ACTION_OnLeftPickTrigger: number;
  79907. /**
  79908. * On right pick
  79909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79910. */
  79911. static readonly ACTION_OnRightPickTrigger: number;
  79912. /**
  79913. * On center pick
  79914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79915. */
  79916. static readonly ACTION_OnCenterPickTrigger: number;
  79917. /**
  79918. * On pick down
  79919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79920. */
  79921. static readonly ACTION_OnPickDownTrigger: number;
  79922. /**
  79923. * On double pick
  79924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79925. */
  79926. static readonly ACTION_OnDoublePickTrigger: number;
  79927. /**
  79928. * On pick up
  79929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79930. */
  79931. static readonly ACTION_OnPickUpTrigger: number;
  79932. /**
  79933. * On pick out.
  79934. * This trigger will only be raised if you also declared a OnPickDown
  79935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79936. */
  79937. static readonly ACTION_OnPickOutTrigger: number;
  79938. /**
  79939. * On long press
  79940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79941. */
  79942. static readonly ACTION_OnLongPressTrigger: number;
  79943. /**
  79944. * On pointer over
  79945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79946. */
  79947. static readonly ACTION_OnPointerOverTrigger: number;
  79948. /**
  79949. * On pointer out
  79950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79951. */
  79952. static readonly ACTION_OnPointerOutTrigger: number;
  79953. /**
  79954. * On every frame
  79955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79956. */
  79957. static readonly ACTION_OnEveryFrameTrigger: number;
  79958. /**
  79959. * On intersection enter
  79960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79961. */
  79962. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79963. /**
  79964. * On intersection exit
  79965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79966. */
  79967. static readonly ACTION_OnIntersectionExitTrigger: number;
  79968. /**
  79969. * On key down
  79970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79971. */
  79972. static readonly ACTION_OnKeyDownTrigger: number;
  79973. /**
  79974. * On key up
  79975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79976. */
  79977. static readonly ACTION_OnKeyUpTrigger: number;
  79978. /**
  79979. * Billboard mode will only apply to Y axis
  79980. */
  79981. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79982. /**
  79983. * Billboard mode will apply to all axes
  79984. */
  79985. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79986. /**
  79987. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79988. */
  79989. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79990. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79991. * Test order :
  79992. * Is the bounding sphere outside the frustum ?
  79993. * If not, are the bounding box vertices outside the frustum ?
  79994. * It not, then the cullable object is in the frustum.
  79995. */
  79996. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79997. /** Culling strategy : Bounding Sphere Only.
  79998. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79999. * It's also less accurate than the standard because some not visible objects can still be selected.
  80000. * Test : is the bounding sphere outside the frustum ?
  80001. * If not, then the cullable object is in the frustum.
  80002. */
  80003. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80004. /** Culling strategy : Optimistic Inclusion.
  80005. * This in an inclusion test first, then the standard exclusion test.
  80006. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80007. * 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.
  80008. * Anyway, it's as accurate as the standard strategy.
  80009. * Test :
  80010. * Is the cullable object bounding sphere center in the frustum ?
  80011. * If not, apply the default culling strategy.
  80012. */
  80013. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80014. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80015. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80016. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80017. * 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.
  80018. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80019. * Test :
  80020. * Is the cullable object bounding sphere center in the frustum ?
  80021. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80022. */
  80023. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80024. /**
  80025. * No logging while loading
  80026. */
  80027. static readonly SCENELOADER_NO_LOGGING: number;
  80028. /**
  80029. * Minimal logging while loading
  80030. */
  80031. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80032. /**
  80033. * Summary logging while loading
  80034. */
  80035. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80036. /**
  80037. * Detailled logging while loading
  80038. */
  80039. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80040. /**
  80041. * Prepass texture index for color
  80042. */
  80043. static readonly PREPASS_COLOR_INDEX: number;
  80044. /**
  80045. * Prepass texture index for irradiance
  80046. */
  80047. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80048. /**
  80049. * Prepass texture index for depth + normal
  80050. */
  80051. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80052. /**
  80053. * Prepass texture index for albedo
  80054. */
  80055. static readonly PREPASS_ALBEDO_INDEX: number;
  80056. }
  80057. }
  80058. declare module BABYLON {
  80059. /**
  80060. * This represents the required contract to create a new type of texture loader.
  80061. */
  80062. export interface IInternalTextureLoader {
  80063. /**
  80064. * Defines wether the loader supports cascade loading the different faces.
  80065. */
  80066. supportCascades: boolean;
  80067. /**
  80068. * This returns if the loader support the current file information.
  80069. * @param extension defines the file extension of the file being loaded
  80070. * @param mimeType defines the optional mime type of the file being loaded
  80071. * @returns true if the loader can load the specified file
  80072. */
  80073. canLoad(extension: string, mimeType?: string): boolean;
  80074. /**
  80075. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80076. * @param data contains the texture data
  80077. * @param texture defines the BabylonJS internal texture
  80078. * @param createPolynomials will be true if polynomials have been requested
  80079. * @param onLoad defines the callback to trigger once the texture is ready
  80080. * @param onError defines the callback to trigger in case of error
  80081. */
  80082. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80083. /**
  80084. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80085. * @param data contains the texture data
  80086. * @param texture defines the BabylonJS internal texture
  80087. * @param callback defines the method to call once ready to upload
  80088. */
  80089. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80090. }
  80091. }
  80092. declare module BABYLON {
  80093. /**
  80094. * Class used to store and describe the pipeline context associated with an effect
  80095. */
  80096. export interface IPipelineContext {
  80097. /**
  80098. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80099. */
  80100. isAsync: boolean;
  80101. /**
  80102. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80103. */
  80104. isReady: boolean;
  80105. /** @hidden */
  80106. _getVertexShaderCode(): string | null;
  80107. /** @hidden */
  80108. _getFragmentShaderCode(): string | null;
  80109. /** @hidden */
  80110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80111. }
  80112. }
  80113. declare module BABYLON {
  80114. /**
  80115. * Class used to store gfx data (like WebGLBuffer)
  80116. */
  80117. export class DataBuffer {
  80118. /**
  80119. * Gets or sets the number of objects referencing this buffer
  80120. */
  80121. references: number;
  80122. /** Gets or sets the size of the underlying buffer */
  80123. capacity: number;
  80124. /**
  80125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80126. */
  80127. is32Bits: boolean;
  80128. /**
  80129. * Gets the underlying buffer
  80130. */
  80131. get underlyingResource(): any;
  80132. }
  80133. }
  80134. declare module BABYLON {
  80135. /** @hidden */
  80136. export interface IShaderProcessor {
  80137. attributeProcessor?: (attribute: string) => string;
  80138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80142. lineProcessor?: (line: string, isFragment: boolean) => string;
  80143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80145. }
  80146. }
  80147. declare module BABYLON {
  80148. /** @hidden */
  80149. export interface ProcessingOptions {
  80150. defines: string[];
  80151. indexParameters: any;
  80152. isFragment: boolean;
  80153. shouldUseHighPrecisionShader: boolean;
  80154. supportsUniformBuffers: boolean;
  80155. shadersRepository: string;
  80156. includesShadersStore: {
  80157. [key: string]: string;
  80158. };
  80159. processor?: IShaderProcessor;
  80160. version: string;
  80161. platformName: string;
  80162. lookForClosingBracketForUniformBuffer?: boolean;
  80163. }
  80164. }
  80165. declare module BABYLON {
  80166. /** @hidden */
  80167. export class ShaderCodeNode {
  80168. line: string;
  80169. children: ShaderCodeNode[];
  80170. additionalDefineKey?: string;
  80171. additionalDefineValue?: string;
  80172. isValid(preprocessors: {
  80173. [key: string]: string;
  80174. }): boolean;
  80175. process(preprocessors: {
  80176. [key: string]: string;
  80177. }, options: ProcessingOptions): string;
  80178. }
  80179. }
  80180. declare module BABYLON {
  80181. /** @hidden */
  80182. export class ShaderCodeCursor {
  80183. private _lines;
  80184. lineIndex: number;
  80185. get currentLine(): string;
  80186. get canRead(): boolean;
  80187. set lines(value: string[]);
  80188. }
  80189. }
  80190. declare module BABYLON {
  80191. /** @hidden */
  80192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80193. process(preprocessors: {
  80194. [key: string]: string;
  80195. }, options: ProcessingOptions): string;
  80196. }
  80197. }
  80198. declare module BABYLON {
  80199. /** @hidden */
  80200. export class ShaderDefineExpression {
  80201. isTrue(preprocessors: {
  80202. [key: string]: string;
  80203. }): boolean;
  80204. private static _OperatorPriority;
  80205. private static _Stack;
  80206. static postfixToInfix(postfix: string[]): string;
  80207. static infixToPostfix(infix: string): string[];
  80208. }
  80209. }
  80210. declare module BABYLON {
  80211. /** @hidden */
  80212. export class ShaderCodeTestNode extends ShaderCodeNode {
  80213. testExpression: ShaderDefineExpression;
  80214. isValid(preprocessors: {
  80215. [key: string]: string;
  80216. }): boolean;
  80217. }
  80218. }
  80219. declare module BABYLON {
  80220. /** @hidden */
  80221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80222. define: string;
  80223. not: boolean;
  80224. constructor(define: string, not?: boolean);
  80225. isTrue(preprocessors: {
  80226. [key: string]: string;
  80227. }): boolean;
  80228. }
  80229. }
  80230. declare module BABYLON {
  80231. /** @hidden */
  80232. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80233. leftOperand: ShaderDefineExpression;
  80234. rightOperand: ShaderDefineExpression;
  80235. isTrue(preprocessors: {
  80236. [key: string]: string;
  80237. }): boolean;
  80238. }
  80239. }
  80240. declare module BABYLON {
  80241. /** @hidden */
  80242. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80243. leftOperand: ShaderDefineExpression;
  80244. rightOperand: ShaderDefineExpression;
  80245. isTrue(preprocessors: {
  80246. [key: string]: string;
  80247. }): boolean;
  80248. }
  80249. }
  80250. declare module BABYLON {
  80251. /** @hidden */
  80252. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80253. define: string;
  80254. operand: string;
  80255. testValue: string;
  80256. constructor(define: string, operand: string, testValue: string);
  80257. isTrue(preprocessors: {
  80258. [key: string]: string;
  80259. }): boolean;
  80260. }
  80261. }
  80262. declare module BABYLON {
  80263. /**
  80264. * Class used to enable access to offline support
  80265. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80266. */
  80267. export interface IOfflineProvider {
  80268. /**
  80269. * Gets a boolean indicating if scene must be saved in the database
  80270. */
  80271. enableSceneOffline: boolean;
  80272. /**
  80273. * Gets a boolean indicating if textures must be saved in the database
  80274. */
  80275. enableTexturesOffline: boolean;
  80276. /**
  80277. * Open the offline support and make it available
  80278. * @param successCallback defines the callback to call on success
  80279. * @param errorCallback defines the callback to call on error
  80280. */
  80281. open(successCallback: () => void, errorCallback: () => void): void;
  80282. /**
  80283. * Loads an image from the offline support
  80284. * @param url defines the url to load from
  80285. * @param image defines the target DOM image
  80286. */
  80287. loadImage(url: string, image: HTMLImageElement): void;
  80288. /**
  80289. * Loads a file from offline support
  80290. * @param url defines the URL to load from
  80291. * @param sceneLoaded defines a callback to call on success
  80292. * @param progressCallBack defines a callback to call when progress changed
  80293. * @param errorCallback defines a callback to call on error
  80294. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80295. */
  80296. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * Class used to help managing file picking and drag'n'drop
  80302. * File Storage
  80303. */
  80304. export class FilesInputStore {
  80305. /**
  80306. * List of files ready to be loaded
  80307. */
  80308. static FilesToLoad: {
  80309. [key: string]: File;
  80310. };
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /**
  80315. * Class used to define a retry strategy when error happens while loading assets
  80316. */
  80317. export class RetryStrategy {
  80318. /**
  80319. * Function used to defines an exponential back off strategy
  80320. * @param maxRetries defines the maximum number of retries (3 by default)
  80321. * @param baseInterval defines the interval between retries
  80322. * @returns the strategy function to use
  80323. */
  80324. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80325. }
  80326. }
  80327. declare module BABYLON {
  80328. /**
  80329. * @ignore
  80330. * Application error to support additional information when loading a file
  80331. */
  80332. export abstract class BaseError extends Error {
  80333. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80334. }
  80335. }
  80336. declare module BABYLON {
  80337. /** @ignore */
  80338. export class LoadFileError extends BaseError {
  80339. request?: WebRequest;
  80340. file?: File;
  80341. /**
  80342. * Creates a new LoadFileError
  80343. * @param message defines the message of the error
  80344. * @param request defines the optional web request
  80345. * @param file defines the optional file
  80346. */
  80347. constructor(message: string, object?: WebRequest | File);
  80348. }
  80349. /** @ignore */
  80350. export class RequestFileError extends BaseError {
  80351. request: WebRequest;
  80352. /**
  80353. * Creates a new LoadFileError
  80354. * @param message defines the message of the error
  80355. * @param request defines the optional web request
  80356. */
  80357. constructor(message: string, request: WebRequest);
  80358. }
  80359. /** @ignore */
  80360. export class ReadFileError extends BaseError {
  80361. file: File;
  80362. /**
  80363. * Creates a new ReadFileError
  80364. * @param message defines the message of the error
  80365. * @param file defines the optional file
  80366. */
  80367. constructor(message: string, file: File);
  80368. }
  80369. /**
  80370. * @hidden
  80371. */
  80372. export class FileTools {
  80373. /**
  80374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80375. */
  80376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80377. /**
  80378. * Gets or sets the base URL to use to load assets
  80379. */
  80380. static BaseUrl: string;
  80381. /**
  80382. * Default behaviour for cors in the application.
  80383. * It can be a string if the expected behavior is identical in the entire app.
  80384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80385. */
  80386. static CorsBehavior: string | ((url: string | string[]) => string);
  80387. /**
  80388. * Gets or sets a function used to pre-process url before using them to load assets
  80389. */
  80390. static PreprocessUrl: (url: string) => string;
  80391. /**
  80392. * Removes unwanted characters from an url
  80393. * @param url defines the url to clean
  80394. * @returns the cleaned url
  80395. */
  80396. private static _CleanUrl;
  80397. /**
  80398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80399. * @param url define the url we are trying
  80400. * @param element define the dom element where to configure the cors policy
  80401. */
  80402. static SetCorsBehavior(url: string | string[], element: {
  80403. crossOrigin: string | null;
  80404. }): void;
  80405. /**
  80406. * Loads an image as an HTMLImageElement.
  80407. * @param input url string, ArrayBuffer, or Blob to load
  80408. * @param onLoad callback called when the image successfully loads
  80409. * @param onError callback called when the image fails to load
  80410. * @param offlineProvider offline provider for caching
  80411. * @param mimeType optional mime type
  80412. * @returns the HTMLImageElement of the loaded image
  80413. */
  80414. 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>;
  80415. /**
  80416. * Reads a file from a File object
  80417. * @param file defines the file to load
  80418. * @param onSuccess defines the callback to call when data is loaded
  80419. * @param onProgress defines the callback to call during loading process
  80420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80421. * @param onError defines the callback to call when an error occurs
  80422. * @returns a file request object
  80423. */
  80424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80425. /**
  80426. * Loads a file from a url
  80427. * @param url url to load
  80428. * @param onSuccess callback called when the file successfully loads
  80429. * @param onProgress callback called while file is loading (if the server supports this mode)
  80430. * @param offlineProvider defines the offline provider for caching
  80431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80432. * @param onError callback called when the file fails to load
  80433. * @returns a file request object
  80434. */
  80435. 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;
  80436. /**
  80437. * Loads a file
  80438. * @param url url to load
  80439. * @param onSuccess callback called when the file successfully loads
  80440. * @param onProgress callback called while file is loading (if the server supports this mode)
  80441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80442. * @param onError callback called when the file fails to load
  80443. * @param onOpened callback called when the web request is opened
  80444. * @returns a file request object
  80445. */
  80446. 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;
  80447. /**
  80448. * Checks if the loaded document was accessed via `file:`-Protocol.
  80449. * @returns boolean
  80450. */
  80451. static IsFileURL(): boolean;
  80452. }
  80453. }
  80454. declare module BABYLON {
  80455. /** @hidden */
  80456. export class ShaderProcessor {
  80457. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80458. private static _ProcessPrecision;
  80459. private static _ExtractOperation;
  80460. private static _BuildSubExpression;
  80461. private static _BuildExpression;
  80462. private static _MoveCursorWithinIf;
  80463. private static _MoveCursor;
  80464. private static _EvaluatePreProcessors;
  80465. private static _PreparePreProcessors;
  80466. private static _ProcessShaderConversion;
  80467. private static _ProcessIncludes;
  80468. /**
  80469. * Loads a file from a url
  80470. * @param url url to load
  80471. * @param onSuccess callback called when the file successfully loads
  80472. * @param onProgress callback called while file is loading (if the server supports this mode)
  80473. * @param offlineProvider defines the offline provider for caching
  80474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80475. * @param onError callback called when the file fails to load
  80476. * @returns a file request object
  80477. * @hidden
  80478. */
  80479. 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;
  80480. }
  80481. }
  80482. declare module BABYLON {
  80483. /**
  80484. * @hidden
  80485. */
  80486. export interface IColor4Like {
  80487. r: float;
  80488. g: float;
  80489. b: float;
  80490. a: float;
  80491. }
  80492. /**
  80493. * @hidden
  80494. */
  80495. export interface IColor3Like {
  80496. r: float;
  80497. g: float;
  80498. b: float;
  80499. }
  80500. /**
  80501. * @hidden
  80502. */
  80503. export interface IVector4Like {
  80504. x: float;
  80505. y: float;
  80506. z: float;
  80507. w: float;
  80508. }
  80509. /**
  80510. * @hidden
  80511. */
  80512. export interface IVector3Like {
  80513. x: float;
  80514. y: float;
  80515. z: float;
  80516. }
  80517. /**
  80518. * @hidden
  80519. */
  80520. export interface IVector2Like {
  80521. x: float;
  80522. y: float;
  80523. }
  80524. /**
  80525. * @hidden
  80526. */
  80527. export interface IMatrixLike {
  80528. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80529. updateFlag: int;
  80530. }
  80531. /**
  80532. * @hidden
  80533. */
  80534. export interface IViewportLike {
  80535. x: float;
  80536. y: float;
  80537. width: float;
  80538. height: float;
  80539. }
  80540. /**
  80541. * @hidden
  80542. */
  80543. export interface IPlaneLike {
  80544. normal: IVector3Like;
  80545. d: float;
  80546. normalize(): void;
  80547. }
  80548. }
  80549. declare module BABYLON {
  80550. /**
  80551. * Interface used to define common properties for effect fallbacks
  80552. */
  80553. export interface IEffectFallbacks {
  80554. /**
  80555. * Removes the defines that should be removed when falling back.
  80556. * @param currentDefines defines the current define statements for the shader.
  80557. * @param effect defines the current effect we try to compile
  80558. * @returns The resulting defines with defines of the current rank removed.
  80559. */
  80560. reduce(currentDefines: string, effect: Effect): string;
  80561. /**
  80562. * Removes the fallback from the bound mesh.
  80563. */
  80564. unBindMesh(): void;
  80565. /**
  80566. * Checks to see if more fallbacks are still availible.
  80567. */
  80568. hasMoreFallbacks: boolean;
  80569. }
  80570. }
  80571. declare module BABYLON {
  80572. /**
  80573. * Class used to evalaute queries containing `and` and `or` operators
  80574. */
  80575. export class AndOrNotEvaluator {
  80576. /**
  80577. * Evaluate a query
  80578. * @param query defines the query to evaluate
  80579. * @param evaluateCallback defines the callback used to filter result
  80580. * @returns true if the query matches
  80581. */
  80582. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80583. private static _HandleParenthesisContent;
  80584. private static _SimplifyNegation;
  80585. }
  80586. }
  80587. declare module BABYLON {
  80588. /**
  80589. * Class used to store custom tags
  80590. */
  80591. export class Tags {
  80592. /**
  80593. * Adds support for tags on the given object
  80594. * @param obj defines the object to use
  80595. */
  80596. static EnableFor(obj: any): void;
  80597. /**
  80598. * Removes tags support
  80599. * @param obj defines the object to use
  80600. */
  80601. static DisableFor(obj: any): void;
  80602. /**
  80603. * Gets a boolean indicating if the given object has tags
  80604. * @param obj defines the object to use
  80605. * @returns a boolean
  80606. */
  80607. static HasTags(obj: any): boolean;
  80608. /**
  80609. * Gets the tags available on a given object
  80610. * @param obj defines the object to use
  80611. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80612. * @returns the tags
  80613. */
  80614. static GetTags(obj: any, asString?: boolean): any;
  80615. /**
  80616. * Adds tags to an object
  80617. * @param obj defines the object to use
  80618. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80619. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80620. */
  80621. static AddTagsTo(obj: any, tagsString: string): void;
  80622. /**
  80623. * @hidden
  80624. */
  80625. static _AddTagTo(obj: any, tag: string): void;
  80626. /**
  80627. * Removes specific tags from a specific object
  80628. * @param obj defines the object to use
  80629. * @param tagsString defines the tags to remove
  80630. */
  80631. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80632. /**
  80633. * @hidden
  80634. */
  80635. static _RemoveTagFrom(obj: any, tag: string): void;
  80636. /**
  80637. * Defines if tags hosted on an object match a given query
  80638. * @param obj defines the object to use
  80639. * @param tagsQuery defines the tag query
  80640. * @returns a boolean
  80641. */
  80642. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80643. }
  80644. }
  80645. declare module BABYLON {
  80646. /**
  80647. * Scalar computation library
  80648. */
  80649. export class Scalar {
  80650. /**
  80651. * Two pi constants convenient for computation.
  80652. */
  80653. static TwoPi: number;
  80654. /**
  80655. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80656. * @param a number
  80657. * @param b number
  80658. * @param epsilon (default = 1.401298E-45)
  80659. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80660. */
  80661. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80662. /**
  80663. * Returns a string : the upper case translation of the number i to hexadecimal.
  80664. * @param i number
  80665. * @returns the upper case translation of the number i to hexadecimal.
  80666. */
  80667. static ToHex(i: number): string;
  80668. /**
  80669. * Returns -1 if value is negative and +1 is value is positive.
  80670. * @param value the value
  80671. * @returns the value itself if it's equal to zero.
  80672. */
  80673. static Sign(value: number): number;
  80674. /**
  80675. * Returns the value itself if it's between min and max.
  80676. * Returns min if the value is lower than min.
  80677. * Returns max if the value is greater than max.
  80678. * @param value the value to clmap
  80679. * @param min the min value to clamp to (default: 0)
  80680. * @param max the max value to clamp to (default: 1)
  80681. * @returns the clamped value
  80682. */
  80683. static Clamp(value: number, min?: number, max?: number): number;
  80684. /**
  80685. * the log2 of value.
  80686. * @param value the value to compute log2 of
  80687. * @returns the log2 of value.
  80688. */
  80689. static Log2(value: number): number;
  80690. /**
  80691. * Loops the value, so that it is never larger than length and never smaller than 0.
  80692. *
  80693. * This is similar to the modulo operator but it works with floating point numbers.
  80694. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80695. * With t = 5 and length = 2.5, the result would be 0.0.
  80696. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80697. * @param value the value
  80698. * @param length the length
  80699. * @returns the looped value
  80700. */
  80701. static Repeat(value: number, length: number): number;
  80702. /**
  80703. * Normalize the value between 0.0 and 1.0 using min and max values
  80704. * @param value value to normalize
  80705. * @param min max to normalize between
  80706. * @param max min to normalize between
  80707. * @returns the normalized value
  80708. */
  80709. static Normalize(value: number, min: number, max: number): number;
  80710. /**
  80711. * Denormalize the value from 0.0 and 1.0 using min and max values
  80712. * @param normalized value to denormalize
  80713. * @param min max to denormalize between
  80714. * @param max min to denormalize between
  80715. * @returns the denormalized value
  80716. */
  80717. static Denormalize(normalized: number, min: number, max: number): number;
  80718. /**
  80719. * Calculates the shortest difference between two given angles given in degrees.
  80720. * @param current current angle in degrees
  80721. * @param target target angle in degrees
  80722. * @returns the delta
  80723. */
  80724. static DeltaAngle(current: number, target: number): number;
  80725. /**
  80726. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80727. * @param tx value
  80728. * @param length length
  80729. * @returns The returned value will move back and forth between 0 and length
  80730. */
  80731. static PingPong(tx: number, length: number): number;
  80732. /**
  80733. * Interpolates between min and max with smoothing at the limits.
  80734. *
  80735. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80736. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80737. * @param from from
  80738. * @param to to
  80739. * @param tx value
  80740. * @returns the smooth stepped value
  80741. */
  80742. static SmoothStep(from: number, to: number, tx: number): number;
  80743. /**
  80744. * Moves a value current towards target.
  80745. *
  80746. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80747. * Negative values of maxDelta pushes the value away from target.
  80748. * @param current current value
  80749. * @param target target value
  80750. * @param maxDelta max distance to move
  80751. * @returns resulting value
  80752. */
  80753. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80754. /**
  80755. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80756. *
  80757. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80758. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80759. * @param current current value
  80760. * @param target target value
  80761. * @param maxDelta max distance to move
  80762. * @returns resulting angle
  80763. */
  80764. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80765. /**
  80766. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80767. * @param start start value
  80768. * @param end target value
  80769. * @param amount amount to lerp between
  80770. * @returns the lerped value
  80771. */
  80772. static Lerp(start: number, end: number, amount: number): number;
  80773. /**
  80774. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80775. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80776. * @param start start value
  80777. * @param end target value
  80778. * @param amount amount to lerp between
  80779. * @returns the lerped value
  80780. */
  80781. static LerpAngle(start: number, end: number, amount: number): number;
  80782. /**
  80783. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80784. * @param a start value
  80785. * @param b target value
  80786. * @param value value between a and b
  80787. * @returns the inverseLerp value
  80788. */
  80789. static InverseLerp(a: number, b: number, value: number): number;
  80790. /**
  80791. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80792. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80793. * @param value1 spline value
  80794. * @param tangent1 spline value
  80795. * @param value2 spline value
  80796. * @param tangent2 spline value
  80797. * @param amount input value
  80798. * @returns hermite result
  80799. */
  80800. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80801. /**
  80802. * Returns a random float number between and min and max values
  80803. * @param min min value of random
  80804. * @param max max value of random
  80805. * @returns random value
  80806. */
  80807. static RandomRange(min: number, max: number): number;
  80808. /**
  80809. * This function returns percentage of a number in a given range.
  80810. *
  80811. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80812. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80813. * @param number to convert to percentage
  80814. * @param min min range
  80815. * @param max max range
  80816. * @returns the percentage
  80817. */
  80818. static RangeToPercent(number: number, min: number, max: number): number;
  80819. /**
  80820. * This function returns number that corresponds to the percentage in a given range.
  80821. *
  80822. * PercentToRange(0.34,0,100) will return 34.
  80823. * @param percent to convert to number
  80824. * @param min min range
  80825. * @param max max range
  80826. * @returns the number
  80827. */
  80828. static PercentToRange(percent: number, min: number, max: number): number;
  80829. /**
  80830. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80831. * @param angle The angle to normalize in radian.
  80832. * @return The converted angle.
  80833. */
  80834. static NormalizeRadians(angle: number): number;
  80835. }
  80836. }
  80837. declare module BABYLON {
  80838. /**
  80839. * Constant used to convert a value to gamma space
  80840. * @ignorenaming
  80841. */
  80842. export const ToGammaSpace: number;
  80843. /**
  80844. * Constant used to convert a value to linear space
  80845. * @ignorenaming
  80846. */
  80847. export const ToLinearSpace = 2.2;
  80848. /**
  80849. * Constant used to define the minimal number value in Babylon.js
  80850. * @ignorenaming
  80851. */
  80852. let Epsilon: number;
  80853. }
  80854. declare module BABYLON {
  80855. /**
  80856. * Class used to represent a viewport on screen
  80857. */
  80858. export class Viewport {
  80859. /** viewport left coordinate */
  80860. x: number;
  80861. /** viewport top coordinate */
  80862. y: number;
  80863. /**viewport width */
  80864. width: number;
  80865. /** viewport height */
  80866. height: number;
  80867. /**
  80868. * Creates a Viewport object located at (x, y) and sized (width, height)
  80869. * @param x defines viewport left coordinate
  80870. * @param y defines viewport top coordinate
  80871. * @param width defines the viewport width
  80872. * @param height defines the viewport height
  80873. */
  80874. constructor(
  80875. /** viewport left coordinate */
  80876. x: number,
  80877. /** viewport top coordinate */
  80878. y: number,
  80879. /**viewport width */
  80880. width: number,
  80881. /** viewport height */
  80882. height: number);
  80883. /**
  80884. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80885. * @param renderWidth defines the rendering width
  80886. * @param renderHeight defines the rendering height
  80887. * @returns a new Viewport
  80888. */
  80889. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80890. /**
  80891. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80892. * @param renderWidth defines the rendering width
  80893. * @param renderHeight defines the rendering height
  80894. * @param ref defines the target viewport
  80895. * @returns the current viewport
  80896. */
  80897. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80898. /**
  80899. * Returns a new Viewport copied from the current one
  80900. * @returns a new Viewport
  80901. */
  80902. clone(): Viewport;
  80903. }
  80904. }
  80905. declare module BABYLON {
  80906. /**
  80907. * Class containing a set of static utilities functions for arrays.
  80908. */
  80909. export class ArrayTools {
  80910. /**
  80911. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80912. * @param size the number of element to construct and put in the array
  80913. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80914. * @returns a new array filled with new objects
  80915. */
  80916. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80917. }
  80918. }
  80919. declare module BABYLON {
  80920. /**
  80921. * Represents a plane by the equation ax + by + cz + d = 0
  80922. */
  80923. export class Plane {
  80924. private static _TmpMatrix;
  80925. /**
  80926. * Normal of the plane (a,b,c)
  80927. */
  80928. normal: Vector3;
  80929. /**
  80930. * d component of the plane
  80931. */
  80932. d: number;
  80933. /**
  80934. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80935. * @param a a component of the plane
  80936. * @param b b component of the plane
  80937. * @param c c component of the plane
  80938. * @param d d component of the plane
  80939. */
  80940. constructor(a: number, b: number, c: number, d: number);
  80941. /**
  80942. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80943. */
  80944. asArray(): number[];
  80945. /**
  80946. * @returns a new plane copied from the current Plane.
  80947. */
  80948. clone(): Plane;
  80949. /**
  80950. * @returns the string "Plane".
  80951. */
  80952. getClassName(): string;
  80953. /**
  80954. * @returns the Plane hash code.
  80955. */
  80956. getHashCode(): number;
  80957. /**
  80958. * Normalize the current Plane in place.
  80959. * @returns the updated Plane.
  80960. */
  80961. normalize(): Plane;
  80962. /**
  80963. * Applies a transformation the plane and returns the result
  80964. * @param transformation the transformation matrix to be applied to the plane
  80965. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80966. */
  80967. transform(transformation: DeepImmutable<Matrix>): Plane;
  80968. /**
  80969. * Compute the dot product between the point and the plane normal
  80970. * @param point point to calculate the dot product with
  80971. * @returns the dot product (float) of the point coordinates and the plane normal.
  80972. */
  80973. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80974. /**
  80975. * Updates the current Plane from the plane defined by the three given points.
  80976. * @param point1 one of the points used to contruct the plane
  80977. * @param point2 one of the points used to contruct the plane
  80978. * @param point3 one of the points used to contruct the plane
  80979. * @returns the updated Plane.
  80980. */
  80981. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80982. /**
  80983. * Checks if the plane is facing a given direction
  80984. * @param direction the direction to check if the plane is facing
  80985. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80986. * @returns True is the vector "direction" is the same side than the plane normal.
  80987. */
  80988. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80989. /**
  80990. * Calculates the distance to a point
  80991. * @param point point to calculate distance to
  80992. * @returns the signed distance (float) from the given point to the Plane.
  80993. */
  80994. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80995. /**
  80996. * Creates a plane from an array
  80997. * @param array the array to create a plane from
  80998. * @returns a new Plane from the given array.
  80999. */
  81000. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81001. /**
  81002. * Creates a plane from three points
  81003. * @param point1 point used to create the plane
  81004. * @param point2 point used to create the plane
  81005. * @param point3 point used to create the plane
  81006. * @returns a new Plane defined by the three given points.
  81007. */
  81008. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81009. /**
  81010. * Creates a plane from an origin point and a normal
  81011. * @param origin origin of the plane to be constructed
  81012. * @param normal normal of the plane to be constructed
  81013. * @returns a new Plane the normal vector to this plane at the given origin point.
  81014. * Note : the vector "normal" is updated because normalized.
  81015. */
  81016. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81017. /**
  81018. * Calculates the distance from a plane and a point
  81019. * @param origin origin of the plane to be constructed
  81020. * @param normal normal of the plane to be constructed
  81021. * @param point point to calculate distance to
  81022. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81023. */
  81024. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81025. }
  81026. }
  81027. declare module BABYLON {
  81028. /** @hidden */
  81029. export class PerformanceConfigurator {
  81030. /** @hidden */
  81031. static MatrixUse64Bits: boolean;
  81032. /** @hidden */
  81033. static MatrixTrackPrecisionChange: boolean;
  81034. /** @hidden */
  81035. static MatrixCurrentType: any;
  81036. /** @hidden */
  81037. static MatrixTrackedMatrices: Array<any> | null;
  81038. /** @hidden */
  81039. static SetMatrixPrecision(use64bits: boolean): void;
  81040. }
  81041. }
  81042. declare module BABYLON {
  81043. /**
  81044. * Class representing a vector containing 2 coordinates
  81045. */
  81046. export class Vector2 {
  81047. /** defines the first coordinate */
  81048. x: number;
  81049. /** defines the second coordinate */
  81050. y: number;
  81051. /**
  81052. * Creates a new Vector2 from the given x and y coordinates
  81053. * @param x defines the first coordinate
  81054. * @param y defines the second coordinate
  81055. */
  81056. constructor(
  81057. /** defines the first coordinate */
  81058. x?: number,
  81059. /** defines the second coordinate */
  81060. y?: number);
  81061. /**
  81062. * Gets a string with the Vector2 coordinates
  81063. * @returns a string with the Vector2 coordinates
  81064. */
  81065. toString(): string;
  81066. /**
  81067. * Gets class name
  81068. * @returns the string "Vector2"
  81069. */
  81070. getClassName(): string;
  81071. /**
  81072. * Gets current vector hash code
  81073. * @returns the Vector2 hash code as a number
  81074. */
  81075. getHashCode(): number;
  81076. /**
  81077. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81078. * @param array defines the source array
  81079. * @param index defines the offset in source array
  81080. * @returns the current Vector2
  81081. */
  81082. toArray(array: FloatArray, index?: number): Vector2;
  81083. /**
  81084. * Update the current vector from an array
  81085. * @param array defines the destination array
  81086. * @param index defines the offset in the destination array
  81087. * @returns the current Vector3
  81088. */
  81089. fromArray(array: FloatArray, index?: number): Vector2;
  81090. /**
  81091. * Copy the current vector to an array
  81092. * @returns a new array with 2 elements: the Vector2 coordinates.
  81093. */
  81094. asArray(): number[];
  81095. /**
  81096. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81097. * @param source defines the source Vector2
  81098. * @returns the current updated Vector2
  81099. */
  81100. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81101. /**
  81102. * Sets the Vector2 coordinates with the given floats
  81103. * @param x defines the first coordinate
  81104. * @param y defines the second coordinate
  81105. * @returns the current updated Vector2
  81106. */
  81107. copyFromFloats(x: number, y: number): Vector2;
  81108. /**
  81109. * Sets the Vector2 coordinates with the given floats
  81110. * @param x defines the first coordinate
  81111. * @param y defines the second coordinate
  81112. * @returns the current updated Vector2
  81113. */
  81114. set(x: number, y: number): Vector2;
  81115. /**
  81116. * Add another vector with the current one
  81117. * @param otherVector defines the other vector
  81118. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81119. */
  81120. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81121. /**
  81122. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81123. * @param otherVector defines the other vector
  81124. * @param result defines the target vector
  81125. * @returns the unmodified current Vector2
  81126. */
  81127. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81128. /**
  81129. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81130. * @param otherVector defines the other vector
  81131. * @returns the current updated Vector2
  81132. */
  81133. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81134. /**
  81135. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81136. * @param otherVector defines the other vector
  81137. * @returns a new Vector2
  81138. */
  81139. addVector3(otherVector: Vector3): Vector2;
  81140. /**
  81141. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81142. * @param otherVector defines the other vector
  81143. * @returns a new Vector2
  81144. */
  81145. subtract(otherVector: Vector2): Vector2;
  81146. /**
  81147. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81148. * @param otherVector defines the other vector
  81149. * @param result defines the target vector
  81150. * @returns the unmodified current Vector2
  81151. */
  81152. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81153. /**
  81154. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81155. * @param otherVector defines the other vector
  81156. * @returns the current updated Vector2
  81157. */
  81158. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81159. /**
  81160. * Multiplies in place the current Vector2 coordinates by the given ones
  81161. * @param otherVector defines the other vector
  81162. * @returns the current updated Vector2
  81163. */
  81164. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81165. /**
  81166. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81167. * @param otherVector defines the other vector
  81168. * @returns a new Vector2
  81169. */
  81170. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81171. /**
  81172. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81173. * @param otherVector defines the other vector
  81174. * @param result defines the target vector
  81175. * @returns the unmodified current Vector2
  81176. */
  81177. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81178. /**
  81179. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81180. * @param x defines the first coordinate
  81181. * @param y defines the second coordinate
  81182. * @returns a new Vector2
  81183. */
  81184. multiplyByFloats(x: number, y: number): Vector2;
  81185. /**
  81186. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81187. * @param otherVector defines the other vector
  81188. * @returns a new Vector2
  81189. */
  81190. divide(otherVector: Vector2): Vector2;
  81191. /**
  81192. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81193. * @param otherVector defines the other vector
  81194. * @param result defines the target vector
  81195. * @returns the unmodified current Vector2
  81196. */
  81197. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81198. /**
  81199. * Divides the current Vector2 coordinates by the given ones
  81200. * @param otherVector defines the other vector
  81201. * @returns the current updated Vector2
  81202. */
  81203. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81204. /**
  81205. * Gets a new Vector2 with current Vector2 negated coordinates
  81206. * @returns a new Vector2
  81207. */
  81208. negate(): Vector2;
  81209. /**
  81210. * Negate this vector in place
  81211. * @returns this
  81212. */
  81213. negateInPlace(): Vector2;
  81214. /**
  81215. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81216. * @param result defines the Vector3 object where to store the result
  81217. * @returns the current Vector2
  81218. */
  81219. negateToRef(result: Vector2): Vector2;
  81220. /**
  81221. * Multiply the Vector2 coordinates by scale
  81222. * @param scale defines the scaling factor
  81223. * @returns the current updated Vector2
  81224. */
  81225. scaleInPlace(scale: number): Vector2;
  81226. /**
  81227. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81228. * @param scale defines the scaling factor
  81229. * @returns a new Vector2
  81230. */
  81231. scale(scale: number): Vector2;
  81232. /**
  81233. * Scale the current Vector2 values by a factor to a given Vector2
  81234. * @param scale defines the scale factor
  81235. * @param result defines the Vector2 object where to store the result
  81236. * @returns the unmodified current Vector2
  81237. */
  81238. scaleToRef(scale: number, result: Vector2): Vector2;
  81239. /**
  81240. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81241. * @param scale defines the scale factor
  81242. * @param result defines the Vector2 object where to store the result
  81243. * @returns the unmodified current Vector2
  81244. */
  81245. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81246. /**
  81247. * Gets a boolean if two vectors are equals
  81248. * @param otherVector defines the other vector
  81249. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81250. */
  81251. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81252. /**
  81253. * Gets a boolean if two vectors are equals (using an epsilon value)
  81254. * @param otherVector defines the other vector
  81255. * @param epsilon defines the minimal distance to consider equality
  81256. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81257. */
  81258. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81259. /**
  81260. * Gets a new Vector2 from current Vector2 floored values
  81261. * @returns a new Vector2
  81262. */
  81263. floor(): Vector2;
  81264. /**
  81265. * Gets a new Vector2 from current Vector2 floored values
  81266. * @returns a new Vector2
  81267. */
  81268. fract(): Vector2;
  81269. /**
  81270. * Gets the length of the vector
  81271. * @returns the vector length (float)
  81272. */
  81273. length(): number;
  81274. /**
  81275. * Gets the vector squared length
  81276. * @returns the vector squared length (float)
  81277. */
  81278. lengthSquared(): number;
  81279. /**
  81280. * Normalize the vector
  81281. * @returns the current updated Vector2
  81282. */
  81283. normalize(): Vector2;
  81284. /**
  81285. * Gets a new Vector2 copied from the Vector2
  81286. * @returns a new Vector2
  81287. */
  81288. clone(): Vector2;
  81289. /**
  81290. * Gets a new Vector2(0, 0)
  81291. * @returns a new Vector2
  81292. */
  81293. static Zero(): Vector2;
  81294. /**
  81295. * Gets a new Vector2(1, 1)
  81296. * @returns a new Vector2
  81297. */
  81298. static One(): Vector2;
  81299. /**
  81300. * Gets a new Vector2 set from the given index element of the given array
  81301. * @param array defines the data source
  81302. * @param offset defines the offset in the data source
  81303. * @returns a new Vector2
  81304. */
  81305. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81306. /**
  81307. * Sets "result" from the given index element of the given array
  81308. * @param array defines the data source
  81309. * @param offset defines the offset in the data source
  81310. * @param result defines the target vector
  81311. */
  81312. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81313. /**
  81314. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81315. * @param value1 defines 1st point of control
  81316. * @param value2 defines 2nd point of control
  81317. * @param value3 defines 3rd point of control
  81318. * @param value4 defines 4th point of control
  81319. * @param amount defines the interpolation factor
  81320. * @returns a new Vector2
  81321. */
  81322. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81323. /**
  81324. * 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".
  81325. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81326. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81327. * @param value defines the value to clamp
  81328. * @param min defines the lower limit
  81329. * @param max defines the upper limit
  81330. * @returns a new Vector2
  81331. */
  81332. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81333. /**
  81334. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81335. * @param value1 defines the 1st control point
  81336. * @param tangent1 defines the outgoing tangent
  81337. * @param value2 defines the 2nd control point
  81338. * @param tangent2 defines the incoming tangent
  81339. * @param amount defines the interpolation factor
  81340. * @returns a new Vector2
  81341. */
  81342. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81343. /**
  81344. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81345. * @param start defines the start vector
  81346. * @param end defines the end vector
  81347. * @param amount defines the interpolation factor
  81348. * @returns a new Vector2
  81349. */
  81350. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81351. /**
  81352. * Gets the dot product of the vector "left" and the vector "right"
  81353. * @param left defines first vector
  81354. * @param right defines second vector
  81355. * @returns the dot product (float)
  81356. */
  81357. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81358. /**
  81359. * Returns a new Vector2 equal to the normalized given vector
  81360. * @param vector defines the vector to normalize
  81361. * @returns a new Vector2
  81362. */
  81363. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81364. /**
  81365. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81366. * @param left defines 1st vector
  81367. * @param right defines 2nd vector
  81368. * @returns a new Vector2
  81369. */
  81370. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81371. /**
  81372. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81373. * @param left defines 1st vector
  81374. * @param right defines 2nd vector
  81375. * @returns a new Vector2
  81376. */
  81377. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81378. /**
  81379. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81380. * @param vector defines the vector to transform
  81381. * @param transformation defines the matrix to apply
  81382. * @returns a new Vector2
  81383. */
  81384. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81385. /**
  81386. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81387. * @param vector defines the vector to transform
  81388. * @param transformation defines the matrix to apply
  81389. * @param result defines the target vector
  81390. */
  81391. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81392. /**
  81393. * Determines if a given vector is included in a triangle
  81394. * @param p defines the vector to test
  81395. * @param p0 defines 1st triangle point
  81396. * @param p1 defines 2nd triangle point
  81397. * @param p2 defines 3rd triangle point
  81398. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81399. */
  81400. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81401. /**
  81402. * Gets the distance between the vectors "value1" and "value2"
  81403. * @param value1 defines first vector
  81404. * @param value2 defines second vector
  81405. * @returns the distance between vectors
  81406. */
  81407. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81408. /**
  81409. * Returns the squared distance between the vectors "value1" and "value2"
  81410. * @param value1 defines first vector
  81411. * @param value2 defines second vector
  81412. * @returns the squared distance between vectors
  81413. */
  81414. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81415. /**
  81416. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81417. * @param value1 defines first vector
  81418. * @param value2 defines second vector
  81419. * @returns a new Vector2
  81420. */
  81421. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81422. /**
  81423. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81424. * @param p defines the middle point
  81425. * @param segA defines one point of the segment
  81426. * @param segB defines the other point of the segment
  81427. * @returns the shortest distance
  81428. */
  81429. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81430. }
  81431. /**
  81432. * Class used to store (x,y,z) vector representation
  81433. * A Vector3 is the main object used in 3D geometry
  81434. * It can represent etiher the coordinates of a point the space, either a direction
  81435. * Reminder: js uses a left handed forward facing system
  81436. */
  81437. export class Vector3 {
  81438. private static _UpReadOnly;
  81439. private static _ZeroReadOnly;
  81440. /** @hidden */
  81441. _x: number;
  81442. /** @hidden */
  81443. _y: number;
  81444. /** @hidden */
  81445. _z: number;
  81446. /** @hidden */
  81447. _isDirty: boolean;
  81448. /** Gets or sets the x coordinate */
  81449. get x(): number;
  81450. set x(value: number);
  81451. /** Gets or sets the y coordinate */
  81452. get y(): number;
  81453. set y(value: number);
  81454. /** Gets or sets the z coordinate */
  81455. get z(): number;
  81456. set z(value: number);
  81457. /**
  81458. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81459. * @param x defines the first coordinates (on X axis)
  81460. * @param y defines the second coordinates (on Y axis)
  81461. * @param z defines the third coordinates (on Z axis)
  81462. */
  81463. constructor(x?: number, y?: number, z?: number);
  81464. /**
  81465. * Creates a string representation of the Vector3
  81466. * @returns a string with the Vector3 coordinates.
  81467. */
  81468. toString(): string;
  81469. /**
  81470. * Gets the class name
  81471. * @returns the string "Vector3"
  81472. */
  81473. getClassName(): string;
  81474. /**
  81475. * Creates the Vector3 hash code
  81476. * @returns a number which tends to be unique between Vector3 instances
  81477. */
  81478. getHashCode(): number;
  81479. /**
  81480. * Creates an array containing three elements : the coordinates of the Vector3
  81481. * @returns a new array of numbers
  81482. */
  81483. asArray(): number[];
  81484. /**
  81485. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81486. * @param array defines the destination array
  81487. * @param index defines the offset in the destination array
  81488. * @returns the current Vector3
  81489. */
  81490. toArray(array: FloatArray, index?: number): Vector3;
  81491. /**
  81492. * Update the current vector from an array
  81493. * @param array defines the destination array
  81494. * @param index defines the offset in the destination array
  81495. * @returns the current Vector3
  81496. */
  81497. fromArray(array: FloatArray, index?: number): Vector3;
  81498. /**
  81499. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81500. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81501. */
  81502. toQuaternion(): Quaternion;
  81503. /**
  81504. * Adds the given vector to the current Vector3
  81505. * @param otherVector defines the second operand
  81506. * @returns the current updated Vector3
  81507. */
  81508. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81509. /**
  81510. * Adds the given coordinates to the current Vector3
  81511. * @param x defines the x coordinate of the operand
  81512. * @param y defines the y coordinate of the operand
  81513. * @param z defines the z coordinate of the operand
  81514. * @returns the current updated Vector3
  81515. */
  81516. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81517. /**
  81518. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81519. * @param otherVector defines the second operand
  81520. * @returns the resulting Vector3
  81521. */
  81522. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81523. /**
  81524. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81525. * @param otherVector defines the second operand
  81526. * @param result defines the Vector3 object where to store the result
  81527. * @returns the current Vector3
  81528. */
  81529. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81530. /**
  81531. * Subtract the given vector from the current Vector3
  81532. * @param otherVector defines the second operand
  81533. * @returns the current updated Vector3
  81534. */
  81535. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81536. /**
  81537. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81538. * @param otherVector defines the second operand
  81539. * @returns the resulting Vector3
  81540. */
  81541. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81542. /**
  81543. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81544. * @param otherVector defines the second operand
  81545. * @param result defines the Vector3 object where to store the result
  81546. * @returns the current Vector3
  81547. */
  81548. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81549. /**
  81550. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81551. * @param x defines the x coordinate of the operand
  81552. * @param y defines the y coordinate of the operand
  81553. * @param z defines the z coordinate of the operand
  81554. * @returns the resulting Vector3
  81555. */
  81556. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81557. /**
  81558. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81559. * @param x defines the x coordinate of the operand
  81560. * @param y defines the y coordinate of the operand
  81561. * @param z defines the z coordinate of the operand
  81562. * @param result defines the Vector3 object where to store the result
  81563. * @returns the current Vector3
  81564. */
  81565. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81566. /**
  81567. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81568. * @returns a new Vector3
  81569. */
  81570. negate(): Vector3;
  81571. /**
  81572. * Negate this vector in place
  81573. * @returns this
  81574. */
  81575. negateInPlace(): Vector3;
  81576. /**
  81577. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81578. * @param result defines the Vector3 object where to store the result
  81579. * @returns the current Vector3
  81580. */
  81581. negateToRef(result: Vector3): Vector3;
  81582. /**
  81583. * Multiplies the Vector3 coordinates by the float "scale"
  81584. * @param scale defines the multiplier factor
  81585. * @returns the current updated Vector3
  81586. */
  81587. scaleInPlace(scale: number): Vector3;
  81588. /**
  81589. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81590. * @param scale defines the multiplier factor
  81591. * @returns a new Vector3
  81592. */
  81593. scale(scale: number): Vector3;
  81594. /**
  81595. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81596. * @param scale defines the multiplier factor
  81597. * @param result defines the Vector3 object where to store the result
  81598. * @returns the current Vector3
  81599. */
  81600. scaleToRef(scale: number, result: Vector3): Vector3;
  81601. /**
  81602. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81603. * @param scale defines the scale factor
  81604. * @param result defines the Vector3 object where to store the result
  81605. * @returns the unmodified current Vector3
  81606. */
  81607. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81608. /**
  81609. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81610. * @param origin defines the origin of the projection ray
  81611. * @param plane defines the plane to project to
  81612. * @returns the projected vector3
  81613. */
  81614. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81615. /**
  81616. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81617. * @param origin defines the origin of the projection ray
  81618. * @param plane defines the plane to project to
  81619. * @param result defines the Vector3 where to store the result
  81620. */
  81621. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81622. /**
  81623. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81624. * @param otherVector defines the second operand
  81625. * @returns true if both vectors are equals
  81626. */
  81627. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81628. /**
  81629. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81630. * @param otherVector defines the second operand
  81631. * @param epsilon defines the minimal distance to define values as equals
  81632. * @returns true if both vectors are distant less than epsilon
  81633. */
  81634. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81635. /**
  81636. * Returns true if the current Vector3 coordinates equals the given floats
  81637. * @param x defines the x coordinate of the operand
  81638. * @param y defines the y coordinate of the operand
  81639. * @param z defines the z coordinate of the operand
  81640. * @returns true if both vectors are equals
  81641. */
  81642. equalsToFloats(x: number, y: number, z: number): boolean;
  81643. /**
  81644. * Multiplies the current Vector3 coordinates by the given ones
  81645. * @param otherVector defines the second operand
  81646. * @returns the current updated Vector3
  81647. */
  81648. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81649. /**
  81650. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81651. * @param otherVector defines the second operand
  81652. * @returns the new Vector3
  81653. */
  81654. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81655. /**
  81656. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81657. * @param otherVector defines the second operand
  81658. * @param result defines the Vector3 object where to store the result
  81659. * @returns the current Vector3
  81660. */
  81661. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81662. /**
  81663. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81664. * @param x defines the x coordinate of the operand
  81665. * @param y defines the y coordinate of the operand
  81666. * @param z defines the z coordinate of the operand
  81667. * @returns the new Vector3
  81668. */
  81669. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81670. /**
  81671. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81672. * @param otherVector defines the second operand
  81673. * @returns the new Vector3
  81674. */
  81675. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81676. /**
  81677. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81678. * @param otherVector defines the second operand
  81679. * @param result defines the Vector3 object where to store the result
  81680. * @returns the current Vector3
  81681. */
  81682. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81683. /**
  81684. * Divides the current Vector3 coordinates by the given ones.
  81685. * @param otherVector defines the second operand
  81686. * @returns the current updated Vector3
  81687. */
  81688. divideInPlace(otherVector: Vector3): Vector3;
  81689. /**
  81690. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81691. * @param other defines the second operand
  81692. * @returns the current updated Vector3
  81693. */
  81694. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81695. /**
  81696. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81697. * @param other defines the second operand
  81698. * @returns the current updated Vector3
  81699. */
  81700. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81701. /**
  81702. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81703. * @param x defines the x coordinate of the operand
  81704. * @param y defines the y coordinate of the operand
  81705. * @param z defines the z coordinate of the operand
  81706. * @returns the current updated Vector3
  81707. */
  81708. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81709. /**
  81710. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81711. * @param x defines the x coordinate of the operand
  81712. * @param y defines the y coordinate of the operand
  81713. * @param z defines the z coordinate of the operand
  81714. * @returns the current updated Vector3
  81715. */
  81716. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81717. /**
  81718. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81719. * Check if is non uniform within a certain amount of decimal places to account for this
  81720. * @param epsilon the amount the values can differ
  81721. * @returns if the the vector is non uniform to a certain number of decimal places
  81722. */
  81723. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81724. /**
  81725. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81726. */
  81727. get isNonUniform(): boolean;
  81728. /**
  81729. * Gets a new Vector3 from current Vector3 floored values
  81730. * @returns a new Vector3
  81731. */
  81732. floor(): Vector3;
  81733. /**
  81734. * Gets a new Vector3 from current Vector3 floored values
  81735. * @returns a new Vector3
  81736. */
  81737. fract(): Vector3;
  81738. /**
  81739. * Gets the length of the Vector3
  81740. * @returns the length of the Vector3
  81741. */
  81742. length(): number;
  81743. /**
  81744. * Gets the squared length of the Vector3
  81745. * @returns squared length of the Vector3
  81746. */
  81747. lengthSquared(): number;
  81748. /**
  81749. * Normalize the current Vector3.
  81750. * Please note that this is an in place operation.
  81751. * @returns the current updated Vector3
  81752. */
  81753. normalize(): Vector3;
  81754. /**
  81755. * Reorders the x y z properties of the vector in place
  81756. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81757. * @returns the current updated vector
  81758. */
  81759. reorderInPlace(order: string): this;
  81760. /**
  81761. * Rotates the vector around 0,0,0 by a quaternion
  81762. * @param quaternion the rotation quaternion
  81763. * @param result vector to store the result
  81764. * @returns the resulting vector
  81765. */
  81766. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81767. /**
  81768. * Rotates a vector around a given point
  81769. * @param quaternion the rotation quaternion
  81770. * @param point the point to rotate around
  81771. * @param result vector to store the result
  81772. * @returns the resulting vector
  81773. */
  81774. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81775. /**
  81776. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81777. * The cross product is then orthogonal to both current and "other"
  81778. * @param other defines the right operand
  81779. * @returns the cross product
  81780. */
  81781. cross(other: Vector3): Vector3;
  81782. /**
  81783. * Normalize the current Vector3 with the given input length.
  81784. * Please note that this is an in place operation.
  81785. * @param len the length of the vector
  81786. * @returns the current updated Vector3
  81787. */
  81788. normalizeFromLength(len: number): Vector3;
  81789. /**
  81790. * Normalize the current Vector3 to a new vector
  81791. * @returns the new Vector3
  81792. */
  81793. normalizeToNew(): Vector3;
  81794. /**
  81795. * Normalize the current Vector3 to the reference
  81796. * @param reference define the Vector3 to update
  81797. * @returns the updated Vector3
  81798. */
  81799. normalizeToRef(reference: Vector3): Vector3;
  81800. /**
  81801. * Creates a new Vector3 copied from the current Vector3
  81802. * @returns the new Vector3
  81803. */
  81804. clone(): Vector3;
  81805. /**
  81806. * Copies the given vector coordinates to the current Vector3 ones
  81807. * @param source defines the source Vector3
  81808. * @returns the current updated Vector3
  81809. */
  81810. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81811. /**
  81812. * Copies the given floats to the current Vector3 coordinates
  81813. * @param x defines the x coordinate of the operand
  81814. * @param y defines the y coordinate of the operand
  81815. * @param z defines the z coordinate of the operand
  81816. * @returns the current updated Vector3
  81817. */
  81818. copyFromFloats(x: number, y: number, z: number): Vector3;
  81819. /**
  81820. * Copies the given floats to the current Vector3 coordinates
  81821. * @param x defines the x coordinate of the operand
  81822. * @param y defines the y coordinate of the operand
  81823. * @param z defines the z coordinate of the operand
  81824. * @returns the current updated Vector3
  81825. */
  81826. set(x: number, y: number, z: number): Vector3;
  81827. /**
  81828. * Copies the given float to the current Vector3 coordinates
  81829. * @param v defines the x, y and z coordinates of the operand
  81830. * @returns the current updated Vector3
  81831. */
  81832. setAll(v: number): Vector3;
  81833. /**
  81834. * Get the clip factor between two vectors
  81835. * @param vector0 defines the first operand
  81836. * @param vector1 defines the second operand
  81837. * @param axis defines the axis to use
  81838. * @param size defines the size along the axis
  81839. * @returns the clip factor
  81840. */
  81841. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81842. /**
  81843. * Get angle between two vectors
  81844. * @param vector0 angle between vector0 and vector1
  81845. * @param vector1 angle between vector0 and vector1
  81846. * @param normal direction of the normal
  81847. * @return the angle between vector0 and vector1
  81848. */
  81849. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81850. /**
  81851. * Returns a new Vector3 set from the index "offset" of the given array
  81852. * @param array defines the source array
  81853. * @param offset defines the offset in the source array
  81854. * @returns the new Vector3
  81855. */
  81856. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81857. /**
  81858. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81859. * @param array defines the source array
  81860. * @param offset defines the offset in the source array
  81861. * @returns the new Vector3
  81862. * @deprecated Please use FromArray instead.
  81863. */
  81864. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81865. /**
  81866. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81867. * @param array defines the source array
  81868. * @param offset defines the offset in the source array
  81869. * @param result defines the Vector3 where to store the result
  81870. */
  81871. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81872. /**
  81873. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81874. * @param array defines the source array
  81875. * @param offset defines the offset in the source array
  81876. * @param result defines the Vector3 where to store the result
  81877. * @deprecated Please use FromArrayToRef instead.
  81878. */
  81879. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81880. /**
  81881. * Sets the given vector "result" with the given floats.
  81882. * @param x defines the x coordinate of the source
  81883. * @param y defines the y coordinate of the source
  81884. * @param z defines the z coordinate of the source
  81885. * @param result defines the Vector3 where to store the result
  81886. */
  81887. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81888. /**
  81889. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81890. * @returns a new empty Vector3
  81891. */
  81892. static Zero(): Vector3;
  81893. /**
  81894. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81895. * @returns a new unit Vector3
  81896. */
  81897. static One(): Vector3;
  81898. /**
  81899. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81900. * @returns a new up Vector3
  81901. */
  81902. static Up(): Vector3;
  81903. /**
  81904. * Gets a up Vector3 that must not be updated
  81905. */
  81906. static get UpReadOnly(): DeepImmutable<Vector3>;
  81907. /**
  81908. * Gets a zero Vector3 that must not be updated
  81909. */
  81910. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81911. /**
  81912. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81913. * @returns a new down Vector3
  81914. */
  81915. static Down(): Vector3;
  81916. /**
  81917. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81918. * @param rightHandedSystem is the scene right-handed (negative z)
  81919. * @returns a new forward Vector3
  81920. */
  81921. static Forward(rightHandedSystem?: boolean): Vector3;
  81922. /**
  81923. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81924. * @param rightHandedSystem is the scene right-handed (negative-z)
  81925. * @returns a new forward Vector3
  81926. */
  81927. static Backward(rightHandedSystem?: boolean): Vector3;
  81928. /**
  81929. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81930. * @returns a new right Vector3
  81931. */
  81932. static Right(): Vector3;
  81933. /**
  81934. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81935. * @returns a new left Vector3
  81936. */
  81937. static Left(): Vector3;
  81938. /**
  81939. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81940. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81941. * @param vector defines the Vector3 to transform
  81942. * @param transformation defines the transformation matrix
  81943. * @returns the transformed Vector3
  81944. */
  81945. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81946. /**
  81947. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81948. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81949. * @param vector defines the Vector3 to transform
  81950. * @param transformation defines the transformation matrix
  81951. * @param result defines the Vector3 where to store the result
  81952. */
  81953. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81954. /**
  81955. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81956. * This method computes tranformed coordinates only, not transformed direction vectors
  81957. * @param x define the x coordinate of the source vector
  81958. * @param y define the y coordinate of the source vector
  81959. * @param z define the z coordinate of the source vector
  81960. * @param transformation defines the transformation matrix
  81961. * @param result defines the Vector3 where to store the result
  81962. */
  81963. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81964. /**
  81965. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81966. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81967. * @param vector defines the Vector3 to transform
  81968. * @param transformation defines the transformation matrix
  81969. * @returns the new Vector3
  81970. */
  81971. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81972. /**
  81973. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81974. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81975. * @param vector defines the Vector3 to transform
  81976. * @param transformation defines the transformation matrix
  81977. * @param result defines the Vector3 where to store the result
  81978. */
  81979. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81980. /**
  81981. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81982. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81983. * @param x define the x coordinate of the source vector
  81984. * @param y define the y coordinate of the source vector
  81985. * @param z define the z coordinate of the source vector
  81986. * @param transformation defines the transformation matrix
  81987. * @param result defines the Vector3 where to store the result
  81988. */
  81989. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81990. /**
  81991. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81992. * @param value1 defines the first control point
  81993. * @param value2 defines the second control point
  81994. * @param value3 defines the third control point
  81995. * @param value4 defines the fourth control point
  81996. * @param amount defines the amount on the spline to use
  81997. * @returns the new Vector3
  81998. */
  81999. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82000. /**
  82001. * 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"
  82002. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82003. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82004. * @param value defines the current value
  82005. * @param min defines the lower range value
  82006. * @param max defines the upper range value
  82007. * @returns the new Vector3
  82008. */
  82009. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82010. /**
  82011. * 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"
  82012. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82013. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82014. * @param value defines the current value
  82015. * @param min defines the lower range value
  82016. * @param max defines the upper range value
  82017. * @param result defines the Vector3 where to store the result
  82018. */
  82019. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82020. /**
  82021. * Checks if a given vector is inside a specific range
  82022. * @param v defines the vector to test
  82023. * @param min defines the minimum range
  82024. * @param max defines the maximum range
  82025. */
  82026. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82027. /**
  82028. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82029. * @param value1 defines the first control point
  82030. * @param tangent1 defines the first tangent vector
  82031. * @param value2 defines the second control point
  82032. * @param tangent2 defines the second tangent vector
  82033. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82034. * @returns the new Vector3
  82035. */
  82036. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82037. /**
  82038. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82039. * @param start defines the start value
  82040. * @param end defines the end value
  82041. * @param amount max defines amount between both (between 0 and 1)
  82042. * @returns the new Vector3
  82043. */
  82044. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82045. /**
  82046. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82047. * @param start defines the start value
  82048. * @param end defines the end value
  82049. * @param amount max defines amount between both (between 0 and 1)
  82050. * @param result defines the Vector3 where to store the result
  82051. */
  82052. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82053. /**
  82054. * Returns the dot product (float) between the vectors "left" and "right"
  82055. * @param left defines the left operand
  82056. * @param right defines the right operand
  82057. * @returns the dot product
  82058. */
  82059. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82060. /**
  82061. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82062. * The cross product is then orthogonal to both "left" and "right"
  82063. * @param left defines the left operand
  82064. * @param right defines the right operand
  82065. * @returns the cross product
  82066. */
  82067. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82068. /**
  82069. * Sets the given vector "result" with the cross product of "left" and "right"
  82070. * The cross product is then orthogonal to both "left" and "right"
  82071. * @param left defines the left operand
  82072. * @param right defines the right operand
  82073. * @param result defines the Vector3 where to store the result
  82074. */
  82075. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82076. /**
  82077. * Returns a new Vector3 as the normalization of the given vector
  82078. * @param vector defines the Vector3 to normalize
  82079. * @returns the new Vector3
  82080. */
  82081. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82082. /**
  82083. * Sets the given vector "result" with the normalization of the given first vector
  82084. * @param vector defines the Vector3 to normalize
  82085. * @param result defines the Vector3 where to store the result
  82086. */
  82087. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82088. /**
  82089. * Project a Vector3 onto screen space
  82090. * @param vector defines the Vector3 to project
  82091. * @param world defines the world matrix to use
  82092. * @param transform defines the transform (view x projection) matrix to use
  82093. * @param viewport defines the screen viewport to use
  82094. * @returns the new Vector3
  82095. */
  82096. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82097. /** @hidden */
  82098. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82099. /**
  82100. * Unproject from screen space to object space
  82101. * @param source defines the screen space Vector3 to use
  82102. * @param viewportWidth defines the current width of the viewport
  82103. * @param viewportHeight defines the current height of the viewport
  82104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82105. * @param transform defines the transform (view x projection) matrix to use
  82106. * @returns the new Vector3
  82107. */
  82108. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82109. /**
  82110. * Unproject from screen space to object space
  82111. * @param source defines the screen space Vector3 to use
  82112. * @param viewportWidth defines the current width of the viewport
  82113. * @param viewportHeight defines the current height of the viewport
  82114. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82115. * @param view defines the view matrix to use
  82116. * @param projection defines the projection matrix to use
  82117. * @returns the new Vector3
  82118. */
  82119. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82120. /**
  82121. * Unproject from screen space to object space
  82122. * @param source defines the screen space Vector3 to use
  82123. * @param viewportWidth defines the current width of the viewport
  82124. * @param viewportHeight defines the current height of the viewport
  82125. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82126. * @param view defines the view matrix to use
  82127. * @param projection defines the projection matrix to use
  82128. * @param result defines the Vector3 where to store the result
  82129. */
  82130. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82131. /**
  82132. * Unproject from screen space to object space
  82133. * @param sourceX defines the screen space x coordinate to use
  82134. * @param sourceY defines the screen space y coordinate to use
  82135. * @param sourceZ defines the screen space z coordinate to use
  82136. * @param viewportWidth defines the current width of the viewport
  82137. * @param viewportHeight defines the current height of the viewport
  82138. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82139. * @param view defines the view matrix to use
  82140. * @param projection defines the projection matrix to use
  82141. * @param result defines the Vector3 where to store the result
  82142. */
  82143. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82144. /**
  82145. * Gets the minimal coordinate values between two Vector3
  82146. * @param left defines the first operand
  82147. * @param right defines the second operand
  82148. * @returns the new Vector3
  82149. */
  82150. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82151. /**
  82152. * Gets the maximal coordinate values between two Vector3
  82153. * @param left defines the first operand
  82154. * @param right defines the second operand
  82155. * @returns the new Vector3
  82156. */
  82157. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82158. /**
  82159. * Returns the distance between the vectors "value1" and "value2"
  82160. * @param value1 defines the first operand
  82161. * @param value2 defines the second operand
  82162. * @returns the distance
  82163. */
  82164. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82165. /**
  82166. * Returns the squared distance between the vectors "value1" and "value2"
  82167. * @param value1 defines the first operand
  82168. * @param value2 defines the second operand
  82169. * @returns the squared distance
  82170. */
  82171. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82172. /**
  82173. * Returns a new Vector3 located at the center between "value1" and "value2"
  82174. * @param value1 defines the first operand
  82175. * @param value2 defines the second operand
  82176. * @returns the new Vector3
  82177. */
  82178. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82179. /**
  82180. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82181. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82182. * to something in order to rotate it from its local system to the given target system
  82183. * Note: axis1, axis2 and axis3 are normalized during this operation
  82184. * @param axis1 defines the first axis
  82185. * @param axis2 defines the second axis
  82186. * @param axis3 defines the third axis
  82187. * @returns a new Vector3
  82188. */
  82189. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82190. /**
  82191. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82192. * @param axis1 defines the first axis
  82193. * @param axis2 defines the second axis
  82194. * @param axis3 defines the third axis
  82195. * @param ref defines the Vector3 where to store the result
  82196. */
  82197. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82198. }
  82199. /**
  82200. * Vector4 class created for EulerAngle class conversion to Quaternion
  82201. */
  82202. export class Vector4 {
  82203. /** x value of the vector */
  82204. x: number;
  82205. /** y value of the vector */
  82206. y: number;
  82207. /** z value of the vector */
  82208. z: number;
  82209. /** w value of the vector */
  82210. w: number;
  82211. /**
  82212. * Creates a Vector4 object from the given floats.
  82213. * @param x x value of the vector
  82214. * @param y y value of the vector
  82215. * @param z z value of the vector
  82216. * @param w w value of the vector
  82217. */
  82218. constructor(
  82219. /** x value of the vector */
  82220. x: number,
  82221. /** y value of the vector */
  82222. y: number,
  82223. /** z value of the vector */
  82224. z: number,
  82225. /** w value of the vector */
  82226. w: number);
  82227. /**
  82228. * Returns the string with the Vector4 coordinates.
  82229. * @returns a string containing all the vector values
  82230. */
  82231. toString(): string;
  82232. /**
  82233. * Returns the string "Vector4".
  82234. * @returns "Vector4"
  82235. */
  82236. getClassName(): string;
  82237. /**
  82238. * Returns the Vector4 hash code.
  82239. * @returns a unique hash code
  82240. */
  82241. getHashCode(): number;
  82242. /**
  82243. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82244. * @returns the resulting array
  82245. */
  82246. asArray(): number[];
  82247. /**
  82248. * Populates the given array from the given index with the Vector4 coordinates.
  82249. * @param array array to populate
  82250. * @param index index of the array to start at (default: 0)
  82251. * @returns the Vector4.
  82252. */
  82253. toArray(array: FloatArray, index?: number): Vector4;
  82254. /**
  82255. * Update the current vector from an array
  82256. * @param array defines the destination array
  82257. * @param index defines the offset in the destination array
  82258. * @returns the current Vector3
  82259. */
  82260. fromArray(array: FloatArray, index?: number): Vector4;
  82261. /**
  82262. * Adds the given vector to the current Vector4.
  82263. * @param otherVector the vector to add
  82264. * @returns the updated Vector4.
  82265. */
  82266. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82267. /**
  82268. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82269. * @param otherVector the vector to add
  82270. * @returns the resulting vector
  82271. */
  82272. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82273. /**
  82274. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82275. * @param otherVector the vector to add
  82276. * @param result the vector to store the result
  82277. * @returns the current Vector4.
  82278. */
  82279. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82280. /**
  82281. * Subtract in place the given vector from the current Vector4.
  82282. * @param otherVector the vector to subtract
  82283. * @returns the updated Vector4.
  82284. */
  82285. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82286. /**
  82287. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82288. * @param otherVector the vector to add
  82289. * @returns the new vector with the result
  82290. */
  82291. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82292. /**
  82293. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82294. * @param otherVector the vector to subtract
  82295. * @param result the vector to store the result
  82296. * @returns the current Vector4.
  82297. */
  82298. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82299. /**
  82300. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82301. */
  82302. /**
  82303. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82304. * @param x value to subtract
  82305. * @param y value to subtract
  82306. * @param z value to subtract
  82307. * @param w value to subtract
  82308. * @returns new vector containing the result
  82309. */
  82310. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82311. /**
  82312. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82313. * @param x value to subtract
  82314. * @param y value to subtract
  82315. * @param z value to subtract
  82316. * @param w value to subtract
  82317. * @param result the vector to store the result in
  82318. * @returns the current Vector4.
  82319. */
  82320. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82321. /**
  82322. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82323. * @returns a new vector with the negated values
  82324. */
  82325. negate(): Vector4;
  82326. /**
  82327. * Negate this vector in place
  82328. * @returns this
  82329. */
  82330. negateInPlace(): Vector4;
  82331. /**
  82332. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82333. * @param result defines the Vector3 object where to store the result
  82334. * @returns the current Vector4
  82335. */
  82336. negateToRef(result: Vector4): Vector4;
  82337. /**
  82338. * Multiplies the current Vector4 coordinates by scale (float).
  82339. * @param scale the number to scale with
  82340. * @returns the updated Vector4.
  82341. */
  82342. scaleInPlace(scale: number): Vector4;
  82343. /**
  82344. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82345. * @param scale the number to scale with
  82346. * @returns a new vector with the result
  82347. */
  82348. scale(scale: number): Vector4;
  82349. /**
  82350. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82351. * @param scale the number to scale with
  82352. * @param result a vector to store the result in
  82353. * @returns the current Vector4.
  82354. */
  82355. scaleToRef(scale: number, result: Vector4): Vector4;
  82356. /**
  82357. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82358. * @param scale defines the scale factor
  82359. * @param result defines the Vector4 object where to store the result
  82360. * @returns the unmodified current Vector4
  82361. */
  82362. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82363. /**
  82364. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82365. * @param otherVector the vector to compare against
  82366. * @returns true if they are equal
  82367. */
  82368. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82369. /**
  82370. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82371. * @param otherVector vector to compare against
  82372. * @param epsilon (Default: very small number)
  82373. * @returns true if they are equal
  82374. */
  82375. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82376. /**
  82377. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82378. * @param x x value to compare against
  82379. * @param y y value to compare against
  82380. * @param z z value to compare against
  82381. * @param w w value to compare against
  82382. * @returns true if equal
  82383. */
  82384. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82385. /**
  82386. * Multiplies in place the current Vector4 by the given one.
  82387. * @param otherVector vector to multiple with
  82388. * @returns the updated Vector4.
  82389. */
  82390. multiplyInPlace(otherVector: Vector4): Vector4;
  82391. /**
  82392. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82393. * @param otherVector vector to multiple with
  82394. * @returns resulting new vector
  82395. */
  82396. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82397. /**
  82398. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82399. * @param otherVector vector to multiple with
  82400. * @param result vector to store the result
  82401. * @returns the current Vector4.
  82402. */
  82403. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82404. /**
  82405. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82406. * @param x x value multiply with
  82407. * @param y y value multiply with
  82408. * @param z z value multiply with
  82409. * @param w w value multiply with
  82410. * @returns resulting new vector
  82411. */
  82412. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82413. /**
  82414. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82415. * @param otherVector vector to devide with
  82416. * @returns resulting new vector
  82417. */
  82418. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82419. /**
  82420. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82421. * @param otherVector vector to devide with
  82422. * @param result vector to store the result
  82423. * @returns the current Vector4.
  82424. */
  82425. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82426. /**
  82427. * Divides the current Vector3 coordinates by the given ones.
  82428. * @param otherVector vector to devide with
  82429. * @returns the updated Vector3.
  82430. */
  82431. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82432. /**
  82433. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82434. * @param other defines the second operand
  82435. * @returns the current updated Vector4
  82436. */
  82437. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82438. /**
  82439. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82440. * @param other defines the second operand
  82441. * @returns the current updated Vector4
  82442. */
  82443. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82444. /**
  82445. * Gets a new Vector4 from current Vector4 floored values
  82446. * @returns a new Vector4
  82447. */
  82448. floor(): Vector4;
  82449. /**
  82450. * Gets a new Vector4 from current Vector3 floored values
  82451. * @returns a new Vector4
  82452. */
  82453. fract(): Vector4;
  82454. /**
  82455. * Returns the Vector4 length (float).
  82456. * @returns the length
  82457. */
  82458. length(): number;
  82459. /**
  82460. * Returns the Vector4 squared length (float).
  82461. * @returns the length squared
  82462. */
  82463. lengthSquared(): number;
  82464. /**
  82465. * Normalizes in place the Vector4.
  82466. * @returns the updated Vector4.
  82467. */
  82468. normalize(): Vector4;
  82469. /**
  82470. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82471. * @returns this converted to a new vector3
  82472. */
  82473. toVector3(): Vector3;
  82474. /**
  82475. * Returns a new Vector4 copied from the current one.
  82476. * @returns the new cloned vector
  82477. */
  82478. clone(): Vector4;
  82479. /**
  82480. * Updates the current Vector4 with the given one coordinates.
  82481. * @param source the source vector to copy from
  82482. * @returns the updated Vector4.
  82483. */
  82484. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82485. /**
  82486. * Updates the current Vector4 coordinates with the given floats.
  82487. * @param x float to copy from
  82488. * @param y float to copy from
  82489. * @param z float to copy from
  82490. * @param w float to copy from
  82491. * @returns the updated Vector4.
  82492. */
  82493. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82494. /**
  82495. * Updates the current Vector4 coordinates with the given floats.
  82496. * @param x float to set from
  82497. * @param y float to set from
  82498. * @param z float to set from
  82499. * @param w float to set from
  82500. * @returns the updated Vector4.
  82501. */
  82502. set(x: number, y: number, z: number, w: number): Vector4;
  82503. /**
  82504. * Copies the given float to the current Vector3 coordinates
  82505. * @param v defines the x, y, z and w coordinates of the operand
  82506. * @returns the current updated Vector3
  82507. */
  82508. setAll(v: number): Vector4;
  82509. /**
  82510. * Returns a new Vector4 set from the starting index of the given array.
  82511. * @param array the array to pull values from
  82512. * @param offset the offset into the array to start at
  82513. * @returns the new vector
  82514. */
  82515. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82516. /**
  82517. * Updates the given vector "result" from the starting index of the given array.
  82518. * @param array the array to pull values from
  82519. * @param offset the offset into the array to start at
  82520. * @param result the vector to store the result in
  82521. */
  82522. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82523. /**
  82524. * Updates the given vector "result" from the starting index of the given Float32Array.
  82525. * @param array the array to pull values from
  82526. * @param offset the offset into the array to start at
  82527. * @param result the vector to store the result in
  82528. */
  82529. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82530. /**
  82531. * Updates the given vector "result" coordinates from the given floats.
  82532. * @param x float to set from
  82533. * @param y float to set from
  82534. * @param z float to set from
  82535. * @param w float to set from
  82536. * @param result the vector to the floats in
  82537. */
  82538. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82539. /**
  82540. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82541. * @returns the new vector
  82542. */
  82543. static Zero(): Vector4;
  82544. /**
  82545. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82546. * @returns the new vector
  82547. */
  82548. static One(): Vector4;
  82549. /**
  82550. * Returns a new normalized Vector4 from the given one.
  82551. * @param vector the vector to normalize
  82552. * @returns the vector
  82553. */
  82554. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82555. /**
  82556. * Updates the given vector "result" from the normalization of the given one.
  82557. * @param vector the vector to normalize
  82558. * @param result the vector to store the result in
  82559. */
  82560. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82561. /**
  82562. * Returns a vector with the minimum values from the left and right vectors
  82563. * @param left left vector to minimize
  82564. * @param right right vector to minimize
  82565. * @returns a new vector with the minimum of the left and right vector values
  82566. */
  82567. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82568. /**
  82569. * Returns a vector with the maximum values from the left and right vectors
  82570. * @param left left vector to maximize
  82571. * @param right right vector to maximize
  82572. * @returns a new vector with the maximum of the left and right vector values
  82573. */
  82574. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82575. /**
  82576. * Returns the distance (float) between the vectors "value1" and "value2".
  82577. * @param value1 value to calulate the distance between
  82578. * @param value2 value to calulate the distance between
  82579. * @return the distance between the two vectors
  82580. */
  82581. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82582. /**
  82583. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82584. * @param value1 value to calulate the distance between
  82585. * @param value2 value to calulate the distance between
  82586. * @return the distance between the two vectors squared
  82587. */
  82588. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82589. /**
  82590. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82591. * @param value1 value to calulate the center between
  82592. * @param value2 value to calulate the center between
  82593. * @return the center between the two vectors
  82594. */
  82595. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82596. /**
  82597. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82598. * This methods computes transformed normalized direction vectors only.
  82599. * @param vector the vector to transform
  82600. * @param transformation the transformation matrix to apply
  82601. * @returns the new vector
  82602. */
  82603. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82604. /**
  82605. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82606. * This methods computes transformed normalized direction vectors only.
  82607. * @param vector the vector to transform
  82608. * @param transformation the transformation matrix to apply
  82609. * @param result the vector to store the result in
  82610. */
  82611. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82612. /**
  82613. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82614. * This methods computes transformed normalized direction vectors only.
  82615. * @param x value to transform
  82616. * @param y value to transform
  82617. * @param z value to transform
  82618. * @param w value to transform
  82619. * @param transformation the transformation matrix to apply
  82620. * @param result the vector to store the results in
  82621. */
  82622. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82623. /**
  82624. * Creates a new Vector4 from a Vector3
  82625. * @param source defines the source data
  82626. * @param w defines the 4th component (default is 0)
  82627. * @returns a new Vector4
  82628. */
  82629. static FromVector3(source: Vector3, w?: number): Vector4;
  82630. }
  82631. /**
  82632. * Class used to store quaternion data
  82633. * @see https://en.wikipedia.org/wiki/Quaternion
  82634. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82635. */
  82636. export class Quaternion {
  82637. /** @hidden */
  82638. _x: number;
  82639. /** @hidden */
  82640. _y: number;
  82641. /** @hidden */
  82642. _z: number;
  82643. /** @hidden */
  82644. _w: number;
  82645. /** @hidden */
  82646. _isDirty: boolean;
  82647. /** Gets or sets the x coordinate */
  82648. get x(): number;
  82649. set x(value: number);
  82650. /** Gets or sets the y coordinate */
  82651. get y(): number;
  82652. set y(value: number);
  82653. /** Gets or sets the z coordinate */
  82654. get z(): number;
  82655. set z(value: number);
  82656. /** Gets or sets the w coordinate */
  82657. get w(): number;
  82658. set w(value: number);
  82659. /**
  82660. * Creates a new Quaternion from the given floats
  82661. * @param x defines the first component (0 by default)
  82662. * @param y defines the second component (0 by default)
  82663. * @param z defines the third component (0 by default)
  82664. * @param w defines the fourth component (1.0 by default)
  82665. */
  82666. constructor(x?: number, y?: number, z?: number, w?: number);
  82667. /**
  82668. * Gets a string representation for the current quaternion
  82669. * @returns a string with the Quaternion coordinates
  82670. */
  82671. toString(): string;
  82672. /**
  82673. * Gets the class name of the quaternion
  82674. * @returns the string "Quaternion"
  82675. */
  82676. getClassName(): string;
  82677. /**
  82678. * Gets a hash code for this quaternion
  82679. * @returns the quaternion hash code
  82680. */
  82681. getHashCode(): number;
  82682. /**
  82683. * Copy the quaternion to an array
  82684. * @returns a new array populated with 4 elements from the quaternion coordinates
  82685. */
  82686. asArray(): number[];
  82687. /**
  82688. * Check if two quaternions are equals
  82689. * @param otherQuaternion defines the second operand
  82690. * @return true if the current quaternion and the given one coordinates are strictly equals
  82691. */
  82692. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82693. /**
  82694. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82695. * @param otherQuaternion defines the other quaternion
  82696. * @param epsilon defines the minimal distance to consider equality
  82697. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82698. */
  82699. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82700. /**
  82701. * Clone the current quaternion
  82702. * @returns a new quaternion copied from the current one
  82703. */
  82704. clone(): Quaternion;
  82705. /**
  82706. * Copy a quaternion to the current one
  82707. * @param other defines the other quaternion
  82708. * @returns the updated current quaternion
  82709. */
  82710. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82711. /**
  82712. * Updates the current quaternion with the given float coordinates
  82713. * @param x defines the x coordinate
  82714. * @param y defines the y coordinate
  82715. * @param z defines the z coordinate
  82716. * @param w defines the w coordinate
  82717. * @returns the updated current quaternion
  82718. */
  82719. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82720. /**
  82721. * Updates the current quaternion from the given float coordinates
  82722. * @param x defines the x coordinate
  82723. * @param y defines the y coordinate
  82724. * @param z defines the z coordinate
  82725. * @param w defines the w coordinate
  82726. * @returns the updated current quaternion
  82727. */
  82728. set(x: number, y: number, z: number, w: number): Quaternion;
  82729. /**
  82730. * Adds two quaternions
  82731. * @param other defines the second operand
  82732. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82733. */
  82734. add(other: DeepImmutable<Quaternion>): Quaternion;
  82735. /**
  82736. * Add a quaternion to the current one
  82737. * @param other defines the quaternion to add
  82738. * @returns the current quaternion
  82739. */
  82740. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82741. /**
  82742. * Subtract two quaternions
  82743. * @param other defines the second operand
  82744. * @returns a new quaternion as the subtraction result of the given one from the current one
  82745. */
  82746. subtract(other: Quaternion): Quaternion;
  82747. /**
  82748. * Multiplies the current quaternion by a scale factor
  82749. * @param value defines the scale factor
  82750. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82751. */
  82752. scale(value: number): Quaternion;
  82753. /**
  82754. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82755. * @param scale defines the scale factor
  82756. * @param result defines the Quaternion object where to store the result
  82757. * @returns the unmodified current quaternion
  82758. */
  82759. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82760. /**
  82761. * Multiplies in place the current quaternion by a scale factor
  82762. * @param value defines the scale factor
  82763. * @returns the current modified quaternion
  82764. */
  82765. scaleInPlace(value: number): Quaternion;
  82766. /**
  82767. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82768. * @param scale defines the scale factor
  82769. * @param result defines the Quaternion object where to store the result
  82770. * @returns the unmodified current quaternion
  82771. */
  82772. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82773. /**
  82774. * Multiplies two quaternions
  82775. * @param q1 defines the second operand
  82776. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82777. */
  82778. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82779. /**
  82780. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82781. * @param q1 defines the second operand
  82782. * @param result defines the target quaternion
  82783. * @returns the current quaternion
  82784. */
  82785. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82786. /**
  82787. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82788. * @param q1 defines the second operand
  82789. * @returns the currentupdated quaternion
  82790. */
  82791. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82792. /**
  82793. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82794. * @param ref defines the target quaternion
  82795. * @returns the current quaternion
  82796. */
  82797. conjugateToRef(ref: Quaternion): Quaternion;
  82798. /**
  82799. * Conjugates in place (1-q) the current quaternion
  82800. * @returns the current updated quaternion
  82801. */
  82802. conjugateInPlace(): Quaternion;
  82803. /**
  82804. * Conjugates in place (1-q) the current quaternion
  82805. * @returns a new quaternion
  82806. */
  82807. conjugate(): Quaternion;
  82808. /**
  82809. * Gets length of current quaternion
  82810. * @returns the quaternion length (float)
  82811. */
  82812. length(): number;
  82813. /**
  82814. * Normalize in place the current quaternion
  82815. * @returns the current updated quaternion
  82816. */
  82817. normalize(): Quaternion;
  82818. /**
  82819. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82820. * @param order is a reserved parameter and is ignore for now
  82821. * @returns a new Vector3 containing the Euler angles
  82822. */
  82823. toEulerAngles(order?: string): Vector3;
  82824. /**
  82825. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82826. * @param result defines the vector which will be filled with the Euler angles
  82827. * @param order is a reserved parameter and is ignore for now
  82828. * @returns the current unchanged quaternion
  82829. */
  82830. toEulerAnglesToRef(result: Vector3): Quaternion;
  82831. /**
  82832. * Updates the given rotation matrix with the current quaternion values
  82833. * @param result defines the target matrix
  82834. * @returns the current unchanged quaternion
  82835. */
  82836. toRotationMatrix(result: Matrix): Quaternion;
  82837. /**
  82838. * Updates the current quaternion from the given rotation matrix values
  82839. * @param matrix defines the source matrix
  82840. * @returns the current updated quaternion
  82841. */
  82842. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82843. /**
  82844. * Creates a new quaternion from a rotation matrix
  82845. * @param matrix defines the source matrix
  82846. * @returns a new quaternion created from the given rotation matrix values
  82847. */
  82848. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82849. /**
  82850. * Updates the given quaternion with the given rotation matrix values
  82851. * @param matrix defines the source matrix
  82852. * @param result defines the target quaternion
  82853. */
  82854. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82855. /**
  82856. * Returns the dot product (float) between the quaternions "left" and "right"
  82857. * @param left defines the left operand
  82858. * @param right defines the right operand
  82859. * @returns the dot product
  82860. */
  82861. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82862. /**
  82863. * Checks if the two quaternions are close to each other
  82864. * @param quat0 defines the first quaternion to check
  82865. * @param quat1 defines the second quaternion to check
  82866. * @returns true if the two quaternions are close to each other
  82867. */
  82868. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82869. /**
  82870. * Creates an empty quaternion
  82871. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82872. */
  82873. static Zero(): Quaternion;
  82874. /**
  82875. * Inverse a given quaternion
  82876. * @param q defines the source quaternion
  82877. * @returns a new quaternion as the inverted current quaternion
  82878. */
  82879. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82880. /**
  82881. * Inverse a given quaternion
  82882. * @param q defines the source quaternion
  82883. * @param result the quaternion the result will be stored in
  82884. * @returns the result quaternion
  82885. */
  82886. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82887. /**
  82888. * Creates an identity quaternion
  82889. * @returns the identity quaternion
  82890. */
  82891. static Identity(): Quaternion;
  82892. /**
  82893. * Gets a boolean indicating if the given quaternion is identity
  82894. * @param quaternion defines the quaternion to check
  82895. * @returns true if the quaternion is identity
  82896. */
  82897. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82898. /**
  82899. * Creates a quaternion from a rotation around an axis
  82900. * @param axis defines the axis to use
  82901. * @param angle defines the angle to use
  82902. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82903. */
  82904. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82905. /**
  82906. * Creates a rotation around an axis and stores it into the given quaternion
  82907. * @param axis defines the axis to use
  82908. * @param angle defines the angle to use
  82909. * @param result defines the target quaternion
  82910. * @returns the target quaternion
  82911. */
  82912. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82913. /**
  82914. * Creates a new quaternion from data stored into an array
  82915. * @param array defines the data source
  82916. * @param offset defines the offset in the source array where the data starts
  82917. * @returns a new quaternion
  82918. */
  82919. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82920. /**
  82921. * Updates the given quaternion "result" from the starting index of the given array.
  82922. * @param array the array to pull values from
  82923. * @param offset the offset into the array to start at
  82924. * @param result the quaternion to store the result in
  82925. */
  82926. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82927. /**
  82928. * Create a quaternion from Euler rotation angles
  82929. * @param x Pitch
  82930. * @param y Yaw
  82931. * @param z Roll
  82932. * @returns the new Quaternion
  82933. */
  82934. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82935. /**
  82936. * Updates a quaternion from Euler rotation angles
  82937. * @param x Pitch
  82938. * @param y Yaw
  82939. * @param z Roll
  82940. * @param result the quaternion to store the result
  82941. * @returns the updated quaternion
  82942. */
  82943. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82944. /**
  82945. * Create a quaternion from Euler rotation vector
  82946. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82947. * @returns the new Quaternion
  82948. */
  82949. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82950. /**
  82951. * Updates a quaternion from Euler rotation vector
  82952. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82953. * @param result the quaternion to store the result
  82954. * @returns the updated quaternion
  82955. */
  82956. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82957. /**
  82958. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82959. * @param yaw defines the rotation around Y axis
  82960. * @param pitch defines the rotation around X axis
  82961. * @param roll defines the rotation around Z axis
  82962. * @returns the new quaternion
  82963. */
  82964. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82965. /**
  82966. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82967. * @param yaw defines the rotation around Y axis
  82968. * @param pitch defines the rotation around X axis
  82969. * @param roll defines the rotation around Z axis
  82970. * @param result defines the target quaternion
  82971. */
  82972. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82973. /**
  82974. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82975. * @param alpha defines the rotation around first axis
  82976. * @param beta defines the rotation around second axis
  82977. * @param gamma defines the rotation around third axis
  82978. * @returns the new quaternion
  82979. */
  82980. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82981. /**
  82982. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82983. * @param alpha defines the rotation around first axis
  82984. * @param beta defines the rotation around second axis
  82985. * @param gamma defines the rotation around third axis
  82986. * @param result defines the target quaternion
  82987. */
  82988. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82989. /**
  82990. * 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)
  82991. * @param axis1 defines the first axis
  82992. * @param axis2 defines the second axis
  82993. * @param axis3 defines the third axis
  82994. * @returns the new quaternion
  82995. */
  82996. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82997. /**
  82998. * 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
  82999. * @param axis1 defines the first axis
  83000. * @param axis2 defines the second axis
  83001. * @param axis3 defines the third axis
  83002. * @param ref defines the target quaternion
  83003. */
  83004. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83005. /**
  83006. * Interpolates between two quaternions
  83007. * @param left defines first quaternion
  83008. * @param right defines second quaternion
  83009. * @param amount defines the gradient to use
  83010. * @returns the new interpolated quaternion
  83011. */
  83012. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83013. /**
  83014. * Interpolates between two quaternions and stores it into a target quaternion
  83015. * @param left defines first quaternion
  83016. * @param right defines second quaternion
  83017. * @param amount defines the gradient to use
  83018. * @param result defines the target quaternion
  83019. */
  83020. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83021. /**
  83022. * Interpolate between two quaternions using Hermite interpolation
  83023. * @param value1 defines first quaternion
  83024. * @param tangent1 defines the incoming tangent
  83025. * @param value2 defines second quaternion
  83026. * @param tangent2 defines the outgoing tangent
  83027. * @param amount defines the target quaternion
  83028. * @returns the new interpolated quaternion
  83029. */
  83030. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83031. }
  83032. /**
  83033. * Class used to store matrix data (4x4)
  83034. */
  83035. export class Matrix {
  83036. /**
  83037. * Gets the precision of matrix computations
  83038. */
  83039. static get Use64Bits(): boolean;
  83040. private static _updateFlagSeed;
  83041. private static _identityReadOnly;
  83042. private _isIdentity;
  83043. private _isIdentityDirty;
  83044. private _isIdentity3x2;
  83045. private _isIdentity3x2Dirty;
  83046. /**
  83047. * Gets the update flag of the matrix which is an unique number for the matrix.
  83048. * It will be incremented every time the matrix data change.
  83049. * You can use it to speed the comparison between two versions of the same matrix.
  83050. */
  83051. updateFlag: number;
  83052. private readonly _m;
  83053. /**
  83054. * Gets the internal data of the matrix
  83055. */
  83056. get m(): DeepImmutable<Float32Array | Array<number>>;
  83057. /** @hidden */
  83058. _markAsUpdated(): void;
  83059. /** @hidden */
  83060. private _updateIdentityStatus;
  83061. /**
  83062. * Creates an empty matrix (filled with zeros)
  83063. */
  83064. constructor();
  83065. /**
  83066. * Check if the current matrix is identity
  83067. * @returns true is the matrix is the identity matrix
  83068. */
  83069. isIdentity(): boolean;
  83070. /**
  83071. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83072. * @returns true is the matrix is the identity matrix
  83073. */
  83074. isIdentityAs3x2(): boolean;
  83075. /**
  83076. * Gets the determinant of the matrix
  83077. * @returns the matrix determinant
  83078. */
  83079. determinant(): number;
  83080. /**
  83081. * Returns the matrix as a Float32Array or Array<number>
  83082. * @returns the matrix underlying array
  83083. */
  83084. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83085. /**
  83086. * Returns the matrix as a Float32Array or Array<number>
  83087. * @returns the matrix underlying array.
  83088. */
  83089. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83090. /**
  83091. * Inverts the current matrix in place
  83092. * @returns the current inverted matrix
  83093. */
  83094. invert(): Matrix;
  83095. /**
  83096. * Sets all the matrix elements to zero
  83097. * @returns the current matrix
  83098. */
  83099. reset(): Matrix;
  83100. /**
  83101. * Adds the current matrix with a second one
  83102. * @param other defines the matrix to add
  83103. * @returns a new matrix as the addition of the current matrix and the given one
  83104. */
  83105. add(other: DeepImmutable<Matrix>): Matrix;
  83106. /**
  83107. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83108. * @param other defines the matrix to add
  83109. * @param result defines the target matrix
  83110. * @returns the current matrix
  83111. */
  83112. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83113. /**
  83114. * Adds in place the given matrix to the current matrix
  83115. * @param other defines the second operand
  83116. * @returns the current updated matrix
  83117. */
  83118. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83119. /**
  83120. * Sets the given matrix to the current inverted Matrix
  83121. * @param other defines the target matrix
  83122. * @returns the unmodified current matrix
  83123. */
  83124. invertToRef(other: Matrix): Matrix;
  83125. /**
  83126. * add a value at the specified position in the current Matrix
  83127. * @param index the index of the value within the matrix. between 0 and 15.
  83128. * @param value the value to be added
  83129. * @returns the current updated matrix
  83130. */
  83131. addAtIndex(index: number, value: number): Matrix;
  83132. /**
  83133. * mutiply the specified position in the current Matrix by a value
  83134. * @param index the index of the value within the matrix. between 0 and 15.
  83135. * @param value the value to be added
  83136. * @returns the current updated matrix
  83137. */
  83138. multiplyAtIndex(index: number, value: number): Matrix;
  83139. /**
  83140. * Inserts the translation vector (using 3 floats) in the current matrix
  83141. * @param x defines the 1st component of the translation
  83142. * @param y defines the 2nd component of the translation
  83143. * @param z defines the 3rd component of the translation
  83144. * @returns the current updated matrix
  83145. */
  83146. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83147. /**
  83148. * Adds the translation vector (using 3 floats) in the current matrix
  83149. * @param x defines the 1st component of the translation
  83150. * @param y defines the 2nd component of the translation
  83151. * @param z defines the 3rd component of the translation
  83152. * @returns the current updated matrix
  83153. */
  83154. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83155. /**
  83156. * Inserts the translation vector in the current matrix
  83157. * @param vector3 defines the translation to insert
  83158. * @returns the current updated matrix
  83159. */
  83160. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83161. /**
  83162. * Gets the translation value of the current matrix
  83163. * @returns a new Vector3 as the extracted translation from the matrix
  83164. */
  83165. getTranslation(): Vector3;
  83166. /**
  83167. * Fill a Vector3 with the extracted translation from the matrix
  83168. * @param result defines the Vector3 where to store the translation
  83169. * @returns the current matrix
  83170. */
  83171. getTranslationToRef(result: Vector3): Matrix;
  83172. /**
  83173. * Remove rotation and scaling part from the matrix
  83174. * @returns the updated matrix
  83175. */
  83176. removeRotationAndScaling(): Matrix;
  83177. /**
  83178. * Multiply two matrices
  83179. * @param other defines the second operand
  83180. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83181. */
  83182. multiply(other: DeepImmutable<Matrix>): Matrix;
  83183. /**
  83184. * Copy the current matrix from the given one
  83185. * @param other defines the source matrix
  83186. * @returns the current updated matrix
  83187. */
  83188. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83189. /**
  83190. * Populates the given array from the starting index with the current matrix values
  83191. * @param array defines the target array
  83192. * @param offset defines the offset in the target array where to start storing values
  83193. * @returns the current matrix
  83194. */
  83195. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83196. /**
  83197. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83198. * @param other defines the second operand
  83199. * @param result defines the matrix where to store the multiplication
  83200. * @returns the current matrix
  83201. */
  83202. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83203. /**
  83204. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83205. * @param other defines the second operand
  83206. * @param result defines the array where to store the multiplication
  83207. * @param offset defines the offset in the target array where to start storing values
  83208. * @returns the current matrix
  83209. */
  83210. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83211. /**
  83212. * Check equality between this matrix and a second one
  83213. * @param value defines the second matrix to compare
  83214. * @returns true is the current matrix and the given one values are strictly equal
  83215. */
  83216. equals(value: DeepImmutable<Matrix>): boolean;
  83217. /**
  83218. * Clone the current matrix
  83219. * @returns a new matrix from the current matrix
  83220. */
  83221. clone(): Matrix;
  83222. /**
  83223. * Returns the name of the current matrix class
  83224. * @returns the string "Matrix"
  83225. */
  83226. getClassName(): string;
  83227. /**
  83228. * Gets the hash code of the current matrix
  83229. * @returns the hash code
  83230. */
  83231. getHashCode(): number;
  83232. /**
  83233. * Decomposes the current Matrix into a translation, rotation and scaling components
  83234. * @param scale defines the scale vector3 given as a reference to update
  83235. * @param rotation defines the rotation quaternion given as a reference to update
  83236. * @param translation defines the translation vector3 given as a reference to update
  83237. * @returns true if operation was successful
  83238. */
  83239. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83240. /**
  83241. * Gets specific row of the matrix
  83242. * @param index defines the number of the row to get
  83243. * @returns the index-th row of the current matrix as a new Vector4
  83244. */
  83245. getRow(index: number): Nullable<Vector4>;
  83246. /**
  83247. * Sets the index-th row of the current matrix to the vector4 values
  83248. * @param index defines the number of the row to set
  83249. * @param row defines the target vector4
  83250. * @returns the updated current matrix
  83251. */
  83252. setRow(index: number, row: Vector4): Matrix;
  83253. /**
  83254. * Compute the transpose of the matrix
  83255. * @returns the new transposed matrix
  83256. */
  83257. transpose(): Matrix;
  83258. /**
  83259. * Compute the transpose of the matrix and store it in a given matrix
  83260. * @param result defines the target matrix
  83261. * @returns the current matrix
  83262. */
  83263. transposeToRef(result: Matrix): Matrix;
  83264. /**
  83265. * Sets the index-th row of the current matrix with the given 4 x float values
  83266. * @param index defines the row index
  83267. * @param x defines the x component to set
  83268. * @param y defines the y component to set
  83269. * @param z defines the z component to set
  83270. * @param w defines the w component to set
  83271. * @returns the updated current matrix
  83272. */
  83273. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83274. /**
  83275. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83276. * @param scale defines the scale factor
  83277. * @returns a new matrix
  83278. */
  83279. scale(scale: number): Matrix;
  83280. /**
  83281. * Scale the current matrix values by a factor to a given result matrix
  83282. * @param scale defines the scale factor
  83283. * @param result defines the matrix to store the result
  83284. * @returns the current matrix
  83285. */
  83286. scaleToRef(scale: number, result: Matrix): Matrix;
  83287. /**
  83288. * Scale the current matrix values by a factor and add the result to a given matrix
  83289. * @param scale defines the scale factor
  83290. * @param result defines the Matrix to store the result
  83291. * @returns the current matrix
  83292. */
  83293. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83294. /**
  83295. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83296. * @param ref matrix to store the result
  83297. */
  83298. toNormalMatrix(ref: Matrix): void;
  83299. /**
  83300. * Gets only rotation part of the current matrix
  83301. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83302. */
  83303. getRotationMatrix(): Matrix;
  83304. /**
  83305. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83306. * @param result defines the target matrix to store data to
  83307. * @returns the current matrix
  83308. */
  83309. getRotationMatrixToRef(result: Matrix): Matrix;
  83310. /**
  83311. * Toggles model matrix from being right handed to left handed in place and vice versa
  83312. */
  83313. toggleModelMatrixHandInPlace(): void;
  83314. /**
  83315. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83316. */
  83317. toggleProjectionMatrixHandInPlace(): void;
  83318. /**
  83319. * Creates a matrix from an array
  83320. * @param array defines the source array
  83321. * @param offset defines an offset in the source array
  83322. * @returns a new Matrix set from the starting index of the given array
  83323. */
  83324. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83325. /**
  83326. * Copy the content of an array into a given matrix
  83327. * @param array defines the source array
  83328. * @param offset defines an offset in the source array
  83329. * @param result defines the target matrix
  83330. */
  83331. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83332. /**
  83333. * Stores an array into a matrix after having multiplied each component by a given factor
  83334. * @param array defines the source array
  83335. * @param offset defines the offset in the source array
  83336. * @param scale defines the scaling factor
  83337. * @param result defines the target matrix
  83338. */
  83339. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83340. /**
  83341. * Gets an identity matrix that must not be updated
  83342. */
  83343. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83344. /**
  83345. * Stores a list of values (16) inside a given matrix
  83346. * @param initialM11 defines 1st value of 1st row
  83347. * @param initialM12 defines 2nd value of 1st row
  83348. * @param initialM13 defines 3rd value of 1st row
  83349. * @param initialM14 defines 4th value of 1st row
  83350. * @param initialM21 defines 1st value of 2nd row
  83351. * @param initialM22 defines 2nd value of 2nd row
  83352. * @param initialM23 defines 3rd value of 2nd row
  83353. * @param initialM24 defines 4th value of 2nd row
  83354. * @param initialM31 defines 1st value of 3rd row
  83355. * @param initialM32 defines 2nd value of 3rd row
  83356. * @param initialM33 defines 3rd value of 3rd row
  83357. * @param initialM34 defines 4th value of 3rd row
  83358. * @param initialM41 defines 1st value of 4th row
  83359. * @param initialM42 defines 2nd value of 4th row
  83360. * @param initialM43 defines 3rd value of 4th row
  83361. * @param initialM44 defines 4th value of 4th row
  83362. * @param result defines the target matrix
  83363. */
  83364. 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;
  83365. /**
  83366. * Creates new matrix from a list of values (16)
  83367. * @param initialM11 defines 1st value of 1st row
  83368. * @param initialM12 defines 2nd value of 1st row
  83369. * @param initialM13 defines 3rd value of 1st row
  83370. * @param initialM14 defines 4th value of 1st row
  83371. * @param initialM21 defines 1st value of 2nd row
  83372. * @param initialM22 defines 2nd value of 2nd row
  83373. * @param initialM23 defines 3rd value of 2nd row
  83374. * @param initialM24 defines 4th value of 2nd row
  83375. * @param initialM31 defines 1st value of 3rd row
  83376. * @param initialM32 defines 2nd value of 3rd row
  83377. * @param initialM33 defines 3rd value of 3rd row
  83378. * @param initialM34 defines 4th value of 3rd row
  83379. * @param initialM41 defines 1st value of 4th row
  83380. * @param initialM42 defines 2nd value of 4th row
  83381. * @param initialM43 defines 3rd value of 4th row
  83382. * @param initialM44 defines 4th value of 4th row
  83383. * @returns the new matrix
  83384. */
  83385. 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;
  83386. /**
  83387. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83388. * @param scale defines the scale vector3
  83389. * @param rotation defines the rotation quaternion
  83390. * @param translation defines the translation vector3
  83391. * @returns a new matrix
  83392. */
  83393. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83394. /**
  83395. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83396. * @param scale defines the scale vector3
  83397. * @param rotation defines the rotation quaternion
  83398. * @param translation defines the translation vector3
  83399. * @param result defines the target matrix
  83400. */
  83401. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83402. /**
  83403. * Creates a new identity matrix
  83404. * @returns a new identity matrix
  83405. */
  83406. static Identity(): Matrix;
  83407. /**
  83408. * Creates a new identity matrix and stores the result in a given matrix
  83409. * @param result defines the target matrix
  83410. */
  83411. static IdentityToRef(result: Matrix): void;
  83412. /**
  83413. * Creates a new zero matrix
  83414. * @returns a new zero matrix
  83415. */
  83416. static Zero(): Matrix;
  83417. /**
  83418. * Creates a new rotation matrix for "angle" radians around the X axis
  83419. * @param angle defines the angle (in radians) to use
  83420. * @return the new matrix
  83421. */
  83422. static RotationX(angle: number): Matrix;
  83423. /**
  83424. * Creates a new matrix as the invert of a given matrix
  83425. * @param source defines the source matrix
  83426. * @returns the new matrix
  83427. */
  83428. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83429. /**
  83430. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83431. * @param angle defines the angle (in radians) to use
  83432. * @param result defines the target matrix
  83433. */
  83434. static RotationXToRef(angle: number, result: Matrix): void;
  83435. /**
  83436. * Creates a new rotation matrix for "angle" radians around the Y axis
  83437. * @param angle defines the angle (in radians) to use
  83438. * @return the new matrix
  83439. */
  83440. static RotationY(angle: number): Matrix;
  83441. /**
  83442. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83443. * @param angle defines the angle (in radians) to use
  83444. * @param result defines the target matrix
  83445. */
  83446. static RotationYToRef(angle: number, result: Matrix): void;
  83447. /**
  83448. * Creates a new rotation matrix for "angle" radians around the Z axis
  83449. * @param angle defines the angle (in radians) to use
  83450. * @return the new matrix
  83451. */
  83452. static RotationZ(angle: number): Matrix;
  83453. /**
  83454. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83455. * @param angle defines the angle (in radians) to use
  83456. * @param result defines the target matrix
  83457. */
  83458. static RotationZToRef(angle: number, result: Matrix): void;
  83459. /**
  83460. * Creates a new rotation matrix for "angle" radians around the given axis
  83461. * @param axis defines the axis to use
  83462. * @param angle defines the angle (in radians) to use
  83463. * @return the new matrix
  83464. */
  83465. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83466. /**
  83467. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83468. * @param axis defines the axis to use
  83469. * @param angle defines the angle (in radians) to use
  83470. * @param result defines the target matrix
  83471. */
  83472. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83473. /**
  83474. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83475. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83476. * @param from defines the vector to align
  83477. * @param to defines the vector to align to
  83478. * @param result defines the target matrix
  83479. */
  83480. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83481. /**
  83482. * Creates a rotation matrix
  83483. * @param yaw defines the yaw angle in radians (Y axis)
  83484. * @param pitch defines the pitch angle in radians (X axis)
  83485. * @param roll defines the roll angle in radians (Z axis)
  83486. * @returns the new rotation matrix
  83487. */
  83488. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83489. /**
  83490. * Creates a rotation matrix and stores it in a given matrix
  83491. * @param yaw defines the yaw angle in radians (Y axis)
  83492. * @param pitch defines the pitch angle in radians (X axis)
  83493. * @param roll defines the roll angle in radians (Z axis)
  83494. * @param result defines the target matrix
  83495. */
  83496. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83497. /**
  83498. * Creates a scaling matrix
  83499. * @param x defines the scale factor on X axis
  83500. * @param y defines the scale factor on Y axis
  83501. * @param z defines the scale factor on Z axis
  83502. * @returns the new matrix
  83503. */
  83504. static Scaling(x: number, y: number, z: number): Matrix;
  83505. /**
  83506. * Creates a scaling matrix and stores it in a given matrix
  83507. * @param x defines the scale factor on X axis
  83508. * @param y defines the scale factor on Y axis
  83509. * @param z defines the scale factor on Z axis
  83510. * @param result defines the target matrix
  83511. */
  83512. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83513. /**
  83514. * Creates a translation matrix
  83515. * @param x defines the translation on X axis
  83516. * @param y defines the translation on Y axis
  83517. * @param z defines the translationon Z axis
  83518. * @returns the new matrix
  83519. */
  83520. static Translation(x: number, y: number, z: number): Matrix;
  83521. /**
  83522. * Creates a translation matrix and stores it in a given matrix
  83523. * @param x defines the translation on X axis
  83524. * @param y defines the translation on Y axis
  83525. * @param z defines the translationon Z axis
  83526. * @param result defines the target matrix
  83527. */
  83528. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83529. /**
  83530. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83531. * @param startValue defines the start value
  83532. * @param endValue defines the end value
  83533. * @param gradient defines the gradient factor
  83534. * @returns the new matrix
  83535. */
  83536. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83537. /**
  83538. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83539. * @param startValue defines the start value
  83540. * @param endValue defines the end value
  83541. * @param gradient defines the gradient factor
  83542. * @param result defines the Matrix object where to store data
  83543. */
  83544. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83545. /**
  83546. * Builds a new matrix whose values are computed by:
  83547. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83548. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83549. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83550. * @param startValue defines the first matrix
  83551. * @param endValue defines the second matrix
  83552. * @param gradient defines the gradient between the two matrices
  83553. * @returns the new matrix
  83554. */
  83555. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83556. /**
  83557. * Update a matrix to values which are computed by:
  83558. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83559. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83560. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83561. * @param startValue defines the first matrix
  83562. * @param endValue defines the second matrix
  83563. * @param gradient defines the gradient between the two matrices
  83564. * @param result defines the target matrix
  83565. */
  83566. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83567. /**
  83568. * 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"
  83569. * This function works in left handed mode
  83570. * @param eye defines the final position of the entity
  83571. * @param target defines where the entity should look at
  83572. * @param up defines the up vector for the entity
  83573. * @returns the new matrix
  83574. */
  83575. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83576. /**
  83577. * 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".
  83578. * This function works in left handed mode
  83579. * @param eye defines the final position of the entity
  83580. * @param target defines where the entity should look at
  83581. * @param up defines the up vector for the entity
  83582. * @param result defines the target matrix
  83583. */
  83584. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83585. /**
  83586. * 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"
  83587. * This function works in right handed mode
  83588. * @param eye defines the final position of the entity
  83589. * @param target defines where the entity should look at
  83590. * @param up defines the up vector for the entity
  83591. * @returns the new matrix
  83592. */
  83593. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83594. /**
  83595. * 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".
  83596. * This function works in right handed mode
  83597. * @param eye defines the final position of the entity
  83598. * @param target defines where the entity should look at
  83599. * @param up defines the up vector for the entity
  83600. * @param result defines the target matrix
  83601. */
  83602. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83603. /**
  83604. * Create a left-handed orthographic projection matrix
  83605. * @param width defines the viewport width
  83606. * @param height defines the viewport height
  83607. * @param znear defines the near clip plane
  83608. * @param zfar defines the far clip plane
  83609. * @returns a new matrix as a left-handed orthographic projection matrix
  83610. */
  83611. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83612. /**
  83613. * Store a left-handed orthographic projection to a given matrix
  83614. * @param width defines the viewport width
  83615. * @param height defines the viewport height
  83616. * @param znear defines the near clip plane
  83617. * @param zfar defines the far clip plane
  83618. * @param result defines the target matrix
  83619. */
  83620. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83621. /**
  83622. * Create a left-handed orthographic projection matrix
  83623. * @param left defines the viewport left coordinate
  83624. * @param right defines the viewport right coordinate
  83625. * @param bottom defines the viewport bottom coordinate
  83626. * @param top defines the viewport top coordinate
  83627. * @param znear defines the near clip plane
  83628. * @param zfar defines the far clip plane
  83629. * @returns a new matrix as a left-handed orthographic projection matrix
  83630. */
  83631. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83632. /**
  83633. * Stores a left-handed orthographic projection into a given matrix
  83634. * @param left defines the viewport left coordinate
  83635. * @param right defines the viewport right coordinate
  83636. * @param bottom defines the viewport bottom coordinate
  83637. * @param top defines the viewport top coordinate
  83638. * @param znear defines the near clip plane
  83639. * @param zfar defines the far clip plane
  83640. * @param result defines the target matrix
  83641. */
  83642. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83643. /**
  83644. * Creates a right-handed orthographic projection matrix
  83645. * @param left defines the viewport left coordinate
  83646. * @param right defines the viewport right coordinate
  83647. * @param bottom defines the viewport bottom coordinate
  83648. * @param top defines the viewport top coordinate
  83649. * @param znear defines the near clip plane
  83650. * @param zfar defines the far clip plane
  83651. * @returns a new matrix as a right-handed orthographic projection matrix
  83652. */
  83653. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83654. /**
  83655. * Stores a right-handed orthographic projection into a given matrix
  83656. * @param left defines the viewport left coordinate
  83657. * @param right defines the viewport right coordinate
  83658. * @param bottom defines the viewport bottom coordinate
  83659. * @param top defines the viewport top coordinate
  83660. * @param znear defines the near clip plane
  83661. * @param zfar defines the far clip plane
  83662. * @param result defines the target matrix
  83663. */
  83664. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83665. /**
  83666. * Creates a left-handed perspective projection matrix
  83667. * @param width defines the viewport width
  83668. * @param height defines the viewport height
  83669. * @param znear defines the near clip plane
  83670. * @param zfar defines the far clip plane
  83671. * @returns a new matrix as a left-handed perspective projection matrix
  83672. */
  83673. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83674. /**
  83675. * Creates a left-handed perspective projection matrix
  83676. * @param fov defines the horizontal field of view
  83677. * @param aspect defines the aspect ratio
  83678. * @param znear defines the near clip plane
  83679. * @param zfar defines the far clip plane
  83680. * @returns a new matrix as a left-handed perspective projection matrix
  83681. */
  83682. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83683. /**
  83684. * Stores a left-handed perspective projection into a given matrix
  83685. * @param fov defines the horizontal field of view
  83686. * @param aspect defines the aspect ratio
  83687. * @param znear defines the near clip plane
  83688. * @param zfar defines the far clip plane
  83689. * @param result defines the target matrix
  83690. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83691. */
  83692. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83693. /**
  83694. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83695. * @param fov defines the horizontal field of view
  83696. * @param aspect defines the aspect ratio
  83697. * @param znear defines the near clip plane
  83698. * @param zfar not used as infinity is used as far clip
  83699. * @param result defines the target matrix
  83700. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83701. */
  83702. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83703. /**
  83704. * Creates a right-handed perspective projection matrix
  83705. * @param fov defines the horizontal field of view
  83706. * @param aspect defines the aspect ratio
  83707. * @param znear defines the near clip plane
  83708. * @param zfar defines the far clip plane
  83709. * @returns a new matrix as a right-handed perspective projection matrix
  83710. */
  83711. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83712. /**
  83713. * Stores a right-handed perspective projection into a given matrix
  83714. * @param fov defines the horizontal field of view
  83715. * @param aspect defines the aspect ratio
  83716. * @param znear defines the near clip plane
  83717. * @param zfar defines the far clip plane
  83718. * @param result defines the target matrix
  83719. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83720. */
  83721. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83722. /**
  83723. * Stores a right-handed perspective projection into a given matrix
  83724. * @param fov defines the horizontal field of view
  83725. * @param aspect defines the aspect ratio
  83726. * @param znear defines the near clip plane
  83727. * @param zfar not used as infinity is used as far clip
  83728. * @param result defines the target matrix
  83729. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83730. */
  83731. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83732. /**
  83733. * Stores a perspective projection for WebVR info a given matrix
  83734. * @param fov defines the field of view
  83735. * @param znear defines the near clip plane
  83736. * @param zfar defines the far clip plane
  83737. * @param result defines the target matrix
  83738. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83739. */
  83740. static PerspectiveFovWebVRToRef(fov: {
  83741. upDegrees: number;
  83742. downDegrees: number;
  83743. leftDegrees: number;
  83744. rightDegrees: number;
  83745. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83746. /**
  83747. * Computes a complete transformation matrix
  83748. * @param viewport defines the viewport to use
  83749. * @param world defines the world matrix
  83750. * @param view defines the view matrix
  83751. * @param projection defines the projection matrix
  83752. * @param zmin defines the near clip plane
  83753. * @param zmax defines the far clip plane
  83754. * @returns the transformation matrix
  83755. */
  83756. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83757. /**
  83758. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83759. * @param matrix defines the matrix to use
  83760. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83761. */
  83762. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83763. /**
  83764. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83765. * @param matrix defines the matrix to use
  83766. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83767. */
  83768. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83769. /**
  83770. * Compute the transpose of a given matrix
  83771. * @param matrix defines the matrix to transpose
  83772. * @returns the new matrix
  83773. */
  83774. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83775. /**
  83776. * Compute the transpose of a matrix and store it in a target matrix
  83777. * @param matrix defines the matrix to transpose
  83778. * @param result defines the target matrix
  83779. */
  83780. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83781. /**
  83782. * Computes a reflection matrix from a plane
  83783. * @param plane defines the reflection plane
  83784. * @returns a new matrix
  83785. */
  83786. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83787. /**
  83788. * Computes a reflection matrix from a plane
  83789. * @param plane defines the reflection plane
  83790. * @param result defines the target matrix
  83791. */
  83792. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83793. /**
  83794. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83795. * @param xaxis defines the value of the 1st axis
  83796. * @param yaxis defines the value of the 2nd axis
  83797. * @param zaxis defines the value of the 3rd axis
  83798. * @param result defines the target matrix
  83799. */
  83800. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83801. /**
  83802. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83803. * @param quat defines the quaternion to use
  83804. * @param result defines the target matrix
  83805. */
  83806. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83807. }
  83808. /**
  83809. * @hidden
  83810. */
  83811. export class TmpVectors {
  83812. static Vector2: Vector2[];
  83813. static Vector3: Vector3[];
  83814. static Vector4: Vector4[];
  83815. static Quaternion: Quaternion[];
  83816. static Matrix: Matrix[];
  83817. }
  83818. }
  83819. declare module BABYLON {
  83820. /**
  83821. * Defines potential orientation for back face culling
  83822. */
  83823. export enum Orientation {
  83824. /**
  83825. * Clockwise
  83826. */
  83827. CW = 0,
  83828. /** Counter clockwise */
  83829. CCW = 1
  83830. }
  83831. /** Class used to represent a Bezier curve */
  83832. export class BezierCurve {
  83833. /**
  83834. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83835. * @param t defines the time
  83836. * @param x1 defines the left coordinate on X axis
  83837. * @param y1 defines the left coordinate on Y axis
  83838. * @param x2 defines the right coordinate on X axis
  83839. * @param y2 defines the right coordinate on Y axis
  83840. * @returns the interpolated value
  83841. */
  83842. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83843. }
  83844. /**
  83845. * Defines angle representation
  83846. */
  83847. export class Angle {
  83848. private _radians;
  83849. /**
  83850. * Creates an Angle object of "radians" radians (float).
  83851. * @param radians the angle in radians
  83852. */
  83853. constructor(radians: number);
  83854. /**
  83855. * Get value in degrees
  83856. * @returns the Angle value in degrees (float)
  83857. */
  83858. degrees(): number;
  83859. /**
  83860. * Get value in radians
  83861. * @returns the Angle value in radians (float)
  83862. */
  83863. radians(): number;
  83864. /**
  83865. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83866. * @param a defines first point as the origin
  83867. * @param b defines point
  83868. * @returns a new Angle
  83869. */
  83870. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83871. /**
  83872. * Gets a new Angle object from the given float in radians
  83873. * @param radians defines the angle value in radians
  83874. * @returns a new Angle
  83875. */
  83876. static FromRadians(radians: number): Angle;
  83877. /**
  83878. * Gets a new Angle object from the given float in degrees
  83879. * @param degrees defines the angle value in degrees
  83880. * @returns a new Angle
  83881. */
  83882. static FromDegrees(degrees: number): Angle;
  83883. }
  83884. /**
  83885. * This represents an arc in a 2d space.
  83886. */
  83887. export class Arc2 {
  83888. /** Defines the start point of the arc */
  83889. startPoint: Vector2;
  83890. /** Defines the mid point of the arc */
  83891. midPoint: Vector2;
  83892. /** Defines the end point of the arc */
  83893. endPoint: Vector2;
  83894. /**
  83895. * Defines the center point of the arc.
  83896. */
  83897. centerPoint: Vector2;
  83898. /**
  83899. * Defines the radius of the arc.
  83900. */
  83901. radius: number;
  83902. /**
  83903. * Defines the angle of the arc (from mid point to end point).
  83904. */
  83905. angle: Angle;
  83906. /**
  83907. * Defines the start angle of the arc (from start point to middle point).
  83908. */
  83909. startAngle: Angle;
  83910. /**
  83911. * Defines the orientation of the arc (clock wise/counter clock wise).
  83912. */
  83913. orientation: Orientation;
  83914. /**
  83915. * Creates an Arc object from the three given points : start, middle and end.
  83916. * @param startPoint Defines the start point of the arc
  83917. * @param midPoint Defines the midlle point of the arc
  83918. * @param endPoint Defines the end point of the arc
  83919. */
  83920. constructor(
  83921. /** Defines the start point of the arc */
  83922. startPoint: Vector2,
  83923. /** Defines the mid point of the arc */
  83924. midPoint: Vector2,
  83925. /** Defines the end point of the arc */
  83926. endPoint: Vector2);
  83927. }
  83928. /**
  83929. * Represents a 2D path made up of multiple 2D points
  83930. */
  83931. export class Path2 {
  83932. private _points;
  83933. private _length;
  83934. /**
  83935. * If the path start and end point are the same
  83936. */
  83937. closed: boolean;
  83938. /**
  83939. * Creates a Path2 object from the starting 2D coordinates x and y.
  83940. * @param x the starting points x value
  83941. * @param y the starting points y value
  83942. */
  83943. constructor(x: number, y: number);
  83944. /**
  83945. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83946. * @param x the added points x value
  83947. * @param y the added points y value
  83948. * @returns the updated Path2.
  83949. */
  83950. addLineTo(x: number, y: number): Path2;
  83951. /**
  83952. * 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.
  83953. * @param midX middle point x value
  83954. * @param midY middle point y value
  83955. * @param endX end point x value
  83956. * @param endY end point y value
  83957. * @param numberOfSegments (default: 36)
  83958. * @returns the updated Path2.
  83959. */
  83960. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83961. /**
  83962. * Closes the Path2.
  83963. * @returns the Path2.
  83964. */
  83965. close(): Path2;
  83966. /**
  83967. * Gets the sum of the distance between each sequential point in the path
  83968. * @returns the Path2 total length (float).
  83969. */
  83970. length(): number;
  83971. /**
  83972. * Gets the points which construct the path
  83973. * @returns the Path2 internal array of points.
  83974. */
  83975. getPoints(): Vector2[];
  83976. /**
  83977. * Retreives the point at the distance aways from the starting point
  83978. * @param normalizedLengthPosition the length along the path to retreive the point from
  83979. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83980. */
  83981. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83982. /**
  83983. * Creates a new path starting from an x and y position
  83984. * @param x starting x value
  83985. * @param y starting y value
  83986. * @returns a new Path2 starting at the coordinates (x, y).
  83987. */
  83988. static StartingAt(x: number, y: number): Path2;
  83989. }
  83990. /**
  83991. * Represents a 3D path made up of multiple 3D points
  83992. */
  83993. export class Path3D {
  83994. /**
  83995. * an array of Vector3, the curve axis of the Path3D
  83996. */
  83997. path: Vector3[];
  83998. private _curve;
  83999. private _distances;
  84000. private _tangents;
  84001. private _normals;
  84002. private _binormals;
  84003. private _raw;
  84004. private _alignTangentsWithPath;
  84005. private readonly _pointAtData;
  84006. /**
  84007. * new Path3D(path, normal, raw)
  84008. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84009. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84010. * @param path an array of Vector3, the curve axis of the Path3D
  84011. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84012. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84013. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84014. */
  84015. constructor(
  84016. /**
  84017. * an array of Vector3, the curve axis of the Path3D
  84018. */
  84019. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84020. /**
  84021. * Returns the Path3D array of successive Vector3 designing its curve.
  84022. * @returns the Path3D array of successive Vector3 designing its curve.
  84023. */
  84024. getCurve(): Vector3[];
  84025. /**
  84026. * Returns the Path3D array of successive Vector3 designing its curve.
  84027. * @returns the Path3D array of successive Vector3 designing its curve.
  84028. */
  84029. getPoints(): Vector3[];
  84030. /**
  84031. * @returns the computed length (float) of the path.
  84032. */
  84033. length(): number;
  84034. /**
  84035. * Returns an array populated with tangent vectors on each Path3D curve point.
  84036. * @returns an array populated with tangent vectors on each Path3D curve point.
  84037. */
  84038. getTangents(): Vector3[];
  84039. /**
  84040. * Returns an array populated with normal vectors on each Path3D curve point.
  84041. * @returns an array populated with normal vectors on each Path3D curve point.
  84042. */
  84043. getNormals(): Vector3[];
  84044. /**
  84045. * Returns an array populated with binormal vectors on each Path3D curve point.
  84046. * @returns an array populated with binormal vectors on each Path3D curve point.
  84047. */
  84048. getBinormals(): Vector3[];
  84049. /**
  84050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84052. */
  84053. getDistances(): number[];
  84054. /**
  84055. * Returns an interpolated point along this path
  84056. * @param position the position of the point along this path, from 0.0 to 1.0
  84057. * @returns a new Vector3 as the point
  84058. */
  84059. getPointAt(position: number): Vector3;
  84060. /**
  84061. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84062. * @param position the position of the point along this path, from 0.0 to 1.0
  84063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84064. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84065. */
  84066. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84067. /**
  84068. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84069. * @param position the position of the point along this path, from 0.0 to 1.0
  84070. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84071. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84072. */
  84073. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84074. /**
  84075. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84076. * @param position the position of the point along this path, from 0.0 to 1.0
  84077. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84078. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84079. */
  84080. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84081. /**
  84082. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84083. * @param position the position of the point along this path, from 0.0 to 1.0
  84084. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84085. */
  84086. getDistanceAt(position: number): number;
  84087. /**
  84088. * Returns the array index of the previous point of an interpolated point along this path
  84089. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84090. * @returns the array index
  84091. */
  84092. getPreviousPointIndexAt(position: number): number;
  84093. /**
  84094. * 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)
  84095. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84096. * @returns the sub position
  84097. */
  84098. getSubPositionAt(position: number): number;
  84099. /**
  84100. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84101. * @param target the vector of which to get the closest position to
  84102. * @returns the position of the closest virtual point on this path to the target vector
  84103. */
  84104. getClosestPositionTo(target: Vector3): number;
  84105. /**
  84106. * Returns a sub path (slice) of this path
  84107. * @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
  84108. * @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
  84109. * @returns a sub path (slice) of this path
  84110. */
  84111. slice(start?: number, end?: number): Path3D;
  84112. /**
  84113. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84114. * @param path path which all values are copied into the curves points
  84115. * @param firstNormal which should be projected onto the curve
  84116. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84117. * @returns the same object updated.
  84118. */
  84119. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84120. private _compute;
  84121. private _getFirstNonNullVector;
  84122. private _getLastNonNullVector;
  84123. private _normalVector;
  84124. /**
  84125. * Updates the point at data for an interpolated point along this curve
  84126. * @param position the position of the point along this curve, from 0.0 to 1.0
  84127. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84128. * @returns the (updated) point at data
  84129. */
  84130. private _updatePointAtData;
  84131. /**
  84132. * Updates the point at data from the specified parameters
  84133. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84134. * @param point the interpolated point
  84135. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84136. */
  84137. private _setPointAtData;
  84138. /**
  84139. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84140. */
  84141. private _updateInterpolationMatrix;
  84142. }
  84143. /**
  84144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84145. * A Curve3 is designed from a series of successive Vector3.
  84146. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84147. */
  84148. export class Curve3 {
  84149. private _points;
  84150. private _length;
  84151. /**
  84152. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84153. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84154. * @param v1 (Vector3) the control point
  84155. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84156. * @param nbPoints (integer) the wanted number of points in the curve
  84157. * @returns the created Curve3
  84158. */
  84159. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84160. /**
  84161. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84162. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84163. * @param v1 (Vector3) the first control point
  84164. * @param v2 (Vector3) the second control point
  84165. * @param v3 (Vector3) the end point of the Cubic Bezier
  84166. * @param nbPoints (integer) the wanted number of points in the curve
  84167. * @returns the created Curve3
  84168. */
  84169. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84170. /**
  84171. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84172. * @param p1 (Vector3) the origin point of the Hermite Spline
  84173. * @param t1 (Vector3) the tangent vector at the origin point
  84174. * @param p2 (Vector3) the end point of the Hermite Spline
  84175. * @param t2 (Vector3) the tangent vector at the end point
  84176. * @param nbPoints (integer) the wanted number of points in the curve
  84177. * @returns the created Curve3
  84178. */
  84179. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84180. /**
  84181. * Returns a Curve3 object along a CatmullRom Spline curve :
  84182. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84183. * @param nbPoints (integer) the wanted number of points between each curve control points
  84184. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84185. * @returns the created Curve3
  84186. */
  84187. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84188. /**
  84189. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84190. * A Curve3 is designed from a series of successive Vector3.
  84191. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84192. * @param points points which make up the curve
  84193. */
  84194. constructor(points: Vector3[]);
  84195. /**
  84196. * @returns the Curve3 stored array of successive Vector3
  84197. */
  84198. getPoints(): Vector3[];
  84199. /**
  84200. * @returns the computed length (float) of the curve.
  84201. */
  84202. length(): number;
  84203. /**
  84204. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84205. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84206. * curveA and curveB keep unchanged.
  84207. * @param curve the curve to continue from this curve
  84208. * @returns the newly constructed curve
  84209. */
  84210. continue(curve: DeepImmutable<Curve3>): Curve3;
  84211. private _computeLength;
  84212. }
  84213. }
  84214. declare module BABYLON {
  84215. /**
  84216. * This represents the main contract an easing function should follow.
  84217. * Easing functions are used throughout the animation system.
  84218. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84219. */
  84220. export interface IEasingFunction {
  84221. /**
  84222. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84223. * of the easing function.
  84224. * The link below provides some of the most common examples of easing functions.
  84225. * @see https://easings.net/
  84226. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84227. * @returns the corresponding value on the curve defined by the easing function
  84228. */
  84229. ease(gradient: number): number;
  84230. }
  84231. /**
  84232. * Base class used for every default easing function.
  84233. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84234. */
  84235. export class EasingFunction implements IEasingFunction {
  84236. /**
  84237. * Interpolation follows the mathematical formula associated with the easing function.
  84238. */
  84239. static readonly EASINGMODE_EASEIN: number;
  84240. /**
  84241. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84242. */
  84243. static readonly EASINGMODE_EASEOUT: number;
  84244. /**
  84245. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84246. */
  84247. static readonly EASINGMODE_EASEINOUT: number;
  84248. private _easingMode;
  84249. /**
  84250. * Sets the easing mode of the current function.
  84251. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84252. */
  84253. setEasingMode(easingMode: number): void;
  84254. /**
  84255. * Gets the current easing mode.
  84256. * @returns the easing mode
  84257. */
  84258. getEasingMode(): number;
  84259. /**
  84260. * @hidden
  84261. */
  84262. easeInCore(gradient: number): number;
  84263. /**
  84264. * Given an input gradient between 0 and 1, this returns the corresponding value
  84265. * of the easing function.
  84266. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84267. * @returns the corresponding value on the curve defined by the easing function
  84268. */
  84269. ease(gradient: number): number;
  84270. }
  84271. /**
  84272. * Easing function with a circle shape (see link below).
  84273. * @see https://easings.net/#easeInCirc
  84274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84275. */
  84276. export class CircleEase extends EasingFunction implements IEasingFunction {
  84277. /** @hidden */
  84278. easeInCore(gradient: number): number;
  84279. }
  84280. /**
  84281. * Easing function with a ease back shape (see link below).
  84282. * @see https://easings.net/#easeInBack
  84283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84284. */
  84285. export class BackEase extends EasingFunction implements IEasingFunction {
  84286. /** Defines the amplitude of the function */
  84287. amplitude: number;
  84288. /**
  84289. * Instantiates a back ease easing
  84290. * @see https://easings.net/#easeInBack
  84291. * @param amplitude Defines the amplitude of the function
  84292. */
  84293. constructor(
  84294. /** Defines the amplitude of the function */
  84295. amplitude?: number);
  84296. /** @hidden */
  84297. easeInCore(gradient: number): number;
  84298. }
  84299. /**
  84300. * Easing function with a bouncing shape (see link below).
  84301. * @see https://easings.net/#easeInBounce
  84302. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84303. */
  84304. export class BounceEase extends EasingFunction implements IEasingFunction {
  84305. /** Defines the number of bounces */
  84306. bounces: number;
  84307. /** Defines the amplitude of the bounce */
  84308. bounciness: number;
  84309. /**
  84310. * Instantiates a bounce easing
  84311. * @see https://easings.net/#easeInBounce
  84312. * @param bounces Defines the number of bounces
  84313. * @param bounciness Defines the amplitude of the bounce
  84314. */
  84315. constructor(
  84316. /** Defines the number of bounces */
  84317. bounces?: number,
  84318. /** Defines the amplitude of the bounce */
  84319. bounciness?: number);
  84320. /** @hidden */
  84321. easeInCore(gradient: number): number;
  84322. }
  84323. /**
  84324. * Easing function with a power of 3 shape (see link below).
  84325. * @see https://easings.net/#easeInCubic
  84326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84327. */
  84328. export class CubicEase extends EasingFunction implements IEasingFunction {
  84329. /** @hidden */
  84330. easeInCore(gradient: number): number;
  84331. }
  84332. /**
  84333. * Easing function with an elastic shape (see link below).
  84334. * @see https://easings.net/#easeInElastic
  84335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84336. */
  84337. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84338. /** Defines the number of oscillations*/
  84339. oscillations: number;
  84340. /** Defines the amplitude of the oscillations*/
  84341. springiness: number;
  84342. /**
  84343. * Instantiates an elastic easing function
  84344. * @see https://easings.net/#easeInElastic
  84345. * @param oscillations Defines the number of oscillations
  84346. * @param springiness Defines the amplitude of the oscillations
  84347. */
  84348. constructor(
  84349. /** Defines the number of oscillations*/
  84350. oscillations?: number,
  84351. /** Defines the amplitude of the oscillations*/
  84352. springiness?: number);
  84353. /** @hidden */
  84354. easeInCore(gradient: number): number;
  84355. }
  84356. /**
  84357. * Easing function with an exponential shape (see link below).
  84358. * @see https://easings.net/#easeInExpo
  84359. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84360. */
  84361. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84362. /** Defines the exponent of the function */
  84363. exponent: number;
  84364. /**
  84365. * Instantiates an exponential easing function
  84366. * @see https://easings.net/#easeInExpo
  84367. * @param exponent Defines the exponent of the function
  84368. */
  84369. constructor(
  84370. /** Defines the exponent of the function */
  84371. exponent?: number);
  84372. /** @hidden */
  84373. easeInCore(gradient: number): number;
  84374. }
  84375. /**
  84376. * Easing function with a power shape (see link below).
  84377. * @see https://easings.net/#easeInQuad
  84378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84379. */
  84380. export class PowerEase extends EasingFunction implements IEasingFunction {
  84381. /** Defines the power of the function */
  84382. power: number;
  84383. /**
  84384. * Instantiates an power base easing function
  84385. * @see https://easings.net/#easeInQuad
  84386. * @param power Defines the power of the function
  84387. */
  84388. constructor(
  84389. /** Defines the power of the function */
  84390. power?: number);
  84391. /** @hidden */
  84392. easeInCore(gradient: number): number;
  84393. }
  84394. /**
  84395. * Easing function with a power of 2 shape (see link below).
  84396. * @see https://easings.net/#easeInQuad
  84397. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84398. */
  84399. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84400. /** @hidden */
  84401. easeInCore(gradient: number): number;
  84402. }
  84403. /**
  84404. * Easing function with a power of 4 shape (see link below).
  84405. * @see https://easings.net/#easeInQuart
  84406. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84407. */
  84408. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84409. /** @hidden */
  84410. easeInCore(gradient: number): number;
  84411. }
  84412. /**
  84413. * Easing function with a power of 5 shape (see link below).
  84414. * @see https://easings.net/#easeInQuint
  84415. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84416. */
  84417. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84418. /** @hidden */
  84419. easeInCore(gradient: number): number;
  84420. }
  84421. /**
  84422. * Easing function with a sin shape (see link below).
  84423. * @see https://easings.net/#easeInSine
  84424. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84425. */
  84426. export class SineEase extends EasingFunction implements IEasingFunction {
  84427. /** @hidden */
  84428. easeInCore(gradient: number): number;
  84429. }
  84430. /**
  84431. * Easing function with a bezier shape (see link below).
  84432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84433. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84434. */
  84435. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84436. /** Defines the x component of the start tangent in the bezier curve */
  84437. x1: number;
  84438. /** Defines the y component of the start tangent in the bezier curve */
  84439. y1: number;
  84440. /** Defines the x component of the end tangent in the bezier curve */
  84441. x2: number;
  84442. /** Defines the y component of the end tangent in the bezier curve */
  84443. y2: number;
  84444. /**
  84445. * Instantiates a bezier function
  84446. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84447. * @param x1 Defines the x component of the start tangent in the bezier curve
  84448. * @param y1 Defines the y component of the start tangent in the bezier curve
  84449. * @param x2 Defines the x component of the end tangent in the bezier curve
  84450. * @param y2 Defines the y component of the end tangent in the bezier curve
  84451. */
  84452. constructor(
  84453. /** Defines the x component of the start tangent in the bezier curve */
  84454. x1?: number,
  84455. /** Defines the y component of the start tangent in the bezier curve */
  84456. y1?: number,
  84457. /** Defines the x component of the end tangent in the bezier curve */
  84458. x2?: number,
  84459. /** Defines the y component of the end tangent in the bezier curve */
  84460. y2?: number);
  84461. /** @hidden */
  84462. easeInCore(gradient: number): number;
  84463. }
  84464. }
  84465. declare module BABYLON {
  84466. /**
  84467. * Class used to hold a RBG color
  84468. */
  84469. export class Color3 {
  84470. /**
  84471. * Defines the red component (between 0 and 1, default is 0)
  84472. */
  84473. r: number;
  84474. /**
  84475. * Defines the green component (between 0 and 1, default is 0)
  84476. */
  84477. g: number;
  84478. /**
  84479. * Defines the blue component (between 0 and 1, default is 0)
  84480. */
  84481. b: number;
  84482. /**
  84483. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84484. * @param r defines the red component (between 0 and 1, default is 0)
  84485. * @param g defines the green component (between 0 and 1, default is 0)
  84486. * @param b defines the blue component (between 0 and 1, default is 0)
  84487. */
  84488. constructor(
  84489. /**
  84490. * Defines the red component (between 0 and 1, default is 0)
  84491. */
  84492. r?: number,
  84493. /**
  84494. * Defines the green component (between 0 and 1, default is 0)
  84495. */
  84496. g?: number,
  84497. /**
  84498. * Defines the blue component (between 0 and 1, default is 0)
  84499. */
  84500. b?: number);
  84501. /**
  84502. * Creates a string with the Color3 current values
  84503. * @returns the string representation of the Color3 object
  84504. */
  84505. toString(): string;
  84506. /**
  84507. * Returns the string "Color3"
  84508. * @returns "Color3"
  84509. */
  84510. getClassName(): string;
  84511. /**
  84512. * Compute the Color3 hash code
  84513. * @returns an unique number that can be used to hash Color3 objects
  84514. */
  84515. getHashCode(): number;
  84516. /**
  84517. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84518. * @param array defines the array where to store the r,g,b components
  84519. * @param index defines an optional index in the target array to define where to start storing values
  84520. * @returns the current Color3 object
  84521. */
  84522. toArray(array: FloatArray, index?: number): Color3;
  84523. /**
  84524. * Update the current color with values stored in an array from the starting index of the given array
  84525. * @param array defines the source array
  84526. * @param offset defines an offset in the source array
  84527. * @returns the current Color3 object
  84528. */
  84529. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84530. /**
  84531. * Returns a new Color4 object from the current Color3 and the given alpha
  84532. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84533. * @returns a new Color4 object
  84534. */
  84535. toColor4(alpha?: number): Color4;
  84536. /**
  84537. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84538. * @returns the new array
  84539. */
  84540. asArray(): number[];
  84541. /**
  84542. * Returns the luminance value
  84543. * @returns a float value
  84544. */
  84545. toLuminance(): number;
  84546. /**
  84547. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84548. * @param otherColor defines the second operand
  84549. * @returns the new Color3 object
  84550. */
  84551. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84552. /**
  84553. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84554. * @param otherColor defines the second operand
  84555. * @param result defines the Color3 object where to store the result
  84556. * @returns the current Color3
  84557. */
  84558. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84559. /**
  84560. * Determines equality between Color3 objects
  84561. * @param otherColor defines the second operand
  84562. * @returns true if the rgb values are equal to the given ones
  84563. */
  84564. equals(otherColor: DeepImmutable<Color3>): boolean;
  84565. /**
  84566. * Determines equality between the current Color3 object and a set of r,b,g values
  84567. * @param r defines the red component to check
  84568. * @param g defines the green component to check
  84569. * @param b defines the blue component to check
  84570. * @returns true if the rgb values are equal to the given ones
  84571. */
  84572. equalsFloats(r: number, g: number, b: number): boolean;
  84573. /**
  84574. * Multiplies in place each rgb value by scale
  84575. * @param scale defines the scaling factor
  84576. * @returns the updated Color3
  84577. */
  84578. scale(scale: number): Color3;
  84579. /**
  84580. * Multiplies the rgb values by scale and stores the result into "result"
  84581. * @param scale defines the scaling factor
  84582. * @param result defines the Color3 object where to store the result
  84583. * @returns the unmodified current Color3
  84584. */
  84585. scaleToRef(scale: number, result: Color3): Color3;
  84586. /**
  84587. * Scale the current Color3 values by a factor and add the result to a given Color3
  84588. * @param scale defines the scale factor
  84589. * @param result defines color to store the result into
  84590. * @returns the unmodified current Color3
  84591. */
  84592. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84593. /**
  84594. * Clamps the rgb values by the min and max values and stores the result into "result"
  84595. * @param min defines minimum clamping value (default is 0)
  84596. * @param max defines maximum clamping value (default is 1)
  84597. * @param result defines color to store the result into
  84598. * @returns the original Color3
  84599. */
  84600. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84601. /**
  84602. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84603. * @param otherColor defines the second operand
  84604. * @returns the new Color3
  84605. */
  84606. add(otherColor: DeepImmutable<Color3>): Color3;
  84607. /**
  84608. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84609. * @param otherColor defines the second operand
  84610. * @param result defines Color3 object to store the result into
  84611. * @returns the unmodified current Color3
  84612. */
  84613. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84614. /**
  84615. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84616. * @param otherColor defines the second operand
  84617. * @returns the new Color3
  84618. */
  84619. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84620. /**
  84621. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84622. * @param otherColor defines the second operand
  84623. * @param result defines Color3 object to store the result into
  84624. * @returns the unmodified current Color3
  84625. */
  84626. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84627. /**
  84628. * Copy the current object
  84629. * @returns a new Color3 copied the current one
  84630. */
  84631. clone(): Color3;
  84632. /**
  84633. * Copies the rgb values from the source in the current Color3
  84634. * @param source defines the source Color3 object
  84635. * @returns the updated Color3 object
  84636. */
  84637. copyFrom(source: DeepImmutable<Color3>): Color3;
  84638. /**
  84639. * Updates the Color3 rgb values from the given floats
  84640. * @param r defines the red component to read from
  84641. * @param g defines the green component to read from
  84642. * @param b defines the blue component to read from
  84643. * @returns the current Color3 object
  84644. */
  84645. copyFromFloats(r: number, g: number, b: number): Color3;
  84646. /**
  84647. * Updates the Color3 rgb values from the given floats
  84648. * @param r defines the red component to read from
  84649. * @param g defines the green component to read from
  84650. * @param b defines the blue component to read from
  84651. * @returns the current Color3 object
  84652. */
  84653. set(r: number, g: number, b: number): Color3;
  84654. /**
  84655. * Compute the Color3 hexadecimal code as a string
  84656. * @returns a string containing the hexadecimal representation of the Color3 object
  84657. */
  84658. toHexString(): string;
  84659. /**
  84660. * Computes a new Color3 converted from the current one to linear space
  84661. * @returns a new Color3 object
  84662. */
  84663. toLinearSpace(): Color3;
  84664. /**
  84665. * Converts current color in rgb space to HSV values
  84666. * @returns a new color3 representing the HSV values
  84667. */
  84668. toHSV(): Color3;
  84669. /**
  84670. * Converts current color in rgb space to HSV values
  84671. * @param result defines the Color3 where to store the HSV values
  84672. */
  84673. toHSVToRef(result: Color3): void;
  84674. /**
  84675. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84676. * @param convertedColor defines the Color3 object where to store the linear space version
  84677. * @returns the unmodified Color3
  84678. */
  84679. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84680. /**
  84681. * Computes a new Color3 converted from the current one to gamma space
  84682. * @returns a new Color3 object
  84683. */
  84684. toGammaSpace(): Color3;
  84685. /**
  84686. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84687. * @param convertedColor defines the Color3 object where to store the gamma space version
  84688. * @returns the unmodified Color3
  84689. */
  84690. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84691. private static _BlackReadOnly;
  84692. /**
  84693. * Convert Hue, saturation and value to a Color3 (RGB)
  84694. * @param hue defines the hue
  84695. * @param saturation defines the saturation
  84696. * @param value defines the value
  84697. * @param result defines the Color3 where to store the RGB values
  84698. */
  84699. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84700. /**
  84701. * Creates a new Color3 from the string containing valid hexadecimal values
  84702. * @param hex defines a string containing valid hexadecimal values
  84703. * @returns a new Color3 object
  84704. */
  84705. static FromHexString(hex: string): Color3;
  84706. /**
  84707. * Creates a new Color3 from the starting index of the given array
  84708. * @param array defines the source array
  84709. * @param offset defines an offset in the source array
  84710. * @returns a new Color3 object
  84711. */
  84712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84713. /**
  84714. * Creates a new Color3 from the starting index element of the given array
  84715. * @param array defines the source array to read from
  84716. * @param offset defines the offset in the source array
  84717. * @param result defines the target Color3 object
  84718. */
  84719. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84720. /**
  84721. * Creates a new Color3 from integer values (< 256)
  84722. * @param r defines the red component to read from (value between 0 and 255)
  84723. * @param g defines the green component to read from (value between 0 and 255)
  84724. * @param b defines the blue component to read from (value between 0 and 255)
  84725. * @returns a new Color3 object
  84726. */
  84727. static FromInts(r: number, g: number, b: number): Color3;
  84728. /**
  84729. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84730. * @param start defines the start Color3 value
  84731. * @param end defines the end Color3 value
  84732. * @param amount defines the gradient value between start and end
  84733. * @returns a new Color3 object
  84734. */
  84735. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84736. /**
  84737. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84738. * @param left defines the start value
  84739. * @param right defines the end value
  84740. * @param amount defines the gradient factor
  84741. * @param result defines the Color3 object where to store the result
  84742. */
  84743. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84744. /**
  84745. * Returns a Color3 value containing a red color
  84746. * @returns a new Color3 object
  84747. */
  84748. static Red(): Color3;
  84749. /**
  84750. * Returns a Color3 value containing a green color
  84751. * @returns a new Color3 object
  84752. */
  84753. static Green(): Color3;
  84754. /**
  84755. * Returns a Color3 value containing a blue color
  84756. * @returns a new Color3 object
  84757. */
  84758. static Blue(): Color3;
  84759. /**
  84760. * Returns a Color3 value containing a black color
  84761. * @returns a new Color3 object
  84762. */
  84763. static Black(): Color3;
  84764. /**
  84765. * Gets a Color3 value containing a black color that must not be updated
  84766. */
  84767. static get BlackReadOnly(): DeepImmutable<Color3>;
  84768. /**
  84769. * Returns a Color3 value containing a white color
  84770. * @returns a new Color3 object
  84771. */
  84772. static White(): Color3;
  84773. /**
  84774. * Returns a Color3 value containing a purple color
  84775. * @returns a new Color3 object
  84776. */
  84777. static Purple(): Color3;
  84778. /**
  84779. * Returns a Color3 value containing a magenta color
  84780. * @returns a new Color3 object
  84781. */
  84782. static Magenta(): Color3;
  84783. /**
  84784. * Returns a Color3 value containing a yellow color
  84785. * @returns a new Color3 object
  84786. */
  84787. static Yellow(): Color3;
  84788. /**
  84789. * Returns a Color3 value containing a gray color
  84790. * @returns a new Color3 object
  84791. */
  84792. static Gray(): Color3;
  84793. /**
  84794. * Returns a Color3 value containing a teal color
  84795. * @returns a new Color3 object
  84796. */
  84797. static Teal(): Color3;
  84798. /**
  84799. * Returns a Color3 value containing a random color
  84800. * @returns a new Color3 object
  84801. */
  84802. static Random(): Color3;
  84803. }
  84804. /**
  84805. * Class used to hold a RBGA color
  84806. */
  84807. export class Color4 {
  84808. /**
  84809. * Defines the red component (between 0 and 1, default is 0)
  84810. */
  84811. r: number;
  84812. /**
  84813. * Defines the green component (between 0 and 1, default is 0)
  84814. */
  84815. g: number;
  84816. /**
  84817. * Defines the blue component (between 0 and 1, default is 0)
  84818. */
  84819. b: number;
  84820. /**
  84821. * Defines the alpha component (between 0 and 1, default is 1)
  84822. */
  84823. a: number;
  84824. /**
  84825. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84826. * @param r defines the red component (between 0 and 1, default is 0)
  84827. * @param g defines the green component (between 0 and 1, default is 0)
  84828. * @param b defines the blue component (between 0 and 1, default is 0)
  84829. * @param a defines the alpha component (between 0 and 1, default is 1)
  84830. */
  84831. constructor(
  84832. /**
  84833. * Defines the red component (between 0 and 1, default is 0)
  84834. */
  84835. r?: number,
  84836. /**
  84837. * Defines the green component (between 0 and 1, default is 0)
  84838. */
  84839. g?: number,
  84840. /**
  84841. * Defines the blue component (between 0 and 1, default is 0)
  84842. */
  84843. b?: number,
  84844. /**
  84845. * Defines the alpha component (between 0 and 1, default is 1)
  84846. */
  84847. a?: number);
  84848. /**
  84849. * Adds in place the given Color4 values to the current Color4 object
  84850. * @param right defines the second operand
  84851. * @returns the current updated Color4 object
  84852. */
  84853. addInPlace(right: DeepImmutable<Color4>): Color4;
  84854. /**
  84855. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84856. * @returns the new array
  84857. */
  84858. asArray(): number[];
  84859. /**
  84860. * Stores from the starting index in the given array the Color4 successive values
  84861. * @param array defines the array where to store the r,g,b components
  84862. * @param index defines an optional index in the target array to define where to start storing values
  84863. * @returns the current Color4 object
  84864. */
  84865. toArray(array: number[], index?: number): Color4;
  84866. /**
  84867. * Update the current color with values stored in an array from the starting index of the given array
  84868. * @param array defines the source array
  84869. * @param offset defines an offset in the source array
  84870. * @returns the current Color4 object
  84871. */
  84872. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84873. /**
  84874. * Determines equality between Color4 objects
  84875. * @param otherColor defines the second operand
  84876. * @returns true if the rgba values are equal to the given ones
  84877. */
  84878. equals(otherColor: DeepImmutable<Color4>): boolean;
  84879. /**
  84880. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84881. * @param right defines the second operand
  84882. * @returns a new Color4 object
  84883. */
  84884. add(right: DeepImmutable<Color4>): Color4;
  84885. /**
  84886. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84887. * @param right defines the second operand
  84888. * @returns a new Color4 object
  84889. */
  84890. subtract(right: DeepImmutable<Color4>): Color4;
  84891. /**
  84892. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84893. * @param right defines the second operand
  84894. * @param result defines the Color4 object where to store the result
  84895. * @returns the current Color4 object
  84896. */
  84897. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84898. /**
  84899. * Creates a new Color4 with the current Color4 values multiplied by scale
  84900. * @param scale defines the scaling factor to apply
  84901. * @returns a new Color4 object
  84902. */
  84903. scale(scale: number): Color4;
  84904. /**
  84905. * Multiplies the current Color4 values by scale and stores the result in "result"
  84906. * @param scale defines the scaling factor to apply
  84907. * @param result defines the Color4 object where to store the result
  84908. * @returns the current unmodified Color4
  84909. */
  84910. scaleToRef(scale: number, result: Color4): Color4;
  84911. /**
  84912. * Scale the current Color4 values by a factor and add the result to a given Color4
  84913. * @param scale defines the scale factor
  84914. * @param result defines the Color4 object where to store the result
  84915. * @returns the unmodified current Color4
  84916. */
  84917. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84918. /**
  84919. * Clamps the rgb values by the min and max values and stores the result into "result"
  84920. * @param min defines minimum clamping value (default is 0)
  84921. * @param max defines maximum clamping value (default is 1)
  84922. * @param result defines color to store the result into.
  84923. * @returns the cuurent Color4
  84924. */
  84925. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84926. /**
  84927. * Multipy an Color4 value by another and return a new Color4 object
  84928. * @param color defines the Color4 value to multiply by
  84929. * @returns a new Color4 object
  84930. */
  84931. multiply(color: Color4): Color4;
  84932. /**
  84933. * Multipy a Color4 value by another and push the result in a reference value
  84934. * @param color defines the Color4 value to multiply by
  84935. * @param result defines the Color4 to fill the result in
  84936. * @returns the result Color4
  84937. */
  84938. multiplyToRef(color: Color4, result: Color4): Color4;
  84939. /**
  84940. * Creates a string with the Color4 current values
  84941. * @returns the string representation of the Color4 object
  84942. */
  84943. toString(): string;
  84944. /**
  84945. * Returns the string "Color4"
  84946. * @returns "Color4"
  84947. */
  84948. getClassName(): string;
  84949. /**
  84950. * Compute the Color4 hash code
  84951. * @returns an unique number that can be used to hash Color4 objects
  84952. */
  84953. getHashCode(): number;
  84954. /**
  84955. * Creates a new Color4 copied from the current one
  84956. * @returns a new Color4 object
  84957. */
  84958. clone(): Color4;
  84959. /**
  84960. * Copies the given Color4 values into the current one
  84961. * @param source defines the source Color4 object
  84962. * @returns the current updated Color4 object
  84963. */
  84964. copyFrom(source: Color4): Color4;
  84965. /**
  84966. * Copies the given float values into the current one
  84967. * @param r defines the red component to read from
  84968. * @param g defines the green component to read from
  84969. * @param b defines the blue component to read from
  84970. * @param a defines the alpha component to read from
  84971. * @returns the current updated Color4 object
  84972. */
  84973. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84974. /**
  84975. * Copies the given float values into the current one
  84976. * @param r defines the red component to read from
  84977. * @param g defines the green component to read from
  84978. * @param b defines the blue component to read from
  84979. * @param a defines the alpha component to read from
  84980. * @returns the current updated Color4 object
  84981. */
  84982. set(r: number, g: number, b: number, a: number): Color4;
  84983. /**
  84984. * Compute the Color4 hexadecimal code as a string
  84985. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84986. * @returns a string containing the hexadecimal representation of the Color4 object
  84987. */
  84988. toHexString(returnAsColor3?: boolean): string;
  84989. /**
  84990. * Computes a new Color4 converted from the current one to linear space
  84991. * @returns a new Color4 object
  84992. */
  84993. toLinearSpace(): Color4;
  84994. /**
  84995. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84996. * @param convertedColor defines the Color4 object where to store the linear space version
  84997. * @returns the unmodified Color4
  84998. */
  84999. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85000. /**
  85001. * Computes a new Color4 converted from the current one to gamma space
  85002. * @returns a new Color4 object
  85003. */
  85004. toGammaSpace(): Color4;
  85005. /**
  85006. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85007. * @param convertedColor defines the Color4 object where to store the gamma space version
  85008. * @returns the unmodified Color4
  85009. */
  85010. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85011. /**
  85012. * Creates a new Color4 from the string containing valid hexadecimal values
  85013. * @param hex defines a string containing valid hexadecimal values
  85014. * @returns a new Color4 object
  85015. */
  85016. static FromHexString(hex: string): Color4;
  85017. /**
  85018. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85019. * @param left defines the start value
  85020. * @param right defines the end value
  85021. * @param amount defines the gradient factor
  85022. * @returns a new Color4 object
  85023. */
  85024. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85025. /**
  85026. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85027. * @param left defines the start value
  85028. * @param right defines the end value
  85029. * @param amount defines the gradient factor
  85030. * @param result defines the Color4 object where to store data
  85031. */
  85032. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85033. /**
  85034. * Creates a new Color4 from a Color3 and an alpha value
  85035. * @param color3 defines the source Color3 to read from
  85036. * @param alpha defines the alpha component (1.0 by default)
  85037. * @returns a new Color4 object
  85038. */
  85039. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85040. /**
  85041. * Creates a new Color4 from the starting index element of the given array
  85042. * @param array defines the source array to read from
  85043. * @param offset defines the offset in the source array
  85044. * @returns a new Color4 object
  85045. */
  85046. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85047. /**
  85048. * Creates a new Color4 from the starting index element of the given array
  85049. * @param array defines the source array to read from
  85050. * @param offset defines the offset in the source array
  85051. * @param result defines the target Color4 object
  85052. */
  85053. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85054. /**
  85055. * Creates a new Color3 from integer values (< 256)
  85056. * @param r defines the red component to read from (value between 0 and 255)
  85057. * @param g defines the green component to read from (value between 0 and 255)
  85058. * @param b defines the blue component to read from (value between 0 and 255)
  85059. * @param a defines the alpha component to read from (value between 0 and 255)
  85060. * @returns a new Color3 object
  85061. */
  85062. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85063. /**
  85064. * Check the content of a given array and convert it to an array containing RGBA data
  85065. * If the original array was already containing count * 4 values then it is returned directly
  85066. * @param colors defines the array to check
  85067. * @param count defines the number of RGBA data to expect
  85068. * @returns an array containing count * 4 values (RGBA)
  85069. */
  85070. static CheckColors4(colors: number[], count: number): number[];
  85071. }
  85072. /**
  85073. * @hidden
  85074. */
  85075. export class TmpColors {
  85076. static Color3: Color3[];
  85077. static Color4: Color4[];
  85078. }
  85079. }
  85080. declare module BABYLON {
  85081. /**
  85082. * Defines an interface which represents an animation key frame
  85083. */
  85084. export interface IAnimationKey {
  85085. /**
  85086. * Frame of the key frame
  85087. */
  85088. frame: number;
  85089. /**
  85090. * Value at the specifies key frame
  85091. */
  85092. value: any;
  85093. /**
  85094. * The input tangent for the cubic hermite spline
  85095. */
  85096. inTangent?: any;
  85097. /**
  85098. * The output tangent for the cubic hermite spline
  85099. */
  85100. outTangent?: any;
  85101. /**
  85102. * The animation interpolation type
  85103. */
  85104. interpolation?: AnimationKeyInterpolation;
  85105. }
  85106. /**
  85107. * Enum for the animation key frame interpolation type
  85108. */
  85109. export enum AnimationKeyInterpolation {
  85110. /**
  85111. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85112. */
  85113. STEP = 1
  85114. }
  85115. }
  85116. declare module BABYLON {
  85117. /**
  85118. * Represents the range of an animation
  85119. */
  85120. export class AnimationRange {
  85121. /**The name of the animation range**/
  85122. name: string;
  85123. /**The starting frame of the animation */
  85124. from: number;
  85125. /**The ending frame of the animation*/
  85126. to: number;
  85127. /**
  85128. * Initializes the range of an animation
  85129. * @param name The name of the animation range
  85130. * @param from The starting frame of the animation
  85131. * @param to The ending frame of the animation
  85132. */
  85133. constructor(
  85134. /**The name of the animation range**/
  85135. name: string,
  85136. /**The starting frame of the animation */
  85137. from: number,
  85138. /**The ending frame of the animation*/
  85139. to: number);
  85140. /**
  85141. * Makes a copy of the animation range
  85142. * @returns A copy of the animation range
  85143. */
  85144. clone(): AnimationRange;
  85145. }
  85146. }
  85147. declare module BABYLON {
  85148. /**
  85149. * Composed of a frame, and an action function
  85150. */
  85151. export class AnimationEvent {
  85152. /** The frame for which the event is triggered **/
  85153. frame: number;
  85154. /** The event to perform when triggered **/
  85155. action: (currentFrame: number) => void;
  85156. /** Specifies if the event should be triggered only once**/
  85157. onlyOnce?: boolean | undefined;
  85158. /**
  85159. * Specifies if the animation event is done
  85160. */
  85161. isDone: boolean;
  85162. /**
  85163. * Initializes the animation event
  85164. * @param frame The frame for which the event is triggered
  85165. * @param action The event to perform when triggered
  85166. * @param onlyOnce Specifies if the event should be triggered only once
  85167. */
  85168. constructor(
  85169. /** The frame for which the event is triggered **/
  85170. frame: number,
  85171. /** The event to perform when triggered **/
  85172. action: (currentFrame: number) => void,
  85173. /** Specifies if the event should be triggered only once**/
  85174. onlyOnce?: boolean | undefined);
  85175. /** @hidden */
  85176. _clone(): AnimationEvent;
  85177. }
  85178. }
  85179. declare module BABYLON {
  85180. /**
  85181. * Interface used to define a behavior
  85182. */
  85183. export interface Behavior<T> {
  85184. /** gets or sets behavior's name */
  85185. name: string;
  85186. /**
  85187. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85188. */
  85189. init(): void;
  85190. /**
  85191. * Called when the behavior is attached to a target
  85192. * @param target defines the target where the behavior is attached to
  85193. */
  85194. attach(target: T): void;
  85195. /**
  85196. * Called when the behavior is detached from its target
  85197. */
  85198. detach(): void;
  85199. }
  85200. /**
  85201. * Interface implemented by classes supporting behaviors
  85202. */
  85203. export interface IBehaviorAware<T> {
  85204. /**
  85205. * Attach a behavior
  85206. * @param behavior defines the behavior to attach
  85207. * @returns the current host
  85208. */
  85209. addBehavior(behavior: Behavior<T>): T;
  85210. /**
  85211. * Remove a behavior from the current object
  85212. * @param behavior defines the behavior to detach
  85213. * @returns the current host
  85214. */
  85215. removeBehavior(behavior: Behavior<T>): T;
  85216. /**
  85217. * Gets a behavior using its name to search
  85218. * @param name defines the name to search
  85219. * @returns the behavior or null if not found
  85220. */
  85221. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85222. }
  85223. }
  85224. declare module BABYLON {
  85225. /**
  85226. * Defines an array and its length.
  85227. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85228. */
  85229. export interface ISmartArrayLike<T> {
  85230. /**
  85231. * The data of the array.
  85232. */
  85233. data: Array<T>;
  85234. /**
  85235. * The active length of the array.
  85236. */
  85237. length: number;
  85238. }
  85239. /**
  85240. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85241. */
  85242. export class SmartArray<T> implements ISmartArrayLike<T> {
  85243. /**
  85244. * The full set of data from the array.
  85245. */
  85246. data: Array<T>;
  85247. /**
  85248. * The active length of the array.
  85249. */
  85250. length: number;
  85251. protected _id: number;
  85252. /**
  85253. * Instantiates a Smart Array.
  85254. * @param capacity defines the default capacity of the array.
  85255. */
  85256. constructor(capacity: number);
  85257. /**
  85258. * Pushes a value at the end of the active data.
  85259. * @param value defines the object to push in the array.
  85260. */
  85261. push(value: T): void;
  85262. /**
  85263. * Iterates over the active data and apply the lambda to them.
  85264. * @param func defines the action to apply on each value.
  85265. */
  85266. forEach(func: (content: T) => void): void;
  85267. /**
  85268. * Sorts the full sets of data.
  85269. * @param compareFn defines the comparison function to apply.
  85270. */
  85271. sort(compareFn: (a: T, b: T) => number): void;
  85272. /**
  85273. * Resets the active data to an empty array.
  85274. */
  85275. reset(): void;
  85276. /**
  85277. * Releases all the data from the array as well as the array.
  85278. */
  85279. dispose(): void;
  85280. /**
  85281. * Concats the active data with a given array.
  85282. * @param array defines the data to concatenate with.
  85283. */
  85284. concat(array: any): void;
  85285. /**
  85286. * Returns the position of a value in the active data.
  85287. * @param value defines the value to find the index for
  85288. * @returns the index if found in the active data otherwise -1
  85289. */
  85290. indexOf(value: T): number;
  85291. /**
  85292. * Returns whether an element is part of the active data.
  85293. * @param value defines the value to look for
  85294. * @returns true if found in the active data otherwise false
  85295. */
  85296. contains(value: T): boolean;
  85297. private static _GlobalId;
  85298. }
  85299. /**
  85300. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85301. * The data in this array can only be present once
  85302. */
  85303. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85304. private _duplicateId;
  85305. /**
  85306. * Pushes a value at the end of the active data.
  85307. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85308. * @param value defines the object to push in the array.
  85309. */
  85310. push(value: T): void;
  85311. /**
  85312. * Pushes a value at the end of the active data.
  85313. * If the data is already present, it won t be added again
  85314. * @param value defines the object to push in the array.
  85315. * @returns true if added false if it was already present
  85316. */
  85317. pushNoDuplicate(value: T): boolean;
  85318. /**
  85319. * Resets the active data to an empty array.
  85320. */
  85321. reset(): void;
  85322. /**
  85323. * Concats the active data with a given array.
  85324. * This ensures no dupplicate will be present in the result.
  85325. * @param array defines the data to concatenate with.
  85326. */
  85327. concatWithNoDuplicate(array: any): void;
  85328. }
  85329. }
  85330. declare module BABYLON {
  85331. /**
  85332. * @ignore
  85333. * This is a list of all the different input types that are available in the application.
  85334. * Fo instance: ArcRotateCameraGamepadInput...
  85335. */
  85336. export var CameraInputTypes: {};
  85337. /**
  85338. * This is the contract to implement in order to create a new input class.
  85339. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85340. */
  85341. export interface ICameraInput<TCamera extends Camera> {
  85342. /**
  85343. * Defines the camera the input is attached to.
  85344. */
  85345. camera: Nullable<TCamera>;
  85346. /**
  85347. * Gets the class name of the current intput.
  85348. * @returns the class name
  85349. */
  85350. getClassName(): string;
  85351. /**
  85352. * Get the friendly name associated with the input class.
  85353. * @returns the input friendly name
  85354. */
  85355. getSimpleName(): string;
  85356. /**
  85357. * Attach the input controls to a specific dom element to get the input from.
  85358. * @param element Defines the element the controls should be listened from
  85359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85360. */
  85361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85362. /**
  85363. * Detach the current controls from the specified dom element.
  85364. * @param element Defines the element to stop listening the inputs from
  85365. */
  85366. detachControl(element: Nullable<HTMLElement>): void;
  85367. /**
  85368. * Update the current camera state depending on the inputs that have been used this frame.
  85369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85370. */
  85371. checkInputs?: () => void;
  85372. }
  85373. /**
  85374. * Represents a map of input types to input instance or input index to input instance.
  85375. */
  85376. export interface CameraInputsMap<TCamera extends Camera> {
  85377. /**
  85378. * Accessor to the input by input type.
  85379. */
  85380. [name: string]: ICameraInput<TCamera>;
  85381. /**
  85382. * Accessor to the input by input index.
  85383. */
  85384. [idx: number]: ICameraInput<TCamera>;
  85385. }
  85386. /**
  85387. * This represents the input manager used within a camera.
  85388. * It helps dealing with all the different kind of input attached to a camera.
  85389. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85390. */
  85391. export class CameraInputsManager<TCamera extends Camera> {
  85392. /**
  85393. * Defines the list of inputs attahed to the camera.
  85394. */
  85395. attached: CameraInputsMap<TCamera>;
  85396. /**
  85397. * Defines the dom element the camera is collecting inputs from.
  85398. * This is null if the controls have not been attached.
  85399. */
  85400. attachedElement: Nullable<HTMLElement>;
  85401. /**
  85402. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85403. */
  85404. noPreventDefault: boolean;
  85405. /**
  85406. * Defined the camera the input manager belongs to.
  85407. */
  85408. camera: TCamera;
  85409. /**
  85410. * Update the current camera state depending on the inputs that have been used this frame.
  85411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85412. */
  85413. checkInputs: () => void;
  85414. /**
  85415. * Instantiate a new Camera Input Manager.
  85416. * @param camera Defines the camera the input manager blongs to
  85417. */
  85418. constructor(camera: TCamera);
  85419. /**
  85420. * Add an input method to a camera
  85421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85422. * @param input camera input method
  85423. */
  85424. add(input: ICameraInput<TCamera>): void;
  85425. /**
  85426. * Remove a specific input method from a camera
  85427. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85428. * @param inputToRemove camera input method
  85429. */
  85430. remove(inputToRemove: ICameraInput<TCamera>): void;
  85431. /**
  85432. * Remove a specific input type from a camera
  85433. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85434. * @param inputType the type of the input to remove
  85435. */
  85436. removeByType(inputType: string): void;
  85437. private _addCheckInputs;
  85438. /**
  85439. * Attach the input controls to the currently attached dom element to listen the events from.
  85440. * @param input Defines the input to attach
  85441. */
  85442. attachInput(input: ICameraInput<TCamera>): void;
  85443. /**
  85444. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85445. * @param element Defines the dom element to collect the events from
  85446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85447. */
  85448. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85449. /**
  85450. * Detach the current manager inputs controls from a specific dom element.
  85451. * @param element Defines the dom element to collect the events from
  85452. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85453. */
  85454. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85455. /**
  85456. * Rebuild the dynamic inputCheck function from the current list of
  85457. * defined inputs in the manager.
  85458. */
  85459. rebuildInputCheck(): void;
  85460. /**
  85461. * Remove all attached input methods from a camera
  85462. */
  85463. clear(): void;
  85464. /**
  85465. * Serialize the current input manager attached to a camera.
  85466. * This ensures than once parsed,
  85467. * the input associated to the camera will be identical to the current ones
  85468. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85469. */
  85470. serialize(serializedCamera: any): void;
  85471. /**
  85472. * Parses an input manager serialized JSON to restore the previous list of inputs
  85473. * and states associated to a camera.
  85474. * @param parsedCamera Defines the JSON to parse
  85475. */
  85476. parse(parsedCamera: any): void;
  85477. }
  85478. }
  85479. declare module BABYLON {
  85480. /**
  85481. * Class used to store data that will be store in GPU memory
  85482. */
  85483. export class Buffer {
  85484. private _engine;
  85485. private _buffer;
  85486. /** @hidden */
  85487. _data: Nullable<DataArray>;
  85488. private _updatable;
  85489. private _instanced;
  85490. private _divisor;
  85491. /**
  85492. * Gets the byte stride.
  85493. */
  85494. readonly byteStride: number;
  85495. /**
  85496. * Constructor
  85497. * @param engine the engine
  85498. * @param data the data to use for this buffer
  85499. * @param updatable whether the data is updatable
  85500. * @param stride the stride (optional)
  85501. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85502. * @param instanced whether the buffer is instanced (optional)
  85503. * @param useBytes set to true if the stride in in bytes (optional)
  85504. * @param divisor sets an optional divisor for instances (1 by default)
  85505. */
  85506. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85507. /**
  85508. * Create a new VertexBuffer based on the current buffer
  85509. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85510. * @param offset defines offset in the buffer (0 by default)
  85511. * @param size defines the size in floats of attributes (position is 3 for instance)
  85512. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85513. * @param instanced defines if the vertex buffer contains indexed data
  85514. * @param useBytes defines if the offset and stride are in bytes *
  85515. * @param divisor sets an optional divisor for instances (1 by default)
  85516. * @returns the new vertex buffer
  85517. */
  85518. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85519. /**
  85520. * Gets a boolean indicating if the Buffer is updatable?
  85521. * @returns true if the buffer is updatable
  85522. */
  85523. isUpdatable(): boolean;
  85524. /**
  85525. * Gets current buffer's data
  85526. * @returns a DataArray or null
  85527. */
  85528. getData(): Nullable<DataArray>;
  85529. /**
  85530. * Gets underlying native buffer
  85531. * @returns underlying native buffer
  85532. */
  85533. getBuffer(): Nullable<DataBuffer>;
  85534. /**
  85535. * Gets the stride in float32 units (i.e. byte stride / 4).
  85536. * May not be an integer if the byte stride is not divisible by 4.
  85537. * @returns the stride in float32 units
  85538. * @deprecated Please use byteStride instead.
  85539. */
  85540. getStrideSize(): number;
  85541. /**
  85542. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85543. * @param data defines the data to store
  85544. */
  85545. create(data?: Nullable<DataArray>): void;
  85546. /** @hidden */
  85547. _rebuild(): void;
  85548. /**
  85549. * Update current buffer data
  85550. * @param data defines the data to store
  85551. */
  85552. update(data: DataArray): void;
  85553. /**
  85554. * Updates the data directly.
  85555. * @param data the new data
  85556. * @param offset the new offset
  85557. * @param vertexCount the vertex count (optional)
  85558. * @param useBytes set to true if the offset is in bytes
  85559. */
  85560. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85561. /**
  85562. * Release all resources
  85563. */
  85564. dispose(): void;
  85565. }
  85566. /**
  85567. * Specialized buffer used to store vertex data
  85568. */
  85569. export class VertexBuffer {
  85570. /** @hidden */
  85571. _buffer: Buffer;
  85572. private _kind;
  85573. private _size;
  85574. private _ownsBuffer;
  85575. private _instanced;
  85576. private _instanceDivisor;
  85577. /**
  85578. * The byte type.
  85579. */
  85580. static readonly BYTE: number;
  85581. /**
  85582. * The unsigned byte type.
  85583. */
  85584. static readonly UNSIGNED_BYTE: number;
  85585. /**
  85586. * The short type.
  85587. */
  85588. static readonly SHORT: number;
  85589. /**
  85590. * The unsigned short type.
  85591. */
  85592. static readonly UNSIGNED_SHORT: number;
  85593. /**
  85594. * The integer type.
  85595. */
  85596. static readonly INT: number;
  85597. /**
  85598. * The unsigned integer type.
  85599. */
  85600. static readonly UNSIGNED_INT: number;
  85601. /**
  85602. * The float type.
  85603. */
  85604. static readonly FLOAT: number;
  85605. /**
  85606. * Gets or sets the instance divisor when in instanced mode
  85607. */
  85608. get instanceDivisor(): number;
  85609. set instanceDivisor(value: number);
  85610. /**
  85611. * Gets the byte stride.
  85612. */
  85613. readonly byteStride: number;
  85614. /**
  85615. * Gets the byte offset.
  85616. */
  85617. readonly byteOffset: number;
  85618. /**
  85619. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85620. */
  85621. readonly normalized: boolean;
  85622. /**
  85623. * Gets the data type of each component in the array.
  85624. */
  85625. readonly type: number;
  85626. /**
  85627. * Constructor
  85628. * @param engine the engine
  85629. * @param data the data to use for this vertex buffer
  85630. * @param kind the vertex buffer kind
  85631. * @param updatable whether the data is updatable
  85632. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85633. * @param stride the stride (optional)
  85634. * @param instanced whether the buffer is instanced (optional)
  85635. * @param offset the offset of the data (optional)
  85636. * @param size the number of components (optional)
  85637. * @param type the type of the component (optional)
  85638. * @param normalized whether the data contains normalized data (optional)
  85639. * @param useBytes set to true if stride and offset are in bytes (optional)
  85640. * @param divisor defines the instance divisor to use (1 by default)
  85641. */
  85642. 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);
  85643. /** @hidden */
  85644. _rebuild(): void;
  85645. /**
  85646. * Returns the kind of the VertexBuffer (string)
  85647. * @returns a string
  85648. */
  85649. getKind(): string;
  85650. /**
  85651. * Gets a boolean indicating if the VertexBuffer is updatable?
  85652. * @returns true if the buffer is updatable
  85653. */
  85654. isUpdatable(): boolean;
  85655. /**
  85656. * Gets current buffer's data
  85657. * @returns a DataArray or null
  85658. */
  85659. getData(): Nullable<DataArray>;
  85660. /**
  85661. * Gets underlying native buffer
  85662. * @returns underlying native buffer
  85663. */
  85664. getBuffer(): Nullable<DataBuffer>;
  85665. /**
  85666. * Gets the stride in float32 units (i.e. byte stride / 4).
  85667. * May not be an integer if the byte stride is not divisible by 4.
  85668. * @returns the stride in float32 units
  85669. * @deprecated Please use byteStride instead.
  85670. */
  85671. getStrideSize(): number;
  85672. /**
  85673. * Returns the offset as a multiple of the type byte length.
  85674. * @returns the offset in bytes
  85675. * @deprecated Please use byteOffset instead.
  85676. */
  85677. getOffset(): number;
  85678. /**
  85679. * Returns the number of components per vertex attribute (integer)
  85680. * @returns the size in float
  85681. */
  85682. getSize(): number;
  85683. /**
  85684. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85685. * @returns true if this buffer is instanced
  85686. */
  85687. getIsInstanced(): boolean;
  85688. /**
  85689. * Returns the instancing divisor, zero for non-instanced (integer).
  85690. * @returns a number
  85691. */
  85692. getInstanceDivisor(): number;
  85693. /**
  85694. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85695. * @param data defines the data to store
  85696. */
  85697. create(data?: DataArray): void;
  85698. /**
  85699. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85700. * This function will create a new buffer if the current one is not updatable
  85701. * @param data defines the data to store
  85702. */
  85703. update(data: DataArray): void;
  85704. /**
  85705. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85706. * Returns the directly updated WebGLBuffer.
  85707. * @param data the new data
  85708. * @param offset the new offset
  85709. * @param useBytes set to true if the offset is in bytes
  85710. */
  85711. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85712. /**
  85713. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85714. */
  85715. dispose(): void;
  85716. /**
  85717. * Enumerates each value of this vertex buffer as numbers.
  85718. * @param count the number of values to enumerate
  85719. * @param callback the callback function called for each value
  85720. */
  85721. forEach(count: number, callback: (value: number, index: number) => void): void;
  85722. /**
  85723. * Positions
  85724. */
  85725. static readonly PositionKind: string;
  85726. /**
  85727. * Normals
  85728. */
  85729. static readonly NormalKind: string;
  85730. /**
  85731. * Tangents
  85732. */
  85733. static readonly TangentKind: string;
  85734. /**
  85735. * Texture coordinates
  85736. */
  85737. static readonly UVKind: string;
  85738. /**
  85739. * Texture coordinates 2
  85740. */
  85741. static readonly UV2Kind: string;
  85742. /**
  85743. * Texture coordinates 3
  85744. */
  85745. static readonly UV3Kind: string;
  85746. /**
  85747. * Texture coordinates 4
  85748. */
  85749. static readonly UV4Kind: string;
  85750. /**
  85751. * Texture coordinates 5
  85752. */
  85753. static readonly UV5Kind: string;
  85754. /**
  85755. * Texture coordinates 6
  85756. */
  85757. static readonly UV6Kind: string;
  85758. /**
  85759. * Colors
  85760. */
  85761. static readonly ColorKind: string;
  85762. /**
  85763. * Matrix indices (for bones)
  85764. */
  85765. static readonly MatricesIndicesKind: string;
  85766. /**
  85767. * Matrix weights (for bones)
  85768. */
  85769. static readonly MatricesWeightsKind: string;
  85770. /**
  85771. * Additional matrix indices (for bones)
  85772. */
  85773. static readonly MatricesIndicesExtraKind: string;
  85774. /**
  85775. * Additional matrix weights (for bones)
  85776. */
  85777. static readonly MatricesWeightsExtraKind: string;
  85778. /**
  85779. * Deduces the stride given a kind.
  85780. * @param kind The kind string to deduce
  85781. * @returns The deduced stride
  85782. */
  85783. static DeduceStride(kind: string): number;
  85784. /**
  85785. * Gets the byte length of the given type.
  85786. * @param type the type
  85787. * @returns the number of bytes
  85788. */
  85789. static GetTypeByteLength(type: number): number;
  85790. /**
  85791. * Enumerates each value of the given parameters as numbers.
  85792. * @param data the data to enumerate
  85793. * @param byteOffset the byte offset of the data
  85794. * @param byteStride the byte stride of the data
  85795. * @param componentCount the number of components per element
  85796. * @param componentType the type of the component
  85797. * @param count the number of values to enumerate
  85798. * @param normalized whether the data is normalized
  85799. * @param callback the callback function called for each value
  85800. */
  85801. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85802. private static _GetFloatValue;
  85803. }
  85804. }
  85805. declare module BABYLON {
  85806. /**
  85807. * @hidden
  85808. */
  85809. export class IntersectionInfo {
  85810. bu: Nullable<number>;
  85811. bv: Nullable<number>;
  85812. distance: number;
  85813. faceId: number;
  85814. subMeshId: number;
  85815. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85816. }
  85817. }
  85818. declare module BABYLON {
  85819. /**
  85820. * Class used to store bounding sphere information
  85821. */
  85822. export class BoundingSphere {
  85823. /**
  85824. * Gets the center of the bounding sphere in local space
  85825. */
  85826. readonly center: Vector3;
  85827. /**
  85828. * Radius of the bounding sphere in local space
  85829. */
  85830. radius: number;
  85831. /**
  85832. * Gets the center of the bounding sphere in world space
  85833. */
  85834. readonly centerWorld: Vector3;
  85835. /**
  85836. * Radius of the bounding sphere in world space
  85837. */
  85838. radiusWorld: number;
  85839. /**
  85840. * Gets the minimum vector in local space
  85841. */
  85842. readonly minimum: Vector3;
  85843. /**
  85844. * Gets the maximum vector in local space
  85845. */
  85846. readonly maximum: Vector3;
  85847. private _worldMatrix;
  85848. private static readonly TmpVector3;
  85849. /**
  85850. * Creates a new bounding sphere
  85851. * @param min defines the minimum vector (in local space)
  85852. * @param max defines the maximum vector (in local space)
  85853. * @param worldMatrix defines the new world matrix
  85854. */
  85855. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85856. /**
  85857. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85858. * @param min defines the new minimum vector (in local space)
  85859. * @param max defines the new maximum vector (in local space)
  85860. * @param worldMatrix defines the new world matrix
  85861. */
  85862. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85863. /**
  85864. * Scale the current bounding sphere by applying a scale factor
  85865. * @param factor defines the scale factor to apply
  85866. * @returns the current bounding box
  85867. */
  85868. scale(factor: number): BoundingSphere;
  85869. /**
  85870. * Gets the world matrix of the bounding box
  85871. * @returns a matrix
  85872. */
  85873. getWorldMatrix(): DeepImmutable<Matrix>;
  85874. /** @hidden */
  85875. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85876. /**
  85877. * Tests if the bounding sphere is intersecting the frustum planes
  85878. * @param frustumPlanes defines the frustum planes to test
  85879. * @returns true if there is an intersection
  85880. */
  85881. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85882. /**
  85883. * Tests if the bounding sphere center is in between the frustum planes.
  85884. * Used for optimistic fast inclusion.
  85885. * @param frustumPlanes defines the frustum planes to test
  85886. * @returns true if the sphere center is in between the frustum planes
  85887. */
  85888. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85889. /**
  85890. * Tests if a point is inside the bounding sphere
  85891. * @param point defines the point to test
  85892. * @returns true if the point is inside the bounding sphere
  85893. */
  85894. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85895. /**
  85896. * Checks if two sphere intersct
  85897. * @param sphere0 sphere 0
  85898. * @param sphere1 sphere 1
  85899. * @returns true if the speres intersect
  85900. */
  85901. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85902. }
  85903. }
  85904. declare module BABYLON {
  85905. /**
  85906. * Class used to store bounding box information
  85907. */
  85908. export class BoundingBox implements ICullable {
  85909. /**
  85910. * Gets the 8 vectors representing the bounding box in local space
  85911. */
  85912. readonly vectors: Vector3[];
  85913. /**
  85914. * Gets the center of the bounding box in local space
  85915. */
  85916. readonly center: Vector3;
  85917. /**
  85918. * Gets the center of the bounding box in world space
  85919. */
  85920. readonly centerWorld: Vector3;
  85921. /**
  85922. * Gets the extend size in local space
  85923. */
  85924. readonly extendSize: Vector3;
  85925. /**
  85926. * Gets the extend size in world space
  85927. */
  85928. readonly extendSizeWorld: Vector3;
  85929. /**
  85930. * Gets the OBB (object bounding box) directions
  85931. */
  85932. readonly directions: Vector3[];
  85933. /**
  85934. * Gets the 8 vectors representing the bounding box in world space
  85935. */
  85936. readonly vectorsWorld: Vector3[];
  85937. /**
  85938. * Gets the minimum vector in world space
  85939. */
  85940. readonly minimumWorld: Vector3;
  85941. /**
  85942. * Gets the maximum vector in world space
  85943. */
  85944. readonly maximumWorld: Vector3;
  85945. /**
  85946. * Gets the minimum vector in local space
  85947. */
  85948. readonly minimum: Vector3;
  85949. /**
  85950. * Gets the maximum vector in local space
  85951. */
  85952. readonly maximum: Vector3;
  85953. private _worldMatrix;
  85954. private static readonly TmpVector3;
  85955. /**
  85956. * @hidden
  85957. */
  85958. _tag: number;
  85959. /**
  85960. * Creates a new bounding box
  85961. * @param min defines the minimum vector (in local space)
  85962. * @param max defines the maximum vector (in local space)
  85963. * @param worldMatrix defines the new world matrix
  85964. */
  85965. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85966. /**
  85967. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85968. * @param min defines the new minimum vector (in local space)
  85969. * @param max defines the new maximum vector (in local space)
  85970. * @param worldMatrix defines the new world matrix
  85971. */
  85972. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85973. /**
  85974. * Scale the current bounding box by applying a scale factor
  85975. * @param factor defines the scale factor to apply
  85976. * @returns the current bounding box
  85977. */
  85978. scale(factor: number): BoundingBox;
  85979. /**
  85980. * Gets the world matrix of the bounding box
  85981. * @returns a matrix
  85982. */
  85983. getWorldMatrix(): DeepImmutable<Matrix>;
  85984. /** @hidden */
  85985. _update(world: DeepImmutable<Matrix>): void;
  85986. /**
  85987. * Tests if the bounding box is intersecting the frustum planes
  85988. * @param frustumPlanes defines the frustum planes to test
  85989. * @returns true if there is an intersection
  85990. */
  85991. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85992. /**
  85993. * Tests if the bounding box is entirely inside the frustum planes
  85994. * @param frustumPlanes defines the frustum planes to test
  85995. * @returns true if there is an inclusion
  85996. */
  85997. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85998. /**
  85999. * Tests if a point is inside the bounding box
  86000. * @param point defines the point to test
  86001. * @returns true if the point is inside the bounding box
  86002. */
  86003. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86004. /**
  86005. * Tests if the bounding box intersects with a bounding sphere
  86006. * @param sphere defines the sphere to test
  86007. * @returns true if there is an intersection
  86008. */
  86009. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86010. /**
  86011. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86012. * @param min defines the min vector to use
  86013. * @param max defines the max vector to use
  86014. * @returns true if there is an intersection
  86015. */
  86016. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86017. /**
  86018. * Tests if two bounding boxes are intersections
  86019. * @param box0 defines the first box to test
  86020. * @param box1 defines the second box to test
  86021. * @returns true if there is an intersection
  86022. */
  86023. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86024. /**
  86025. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86026. * @param minPoint defines the minimum vector of the bounding box
  86027. * @param maxPoint defines the maximum vector of the bounding box
  86028. * @param sphereCenter defines the sphere center
  86029. * @param sphereRadius defines the sphere radius
  86030. * @returns true if there is an intersection
  86031. */
  86032. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86033. /**
  86034. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86035. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86036. * @param frustumPlanes defines the frustum planes to test
  86037. * @return true if there is an inclusion
  86038. */
  86039. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86040. /**
  86041. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86042. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86043. * @param frustumPlanes defines the frustum planes to test
  86044. * @return true if there is an intersection
  86045. */
  86046. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86047. }
  86048. }
  86049. declare module BABYLON {
  86050. /** @hidden */
  86051. export class Collider {
  86052. /** Define if a collision was found */
  86053. collisionFound: boolean;
  86054. /**
  86055. * Define last intersection point in local space
  86056. */
  86057. intersectionPoint: Vector3;
  86058. /**
  86059. * Define last collided mesh
  86060. */
  86061. collidedMesh: Nullable<AbstractMesh>;
  86062. private _collisionPoint;
  86063. private _planeIntersectionPoint;
  86064. private _tempVector;
  86065. private _tempVector2;
  86066. private _tempVector3;
  86067. private _tempVector4;
  86068. private _edge;
  86069. private _baseToVertex;
  86070. private _destinationPoint;
  86071. private _slidePlaneNormal;
  86072. private _displacementVector;
  86073. /** @hidden */
  86074. _radius: Vector3;
  86075. /** @hidden */
  86076. _retry: number;
  86077. private _velocity;
  86078. private _basePoint;
  86079. private _epsilon;
  86080. /** @hidden */
  86081. _velocityWorldLength: number;
  86082. /** @hidden */
  86083. _basePointWorld: Vector3;
  86084. private _velocityWorld;
  86085. private _normalizedVelocity;
  86086. /** @hidden */
  86087. _initialVelocity: Vector3;
  86088. /** @hidden */
  86089. _initialPosition: Vector3;
  86090. private _nearestDistance;
  86091. private _collisionMask;
  86092. get collisionMask(): number;
  86093. set collisionMask(mask: number);
  86094. /**
  86095. * Gets the plane normal used to compute the sliding response (in local space)
  86096. */
  86097. get slidePlaneNormal(): Vector3;
  86098. /** @hidden */
  86099. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86100. /** @hidden */
  86101. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86102. /** @hidden */
  86103. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86104. /** @hidden */
  86105. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86106. /** @hidden */
  86107. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86108. /** @hidden */
  86109. _getResponse(pos: Vector3, vel: Vector3): void;
  86110. }
  86111. }
  86112. declare module BABYLON {
  86113. /**
  86114. * Interface for cullable objects
  86115. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86116. */
  86117. export interface ICullable {
  86118. /**
  86119. * Checks if the object or part of the object is in the frustum
  86120. * @param frustumPlanes Camera near/planes
  86121. * @returns true if the object is in frustum otherwise false
  86122. */
  86123. isInFrustum(frustumPlanes: Plane[]): boolean;
  86124. /**
  86125. * Checks if a cullable object (mesh...) is in the camera frustum
  86126. * Unlike isInFrustum this cheks the full bounding box
  86127. * @param frustumPlanes Camera near/planes
  86128. * @returns true if the object is in frustum otherwise false
  86129. */
  86130. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86131. }
  86132. /**
  86133. * Info for a bounding data of a mesh
  86134. */
  86135. export class BoundingInfo implements ICullable {
  86136. /**
  86137. * Bounding box for the mesh
  86138. */
  86139. readonly boundingBox: BoundingBox;
  86140. /**
  86141. * Bounding sphere for the mesh
  86142. */
  86143. readonly boundingSphere: BoundingSphere;
  86144. private _isLocked;
  86145. private static readonly TmpVector3;
  86146. /**
  86147. * Constructs bounding info
  86148. * @param minimum min vector of the bounding box/sphere
  86149. * @param maximum max vector of the bounding box/sphere
  86150. * @param worldMatrix defines the new world matrix
  86151. */
  86152. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86153. /**
  86154. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86155. * @param min defines the new minimum vector (in local space)
  86156. * @param max defines the new maximum vector (in local space)
  86157. * @param worldMatrix defines the new world matrix
  86158. */
  86159. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86160. /**
  86161. * min vector of the bounding box/sphere
  86162. */
  86163. get minimum(): Vector3;
  86164. /**
  86165. * max vector of the bounding box/sphere
  86166. */
  86167. get maximum(): Vector3;
  86168. /**
  86169. * If the info is locked and won't be updated to avoid perf overhead
  86170. */
  86171. get isLocked(): boolean;
  86172. set isLocked(value: boolean);
  86173. /**
  86174. * Updates the bounding sphere and box
  86175. * @param world world matrix to be used to update
  86176. */
  86177. update(world: DeepImmutable<Matrix>): void;
  86178. /**
  86179. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86180. * @param center New center of the bounding info
  86181. * @param extend New extend of the bounding info
  86182. * @returns the current bounding info
  86183. */
  86184. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86185. /**
  86186. * Scale the current bounding info by applying a scale factor
  86187. * @param factor defines the scale factor to apply
  86188. * @returns the current bounding info
  86189. */
  86190. scale(factor: number): BoundingInfo;
  86191. /**
  86192. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86193. * @param frustumPlanes defines the frustum to test
  86194. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86195. * @returns true if the bounding info is in the frustum planes
  86196. */
  86197. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86198. /**
  86199. * Gets the world distance between the min and max points of the bounding box
  86200. */
  86201. get diagonalLength(): number;
  86202. /**
  86203. * Checks if a cullable object (mesh...) is in the camera frustum
  86204. * Unlike isInFrustum this cheks the full bounding box
  86205. * @param frustumPlanes Camera near/planes
  86206. * @returns true if the object is in frustum otherwise false
  86207. */
  86208. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86209. /** @hidden */
  86210. _checkCollision(collider: Collider): boolean;
  86211. /**
  86212. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86213. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86214. * @param point the point to check intersection with
  86215. * @returns if the point intersects
  86216. */
  86217. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86218. /**
  86219. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86221. * @param boundingInfo the bounding info to check intersection with
  86222. * @param precise if the intersection should be done using OBB
  86223. * @returns if the bounding info intersects
  86224. */
  86225. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86226. }
  86227. }
  86228. declare module BABYLON {
  86229. /**
  86230. * Extracts minimum and maximum values from a list of indexed positions
  86231. * @param positions defines the positions to use
  86232. * @param indices defines the indices to the positions
  86233. * @param indexStart defines the start index
  86234. * @param indexCount defines the end index
  86235. * @param bias defines bias value to add to the result
  86236. * @return minimum and maximum values
  86237. */
  86238. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86239. minimum: Vector3;
  86240. maximum: Vector3;
  86241. };
  86242. /**
  86243. * Extracts minimum and maximum values from a list of positions
  86244. * @param positions defines the positions to use
  86245. * @param start defines the start index in the positions array
  86246. * @param count defines the number of positions to handle
  86247. * @param bias defines bias value to add to the result
  86248. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86249. * @return minimum and maximum values
  86250. */
  86251. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86252. minimum: Vector3;
  86253. maximum: Vector3;
  86254. };
  86255. }
  86256. declare module BABYLON {
  86257. /** @hidden */
  86258. export class WebGLDataBuffer extends DataBuffer {
  86259. private _buffer;
  86260. constructor(resource: WebGLBuffer);
  86261. get underlyingResource(): any;
  86262. }
  86263. }
  86264. declare module BABYLON {
  86265. /** @hidden */
  86266. export class WebGLPipelineContext implements IPipelineContext {
  86267. engine: ThinEngine;
  86268. program: Nullable<WebGLProgram>;
  86269. context?: WebGLRenderingContext;
  86270. vertexShader?: WebGLShader;
  86271. fragmentShader?: WebGLShader;
  86272. isParallelCompiled: boolean;
  86273. onCompiled?: () => void;
  86274. transformFeedback?: WebGLTransformFeedback | null;
  86275. vertexCompilationError: Nullable<string>;
  86276. fragmentCompilationError: Nullable<string>;
  86277. programLinkError: Nullable<string>;
  86278. programValidationError: Nullable<string>;
  86279. get isAsync(): boolean;
  86280. get isReady(): boolean;
  86281. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86282. _getVertexShaderCode(): string | null;
  86283. _getFragmentShaderCode(): string | null;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. interface ThinEngine {
  86288. /**
  86289. * Create an uniform buffer
  86290. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86291. * @param elements defines the content of the uniform buffer
  86292. * @returns the webGL uniform buffer
  86293. */
  86294. createUniformBuffer(elements: FloatArray): DataBuffer;
  86295. /**
  86296. * Create a dynamic uniform buffer
  86297. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86298. * @param elements defines the content of the uniform buffer
  86299. * @returns the webGL uniform buffer
  86300. */
  86301. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86302. /**
  86303. * Update an existing uniform buffer
  86304. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86305. * @param uniformBuffer defines the target uniform buffer
  86306. * @param elements defines the content to update
  86307. * @param offset defines the offset in the uniform buffer where update should start
  86308. * @param count defines the size of the data to update
  86309. */
  86310. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86311. /**
  86312. * Bind an uniform buffer to the current webGL context
  86313. * @param buffer defines the buffer to bind
  86314. */
  86315. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86316. /**
  86317. * Bind a buffer to the current webGL context at a given location
  86318. * @param buffer defines the buffer to bind
  86319. * @param location defines the index where to bind the buffer
  86320. */
  86321. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86322. /**
  86323. * Bind a specific block at a given index in a specific shader program
  86324. * @param pipelineContext defines the pipeline context to use
  86325. * @param blockName defines the block name
  86326. * @param index defines the index where to bind the block
  86327. */
  86328. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86329. }
  86330. }
  86331. declare module BABYLON {
  86332. /**
  86333. * Uniform buffer objects.
  86334. *
  86335. * Handles blocks of uniform on the GPU.
  86336. *
  86337. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86338. *
  86339. * For more information, please refer to :
  86340. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86341. */
  86342. export class UniformBuffer {
  86343. private _engine;
  86344. private _buffer;
  86345. private _data;
  86346. private _bufferData;
  86347. private _dynamic?;
  86348. private _uniformLocations;
  86349. private _uniformSizes;
  86350. private _uniformLocationPointer;
  86351. private _needSync;
  86352. private _noUBO;
  86353. private _currentEffect;
  86354. /** @hidden */
  86355. _alreadyBound: boolean;
  86356. private static _MAX_UNIFORM_SIZE;
  86357. private static _tempBuffer;
  86358. /**
  86359. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86360. * This is dynamic to allow compat with webgl 1 and 2.
  86361. * You will need to pass the name of the uniform as well as the value.
  86362. */
  86363. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86364. /**
  86365. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86366. * This is dynamic to allow compat with webgl 1 and 2.
  86367. * You will need to pass the name of the uniform as well as the value.
  86368. */
  86369. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86370. /**
  86371. * Lambda to Update a single float in a uniform buffer.
  86372. * This is dynamic to allow compat with webgl 1 and 2.
  86373. * You will need to pass the name of the uniform as well as the value.
  86374. */
  86375. updateFloat: (name: string, x: number) => void;
  86376. /**
  86377. * Lambda to Update a vec2 of float in a uniform buffer.
  86378. * This is dynamic to allow compat with webgl 1 and 2.
  86379. * You will need to pass the name of the uniform as well as the value.
  86380. */
  86381. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86382. /**
  86383. * Lambda to Update a vec3 of float in a uniform buffer.
  86384. * This is dynamic to allow compat with webgl 1 and 2.
  86385. * You will need to pass the name of the uniform as well as the value.
  86386. */
  86387. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86388. /**
  86389. * Lambda to Update a vec4 of float in a uniform buffer.
  86390. * This is dynamic to allow compat with webgl 1 and 2.
  86391. * You will need to pass the name of the uniform as well as the value.
  86392. */
  86393. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86394. /**
  86395. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86396. * This is dynamic to allow compat with webgl 1 and 2.
  86397. * You will need to pass the name of the uniform as well as the value.
  86398. */
  86399. updateMatrix: (name: string, mat: Matrix) => void;
  86400. /**
  86401. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86402. * This is dynamic to allow compat with webgl 1 and 2.
  86403. * You will need to pass the name of the uniform as well as the value.
  86404. */
  86405. updateVector3: (name: string, vector: Vector3) => void;
  86406. /**
  86407. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86408. * This is dynamic to allow compat with webgl 1 and 2.
  86409. * You will need to pass the name of the uniform as well as the value.
  86410. */
  86411. updateVector4: (name: string, vector: Vector4) => void;
  86412. /**
  86413. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86414. * This is dynamic to allow compat with webgl 1 and 2.
  86415. * You will need to pass the name of the uniform as well as the value.
  86416. */
  86417. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86418. /**
  86419. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86420. * This is dynamic to allow compat with webgl 1 and 2.
  86421. * You will need to pass the name of the uniform as well as the value.
  86422. */
  86423. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86424. /**
  86425. * Instantiates a new Uniform buffer objects.
  86426. *
  86427. * Handles blocks of uniform on the GPU.
  86428. *
  86429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86430. *
  86431. * For more information, please refer to :
  86432. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86433. * @param engine Define the engine the buffer is associated with
  86434. * @param data Define the data contained in the buffer
  86435. * @param dynamic Define if the buffer is updatable
  86436. */
  86437. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86438. /**
  86439. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86440. * or just falling back on setUniformXXX calls.
  86441. */
  86442. get useUbo(): boolean;
  86443. /**
  86444. * Indicates if the WebGL underlying uniform buffer is in sync
  86445. * with the javascript cache data.
  86446. */
  86447. get isSync(): boolean;
  86448. /**
  86449. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86450. * Also, a dynamic UniformBuffer will disable cache verification and always
  86451. * update the underlying WebGL uniform buffer to the GPU.
  86452. * @returns if Dynamic, otherwise false
  86453. */
  86454. isDynamic(): boolean;
  86455. /**
  86456. * The data cache on JS side.
  86457. * @returns the underlying data as a float array
  86458. */
  86459. getData(): Float32Array;
  86460. /**
  86461. * The underlying WebGL Uniform buffer.
  86462. * @returns the webgl buffer
  86463. */
  86464. getBuffer(): Nullable<DataBuffer>;
  86465. /**
  86466. * std140 layout specifies how to align data within an UBO structure.
  86467. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86468. * for specs.
  86469. */
  86470. private _fillAlignment;
  86471. /**
  86472. * Adds an uniform in the buffer.
  86473. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86474. * for the layout to be correct !
  86475. * @param name Name of the uniform, as used in the uniform block in the shader.
  86476. * @param size Data size, or data directly.
  86477. */
  86478. addUniform(name: string, size: number | number[]): void;
  86479. /**
  86480. * Adds a Matrix 4x4 to the uniform buffer.
  86481. * @param name Name of the uniform, as used in the uniform block in the shader.
  86482. * @param mat A 4x4 matrix.
  86483. */
  86484. addMatrix(name: string, mat: Matrix): void;
  86485. /**
  86486. * Adds a vec2 to the uniform buffer.
  86487. * @param name Name of the uniform, as used in the uniform block in the shader.
  86488. * @param x Define the x component value of the vec2
  86489. * @param y Define the y component value of the vec2
  86490. */
  86491. addFloat2(name: string, x: number, y: number): void;
  86492. /**
  86493. * Adds a vec3 to the uniform buffer.
  86494. * @param name Name of the uniform, as used in the uniform block in the shader.
  86495. * @param x Define the x component value of the vec3
  86496. * @param y Define the y component value of the vec3
  86497. * @param z Define the z component value of the vec3
  86498. */
  86499. addFloat3(name: string, x: number, y: number, z: number): void;
  86500. /**
  86501. * Adds a vec3 to the uniform buffer.
  86502. * @param name Name of the uniform, as used in the uniform block in the shader.
  86503. * @param color Define the vec3 from a Color
  86504. */
  86505. addColor3(name: string, color: Color3): void;
  86506. /**
  86507. * Adds a vec4 to the uniform buffer.
  86508. * @param name Name of the uniform, as used in the uniform block in the shader.
  86509. * @param color Define the rgb components from a Color
  86510. * @param alpha Define the a component of the vec4
  86511. */
  86512. addColor4(name: string, color: Color3, alpha: number): void;
  86513. /**
  86514. * Adds a vec3 to the uniform buffer.
  86515. * @param name Name of the uniform, as used in the uniform block in the shader.
  86516. * @param vector Define the vec3 components from a Vector
  86517. */
  86518. addVector3(name: string, vector: Vector3): void;
  86519. /**
  86520. * Adds a Matrix 3x3 to the uniform buffer.
  86521. * @param name Name of the uniform, as used in the uniform block in the shader.
  86522. */
  86523. addMatrix3x3(name: string): void;
  86524. /**
  86525. * Adds a Matrix 2x2 to the uniform buffer.
  86526. * @param name Name of the uniform, as used in the uniform block in the shader.
  86527. */
  86528. addMatrix2x2(name: string): void;
  86529. /**
  86530. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86531. */
  86532. create(): void;
  86533. /** @hidden */
  86534. _rebuild(): void;
  86535. /**
  86536. * Updates the WebGL Uniform Buffer on the GPU.
  86537. * If the `dynamic` flag is set to true, no cache comparison is done.
  86538. * Otherwise, the buffer will be updated only if the cache differs.
  86539. */
  86540. update(): void;
  86541. /**
  86542. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86543. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86544. * @param data Define the flattened data
  86545. * @param size Define the size of the data.
  86546. */
  86547. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86548. private _valueCache;
  86549. private _cacheMatrix;
  86550. private _updateMatrix3x3ForUniform;
  86551. private _updateMatrix3x3ForEffect;
  86552. private _updateMatrix2x2ForEffect;
  86553. private _updateMatrix2x2ForUniform;
  86554. private _updateFloatForEffect;
  86555. private _updateFloatForUniform;
  86556. private _updateFloat2ForEffect;
  86557. private _updateFloat2ForUniform;
  86558. private _updateFloat3ForEffect;
  86559. private _updateFloat3ForUniform;
  86560. private _updateFloat4ForEffect;
  86561. private _updateFloat4ForUniform;
  86562. private _updateMatrixForEffect;
  86563. private _updateMatrixForUniform;
  86564. private _updateVector3ForEffect;
  86565. private _updateVector3ForUniform;
  86566. private _updateVector4ForEffect;
  86567. private _updateVector4ForUniform;
  86568. private _updateColor3ForEffect;
  86569. private _updateColor3ForUniform;
  86570. private _updateColor4ForEffect;
  86571. private _updateColor4ForUniform;
  86572. /**
  86573. * Sets a sampler uniform on the effect.
  86574. * @param name Define the name of the sampler.
  86575. * @param texture Define the texture to set in the sampler
  86576. */
  86577. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86578. /**
  86579. * Directly updates the value of the uniform in the cache AND on the GPU.
  86580. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86581. * @param data Define the flattened data
  86582. */
  86583. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86584. /**
  86585. * Binds this uniform buffer to an effect.
  86586. * @param effect Define the effect to bind the buffer to
  86587. * @param name Name of the uniform block in the shader.
  86588. */
  86589. bindToEffect(effect: Effect, name: string): void;
  86590. /**
  86591. * Disposes the uniform buffer.
  86592. */
  86593. dispose(): void;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * Enum that determines the text-wrapping mode to use.
  86599. */
  86600. export enum InspectableType {
  86601. /**
  86602. * Checkbox for booleans
  86603. */
  86604. Checkbox = 0,
  86605. /**
  86606. * Sliders for numbers
  86607. */
  86608. Slider = 1,
  86609. /**
  86610. * Vector3
  86611. */
  86612. Vector3 = 2,
  86613. /**
  86614. * Quaternions
  86615. */
  86616. Quaternion = 3,
  86617. /**
  86618. * Color3
  86619. */
  86620. Color3 = 4,
  86621. /**
  86622. * String
  86623. */
  86624. String = 5
  86625. }
  86626. /**
  86627. * Interface used to define custom inspectable properties.
  86628. * This interface is used by the inspector to display custom property grids
  86629. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86630. */
  86631. export interface IInspectable {
  86632. /**
  86633. * Gets the label to display
  86634. */
  86635. label: string;
  86636. /**
  86637. * Gets the name of the property to edit
  86638. */
  86639. propertyName: string;
  86640. /**
  86641. * Gets the type of the editor to use
  86642. */
  86643. type: InspectableType;
  86644. /**
  86645. * Gets the minimum value of the property when using in "slider" mode
  86646. */
  86647. min?: number;
  86648. /**
  86649. * Gets the maximum value of the property when using in "slider" mode
  86650. */
  86651. max?: number;
  86652. /**
  86653. * Gets the setp to use when using in "slider" mode
  86654. */
  86655. step?: number;
  86656. }
  86657. }
  86658. declare module BABYLON {
  86659. /**
  86660. * Class used to provide helper for timing
  86661. */
  86662. export class TimingTools {
  86663. /**
  86664. * Polyfill for setImmediate
  86665. * @param action defines the action to execute after the current execution block
  86666. */
  86667. static SetImmediate(action: () => void): void;
  86668. }
  86669. }
  86670. declare module BABYLON {
  86671. /**
  86672. * Class used to enable instatition of objects by class name
  86673. */
  86674. export class InstantiationTools {
  86675. /**
  86676. * Use this object to register external classes like custom textures or material
  86677. * to allow the laoders to instantiate them
  86678. */
  86679. static RegisteredExternalClasses: {
  86680. [key: string]: Object;
  86681. };
  86682. /**
  86683. * Tries to instantiate a new object from a given class name
  86684. * @param className defines the class name to instantiate
  86685. * @returns the new object or null if the system was not able to do the instantiation
  86686. */
  86687. static Instantiate(className: string): any;
  86688. }
  86689. }
  86690. declare module BABYLON {
  86691. /**
  86692. * Define options used to create a depth texture
  86693. */
  86694. export class DepthTextureCreationOptions {
  86695. /** Specifies whether or not a stencil should be allocated in the texture */
  86696. generateStencil?: boolean;
  86697. /** Specifies whether or not bilinear filtering is enable on the texture */
  86698. bilinearFiltering?: boolean;
  86699. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86700. comparisonFunction?: number;
  86701. /** Specifies if the created texture is a cube texture */
  86702. isCube?: boolean;
  86703. }
  86704. }
  86705. declare module BABYLON {
  86706. interface ThinEngine {
  86707. /**
  86708. * Creates a depth stencil cube texture.
  86709. * This is only available in WebGL 2.
  86710. * @param size The size of face edge in the cube texture.
  86711. * @param options The options defining the cube texture.
  86712. * @returns The cube texture
  86713. */
  86714. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86715. /**
  86716. * Creates a cube texture
  86717. * @param rootUrl defines the url where the files to load is located
  86718. * @param scene defines the current scene
  86719. * @param files defines the list of files to load (1 per face)
  86720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86721. * @param onLoad defines an optional callback raised when the texture is loaded
  86722. * @param onError defines an optional callback raised if there is an issue to load the texture
  86723. * @param format defines the format of the data
  86724. * @param forcedExtension defines the extension to use to pick the right loader
  86725. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86726. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86727. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86728. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86729. * @returns the cube texture as an InternalTexture
  86730. */
  86731. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  86732. /**
  86733. * Creates a cube texture
  86734. * @param rootUrl defines the url where the files to load is located
  86735. * @param scene defines the current scene
  86736. * @param files defines the list of files to load (1 per face)
  86737. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86738. * @param onLoad defines an optional callback raised when the texture is loaded
  86739. * @param onError defines an optional callback raised if there is an issue to load the texture
  86740. * @param format defines the format of the data
  86741. * @param forcedExtension defines the extension to use to pick the right loader
  86742. * @returns the cube texture as an InternalTexture
  86743. */
  86744. 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;
  86745. /**
  86746. * Creates a cube texture
  86747. * @param rootUrl defines the url where the files to load is located
  86748. * @param scene defines the current scene
  86749. * @param files defines the list of files to load (1 per face)
  86750. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86751. * @param onLoad defines an optional callback raised when the texture is loaded
  86752. * @param onError defines an optional callback raised if there is an issue to load the texture
  86753. * @param format defines the format of the data
  86754. * @param forcedExtension defines the extension to use to pick the right loader
  86755. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86758. * @returns the cube texture as an InternalTexture
  86759. */
  86760. 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;
  86761. /** @hidden */
  86762. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86763. /** @hidden */
  86764. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86765. /** @hidden */
  86766. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86767. /** @hidden */
  86768. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86769. /**
  86770. * @hidden
  86771. */
  86772. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86773. }
  86774. }
  86775. declare module BABYLON {
  86776. /**
  86777. * Class for creating a cube texture
  86778. */
  86779. export class CubeTexture extends BaseTexture {
  86780. private _delayedOnLoad;
  86781. /**
  86782. * Observable triggered once the texture has been loaded.
  86783. */
  86784. onLoadObservable: Observable<CubeTexture>;
  86785. /**
  86786. * The url of the texture
  86787. */
  86788. url: string;
  86789. /**
  86790. * Gets or sets the center of the bounding box associated with the cube texture.
  86791. * It must define where the camera used to render the texture was set
  86792. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86793. */
  86794. boundingBoxPosition: Vector3;
  86795. private _boundingBoxSize;
  86796. /**
  86797. * Gets or sets the size of the bounding box associated with the cube texture
  86798. * When defined, the cubemap will switch to local mode
  86799. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86800. * @example https://www.babylonjs-playground.com/#RNASML
  86801. */
  86802. set boundingBoxSize(value: Vector3);
  86803. /**
  86804. * Returns the bounding box size
  86805. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86806. */
  86807. get boundingBoxSize(): Vector3;
  86808. protected _rotationY: number;
  86809. /**
  86810. * Sets texture matrix rotation angle around Y axis in radians.
  86811. */
  86812. set rotationY(value: number);
  86813. /**
  86814. * Gets texture matrix rotation angle around Y axis radians.
  86815. */
  86816. get rotationY(): number;
  86817. /**
  86818. * Are mip maps generated for this texture or not.
  86819. */
  86820. get noMipmap(): boolean;
  86821. private _noMipmap;
  86822. private _files;
  86823. protected _forcedExtension: Nullable<string>;
  86824. private _extensions;
  86825. private _textureMatrix;
  86826. private _format;
  86827. private _createPolynomials;
  86828. /**
  86829. * Creates a cube texture from an array of image urls
  86830. * @param files defines an array of image urls
  86831. * @param scene defines the hosting scene
  86832. * @param noMipmap specifies if mip maps are not used
  86833. * @returns a cube texture
  86834. */
  86835. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86836. /**
  86837. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86838. * @param url defines the url of the prefiltered texture
  86839. * @param scene defines the scene the texture is attached to
  86840. * @param forcedExtension defines the extension of the file if different from the url
  86841. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86842. * @return the prefiltered texture
  86843. */
  86844. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86845. /**
  86846. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86847. * as prefiltered data.
  86848. * @param rootUrl defines the url of the texture or the root name of the six images
  86849. * @param null defines the scene or engine the texture is attached to
  86850. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86851. * @param noMipmap defines if mipmaps should be created or not
  86852. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86853. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86854. * @param onError defines a callback triggered in case of error during load
  86855. * @param format defines the internal format to use for the texture once loaded
  86856. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86857. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86858. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86859. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86860. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86861. * @return the cube texture
  86862. */
  86863. 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);
  86864. /**
  86865. * Get the current class name of the texture useful for serialization or dynamic coding.
  86866. * @returns "CubeTexture"
  86867. */
  86868. getClassName(): string;
  86869. /**
  86870. * Update the url (and optional buffer) of this texture if url was null during construction.
  86871. * @param url the url of the texture
  86872. * @param forcedExtension defines the extension to use
  86873. * @param onLoad callback called when the texture is loaded (defaults to null)
  86874. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86875. */
  86876. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86877. /**
  86878. * Delays loading of the cube texture
  86879. * @param forcedExtension defines the extension to use
  86880. */
  86881. delayLoad(forcedExtension?: string): void;
  86882. /**
  86883. * Returns the reflection texture matrix
  86884. * @returns the reflection texture matrix
  86885. */
  86886. getReflectionTextureMatrix(): Matrix;
  86887. /**
  86888. * Sets the reflection texture matrix
  86889. * @param value Reflection texture matrix
  86890. */
  86891. setReflectionTextureMatrix(value: Matrix): void;
  86892. /**
  86893. * Parses text to create a cube texture
  86894. * @param parsedTexture define the serialized text to read from
  86895. * @param scene defines the hosting scene
  86896. * @param rootUrl defines the root url of the cube texture
  86897. * @returns a cube texture
  86898. */
  86899. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86900. /**
  86901. * Makes a clone, or deep copy, of the cube texture
  86902. * @returns a new cube texture
  86903. */
  86904. clone(): CubeTexture;
  86905. }
  86906. }
  86907. declare module BABYLON {
  86908. /**
  86909. * Manages the defines for the Material
  86910. */
  86911. export class MaterialDefines {
  86912. /** @hidden */
  86913. protected _keys: string[];
  86914. private _isDirty;
  86915. /** @hidden */
  86916. _renderId: number;
  86917. /** @hidden */
  86918. _areLightsDirty: boolean;
  86919. /** @hidden */
  86920. _areLightsDisposed: boolean;
  86921. /** @hidden */
  86922. _areAttributesDirty: boolean;
  86923. /** @hidden */
  86924. _areTexturesDirty: boolean;
  86925. /** @hidden */
  86926. _areFresnelDirty: boolean;
  86927. /** @hidden */
  86928. _areMiscDirty: boolean;
  86929. /** @hidden */
  86930. _areImageProcessingDirty: boolean;
  86931. /** @hidden */
  86932. _normals: boolean;
  86933. /** @hidden */
  86934. _uvs: boolean;
  86935. /** @hidden */
  86936. _needNormals: boolean;
  86937. /** @hidden */
  86938. _needUVs: boolean;
  86939. [id: string]: any;
  86940. /**
  86941. * Specifies if the material needs to be re-calculated
  86942. */
  86943. get isDirty(): boolean;
  86944. /**
  86945. * Marks the material to indicate that it has been re-calculated
  86946. */
  86947. markAsProcessed(): void;
  86948. /**
  86949. * Marks the material to indicate that it needs to be re-calculated
  86950. */
  86951. markAsUnprocessed(): void;
  86952. /**
  86953. * Marks the material to indicate all of its defines need to be re-calculated
  86954. */
  86955. markAllAsDirty(): void;
  86956. /**
  86957. * Marks the material to indicate that image processing needs to be re-calculated
  86958. */
  86959. markAsImageProcessingDirty(): void;
  86960. /**
  86961. * Marks the material to indicate the lights need to be re-calculated
  86962. * @param disposed Defines whether the light is dirty due to dispose or not
  86963. */
  86964. markAsLightDirty(disposed?: boolean): void;
  86965. /**
  86966. * Marks the attribute state as changed
  86967. */
  86968. markAsAttributesDirty(): void;
  86969. /**
  86970. * Marks the texture state as changed
  86971. */
  86972. markAsTexturesDirty(): void;
  86973. /**
  86974. * Marks the fresnel state as changed
  86975. */
  86976. markAsFresnelDirty(): void;
  86977. /**
  86978. * Marks the misc state as changed
  86979. */
  86980. markAsMiscDirty(): void;
  86981. /**
  86982. * Rebuilds the material defines
  86983. */
  86984. rebuild(): void;
  86985. /**
  86986. * Specifies if two material defines are equal
  86987. * @param other - A material define instance to compare to
  86988. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86989. */
  86990. isEqual(other: MaterialDefines): boolean;
  86991. /**
  86992. * Clones this instance's defines to another instance
  86993. * @param other - material defines to clone values to
  86994. */
  86995. cloneTo(other: MaterialDefines): void;
  86996. /**
  86997. * Resets the material define values
  86998. */
  86999. reset(): void;
  87000. /**
  87001. * Converts the material define values to a string
  87002. * @returns - String of material define information
  87003. */
  87004. toString(): string;
  87005. }
  87006. }
  87007. declare module BABYLON {
  87008. /**
  87009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87011. * 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;
  87012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87013. */
  87014. export class ColorCurves {
  87015. private _dirty;
  87016. private _tempColor;
  87017. private _globalCurve;
  87018. private _highlightsCurve;
  87019. private _midtonesCurve;
  87020. private _shadowsCurve;
  87021. private _positiveCurve;
  87022. private _negativeCurve;
  87023. private _globalHue;
  87024. private _globalDensity;
  87025. private _globalSaturation;
  87026. private _globalExposure;
  87027. /**
  87028. * Gets the global Hue value.
  87029. * 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).
  87030. */
  87031. get globalHue(): number;
  87032. /**
  87033. * Sets the global Hue value.
  87034. * 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).
  87035. */
  87036. set globalHue(value: number);
  87037. /**
  87038. * Gets the global Density value.
  87039. * 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.
  87040. * Values less than zero provide a filter of opposite hue.
  87041. */
  87042. get globalDensity(): number;
  87043. /**
  87044. * Sets the global Density value.
  87045. * 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.
  87046. * Values less than zero provide a filter of opposite hue.
  87047. */
  87048. set globalDensity(value: number);
  87049. /**
  87050. * Gets the global Saturation value.
  87051. * 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.
  87052. */
  87053. get globalSaturation(): number;
  87054. /**
  87055. * Sets the global Saturation value.
  87056. * 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.
  87057. */
  87058. set globalSaturation(value: number);
  87059. /**
  87060. * Gets the global Exposure value.
  87061. * 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.
  87062. */
  87063. get globalExposure(): number;
  87064. /**
  87065. * Sets the global Exposure value.
  87066. * 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.
  87067. */
  87068. set globalExposure(value: number);
  87069. private _highlightsHue;
  87070. private _highlightsDensity;
  87071. private _highlightsSaturation;
  87072. private _highlightsExposure;
  87073. /**
  87074. * Gets the highlights Hue value.
  87075. * 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).
  87076. */
  87077. get highlightsHue(): number;
  87078. /**
  87079. * Sets the highlights Hue value.
  87080. * 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).
  87081. */
  87082. set highlightsHue(value: number);
  87083. /**
  87084. * Gets the highlights Density value.
  87085. * 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.
  87086. * Values less than zero provide a filter of opposite hue.
  87087. */
  87088. get highlightsDensity(): number;
  87089. /**
  87090. * Sets the highlights Density value.
  87091. * 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.
  87092. * Values less than zero provide a filter of opposite hue.
  87093. */
  87094. set highlightsDensity(value: number);
  87095. /**
  87096. * Gets the highlights Saturation value.
  87097. * 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.
  87098. */
  87099. get highlightsSaturation(): number;
  87100. /**
  87101. * Sets the highlights Saturation value.
  87102. * 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.
  87103. */
  87104. set highlightsSaturation(value: number);
  87105. /**
  87106. * Gets the highlights Exposure value.
  87107. * 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.
  87108. */
  87109. get highlightsExposure(): number;
  87110. /**
  87111. * Sets the highlights Exposure value.
  87112. * 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.
  87113. */
  87114. set highlightsExposure(value: number);
  87115. private _midtonesHue;
  87116. private _midtonesDensity;
  87117. private _midtonesSaturation;
  87118. private _midtonesExposure;
  87119. /**
  87120. * Gets the midtones Hue value.
  87121. * 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).
  87122. */
  87123. get midtonesHue(): number;
  87124. /**
  87125. * Sets the midtones Hue value.
  87126. * 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).
  87127. */
  87128. set midtonesHue(value: number);
  87129. /**
  87130. * Gets the midtones Density value.
  87131. * 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.
  87132. * Values less than zero provide a filter of opposite hue.
  87133. */
  87134. get midtonesDensity(): number;
  87135. /**
  87136. * Sets the midtones Density value.
  87137. * 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.
  87138. * Values less than zero provide a filter of opposite hue.
  87139. */
  87140. set midtonesDensity(value: number);
  87141. /**
  87142. * Gets the midtones Saturation value.
  87143. * 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.
  87144. */
  87145. get midtonesSaturation(): number;
  87146. /**
  87147. * Sets the midtones Saturation value.
  87148. * 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.
  87149. */
  87150. set midtonesSaturation(value: number);
  87151. /**
  87152. * Gets the midtones Exposure value.
  87153. * 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.
  87154. */
  87155. get midtonesExposure(): number;
  87156. /**
  87157. * Sets the midtones Exposure value.
  87158. * 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.
  87159. */
  87160. set midtonesExposure(value: number);
  87161. private _shadowsHue;
  87162. private _shadowsDensity;
  87163. private _shadowsSaturation;
  87164. private _shadowsExposure;
  87165. /**
  87166. * Gets the shadows Hue value.
  87167. * 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).
  87168. */
  87169. get shadowsHue(): number;
  87170. /**
  87171. * Sets the shadows Hue value.
  87172. * 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).
  87173. */
  87174. set shadowsHue(value: number);
  87175. /**
  87176. * Gets the shadows Density value.
  87177. * 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.
  87178. * Values less than zero provide a filter of opposite hue.
  87179. */
  87180. get shadowsDensity(): number;
  87181. /**
  87182. * Sets the shadows Density value.
  87183. * 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.
  87184. * Values less than zero provide a filter of opposite hue.
  87185. */
  87186. set shadowsDensity(value: number);
  87187. /**
  87188. * Gets the shadows Saturation value.
  87189. * 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.
  87190. */
  87191. get shadowsSaturation(): number;
  87192. /**
  87193. * Sets the shadows Saturation value.
  87194. * 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.
  87195. */
  87196. set shadowsSaturation(value: number);
  87197. /**
  87198. * Gets the shadows Exposure value.
  87199. * 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.
  87200. */
  87201. get shadowsExposure(): number;
  87202. /**
  87203. * Sets the shadows Exposure value.
  87204. * 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.
  87205. */
  87206. set shadowsExposure(value: number);
  87207. /**
  87208. * Returns the class name
  87209. * @returns The class name
  87210. */
  87211. getClassName(): string;
  87212. /**
  87213. * Binds the color curves to the shader.
  87214. * @param colorCurves The color curve to bind
  87215. * @param effect The effect to bind to
  87216. * @param positiveUniform The positive uniform shader parameter
  87217. * @param neutralUniform The neutral uniform shader parameter
  87218. * @param negativeUniform The negative uniform shader parameter
  87219. */
  87220. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87221. /**
  87222. * Prepare the list of uniforms associated with the ColorCurves effects.
  87223. * @param uniformsList The list of uniforms used in the effect
  87224. */
  87225. static PrepareUniforms(uniformsList: string[]): void;
  87226. /**
  87227. * Returns color grading data based on a hue, density, saturation and exposure value.
  87228. * @param filterHue The hue of the color filter.
  87229. * @param filterDensity The density of the color filter.
  87230. * @param saturation The saturation.
  87231. * @param exposure The exposure.
  87232. * @param result The result data container.
  87233. */
  87234. private getColorGradingDataToRef;
  87235. /**
  87236. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87237. * @param value The input slider value in range [-100,100].
  87238. * @returns Adjusted value.
  87239. */
  87240. private static applyColorGradingSliderNonlinear;
  87241. /**
  87242. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87243. * @param hue The hue (H) input.
  87244. * @param saturation The saturation (S) input.
  87245. * @param brightness The brightness (B) input.
  87246. * @result An RGBA color represented as Vector4.
  87247. */
  87248. private static fromHSBToRef;
  87249. /**
  87250. * Returns a value clamped between min and max
  87251. * @param value The value to clamp
  87252. * @param min The minimum of value
  87253. * @param max The maximum of value
  87254. * @returns The clamped value.
  87255. */
  87256. private static clamp;
  87257. /**
  87258. * Clones the current color curve instance.
  87259. * @return The cloned curves
  87260. */
  87261. clone(): ColorCurves;
  87262. /**
  87263. * Serializes the current color curve instance to a json representation.
  87264. * @return a JSON representation
  87265. */
  87266. serialize(): any;
  87267. /**
  87268. * Parses the color curve from a json representation.
  87269. * @param source the JSON source to parse
  87270. * @return The parsed curves
  87271. */
  87272. static Parse(source: any): ColorCurves;
  87273. }
  87274. }
  87275. declare module BABYLON {
  87276. /**
  87277. * Interface to follow in your material defines to integrate easily the
  87278. * Image proccessing functions.
  87279. * @hidden
  87280. */
  87281. export interface IImageProcessingConfigurationDefines {
  87282. IMAGEPROCESSING: boolean;
  87283. VIGNETTE: boolean;
  87284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87285. VIGNETTEBLENDMODEOPAQUE: boolean;
  87286. TONEMAPPING: boolean;
  87287. TONEMAPPING_ACES: boolean;
  87288. CONTRAST: boolean;
  87289. EXPOSURE: boolean;
  87290. COLORCURVES: boolean;
  87291. COLORGRADING: boolean;
  87292. COLORGRADING3D: boolean;
  87293. SAMPLER3DGREENDEPTH: boolean;
  87294. SAMPLER3DBGRMAP: boolean;
  87295. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87296. }
  87297. /**
  87298. * @hidden
  87299. */
  87300. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87301. IMAGEPROCESSING: boolean;
  87302. VIGNETTE: boolean;
  87303. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87304. VIGNETTEBLENDMODEOPAQUE: boolean;
  87305. TONEMAPPING: boolean;
  87306. TONEMAPPING_ACES: boolean;
  87307. CONTRAST: boolean;
  87308. COLORCURVES: boolean;
  87309. COLORGRADING: boolean;
  87310. COLORGRADING3D: boolean;
  87311. SAMPLER3DGREENDEPTH: boolean;
  87312. SAMPLER3DBGRMAP: boolean;
  87313. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87314. EXPOSURE: boolean;
  87315. constructor();
  87316. }
  87317. /**
  87318. * This groups together the common properties used for image processing either in direct forward pass
  87319. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87320. * or not.
  87321. */
  87322. export class ImageProcessingConfiguration {
  87323. /**
  87324. * Default tone mapping applied in BabylonJS.
  87325. */
  87326. static readonly TONEMAPPING_STANDARD: number;
  87327. /**
  87328. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87329. * to other engines rendering to increase portability.
  87330. */
  87331. static readonly TONEMAPPING_ACES: number;
  87332. /**
  87333. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87334. */
  87335. colorCurves: Nullable<ColorCurves>;
  87336. private _colorCurvesEnabled;
  87337. /**
  87338. * Gets wether the color curves effect is enabled.
  87339. */
  87340. get colorCurvesEnabled(): boolean;
  87341. /**
  87342. * Sets wether the color curves effect is enabled.
  87343. */
  87344. set colorCurvesEnabled(value: boolean);
  87345. private _colorGradingTexture;
  87346. /**
  87347. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87348. */
  87349. get colorGradingTexture(): Nullable<BaseTexture>;
  87350. /**
  87351. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87352. */
  87353. set colorGradingTexture(value: Nullable<BaseTexture>);
  87354. private _colorGradingEnabled;
  87355. /**
  87356. * Gets wether the color grading effect is enabled.
  87357. */
  87358. get colorGradingEnabled(): boolean;
  87359. /**
  87360. * Sets wether the color grading effect is enabled.
  87361. */
  87362. set colorGradingEnabled(value: boolean);
  87363. private _colorGradingWithGreenDepth;
  87364. /**
  87365. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87366. */
  87367. get colorGradingWithGreenDepth(): boolean;
  87368. /**
  87369. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87370. */
  87371. set colorGradingWithGreenDepth(value: boolean);
  87372. private _colorGradingBGR;
  87373. /**
  87374. * Gets wether the color grading texture contains BGR values.
  87375. */
  87376. get colorGradingBGR(): boolean;
  87377. /**
  87378. * Sets wether the color grading texture contains BGR values.
  87379. */
  87380. set colorGradingBGR(value: boolean);
  87381. /** @hidden */
  87382. _exposure: number;
  87383. /**
  87384. * Gets the Exposure used in the effect.
  87385. */
  87386. get exposure(): number;
  87387. /**
  87388. * Sets the Exposure used in the effect.
  87389. */
  87390. set exposure(value: number);
  87391. private _toneMappingEnabled;
  87392. /**
  87393. * Gets wether the tone mapping effect is enabled.
  87394. */
  87395. get toneMappingEnabled(): boolean;
  87396. /**
  87397. * Sets wether the tone mapping effect is enabled.
  87398. */
  87399. set toneMappingEnabled(value: boolean);
  87400. private _toneMappingType;
  87401. /**
  87402. * Gets the type of tone mapping effect.
  87403. */
  87404. get toneMappingType(): number;
  87405. /**
  87406. * Sets the type of tone mapping effect used in BabylonJS.
  87407. */
  87408. set toneMappingType(value: number);
  87409. protected _contrast: number;
  87410. /**
  87411. * Gets the contrast used in the effect.
  87412. */
  87413. get contrast(): number;
  87414. /**
  87415. * Sets the contrast used in the effect.
  87416. */
  87417. set contrast(value: number);
  87418. /**
  87419. * Vignette stretch size.
  87420. */
  87421. vignetteStretch: number;
  87422. /**
  87423. * Vignette centre X Offset.
  87424. */
  87425. vignetteCentreX: number;
  87426. /**
  87427. * Vignette centre Y Offset.
  87428. */
  87429. vignetteCentreY: number;
  87430. /**
  87431. * Vignette weight or intensity of the vignette effect.
  87432. */
  87433. vignetteWeight: number;
  87434. /**
  87435. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87436. * if vignetteEnabled is set to true.
  87437. */
  87438. vignetteColor: Color4;
  87439. /**
  87440. * Camera field of view used by the Vignette effect.
  87441. */
  87442. vignetteCameraFov: number;
  87443. private _vignetteBlendMode;
  87444. /**
  87445. * Gets the vignette blend mode allowing different kind of effect.
  87446. */
  87447. get vignetteBlendMode(): number;
  87448. /**
  87449. * Sets the vignette blend mode allowing different kind of effect.
  87450. */
  87451. set vignetteBlendMode(value: number);
  87452. private _vignetteEnabled;
  87453. /**
  87454. * Gets wether the vignette effect is enabled.
  87455. */
  87456. get vignetteEnabled(): boolean;
  87457. /**
  87458. * Sets wether the vignette effect is enabled.
  87459. */
  87460. set vignetteEnabled(value: boolean);
  87461. private _applyByPostProcess;
  87462. /**
  87463. * Gets wether the image processing is applied through a post process or not.
  87464. */
  87465. get applyByPostProcess(): boolean;
  87466. /**
  87467. * Sets wether the image processing is applied through a post process or not.
  87468. */
  87469. set applyByPostProcess(value: boolean);
  87470. private _isEnabled;
  87471. /**
  87472. * Gets wether the image processing is enabled or not.
  87473. */
  87474. get isEnabled(): boolean;
  87475. /**
  87476. * Sets wether the image processing is enabled or not.
  87477. */
  87478. set isEnabled(value: boolean);
  87479. /**
  87480. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87481. */
  87482. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87483. /**
  87484. * Method called each time the image processing information changes requires to recompile the effect.
  87485. */
  87486. protected _updateParameters(): void;
  87487. /**
  87488. * Gets the current class name.
  87489. * @return "ImageProcessingConfiguration"
  87490. */
  87491. getClassName(): string;
  87492. /**
  87493. * Prepare the list of uniforms associated with the Image Processing effects.
  87494. * @param uniforms The list of uniforms used in the effect
  87495. * @param defines the list of defines currently in use
  87496. */
  87497. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87498. /**
  87499. * Prepare the list of samplers associated with the Image Processing effects.
  87500. * @param samplersList The list of uniforms used in the effect
  87501. * @param defines the list of defines currently in use
  87502. */
  87503. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87504. /**
  87505. * Prepare the list of defines associated to the shader.
  87506. * @param defines the list of defines to complete
  87507. * @param forPostProcess Define if we are currently in post process mode or not
  87508. */
  87509. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87510. /**
  87511. * Returns true if all the image processing information are ready.
  87512. * @returns True if ready, otherwise, false
  87513. */
  87514. isReady(): boolean;
  87515. /**
  87516. * Binds the image processing to the shader.
  87517. * @param effect The effect to bind to
  87518. * @param overrideAspectRatio Override the aspect ratio of the effect
  87519. */
  87520. bind(effect: Effect, overrideAspectRatio?: number): void;
  87521. /**
  87522. * Clones the current image processing instance.
  87523. * @return The cloned image processing
  87524. */
  87525. clone(): ImageProcessingConfiguration;
  87526. /**
  87527. * Serializes the current image processing instance to a json representation.
  87528. * @return a JSON representation
  87529. */
  87530. serialize(): any;
  87531. /**
  87532. * Parses the image processing from a json representation.
  87533. * @param source the JSON source to parse
  87534. * @return The parsed image processing
  87535. */
  87536. static Parse(source: any): ImageProcessingConfiguration;
  87537. private static _VIGNETTEMODE_MULTIPLY;
  87538. private static _VIGNETTEMODE_OPAQUE;
  87539. /**
  87540. * Used to apply the vignette as a mix with the pixel color.
  87541. */
  87542. static get VIGNETTEMODE_MULTIPLY(): number;
  87543. /**
  87544. * Used to apply the vignette as a replacement of the pixel color.
  87545. */
  87546. static get VIGNETTEMODE_OPAQUE(): number;
  87547. }
  87548. }
  87549. declare module BABYLON {
  87550. /** @hidden */
  87551. export var postprocessVertexShader: {
  87552. name: string;
  87553. shader: string;
  87554. };
  87555. }
  87556. declare module BABYLON {
  87557. interface ThinEngine {
  87558. /**
  87559. * Creates a new render target texture
  87560. * @param size defines the size of the texture
  87561. * @param options defines the options used to create the texture
  87562. * @returns a new render target texture stored in an InternalTexture
  87563. */
  87564. createRenderTargetTexture(size: number | {
  87565. width: number;
  87566. height: number;
  87567. layers?: number;
  87568. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87569. /**
  87570. * Creates a depth stencil texture.
  87571. * This is only available in WebGL 2 or with the depth texture extension available.
  87572. * @param size The size of face edge in the texture.
  87573. * @param options The options defining the texture.
  87574. * @returns The texture
  87575. */
  87576. createDepthStencilTexture(size: number | {
  87577. width: number;
  87578. height: number;
  87579. layers?: number;
  87580. }, options: DepthTextureCreationOptions): InternalTexture;
  87581. /** @hidden */
  87582. _createDepthStencilTexture(size: number | {
  87583. width: number;
  87584. height: number;
  87585. layers?: number;
  87586. }, options: DepthTextureCreationOptions): InternalTexture;
  87587. }
  87588. }
  87589. declare module BABYLON {
  87590. /**
  87591. * Defines the kind of connection point for node based material
  87592. */
  87593. export enum NodeMaterialBlockConnectionPointTypes {
  87594. /** Float */
  87595. Float = 1,
  87596. /** Int */
  87597. Int = 2,
  87598. /** Vector2 */
  87599. Vector2 = 4,
  87600. /** Vector3 */
  87601. Vector3 = 8,
  87602. /** Vector4 */
  87603. Vector4 = 16,
  87604. /** Color3 */
  87605. Color3 = 32,
  87606. /** Color4 */
  87607. Color4 = 64,
  87608. /** Matrix */
  87609. Matrix = 128,
  87610. /** Custom object */
  87611. Object = 256,
  87612. /** Detect type based on connection */
  87613. AutoDetect = 1024,
  87614. /** Output type that will be defined by input type */
  87615. BasedOnInput = 2048
  87616. }
  87617. }
  87618. declare module BABYLON {
  87619. /**
  87620. * Enum used to define the target of a block
  87621. */
  87622. export enum NodeMaterialBlockTargets {
  87623. /** Vertex shader */
  87624. Vertex = 1,
  87625. /** Fragment shader */
  87626. Fragment = 2,
  87627. /** Neutral */
  87628. Neutral = 4,
  87629. /** Vertex and Fragment */
  87630. VertexAndFragment = 3
  87631. }
  87632. }
  87633. declare module BABYLON {
  87634. /**
  87635. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87636. */
  87637. export enum NodeMaterialBlockConnectionPointMode {
  87638. /** Value is an uniform */
  87639. Uniform = 0,
  87640. /** Value is a mesh attribute */
  87641. Attribute = 1,
  87642. /** Value is a varying between vertex and fragment shaders */
  87643. Varying = 2,
  87644. /** Mode is undefined */
  87645. Undefined = 3
  87646. }
  87647. }
  87648. declare module BABYLON {
  87649. /**
  87650. * Enum used to define system values e.g. values automatically provided by the system
  87651. */
  87652. export enum NodeMaterialSystemValues {
  87653. /** World */
  87654. World = 1,
  87655. /** View */
  87656. View = 2,
  87657. /** Projection */
  87658. Projection = 3,
  87659. /** ViewProjection */
  87660. ViewProjection = 4,
  87661. /** WorldView */
  87662. WorldView = 5,
  87663. /** WorldViewProjection */
  87664. WorldViewProjection = 6,
  87665. /** CameraPosition */
  87666. CameraPosition = 7,
  87667. /** Fog Color */
  87668. FogColor = 8,
  87669. /** Delta time */
  87670. DeltaTime = 9
  87671. }
  87672. }
  87673. declare module BABYLON {
  87674. /** Defines supported spaces */
  87675. export enum Space {
  87676. /** Local (object) space */
  87677. LOCAL = 0,
  87678. /** World space */
  87679. WORLD = 1,
  87680. /** Bone space */
  87681. BONE = 2
  87682. }
  87683. /** Defines the 3 main axes */
  87684. export class Axis {
  87685. /** X axis */
  87686. static X: Vector3;
  87687. /** Y axis */
  87688. static Y: Vector3;
  87689. /** Z axis */
  87690. static Z: Vector3;
  87691. }
  87692. }
  87693. declare module BABYLON {
  87694. /**
  87695. * Represents a camera frustum
  87696. */
  87697. export class Frustum {
  87698. /**
  87699. * Gets the planes representing the frustum
  87700. * @param transform matrix to be applied to the returned planes
  87701. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87702. */
  87703. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87704. /**
  87705. * Gets the near frustum plane transformed by the transform matrix
  87706. * @param transform transformation matrix to be applied to the resulting frustum plane
  87707. * @param frustumPlane the resuling frustum plane
  87708. */
  87709. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87710. /**
  87711. * Gets the far frustum plane transformed by the transform matrix
  87712. * @param transform transformation matrix to be applied to the resulting frustum plane
  87713. * @param frustumPlane the resuling frustum plane
  87714. */
  87715. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87716. /**
  87717. * Gets the left frustum plane transformed by the transform matrix
  87718. * @param transform transformation matrix to be applied to the resulting frustum plane
  87719. * @param frustumPlane the resuling frustum plane
  87720. */
  87721. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87722. /**
  87723. * Gets the right frustum plane transformed by the transform matrix
  87724. * @param transform transformation matrix to be applied to the resulting frustum plane
  87725. * @param frustumPlane the resuling frustum plane
  87726. */
  87727. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87728. /**
  87729. * Gets the top frustum plane transformed by the transform matrix
  87730. * @param transform transformation matrix to be applied to the resulting frustum plane
  87731. * @param frustumPlane the resuling frustum plane
  87732. */
  87733. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87734. /**
  87735. * Gets the bottom frustum plane transformed by the transform matrix
  87736. * @param transform transformation matrix to be applied to the resulting frustum plane
  87737. * @param frustumPlane the resuling frustum plane
  87738. */
  87739. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87740. /**
  87741. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87742. * @param transform transformation matrix to be applied to the resulting frustum planes
  87743. * @param frustumPlanes the resuling frustum planes
  87744. */
  87745. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87746. }
  87747. }
  87748. declare module BABYLON {
  87749. /**
  87750. * Interface for the size containing width and height
  87751. */
  87752. export interface ISize {
  87753. /**
  87754. * Width
  87755. */
  87756. width: number;
  87757. /**
  87758. * Heighht
  87759. */
  87760. height: number;
  87761. }
  87762. /**
  87763. * Size containing widht and height
  87764. */
  87765. export class Size implements ISize {
  87766. /**
  87767. * Width
  87768. */
  87769. width: number;
  87770. /**
  87771. * Height
  87772. */
  87773. height: number;
  87774. /**
  87775. * Creates a Size object from the given width and height (floats).
  87776. * @param width width of the new size
  87777. * @param height height of the new size
  87778. */
  87779. constructor(width: number, height: number);
  87780. /**
  87781. * Returns a string with the Size width and height
  87782. * @returns a string with the Size width and height
  87783. */
  87784. toString(): string;
  87785. /**
  87786. * "Size"
  87787. * @returns the string "Size"
  87788. */
  87789. getClassName(): string;
  87790. /**
  87791. * Returns the Size hash code.
  87792. * @returns a hash code for a unique width and height
  87793. */
  87794. getHashCode(): number;
  87795. /**
  87796. * Updates the current size from the given one.
  87797. * @param src the given size
  87798. */
  87799. copyFrom(src: Size): void;
  87800. /**
  87801. * Updates in place the current Size from the given floats.
  87802. * @param width width of the new size
  87803. * @param height height of the new size
  87804. * @returns the updated Size.
  87805. */
  87806. copyFromFloats(width: number, height: number): Size;
  87807. /**
  87808. * Updates in place the current Size from the given floats.
  87809. * @param width width to set
  87810. * @param height height to set
  87811. * @returns the updated Size.
  87812. */
  87813. set(width: number, height: number): Size;
  87814. /**
  87815. * Multiplies the width and height by numbers
  87816. * @param w factor to multiple the width by
  87817. * @param h factor to multiple the height by
  87818. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87819. */
  87820. multiplyByFloats(w: number, h: number): Size;
  87821. /**
  87822. * Clones the size
  87823. * @returns a new Size copied from the given one.
  87824. */
  87825. clone(): Size;
  87826. /**
  87827. * True if the current Size and the given one width and height are strictly equal.
  87828. * @param other the other size to compare against
  87829. * @returns True if the current Size and the given one width and height are strictly equal.
  87830. */
  87831. equals(other: Size): boolean;
  87832. /**
  87833. * The surface of the Size : width * height (float).
  87834. */
  87835. get surface(): number;
  87836. /**
  87837. * Create a new size of zero
  87838. * @returns a new Size set to (0.0, 0.0)
  87839. */
  87840. static Zero(): Size;
  87841. /**
  87842. * Sums the width and height of two sizes
  87843. * @param otherSize size to add to this size
  87844. * @returns a new Size set as the addition result of the current Size and the given one.
  87845. */
  87846. add(otherSize: Size): Size;
  87847. /**
  87848. * Subtracts the width and height of two
  87849. * @param otherSize size to subtract to this size
  87850. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87851. */
  87852. subtract(otherSize: Size): Size;
  87853. /**
  87854. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87855. * @param start starting size to lerp between
  87856. * @param end end size to lerp between
  87857. * @param amount amount to lerp between the start and end values
  87858. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87859. */
  87860. static Lerp(start: Size, end: Size, amount: number): Size;
  87861. }
  87862. }
  87863. declare module BABYLON {
  87864. /**
  87865. * Contains position and normal vectors for a vertex
  87866. */
  87867. export class PositionNormalVertex {
  87868. /** the position of the vertex (defaut: 0,0,0) */
  87869. position: Vector3;
  87870. /** the normal of the vertex (defaut: 0,1,0) */
  87871. normal: Vector3;
  87872. /**
  87873. * Creates a PositionNormalVertex
  87874. * @param position the position of the vertex (defaut: 0,0,0)
  87875. * @param normal the normal of the vertex (defaut: 0,1,0)
  87876. */
  87877. constructor(
  87878. /** the position of the vertex (defaut: 0,0,0) */
  87879. position?: Vector3,
  87880. /** the normal of the vertex (defaut: 0,1,0) */
  87881. normal?: Vector3);
  87882. /**
  87883. * Clones the PositionNormalVertex
  87884. * @returns the cloned PositionNormalVertex
  87885. */
  87886. clone(): PositionNormalVertex;
  87887. }
  87888. /**
  87889. * Contains position, normal and uv vectors for a vertex
  87890. */
  87891. export class PositionNormalTextureVertex {
  87892. /** the position of the vertex (defaut: 0,0,0) */
  87893. position: Vector3;
  87894. /** the normal of the vertex (defaut: 0,1,0) */
  87895. normal: Vector3;
  87896. /** the uv of the vertex (default: 0,0) */
  87897. uv: Vector2;
  87898. /**
  87899. * Creates a PositionNormalTextureVertex
  87900. * @param position the position of the vertex (defaut: 0,0,0)
  87901. * @param normal the normal of the vertex (defaut: 0,1,0)
  87902. * @param uv the uv of the vertex (default: 0,0)
  87903. */
  87904. constructor(
  87905. /** the position of the vertex (defaut: 0,0,0) */
  87906. position?: Vector3,
  87907. /** the normal of the vertex (defaut: 0,1,0) */
  87908. normal?: Vector3,
  87909. /** the uv of the vertex (default: 0,0) */
  87910. uv?: Vector2);
  87911. /**
  87912. * Clones the PositionNormalTextureVertex
  87913. * @returns the cloned PositionNormalTextureVertex
  87914. */
  87915. clone(): PositionNormalTextureVertex;
  87916. }
  87917. }
  87918. declare module BABYLON {
  87919. /**
  87920. * Enum defining the type of animations supported by InputBlock
  87921. */
  87922. export enum AnimatedInputBlockTypes {
  87923. /** No animation */
  87924. None = 0,
  87925. /** Time based animation. Will only work for floats */
  87926. Time = 1
  87927. }
  87928. }
  87929. declare module BABYLON {
  87930. /**
  87931. * Interface describing all the common properties and methods a shadow light needs to implement.
  87932. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87933. * as well as binding the different shadow properties to the effects.
  87934. */
  87935. export interface IShadowLight extends Light {
  87936. /**
  87937. * The light id in the scene (used in scene.findLighById for instance)
  87938. */
  87939. id: string;
  87940. /**
  87941. * The position the shdow will be casted from.
  87942. */
  87943. position: Vector3;
  87944. /**
  87945. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87946. */
  87947. direction: Vector3;
  87948. /**
  87949. * The transformed position. Position of the light in world space taking parenting in account.
  87950. */
  87951. transformedPosition: Vector3;
  87952. /**
  87953. * The transformed direction. Direction of the light in world space taking parenting in account.
  87954. */
  87955. transformedDirection: Vector3;
  87956. /**
  87957. * The friendly name of the light in the scene.
  87958. */
  87959. name: string;
  87960. /**
  87961. * Defines the shadow projection clipping minimum z value.
  87962. */
  87963. shadowMinZ: number;
  87964. /**
  87965. * Defines the shadow projection clipping maximum z value.
  87966. */
  87967. shadowMaxZ: number;
  87968. /**
  87969. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87970. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87971. */
  87972. computeTransformedInformation(): boolean;
  87973. /**
  87974. * Gets the scene the light belongs to.
  87975. * @returns The scene
  87976. */
  87977. getScene(): Scene;
  87978. /**
  87979. * Callback defining a custom Projection Matrix Builder.
  87980. * This can be used to override the default projection matrix computation.
  87981. */
  87982. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87983. /**
  87984. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87985. * @param matrix The materix to updated with the projection information
  87986. * @param viewMatrix The transform matrix of the light
  87987. * @param renderList The list of mesh to render in the map
  87988. * @returns The current light
  87989. */
  87990. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87991. /**
  87992. * Gets the current depth scale used in ESM.
  87993. * @returns The scale
  87994. */
  87995. getDepthScale(): number;
  87996. /**
  87997. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87998. * @returns true if a cube texture needs to be use
  87999. */
  88000. needCube(): boolean;
  88001. /**
  88002. * Detects if the projection matrix requires to be recomputed this frame.
  88003. * @returns true if it requires to be recomputed otherwise, false.
  88004. */
  88005. needProjectionMatrixCompute(): boolean;
  88006. /**
  88007. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88008. */
  88009. forceProjectionMatrixCompute(): void;
  88010. /**
  88011. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88012. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88013. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88014. */
  88015. getShadowDirection(faceIndex?: number): Vector3;
  88016. /**
  88017. * Gets the minZ used for shadow according to both the scene and the light.
  88018. * @param activeCamera The camera we are returning the min for
  88019. * @returns the depth min z
  88020. */
  88021. getDepthMinZ(activeCamera: Camera): number;
  88022. /**
  88023. * Gets the maxZ used for shadow according to both the scene and the light.
  88024. * @param activeCamera The camera we are returning the max for
  88025. * @returns the depth max z
  88026. */
  88027. getDepthMaxZ(activeCamera: Camera): number;
  88028. }
  88029. /**
  88030. * Base implementation IShadowLight
  88031. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88032. */
  88033. export abstract class ShadowLight extends Light implements IShadowLight {
  88034. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88035. protected _position: Vector3;
  88036. protected _setPosition(value: Vector3): void;
  88037. /**
  88038. * Sets the position the shadow will be casted from. Also use as the light position for both
  88039. * point and spot lights.
  88040. */
  88041. get position(): Vector3;
  88042. /**
  88043. * Sets the position the shadow will be casted from. Also use as the light position for both
  88044. * point and spot lights.
  88045. */
  88046. set position(value: Vector3);
  88047. protected _direction: Vector3;
  88048. protected _setDirection(value: Vector3): void;
  88049. /**
  88050. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88051. * Also use as the light direction on spot and directional lights.
  88052. */
  88053. get direction(): Vector3;
  88054. /**
  88055. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88056. * Also use as the light direction on spot and directional lights.
  88057. */
  88058. set direction(value: Vector3);
  88059. protected _shadowMinZ: number;
  88060. /**
  88061. * Gets the shadow projection clipping minimum z value.
  88062. */
  88063. get shadowMinZ(): number;
  88064. /**
  88065. * Sets the shadow projection clipping minimum z value.
  88066. */
  88067. set shadowMinZ(value: number);
  88068. protected _shadowMaxZ: number;
  88069. /**
  88070. * Sets the shadow projection clipping maximum z value.
  88071. */
  88072. get shadowMaxZ(): number;
  88073. /**
  88074. * Gets the shadow projection clipping maximum z value.
  88075. */
  88076. set shadowMaxZ(value: number);
  88077. /**
  88078. * Callback defining a custom Projection Matrix Builder.
  88079. * This can be used to override the default projection matrix computation.
  88080. */
  88081. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88082. /**
  88083. * The transformed position. Position of the light in world space taking parenting in account.
  88084. */
  88085. transformedPosition: Vector3;
  88086. /**
  88087. * The transformed direction. Direction of the light in world space taking parenting in account.
  88088. */
  88089. transformedDirection: Vector3;
  88090. private _needProjectionMatrixCompute;
  88091. /**
  88092. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88093. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88094. */
  88095. computeTransformedInformation(): boolean;
  88096. /**
  88097. * Return the depth scale used for the shadow map.
  88098. * @returns the depth scale.
  88099. */
  88100. getDepthScale(): number;
  88101. /**
  88102. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88103. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88104. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88105. */
  88106. getShadowDirection(faceIndex?: number): Vector3;
  88107. /**
  88108. * Returns the ShadowLight absolute position in the World.
  88109. * @returns the position vector in world space
  88110. */
  88111. getAbsolutePosition(): Vector3;
  88112. /**
  88113. * Sets the ShadowLight direction toward the passed target.
  88114. * @param target The point to target in local space
  88115. * @returns the updated ShadowLight direction
  88116. */
  88117. setDirectionToTarget(target: Vector3): Vector3;
  88118. /**
  88119. * Returns the light rotation in euler definition.
  88120. * @returns the x y z rotation in local space.
  88121. */
  88122. getRotation(): Vector3;
  88123. /**
  88124. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88125. * @returns true if a cube texture needs to be use
  88126. */
  88127. needCube(): boolean;
  88128. /**
  88129. * Detects if the projection matrix requires to be recomputed this frame.
  88130. * @returns true if it requires to be recomputed otherwise, false.
  88131. */
  88132. needProjectionMatrixCompute(): boolean;
  88133. /**
  88134. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88135. */
  88136. forceProjectionMatrixCompute(): void;
  88137. /** @hidden */
  88138. _initCache(): void;
  88139. /** @hidden */
  88140. _isSynchronized(): boolean;
  88141. /**
  88142. * Computes the world matrix of the node
  88143. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88144. * @returns the world matrix
  88145. */
  88146. computeWorldMatrix(force?: boolean): Matrix;
  88147. /**
  88148. * Gets the minZ used for shadow according to both the scene and the light.
  88149. * @param activeCamera The camera we are returning the min for
  88150. * @returns the depth min z
  88151. */
  88152. getDepthMinZ(activeCamera: Camera): number;
  88153. /**
  88154. * Gets the maxZ used for shadow according to both the scene and the light.
  88155. * @param activeCamera The camera we are returning the max for
  88156. * @returns the depth max z
  88157. */
  88158. getDepthMaxZ(activeCamera: Camera): number;
  88159. /**
  88160. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88161. * @param matrix The materix to updated with the projection information
  88162. * @param viewMatrix The transform matrix of the light
  88163. * @param renderList The list of mesh to render in the map
  88164. * @returns The current light
  88165. */
  88166. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88167. }
  88168. }
  88169. declare module BABYLON {
  88170. /** @hidden */
  88171. export var packingFunctions: {
  88172. name: string;
  88173. shader: string;
  88174. };
  88175. }
  88176. declare module BABYLON {
  88177. /** @hidden */
  88178. export var bayerDitherFunctions: {
  88179. name: string;
  88180. shader: string;
  88181. };
  88182. }
  88183. declare module BABYLON {
  88184. /** @hidden */
  88185. export var shadowMapFragmentDeclaration: {
  88186. name: string;
  88187. shader: string;
  88188. };
  88189. }
  88190. declare module BABYLON {
  88191. /** @hidden */
  88192. export var clipPlaneFragmentDeclaration: {
  88193. name: string;
  88194. shader: string;
  88195. };
  88196. }
  88197. declare module BABYLON {
  88198. /** @hidden */
  88199. export var clipPlaneFragment: {
  88200. name: string;
  88201. shader: string;
  88202. };
  88203. }
  88204. declare module BABYLON {
  88205. /** @hidden */
  88206. export var shadowMapFragment: {
  88207. name: string;
  88208. shader: string;
  88209. };
  88210. }
  88211. declare module BABYLON {
  88212. /** @hidden */
  88213. export var shadowMapPixelShader: {
  88214. name: string;
  88215. shader: string;
  88216. };
  88217. }
  88218. declare module BABYLON {
  88219. /** @hidden */
  88220. export var bonesDeclaration: {
  88221. name: string;
  88222. shader: string;
  88223. };
  88224. }
  88225. declare module BABYLON {
  88226. /** @hidden */
  88227. export var morphTargetsVertexGlobalDeclaration: {
  88228. name: string;
  88229. shader: string;
  88230. };
  88231. }
  88232. declare module BABYLON {
  88233. /** @hidden */
  88234. export var morphTargetsVertexDeclaration: {
  88235. name: string;
  88236. shader: string;
  88237. };
  88238. }
  88239. declare module BABYLON {
  88240. /** @hidden */
  88241. export var instancesDeclaration: {
  88242. name: string;
  88243. shader: string;
  88244. };
  88245. }
  88246. declare module BABYLON {
  88247. /** @hidden */
  88248. export var helperFunctions: {
  88249. name: string;
  88250. shader: string;
  88251. };
  88252. }
  88253. declare module BABYLON {
  88254. /** @hidden */
  88255. export var shadowMapVertexDeclaration: {
  88256. name: string;
  88257. shader: string;
  88258. };
  88259. }
  88260. declare module BABYLON {
  88261. /** @hidden */
  88262. export var clipPlaneVertexDeclaration: {
  88263. name: string;
  88264. shader: string;
  88265. };
  88266. }
  88267. declare module BABYLON {
  88268. /** @hidden */
  88269. export var morphTargetsVertex: {
  88270. name: string;
  88271. shader: string;
  88272. };
  88273. }
  88274. declare module BABYLON {
  88275. /** @hidden */
  88276. export var instancesVertex: {
  88277. name: string;
  88278. shader: string;
  88279. };
  88280. }
  88281. declare module BABYLON {
  88282. /** @hidden */
  88283. export var bonesVertex: {
  88284. name: string;
  88285. shader: string;
  88286. };
  88287. }
  88288. declare module BABYLON {
  88289. /** @hidden */
  88290. export var shadowMapVertexNormalBias: {
  88291. name: string;
  88292. shader: string;
  88293. };
  88294. }
  88295. declare module BABYLON {
  88296. /** @hidden */
  88297. export var shadowMapVertexMetric: {
  88298. name: string;
  88299. shader: string;
  88300. };
  88301. }
  88302. declare module BABYLON {
  88303. /** @hidden */
  88304. export var clipPlaneVertex: {
  88305. name: string;
  88306. shader: string;
  88307. };
  88308. }
  88309. declare module BABYLON {
  88310. /** @hidden */
  88311. export var shadowMapVertexShader: {
  88312. name: string;
  88313. shader: string;
  88314. };
  88315. }
  88316. declare module BABYLON {
  88317. /** @hidden */
  88318. export var depthBoxBlurPixelShader: {
  88319. name: string;
  88320. shader: string;
  88321. };
  88322. }
  88323. declare module BABYLON {
  88324. /** @hidden */
  88325. export var shadowMapFragmentSoftTransparentShadow: {
  88326. name: string;
  88327. shader: string;
  88328. };
  88329. }
  88330. declare module BABYLON {
  88331. /**
  88332. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88333. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88334. */
  88335. export class EffectFallbacks implements IEffectFallbacks {
  88336. private _defines;
  88337. private _currentRank;
  88338. private _maxRank;
  88339. private _mesh;
  88340. /**
  88341. * Removes the fallback from the bound mesh.
  88342. */
  88343. unBindMesh(): void;
  88344. /**
  88345. * Adds a fallback on the specified property.
  88346. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88347. * @param define The name of the define in the shader
  88348. */
  88349. addFallback(rank: number, define: string): void;
  88350. /**
  88351. * Sets the mesh to use CPU skinning when needing to fallback.
  88352. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88353. * @param mesh The mesh to use the fallbacks.
  88354. */
  88355. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88356. /**
  88357. * Checks to see if more fallbacks are still availible.
  88358. */
  88359. get hasMoreFallbacks(): boolean;
  88360. /**
  88361. * Removes the defines that should be removed when falling back.
  88362. * @param currentDefines defines the current define statements for the shader.
  88363. * @param effect defines the current effect we try to compile
  88364. * @returns The resulting defines with defines of the current rank removed.
  88365. */
  88366. reduce(currentDefines: string, effect: Effect): string;
  88367. }
  88368. }
  88369. declare module BABYLON {
  88370. /**
  88371. * Interface used to define Action
  88372. */
  88373. export interface IAction {
  88374. /**
  88375. * Trigger for the action
  88376. */
  88377. trigger: number;
  88378. /** Options of the trigger */
  88379. triggerOptions: any;
  88380. /**
  88381. * Gets the trigger parameters
  88382. * @returns the trigger parameters
  88383. */
  88384. getTriggerParameter(): any;
  88385. /**
  88386. * Internal only - executes current action event
  88387. * @hidden
  88388. */
  88389. _executeCurrent(evt?: ActionEvent): void;
  88390. /**
  88391. * Serialize placeholder for child classes
  88392. * @param parent of child
  88393. * @returns the serialized object
  88394. */
  88395. serialize(parent: any): any;
  88396. /**
  88397. * Internal only
  88398. * @hidden
  88399. */
  88400. _prepare(): void;
  88401. /**
  88402. * Internal only - manager for action
  88403. * @hidden
  88404. */
  88405. _actionManager: AbstractActionManager;
  88406. /**
  88407. * Adds action to chain of actions, may be a DoNothingAction
  88408. * @param action defines the next action to execute
  88409. * @returns The action passed in
  88410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88411. */
  88412. then(action: IAction): IAction;
  88413. }
  88414. /**
  88415. * The action to be carried out following a trigger
  88416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88417. */
  88418. export class Action implements IAction {
  88419. /** the trigger, with or without parameters, for the action */
  88420. triggerOptions: any;
  88421. /**
  88422. * Trigger for the action
  88423. */
  88424. trigger: number;
  88425. /**
  88426. * Internal only - manager for action
  88427. * @hidden
  88428. */
  88429. _actionManager: ActionManager;
  88430. private _nextActiveAction;
  88431. private _child;
  88432. private _condition?;
  88433. private _triggerParameter;
  88434. /**
  88435. * An event triggered prior to action being executed.
  88436. */
  88437. onBeforeExecuteObservable: Observable<Action>;
  88438. /**
  88439. * Creates a new Action
  88440. * @param triggerOptions the trigger, with or without parameters, for the action
  88441. * @param condition an optional determinant of action
  88442. */
  88443. constructor(
  88444. /** the trigger, with or without parameters, for the action */
  88445. triggerOptions: any, condition?: Condition);
  88446. /**
  88447. * Internal only
  88448. * @hidden
  88449. */
  88450. _prepare(): void;
  88451. /**
  88452. * Gets the trigger parameters
  88453. * @returns the trigger parameters
  88454. */
  88455. getTriggerParameter(): any;
  88456. /**
  88457. * Internal only - executes current action event
  88458. * @hidden
  88459. */
  88460. _executeCurrent(evt?: ActionEvent): void;
  88461. /**
  88462. * Execute placeholder for child classes
  88463. * @param evt optional action event
  88464. */
  88465. execute(evt?: ActionEvent): void;
  88466. /**
  88467. * Skips to next active action
  88468. */
  88469. skipToNextActiveAction(): void;
  88470. /**
  88471. * Adds action to chain of actions, may be a DoNothingAction
  88472. * @param action defines the next action to execute
  88473. * @returns The action passed in
  88474. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88475. */
  88476. then(action: Action): Action;
  88477. /**
  88478. * Internal only
  88479. * @hidden
  88480. */
  88481. _getProperty(propertyPath: string): string;
  88482. /**
  88483. * Internal only
  88484. * @hidden
  88485. */
  88486. _getEffectiveTarget(target: any, propertyPath: string): any;
  88487. /**
  88488. * Serialize placeholder for child classes
  88489. * @param parent of child
  88490. * @returns the serialized object
  88491. */
  88492. serialize(parent: any): any;
  88493. /**
  88494. * Internal only called by serialize
  88495. * @hidden
  88496. */
  88497. protected _serialize(serializedAction: any, parent?: any): any;
  88498. /**
  88499. * Internal only
  88500. * @hidden
  88501. */
  88502. static _SerializeValueAsString: (value: any) => string;
  88503. /**
  88504. * Internal only
  88505. * @hidden
  88506. */
  88507. static _GetTargetProperty: (target: Scene | Node) => {
  88508. name: string;
  88509. targetType: string;
  88510. value: string;
  88511. };
  88512. }
  88513. }
  88514. declare module BABYLON {
  88515. /**
  88516. * A Condition applied to an Action
  88517. */
  88518. export class Condition {
  88519. /**
  88520. * Internal only - manager for action
  88521. * @hidden
  88522. */
  88523. _actionManager: ActionManager;
  88524. /**
  88525. * Internal only
  88526. * @hidden
  88527. */
  88528. _evaluationId: number;
  88529. /**
  88530. * Internal only
  88531. * @hidden
  88532. */
  88533. _currentResult: boolean;
  88534. /**
  88535. * Creates a new Condition
  88536. * @param actionManager the manager of the action the condition is applied to
  88537. */
  88538. constructor(actionManager: ActionManager);
  88539. /**
  88540. * Check if the current condition is valid
  88541. * @returns a boolean
  88542. */
  88543. isValid(): boolean;
  88544. /**
  88545. * Internal only
  88546. * @hidden
  88547. */
  88548. _getProperty(propertyPath: string): string;
  88549. /**
  88550. * Internal only
  88551. * @hidden
  88552. */
  88553. _getEffectiveTarget(target: any, propertyPath: string): any;
  88554. /**
  88555. * Serialize placeholder for child classes
  88556. * @returns the serialized object
  88557. */
  88558. serialize(): any;
  88559. /**
  88560. * Internal only
  88561. * @hidden
  88562. */
  88563. protected _serialize(serializedCondition: any): any;
  88564. }
  88565. /**
  88566. * Defines specific conditional operators as extensions of Condition
  88567. */
  88568. export class ValueCondition extends Condition {
  88569. /** path to specify the property of the target the conditional operator uses */
  88570. propertyPath: string;
  88571. /** the value compared by the conditional operator against the current value of the property */
  88572. value: any;
  88573. /** the conditional operator, default ValueCondition.IsEqual */
  88574. operator: number;
  88575. /**
  88576. * Internal only
  88577. * @hidden
  88578. */
  88579. private static _IsEqual;
  88580. /**
  88581. * Internal only
  88582. * @hidden
  88583. */
  88584. private static _IsDifferent;
  88585. /**
  88586. * Internal only
  88587. * @hidden
  88588. */
  88589. private static _IsGreater;
  88590. /**
  88591. * Internal only
  88592. * @hidden
  88593. */
  88594. private static _IsLesser;
  88595. /**
  88596. * returns the number for IsEqual
  88597. */
  88598. static get IsEqual(): number;
  88599. /**
  88600. * Returns the number for IsDifferent
  88601. */
  88602. static get IsDifferent(): number;
  88603. /**
  88604. * Returns the number for IsGreater
  88605. */
  88606. static get IsGreater(): number;
  88607. /**
  88608. * Returns the number for IsLesser
  88609. */
  88610. static get IsLesser(): number;
  88611. /**
  88612. * Internal only The action manager for the condition
  88613. * @hidden
  88614. */
  88615. _actionManager: ActionManager;
  88616. /**
  88617. * Internal only
  88618. * @hidden
  88619. */
  88620. private _target;
  88621. /**
  88622. * Internal only
  88623. * @hidden
  88624. */
  88625. private _effectiveTarget;
  88626. /**
  88627. * Internal only
  88628. * @hidden
  88629. */
  88630. private _property;
  88631. /**
  88632. * Creates a new ValueCondition
  88633. * @param actionManager manager for the action the condition applies to
  88634. * @param target for the action
  88635. * @param propertyPath path to specify the property of the target the conditional operator uses
  88636. * @param value the value compared by the conditional operator against the current value of the property
  88637. * @param operator the conditional operator, default ValueCondition.IsEqual
  88638. */
  88639. constructor(actionManager: ActionManager, target: any,
  88640. /** path to specify the property of the target the conditional operator uses */
  88641. propertyPath: string,
  88642. /** the value compared by the conditional operator against the current value of the property */
  88643. value: any,
  88644. /** the conditional operator, default ValueCondition.IsEqual */
  88645. operator?: number);
  88646. /**
  88647. * Compares the given value with the property value for the specified conditional operator
  88648. * @returns the result of the comparison
  88649. */
  88650. isValid(): boolean;
  88651. /**
  88652. * Serialize the ValueCondition into a JSON compatible object
  88653. * @returns serialization object
  88654. */
  88655. serialize(): any;
  88656. /**
  88657. * Gets the name of the conditional operator for the ValueCondition
  88658. * @param operator the conditional operator
  88659. * @returns the name
  88660. */
  88661. static GetOperatorName(operator: number): string;
  88662. }
  88663. /**
  88664. * Defines a predicate condition as an extension of Condition
  88665. */
  88666. export class PredicateCondition extends Condition {
  88667. /** defines the predicate function used to validate the condition */
  88668. predicate: () => boolean;
  88669. /**
  88670. * Internal only - manager for action
  88671. * @hidden
  88672. */
  88673. _actionManager: ActionManager;
  88674. /**
  88675. * Creates a new PredicateCondition
  88676. * @param actionManager manager for the action the condition applies to
  88677. * @param predicate defines the predicate function used to validate the condition
  88678. */
  88679. constructor(actionManager: ActionManager,
  88680. /** defines the predicate function used to validate the condition */
  88681. predicate: () => boolean);
  88682. /**
  88683. * @returns the validity of the predicate condition
  88684. */
  88685. isValid(): boolean;
  88686. }
  88687. /**
  88688. * Defines a state condition as an extension of Condition
  88689. */
  88690. export class StateCondition extends Condition {
  88691. /** Value to compare with target state */
  88692. value: string;
  88693. /**
  88694. * Internal only - manager for action
  88695. * @hidden
  88696. */
  88697. _actionManager: ActionManager;
  88698. /**
  88699. * Internal only
  88700. * @hidden
  88701. */
  88702. private _target;
  88703. /**
  88704. * Creates a new StateCondition
  88705. * @param actionManager manager for the action the condition applies to
  88706. * @param target of the condition
  88707. * @param value to compare with target state
  88708. */
  88709. constructor(actionManager: ActionManager, target: any,
  88710. /** Value to compare with target state */
  88711. value: string);
  88712. /**
  88713. * Gets a boolean indicating if the current condition is met
  88714. * @returns the validity of the state
  88715. */
  88716. isValid(): boolean;
  88717. /**
  88718. * Serialize the StateCondition into a JSON compatible object
  88719. * @returns serialization object
  88720. */
  88721. serialize(): any;
  88722. }
  88723. }
  88724. declare module BABYLON {
  88725. /**
  88726. * This defines an action responsible to toggle a boolean once triggered.
  88727. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88728. */
  88729. export class SwitchBooleanAction extends Action {
  88730. /**
  88731. * The path to the boolean property in the target object
  88732. */
  88733. propertyPath: string;
  88734. private _target;
  88735. private _effectiveTarget;
  88736. private _property;
  88737. /**
  88738. * Instantiate the action
  88739. * @param triggerOptions defines the trigger options
  88740. * @param target defines the object containing the boolean
  88741. * @param propertyPath defines the path to the boolean property in the target object
  88742. * @param condition defines the trigger related conditions
  88743. */
  88744. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88745. /** @hidden */
  88746. _prepare(): void;
  88747. /**
  88748. * Execute the action toggle the boolean value.
  88749. */
  88750. execute(): void;
  88751. /**
  88752. * Serializes the actions and its related information.
  88753. * @param parent defines the object to serialize in
  88754. * @returns the serialized object
  88755. */
  88756. serialize(parent: any): any;
  88757. }
  88758. /**
  88759. * This defines an action responsible to set a the state field of the target
  88760. * to a desired value once triggered.
  88761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88762. */
  88763. export class SetStateAction extends Action {
  88764. /**
  88765. * The value to store in the state field.
  88766. */
  88767. value: string;
  88768. private _target;
  88769. /**
  88770. * Instantiate the action
  88771. * @param triggerOptions defines the trigger options
  88772. * @param target defines the object containing the state property
  88773. * @param value defines the value to store in the state field
  88774. * @param condition defines the trigger related conditions
  88775. */
  88776. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88777. /**
  88778. * Execute the action and store the value on the target state property.
  88779. */
  88780. execute(): void;
  88781. /**
  88782. * Serializes the actions and its related information.
  88783. * @param parent defines the object to serialize in
  88784. * @returns the serialized object
  88785. */
  88786. serialize(parent: any): any;
  88787. }
  88788. /**
  88789. * This defines an action responsible to set a property of the target
  88790. * to a desired value once triggered.
  88791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88792. */
  88793. export class SetValueAction extends Action {
  88794. /**
  88795. * The path of the property to set in the target.
  88796. */
  88797. propertyPath: string;
  88798. /**
  88799. * The value to set in the property
  88800. */
  88801. value: any;
  88802. private _target;
  88803. private _effectiveTarget;
  88804. private _property;
  88805. /**
  88806. * Instantiate the action
  88807. * @param triggerOptions defines the trigger options
  88808. * @param target defines the object containing the property
  88809. * @param propertyPath defines the path of the property to set in the target
  88810. * @param value defines the value to set in the property
  88811. * @param condition defines the trigger related conditions
  88812. */
  88813. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88814. /** @hidden */
  88815. _prepare(): void;
  88816. /**
  88817. * Execute the action and set the targetted property to the desired value.
  88818. */
  88819. execute(): void;
  88820. /**
  88821. * Serializes the actions and its related information.
  88822. * @param parent defines the object to serialize in
  88823. * @returns the serialized object
  88824. */
  88825. serialize(parent: any): any;
  88826. }
  88827. /**
  88828. * This defines an action responsible to increment the target value
  88829. * to a desired value once triggered.
  88830. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88831. */
  88832. export class IncrementValueAction extends Action {
  88833. /**
  88834. * The path of the property to increment in the target.
  88835. */
  88836. propertyPath: string;
  88837. /**
  88838. * The value we should increment the property by.
  88839. */
  88840. value: any;
  88841. private _target;
  88842. private _effectiveTarget;
  88843. private _property;
  88844. /**
  88845. * Instantiate the action
  88846. * @param triggerOptions defines the trigger options
  88847. * @param target defines the object containing the property
  88848. * @param propertyPath defines the path of the property to increment in the target
  88849. * @param value defines the value value we should increment the property by
  88850. * @param condition defines the trigger related conditions
  88851. */
  88852. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88853. /** @hidden */
  88854. _prepare(): void;
  88855. /**
  88856. * Execute the action and increment the target of the value amount.
  88857. */
  88858. execute(): void;
  88859. /**
  88860. * Serializes the actions and its related information.
  88861. * @param parent defines the object to serialize in
  88862. * @returns the serialized object
  88863. */
  88864. serialize(parent: any): any;
  88865. }
  88866. /**
  88867. * This defines an action responsible to start an animation once triggered.
  88868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88869. */
  88870. export class PlayAnimationAction extends Action {
  88871. /**
  88872. * Where the animation should start (animation frame)
  88873. */
  88874. from: number;
  88875. /**
  88876. * Where the animation should stop (animation frame)
  88877. */
  88878. to: number;
  88879. /**
  88880. * Define if the animation should loop or stop after the first play.
  88881. */
  88882. loop?: boolean;
  88883. private _target;
  88884. /**
  88885. * Instantiate the action
  88886. * @param triggerOptions defines the trigger options
  88887. * @param target defines the target animation or animation name
  88888. * @param from defines from where the animation should start (animation frame)
  88889. * @param end defines where the animation should stop (animation frame)
  88890. * @param loop defines if the animation should loop or stop after the first play
  88891. * @param condition defines the trigger related conditions
  88892. */
  88893. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88894. /** @hidden */
  88895. _prepare(): void;
  88896. /**
  88897. * Execute the action and play the animation.
  88898. */
  88899. execute(): void;
  88900. /**
  88901. * Serializes the actions and its related information.
  88902. * @param parent defines the object to serialize in
  88903. * @returns the serialized object
  88904. */
  88905. serialize(parent: any): any;
  88906. }
  88907. /**
  88908. * This defines an action responsible to stop an animation once triggered.
  88909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88910. */
  88911. export class StopAnimationAction extends Action {
  88912. private _target;
  88913. /**
  88914. * Instantiate the action
  88915. * @param triggerOptions defines the trigger options
  88916. * @param target defines the target animation or animation name
  88917. * @param condition defines the trigger related conditions
  88918. */
  88919. constructor(triggerOptions: any, target: any, condition?: Condition);
  88920. /** @hidden */
  88921. _prepare(): void;
  88922. /**
  88923. * Execute the action and stop the animation.
  88924. */
  88925. execute(): void;
  88926. /**
  88927. * Serializes the actions and its related information.
  88928. * @param parent defines the object to serialize in
  88929. * @returns the serialized object
  88930. */
  88931. serialize(parent: any): any;
  88932. }
  88933. /**
  88934. * This defines an action responsible that does nothing once triggered.
  88935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88936. */
  88937. export class DoNothingAction extends Action {
  88938. /**
  88939. * Instantiate the action
  88940. * @param triggerOptions defines the trigger options
  88941. * @param condition defines the trigger related conditions
  88942. */
  88943. constructor(triggerOptions?: any, condition?: Condition);
  88944. /**
  88945. * Execute the action and do nothing.
  88946. */
  88947. execute(): void;
  88948. /**
  88949. * Serializes the actions and its related information.
  88950. * @param parent defines the object to serialize in
  88951. * @returns the serialized object
  88952. */
  88953. serialize(parent: any): any;
  88954. }
  88955. /**
  88956. * This defines an action responsible to trigger several actions once triggered.
  88957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88958. */
  88959. export class CombineAction extends Action {
  88960. /**
  88961. * The list of aggregated animations to run.
  88962. */
  88963. children: Action[];
  88964. /**
  88965. * Instantiate the action
  88966. * @param triggerOptions defines the trigger options
  88967. * @param children defines the list of aggregated animations to run
  88968. * @param condition defines the trigger related conditions
  88969. */
  88970. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88971. /** @hidden */
  88972. _prepare(): void;
  88973. /**
  88974. * Execute the action and executes all the aggregated actions.
  88975. */
  88976. execute(evt: ActionEvent): void;
  88977. /**
  88978. * Serializes the actions and its related information.
  88979. * @param parent defines the object to serialize in
  88980. * @returns the serialized object
  88981. */
  88982. serialize(parent: any): any;
  88983. }
  88984. /**
  88985. * This defines an action responsible to run code (external event) once triggered.
  88986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88987. */
  88988. export class ExecuteCodeAction extends Action {
  88989. /**
  88990. * The callback function to run.
  88991. */
  88992. func: (evt: ActionEvent) => void;
  88993. /**
  88994. * Instantiate the action
  88995. * @param triggerOptions defines the trigger options
  88996. * @param func defines the callback function to run
  88997. * @param condition defines the trigger related conditions
  88998. */
  88999. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89000. /**
  89001. * Execute the action and run the attached code.
  89002. */
  89003. execute(evt: ActionEvent): void;
  89004. }
  89005. /**
  89006. * This defines an action responsible to set the parent property of the target once triggered.
  89007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89008. */
  89009. export class SetParentAction extends Action {
  89010. private _parent;
  89011. private _target;
  89012. /**
  89013. * Instantiate the action
  89014. * @param triggerOptions defines the trigger options
  89015. * @param target defines the target containing the parent property
  89016. * @param parent defines from where the animation should start (animation frame)
  89017. * @param condition defines the trigger related conditions
  89018. */
  89019. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89020. /** @hidden */
  89021. _prepare(): void;
  89022. /**
  89023. * Execute the action and set the parent property.
  89024. */
  89025. execute(): void;
  89026. /**
  89027. * Serializes the actions and its related information.
  89028. * @param parent defines the object to serialize in
  89029. * @returns the serialized object
  89030. */
  89031. serialize(parent: any): any;
  89032. }
  89033. }
  89034. declare module BABYLON {
  89035. /**
  89036. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89037. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89039. */
  89040. export class ActionManager extends AbstractActionManager {
  89041. /**
  89042. * Nothing
  89043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89044. */
  89045. static readonly NothingTrigger: number;
  89046. /**
  89047. * On pick
  89048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89049. */
  89050. static readonly OnPickTrigger: number;
  89051. /**
  89052. * On left pick
  89053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89054. */
  89055. static readonly OnLeftPickTrigger: number;
  89056. /**
  89057. * On right pick
  89058. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89059. */
  89060. static readonly OnRightPickTrigger: number;
  89061. /**
  89062. * On center pick
  89063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89064. */
  89065. static readonly OnCenterPickTrigger: number;
  89066. /**
  89067. * On pick down
  89068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89069. */
  89070. static readonly OnPickDownTrigger: number;
  89071. /**
  89072. * On double pick
  89073. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89074. */
  89075. static readonly OnDoublePickTrigger: number;
  89076. /**
  89077. * On pick up
  89078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89079. */
  89080. static readonly OnPickUpTrigger: number;
  89081. /**
  89082. * On pick out.
  89083. * This trigger will only be raised if you also declared a OnPickDown
  89084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89085. */
  89086. static readonly OnPickOutTrigger: number;
  89087. /**
  89088. * On long press
  89089. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89090. */
  89091. static readonly OnLongPressTrigger: number;
  89092. /**
  89093. * On pointer over
  89094. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89095. */
  89096. static readonly OnPointerOverTrigger: number;
  89097. /**
  89098. * On pointer out
  89099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89100. */
  89101. static readonly OnPointerOutTrigger: number;
  89102. /**
  89103. * On every frame
  89104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89105. */
  89106. static readonly OnEveryFrameTrigger: number;
  89107. /**
  89108. * On intersection enter
  89109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89110. */
  89111. static readonly OnIntersectionEnterTrigger: number;
  89112. /**
  89113. * On intersection exit
  89114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89115. */
  89116. static readonly OnIntersectionExitTrigger: number;
  89117. /**
  89118. * On key down
  89119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89120. */
  89121. static readonly OnKeyDownTrigger: number;
  89122. /**
  89123. * On key up
  89124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89125. */
  89126. static readonly OnKeyUpTrigger: number;
  89127. private _scene;
  89128. /**
  89129. * Creates a new action manager
  89130. * @param scene defines the hosting scene
  89131. */
  89132. constructor(scene: Scene);
  89133. /**
  89134. * Releases all associated resources
  89135. */
  89136. dispose(): void;
  89137. /**
  89138. * Gets hosting scene
  89139. * @returns the hosting scene
  89140. */
  89141. getScene(): Scene;
  89142. /**
  89143. * Does this action manager handles actions of any of the given triggers
  89144. * @param triggers defines the triggers to be tested
  89145. * @return a boolean indicating whether one (or more) of the triggers is handled
  89146. */
  89147. hasSpecificTriggers(triggers: number[]): boolean;
  89148. /**
  89149. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89150. * speed.
  89151. * @param triggerA defines the trigger to be tested
  89152. * @param triggerB defines the trigger to be tested
  89153. * @return a boolean indicating whether one (or more) of the triggers is handled
  89154. */
  89155. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89156. /**
  89157. * Does this action manager handles actions of a given trigger
  89158. * @param trigger defines the trigger to be tested
  89159. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89160. * @return whether the trigger is handled
  89161. */
  89162. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89163. /**
  89164. * Does this action manager has pointer triggers
  89165. */
  89166. get hasPointerTriggers(): boolean;
  89167. /**
  89168. * Does this action manager has pick triggers
  89169. */
  89170. get hasPickTriggers(): boolean;
  89171. /**
  89172. * Registers an action to this action manager
  89173. * @param action defines the action to be registered
  89174. * @return the action amended (prepared) after registration
  89175. */
  89176. registerAction(action: IAction): Nullable<IAction>;
  89177. /**
  89178. * Unregisters an action to this action manager
  89179. * @param action defines the action to be unregistered
  89180. * @return a boolean indicating whether the action has been unregistered
  89181. */
  89182. unregisterAction(action: IAction): Boolean;
  89183. /**
  89184. * Process a specific trigger
  89185. * @param trigger defines the trigger to process
  89186. * @param evt defines the event details to be processed
  89187. */
  89188. processTrigger(trigger: number, evt?: IActionEvent): void;
  89189. /** @hidden */
  89190. _getEffectiveTarget(target: any, propertyPath: string): any;
  89191. /** @hidden */
  89192. _getProperty(propertyPath: string): string;
  89193. /**
  89194. * Serialize this manager to a JSON object
  89195. * @param name defines the property name to store this manager
  89196. * @returns a JSON representation of this manager
  89197. */
  89198. serialize(name: string): any;
  89199. /**
  89200. * Creates a new ActionManager from a JSON data
  89201. * @param parsedActions defines the JSON data to read from
  89202. * @param object defines the hosting mesh
  89203. * @param scene defines the hosting scene
  89204. */
  89205. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89206. /**
  89207. * Get a trigger name by index
  89208. * @param trigger defines the trigger index
  89209. * @returns a trigger name
  89210. */
  89211. static GetTriggerName(trigger: number): string;
  89212. }
  89213. }
  89214. declare module BABYLON {
  89215. /**
  89216. * Class used to represent a sprite
  89217. * @see https://doc.babylonjs.com/babylon101/sprites
  89218. */
  89219. export class Sprite implements IAnimatable {
  89220. /** defines the name */
  89221. name: string;
  89222. /** Gets or sets the current world position */
  89223. position: Vector3;
  89224. /** Gets or sets the main color */
  89225. color: Color4;
  89226. /** Gets or sets the width */
  89227. width: number;
  89228. /** Gets or sets the height */
  89229. height: number;
  89230. /** Gets or sets rotation angle */
  89231. angle: number;
  89232. /** Gets or sets the cell index in the sprite sheet */
  89233. cellIndex: number;
  89234. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89235. cellRef: string;
  89236. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89237. invertU: boolean;
  89238. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89239. invertV: boolean;
  89240. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89241. disposeWhenFinishedAnimating: boolean;
  89242. /** Gets the list of attached animations */
  89243. animations: Nullable<Array<Animation>>;
  89244. /** Gets or sets a boolean indicating if the sprite can be picked */
  89245. isPickable: boolean;
  89246. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89247. useAlphaForPicking: boolean;
  89248. /** @hidden */
  89249. _xOffset: number;
  89250. /** @hidden */
  89251. _yOffset: number;
  89252. /** @hidden */
  89253. _xSize: number;
  89254. /** @hidden */
  89255. _ySize: number;
  89256. /**
  89257. * Gets or sets the associated action manager
  89258. */
  89259. actionManager: Nullable<ActionManager>;
  89260. /**
  89261. * An event triggered when the control has been disposed
  89262. */
  89263. onDisposeObservable: Observable<Sprite>;
  89264. private _animationStarted;
  89265. private _loopAnimation;
  89266. private _fromIndex;
  89267. private _toIndex;
  89268. private _delay;
  89269. private _direction;
  89270. private _manager;
  89271. private _time;
  89272. private _onAnimationEnd;
  89273. /**
  89274. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89275. */
  89276. isVisible: boolean;
  89277. /**
  89278. * Gets or sets the sprite size
  89279. */
  89280. get size(): number;
  89281. set size(value: number);
  89282. /**
  89283. * Returns a boolean indicating if the animation is started
  89284. */
  89285. get animationStarted(): boolean;
  89286. /**
  89287. * Gets or sets the unique id of the sprite
  89288. */
  89289. uniqueId: number;
  89290. /**
  89291. * Gets the manager of this sprite
  89292. */
  89293. get manager(): ISpriteManager;
  89294. /**
  89295. * Creates a new Sprite
  89296. * @param name defines the name
  89297. * @param manager defines the manager
  89298. */
  89299. constructor(
  89300. /** defines the name */
  89301. name: string, manager: ISpriteManager);
  89302. /**
  89303. * Returns the string "Sprite"
  89304. * @returns "Sprite"
  89305. */
  89306. getClassName(): string;
  89307. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89308. get fromIndex(): number;
  89309. set fromIndex(value: number);
  89310. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89311. get toIndex(): number;
  89312. set toIndex(value: number);
  89313. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89314. get loopAnimation(): boolean;
  89315. set loopAnimation(value: boolean);
  89316. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89317. get delay(): number;
  89318. set delay(value: number);
  89319. /**
  89320. * Starts an animation
  89321. * @param from defines the initial key
  89322. * @param to defines the end key
  89323. * @param loop defines if the animation must loop
  89324. * @param delay defines the start delay (in ms)
  89325. * @param onAnimationEnd defines a callback to call when animation ends
  89326. */
  89327. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89328. /** Stops current animation (if any) */
  89329. stopAnimation(): void;
  89330. /** @hidden */
  89331. _animate(deltaTime: number): void;
  89332. /** Release associated resources */
  89333. dispose(): void;
  89334. /**
  89335. * Serializes the sprite to a JSON object
  89336. * @returns the JSON object
  89337. */
  89338. serialize(): any;
  89339. /**
  89340. * Parses a JSON object to create a new sprite
  89341. * @param parsedSprite The JSON object to parse
  89342. * @param manager defines the hosting manager
  89343. * @returns the new sprite
  89344. */
  89345. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89346. }
  89347. }
  89348. declare module BABYLON {
  89349. /**
  89350. * Information about the result of picking within a scene
  89351. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89352. */
  89353. export class PickingInfo {
  89354. /** @hidden */
  89355. _pickingUnavailable: boolean;
  89356. /**
  89357. * If the pick collided with an object
  89358. */
  89359. hit: boolean;
  89360. /**
  89361. * Distance away where the pick collided
  89362. */
  89363. distance: number;
  89364. /**
  89365. * The location of pick collision
  89366. */
  89367. pickedPoint: Nullable<Vector3>;
  89368. /**
  89369. * The mesh corresponding the the pick collision
  89370. */
  89371. pickedMesh: Nullable<AbstractMesh>;
  89372. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89373. bu: number;
  89374. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89375. bv: number;
  89376. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89377. faceId: number;
  89378. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89379. subMeshFaceId: number;
  89380. /** Id of the the submesh that was picked */
  89381. subMeshId: number;
  89382. /** If a sprite was picked, this will be the sprite the pick collided with */
  89383. pickedSprite: Nullable<Sprite>;
  89384. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89385. thinInstanceIndex: number;
  89386. /**
  89387. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89388. */
  89389. originMesh: Nullable<AbstractMesh>;
  89390. /**
  89391. * The ray that was used to perform the picking.
  89392. */
  89393. ray: Nullable<Ray>;
  89394. /**
  89395. * Gets the normal correspodning to the face the pick collided with
  89396. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89397. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89398. * @returns The normal correspodning to the face the pick collided with
  89399. */
  89400. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89401. /**
  89402. * Gets the texture coordinates of where the pick occured
  89403. * @returns the vector containing the coordnates of the texture
  89404. */
  89405. getTextureCoordinates(): Nullable<Vector2>;
  89406. }
  89407. }
  89408. declare module BABYLON {
  89409. /**
  89410. * Class representing a ray with position and direction
  89411. */
  89412. export class Ray {
  89413. /** origin point */
  89414. origin: Vector3;
  89415. /** direction */
  89416. direction: Vector3;
  89417. /** length of the ray */
  89418. length: number;
  89419. private static readonly _TmpVector3;
  89420. private _tmpRay;
  89421. /**
  89422. * Creates a new ray
  89423. * @param origin origin point
  89424. * @param direction direction
  89425. * @param length length of the ray
  89426. */
  89427. constructor(
  89428. /** origin point */
  89429. origin: Vector3,
  89430. /** direction */
  89431. direction: Vector3,
  89432. /** length of the ray */
  89433. length?: number);
  89434. /**
  89435. * Checks if the ray intersects a box
  89436. * This does not account for the ray lenght by design to improve perfs.
  89437. * @param minimum bound of the box
  89438. * @param maximum bound of the box
  89439. * @param intersectionTreshold extra extend to be added to the box in all direction
  89440. * @returns if the box was hit
  89441. */
  89442. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89443. /**
  89444. * Checks if the ray intersects a box
  89445. * This does not account for the ray lenght by design to improve perfs.
  89446. * @param box the bounding box to check
  89447. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89448. * @returns if the box was hit
  89449. */
  89450. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89451. /**
  89452. * If the ray hits a sphere
  89453. * @param sphere the bounding sphere to check
  89454. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89455. * @returns true if it hits the sphere
  89456. */
  89457. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89458. /**
  89459. * If the ray hits a triange
  89460. * @param vertex0 triangle vertex
  89461. * @param vertex1 triangle vertex
  89462. * @param vertex2 triangle vertex
  89463. * @returns intersection information if hit
  89464. */
  89465. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89466. /**
  89467. * Checks if ray intersects a plane
  89468. * @param plane the plane to check
  89469. * @returns the distance away it was hit
  89470. */
  89471. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89472. /**
  89473. * Calculate the intercept of a ray on a given axis
  89474. * @param axis to check 'x' | 'y' | 'z'
  89475. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89476. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89477. */
  89478. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89479. /**
  89480. * Checks if ray intersects a mesh
  89481. * @param mesh the mesh to check
  89482. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89483. * @returns picking info of the intersecton
  89484. */
  89485. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89486. /**
  89487. * Checks if ray intersects a mesh
  89488. * @param meshes the meshes to check
  89489. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89490. * @param results array to store result in
  89491. * @returns Array of picking infos
  89492. */
  89493. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89494. private _comparePickingInfo;
  89495. private static smallnum;
  89496. private static rayl;
  89497. /**
  89498. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89499. * @param sega the first point of the segment to test the intersection against
  89500. * @param segb the second point of the segment to test the intersection against
  89501. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89502. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89503. */
  89504. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89505. /**
  89506. * Update the ray from viewport position
  89507. * @param x position
  89508. * @param y y position
  89509. * @param viewportWidth viewport width
  89510. * @param viewportHeight viewport height
  89511. * @param world world matrix
  89512. * @param view view matrix
  89513. * @param projection projection matrix
  89514. * @returns this ray updated
  89515. */
  89516. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89517. /**
  89518. * Creates a ray with origin and direction of 0,0,0
  89519. * @returns the new ray
  89520. */
  89521. static Zero(): Ray;
  89522. /**
  89523. * Creates a new ray from screen space and viewport
  89524. * @param x position
  89525. * @param y y position
  89526. * @param viewportWidth viewport width
  89527. * @param viewportHeight viewport height
  89528. * @param world world matrix
  89529. * @param view view matrix
  89530. * @param projection projection matrix
  89531. * @returns new ray
  89532. */
  89533. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89534. /**
  89535. * 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
  89536. * transformed to the given world matrix.
  89537. * @param origin The origin point
  89538. * @param end The end point
  89539. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89540. * @returns the new ray
  89541. */
  89542. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89543. /**
  89544. * Transforms a ray by a matrix
  89545. * @param ray ray to transform
  89546. * @param matrix matrix to apply
  89547. * @returns the resulting new ray
  89548. */
  89549. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89550. /**
  89551. * Transforms a ray by a matrix
  89552. * @param ray ray to transform
  89553. * @param matrix matrix to apply
  89554. * @param result ray to store result in
  89555. */
  89556. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89557. /**
  89558. * Unproject a ray from screen space to object space
  89559. * @param sourceX defines the screen space x coordinate to use
  89560. * @param sourceY defines the screen space y coordinate to use
  89561. * @param viewportWidth defines the current width of the viewport
  89562. * @param viewportHeight defines the current height of the viewport
  89563. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89564. * @param view defines the view matrix to use
  89565. * @param projection defines the projection matrix to use
  89566. */
  89567. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89568. }
  89569. /**
  89570. * Type used to define predicate used to select faces when a mesh intersection is detected
  89571. */
  89572. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89573. interface Scene {
  89574. /** @hidden */
  89575. _tempPickingRay: Nullable<Ray>;
  89576. /** @hidden */
  89577. _cachedRayForTransform: Ray;
  89578. /** @hidden */
  89579. _pickWithRayInverseMatrix: Matrix;
  89580. /** @hidden */
  89581. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89582. /** @hidden */
  89583. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89584. /** @hidden */
  89585. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89586. }
  89587. }
  89588. declare module BABYLON {
  89589. /**
  89590. * Groups all the scene component constants in one place to ease maintenance.
  89591. * @hidden
  89592. */
  89593. export class SceneComponentConstants {
  89594. static readonly NAME_EFFECTLAYER: string;
  89595. static readonly NAME_LAYER: string;
  89596. static readonly NAME_LENSFLARESYSTEM: string;
  89597. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89598. static readonly NAME_PARTICLESYSTEM: string;
  89599. static readonly NAME_GAMEPAD: string;
  89600. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89601. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89602. static readonly NAME_PREPASSRENDERER: string;
  89603. static readonly NAME_DEPTHRENDERER: string;
  89604. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89605. static readonly NAME_SPRITE: string;
  89606. static readonly NAME_OUTLINERENDERER: string;
  89607. static readonly NAME_PROCEDURALTEXTURE: string;
  89608. static readonly NAME_SHADOWGENERATOR: string;
  89609. static readonly NAME_OCTREE: string;
  89610. static readonly NAME_PHYSICSENGINE: string;
  89611. static readonly NAME_AUDIO: string;
  89612. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89613. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89614. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89615. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89616. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89617. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89618. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89619. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89620. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89621. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89622. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89623. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89624. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89625. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89626. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89627. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89628. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89629. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89630. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89631. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89632. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89633. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89634. static readonly STEP_AFTERRENDER_AUDIO: number;
  89635. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89636. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89637. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89638. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89639. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89640. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89641. static readonly STEP_POINTERMOVE_SPRITE: number;
  89642. static readonly STEP_POINTERDOWN_SPRITE: number;
  89643. static readonly STEP_POINTERUP_SPRITE: number;
  89644. }
  89645. /**
  89646. * This represents a scene component.
  89647. *
  89648. * This is used to decouple the dependency the scene is having on the different workloads like
  89649. * layers, post processes...
  89650. */
  89651. export interface ISceneComponent {
  89652. /**
  89653. * The name of the component. Each component must have a unique name.
  89654. */
  89655. name: string;
  89656. /**
  89657. * The scene the component belongs to.
  89658. */
  89659. scene: Scene;
  89660. /**
  89661. * Register the component to one instance of a scene.
  89662. */
  89663. register(): void;
  89664. /**
  89665. * Rebuilds the elements related to this component in case of
  89666. * context lost for instance.
  89667. */
  89668. rebuild(): void;
  89669. /**
  89670. * Disposes the component and the associated ressources.
  89671. */
  89672. dispose(): void;
  89673. }
  89674. /**
  89675. * This represents a SERIALIZABLE scene component.
  89676. *
  89677. * This extends Scene Component to add Serialization methods on top.
  89678. */
  89679. export interface ISceneSerializableComponent extends ISceneComponent {
  89680. /**
  89681. * Adds all the elements from the container to the scene
  89682. * @param container the container holding the elements
  89683. */
  89684. addFromContainer(container: AbstractScene): void;
  89685. /**
  89686. * Removes all the elements in the container from the scene
  89687. * @param container contains the elements to remove
  89688. * @param dispose if the removed element should be disposed (default: false)
  89689. */
  89690. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89691. /**
  89692. * Serializes the component data to the specified json object
  89693. * @param serializationObject The object to serialize to
  89694. */
  89695. serialize(serializationObject: any): void;
  89696. }
  89697. /**
  89698. * Strong typing of a Mesh related stage step action
  89699. */
  89700. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89701. /**
  89702. * Strong typing of a Evaluate Sub Mesh related stage step action
  89703. */
  89704. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89705. /**
  89706. * Strong typing of a Active Mesh related stage step action
  89707. */
  89708. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89709. /**
  89710. * Strong typing of a Camera related stage step action
  89711. */
  89712. export type CameraStageAction = (camera: Camera) => void;
  89713. /**
  89714. * Strong typing of a Camera Frame buffer related stage step action
  89715. */
  89716. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89717. /**
  89718. * Strong typing of a Render Target related stage step action
  89719. */
  89720. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89721. /**
  89722. * Strong typing of a RenderingGroup related stage step action
  89723. */
  89724. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89725. /**
  89726. * Strong typing of a Mesh Render related stage step action
  89727. */
  89728. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89729. /**
  89730. * Strong typing of a simple stage step action
  89731. */
  89732. export type SimpleStageAction = () => void;
  89733. /**
  89734. * Strong typing of a render target action.
  89735. */
  89736. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89737. /**
  89738. * Strong typing of a pointer move action.
  89739. */
  89740. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89741. /**
  89742. * Strong typing of a pointer up/down action.
  89743. */
  89744. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89745. /**
  89746. * Representation of a stage in the scene (Basically a list of ordered steps)
  89747. * @hidden
  89748. */
  89749. export class Stage<T extends Function> extends Array<{
  89750. index: number;
  89751. component: ISceneComponent;
  89752. action: T;
  89753. }> {
  89754. /**
  89755. * Hide ctor from the rest of the world.
  89756. * @param items The items to add.
  89757. */
  89758. private constructor();
  89759. /**
  89760. * Creates a new Stage.
  89761. * @returns A new instance of a Stage
  89762. */
  89763. static Create<T extends Function>(): Stage<T>;
  89764. /**
  89765. * Registers a step in an ordered way in the targeted stage.
  89766. * @param index Defines the position to register the step in
  89767. * @param component Defines the component attached to the step
  89768. * @param action Defines the action to launch during the step
  89769. */
  89770. registerStep(index: number, component: ISceneComponent, action: T): void;
  89771. /**
  89772. * Clears all the steps from the stage.
  89773. */
  89774. clear(): void;
  89775. }
  89776. }
  89777. declare module BABYLON {
  89778. interface Scene {
  89779. /** @hidden */
  89780. _pointerOverSprite: Nullable<Sprite>;
  89781. /** @hidden */
  89782. _pickedDownSprite: Nullable<Sprite>;
  89783. /** @hidden */
  89784. _tempSpritePickingRay: Nullable<Ray>;
  89785. /**
  89786. * All of the sprite managers added to this scene
  89787. * @see https://doc.babylonjs.com/babylon101/sprites
  89788. */
  89789. spriteManagers: Array<ISpriteManager>;
  89790. /**
  89791. * An event triggered when sprites rendering is about to start
  89792. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89793. */
  89794. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89795. /**
  89796. * An event triggered when sprites rendering is done
  89797. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89798. */
  89799. onAfterSpritesRenderingObservable: Observable<Scene>;
  89800. /** @hidden */
  89801. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89802. /** Launch a ray to try to pick a sprite in the scene
  89803. * @param x position on screen
  89804. * @param y position on screen
  89805. * @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
  89806. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89807. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89808. * @returns a PickingInfo
  89809. */
  89810. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89811. /** Use the given ray to pick a sprite in the scene
  89812. * @param ray The ray (in world space) to use to pick meshes
  89813. * @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
  89814. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89815. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89816. * @returns a PickingInfo
  89817. */
  89818. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89819. /** @hidden */
  89820. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89821. /** Launch a ray to try to pick sprites in the scene
  89822. * @param x position on screen
  89823. * @param y position on screen
  89824. * @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
  89825. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89826. * @returns a PickingInfo array
  89827. */
  89828. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89829. /** Use the given ray to pick sprites in the scene
  89830. * @param ray The ray (in world space) to use to pick meshes
  89831. * @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
  89832. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89833. * @returns a PickingInfo array
  89834. */
  89835. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89836. /**
  89837. * Force the sprite under the pointer
  89838. * @param sprite defines the sprite to use
  89839. */
  89840. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89841. /**
  89842. * Gets the sprite under the pointer
  89843. * @returns a Sprite or null if no sprite is under the pointer
  89844. */
  89845. getPointerOverSprite(): Nullable<Sprite>;
  89846. }
  89847. /**
  89848. * Defines the sprite scene component responsible to manage sprites
  89849. * in a given scene.
  89850. */
  89851. export class SpriteSceneComponent implements ISceneComponent {
  89852. /**
  89853. * The component name helpfull to identify the component in the list of scene components.
  89854. */
  89855. readonly name: string;
  89856. /**
  89857. * The scene the component belongs to.
  89858. */
  89859. scene: Scene;
  89860. /** @hidden */
  89861. private _spritePredicate;
  89862. /**
  89863. * Creates a new instance of the component for the given scene
  89864. * @param scene Defines the scene to register the component in
  89865. */
  89866. constructor(scene: Scene);
  89867. /**
  89868. * Registers the component in a given scene
  89869. */
  89870. register(): void;
  89871. /**
  89872. * Rebuilds the elements related to this component in case of
  89873. * context lost for instance.
  89874. */
  89875. rebuild(): void;
  89876. /**
  89877. * Disposes the component and the associated ressources.
  89878. */
  89879. dispose(): void;
  89880. private _pickSpriteButKeepRay;
  89881. private _pointerMove;
  89882. private _pointerDown;
  89883. private _pointerUp;
  89884. }
  89885. }
  89886. declare module BABYLON {
  89887. /** @hidden */
  89888. export var fogFragmentDeclaration: {
  89889. name: string;
  89890. shader: string;
  89891. };
  89892. }
  89893. declare module BABYLON {
  89894. /** @hidden */
  89895. export var fogFragment: {
  89896. name: string;
  89897. shader: string;
  89898. };
  89899. }
  89900. declare module BABYLON {
  89901. /** @hidden */
  89902. export var spritesPixelShader: {
  89903. name: string;
  89904. shader: string;
  89905. };
  89906. }
  89907. declare module BABYLON {
  89908. /** @hidden */
  89909. export var fogVertexDeclaration: {
  89910. name: string;
  89911. shader: string;
  89912. };
  89913. }
  89914. declare module BABYLON {
  89915. /** @hidden */
  89916. export var spritesVertexShader: {
  89917. name: string;
  89918. shader: string;
  89919. };
  89920. }
  89921. declare module BABYLON {
  89922. /**
  89923. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89924. */
  89925. export interface ISpriteManager extends IDisposable {
  89926. /**
  89927. * Gets manager's name
  89928. */
  89929. name: string;
  89930. /**
  89931. * Restricts the camera to viewing objects with the same layerMask.
  89932. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89933. */
  89934. layerMask: number;
  89935. /**
  89936. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89937. */
  89938. isPickable: boolean;
  89939. /**
  89940. * Gets the hosting scene
  89941. */
  89942. scene: Scene;
  89943. /**
  89944. * Specifies the rendering group id for this mesh (0 by default)
  89945. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89946. */
  89947. renderingGroupId: number;
  89948. /**
  89949. * Defines the list of sprites managed by the manager.
  89950. */
  89951. sprites: Array<Sprite>;
  89952. /**
  89953. * Gets or sets the spritesheet texture
  89954. */
  89955. texture: Texture;
  89956. /** Defines the default width of a cell in the spritesheet */
  89957. cellWidth: number;
  89958. /** Defines the default height of a cell in the spritesheet */
  89959. cellHeight: number;
  89960. /**
  89961. * Tests the intersection of a sprite with a specific ray.
  89962. * @param ray The ray we are sending to test the collision
  89963. * @param camera The camera space we are sending rays in
  89964. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89965. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89966. * @returns picking info or null.
  89967. */
  89968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89969. /**
  89970. * Intersects the sprites with a ray
  89971. * @param ray defines the ray to intersect with
  89972. * @param camera defines the current active camera
  89973. * @param predicate defines a predicate used to select candidate sprites
  89974. * @returns null if no hit or a PickingInfo array
  89975. */
  89976. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89977. /**
  89978. * Renders the list of sprites on screen.
  89979. */
  89980. render(): void;
  89981. }
  89982. /**
  89983. * Class used to manage multiple sprites on the same spritesheet
  89984. * @see https://doc.babylonjs.com/babylon101/sprites
  89985. */
  89986. export class SpriteManager implements ISpriteManager {
  89987. /** defines the manager's name */
  89988. name: string;
  89989. /** Define the Url to load snippets */
  89990. static SnippetUrl: string;
  89991. /** Snippet ID if the manager was created from the snippet server */
  89992. snippetId: string;
  89993. /** Gets the list of sprites */
  89994. sprites: Sprite[];
  89995. /** Gets or sets the rendering group id (0 by default) */
  89996. renderingGroupId: number;
  89997. /** Gets or sets camera layer mask */
  89998. layerMask: number;
  89999. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90000. fogEnabled: boolean;
  90001. /** Gets or sets a boolean indicating if the sprites are pickable */
  90002. isPickable: boolean;
  90003. /** Defines the default width of a cell in the spritesheet */
  90004. cellWidth: number;
  90005. /** Defines the default height of a cell in the spritesheet */
  90006. cellHeight: number;
  90007. /** Associative array from JSON sprite data file */
  90008. private _cellData;
  90009. /** Array of sprite names from JSON sprite data file */
  90010. private _spriteMap;
  90011. /** True when packed cell data from JSON file is ready*/
  90012. private _packedAndReady;
  90013. private _textureContent;
  90014. private _useInstancing;
  90015. /**
  90016. * An event triggered when the manager is disposed.
  90017. */
  90018. onDisposeObservable: Observable<SpriteManager>;
  90019. private _onDisposeObserver;
  90020. /**
  90021. * Callback called when the manager is disposed
  90022. */
  90023. set onDispose(callback: () => void);
  90024. private _capacity;
  90025. private _fromPacked;
  90026. private _spriteTexture;
  90027. private _epsilon;
  90028. private _scene;
  90029. private _vertexData;
  90030. private _buffer;
  90031. private _vertexBuffers;
  90032. private _spriteBuffer;
  90033. private _indexBuffer;
  90034. private _effectBase;
  90035. private _effectFog;
  90036. private _vertexBufferSize;
  90037. /**
  90038. * Gets or sets the unique id of the sprite
  90039. */
  90040. uniqueId: number;
  90041. /**
  90042. * Gets the array of sprites
  90043. */
  90044. get children(): Sprite[];
  90045. /**
  90046. * Gets the hosting scene
  90047. */
  90048. get scene(): Scene;
  90049. /**
  90050. * Gets the capacity of the manager
  90051. */
  90052. get capacity(): number;
  90053. /**
  90054. * Gets or sets the spritesheet texture
  90055. */
  90056. get texture(): Texture;
  90057. set texture(value: Texture);
  90058. private _blendMode;
  90059. /**
  90060. * Blend mode use to render the particle, it can be any of
  90061. * the static Constants.ALPHA_x properties provided in this class.
  90062. * Default value is Constants.ALPHA_COMBINE
  90063. */
  90064. get blendMode(): number;
  90065. set blendMode(blendMode: number);
  90066. /** Disables writing to the depth buffer when rendering the sprites.
  90067. * It can be handy to disable depth writing when using textures without alpha channel
  90068. * and setting some specific blend modes.
  90069. */
  90070. disableDepthWrite: boolean;
  90071. /**
  90072. * Creates a new sprite manager
  90073. * @param name defines the manager's name
  90074. * @param imgUrl defines the sprite sheet url
  90075. * @param capacity defines the maximum allowed number of sprites
  90076. * @param cellSize defines the size of a sprite cell
  90077. * @param scene defines the hosting scene
  90078. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90079. * @param samplingMode defines the smapling mode to use with spritesheet
  90080. * @param fromPacked set to false; do not alter
  90081. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90082. */
  90083. constructor(
  90084. /** defines the manager's name */
  90085. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90086. /**
  90087. * Returns the string "SpriteManager"
  90088. * @returns "SpriteManager"
  90089. */
  90090. getClassName(): string;
  90091. private _makePacked;
  90092. private _appendSpriteVertex;
  90093. private _checkTextureAlpha;
  90094. /**
  90095. * Intersects the sprites with a ray
  90096. * @param ray defines the ray to intersect with
  90097. * @param camera defines the current active camera
  90098. * @param predicate defines a predicate used to select candidate sprites
  90099. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90100. * @returns null if no hit or a PickingInfo
  90101. */
  90102. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90103. /**
  90104. * Intersects the sprites with a ray
  90105. * @param ray defines the ray to intersect with
  90106. * @param camera defines the current active camera
  90107. * @param predicate defines a predicate used to select candidate sprites
  90108. * @returns null if no hit or a PickingInfo array
  90109. */
  90110. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90111. /**
  90112. * Render all child sprites
  90113. */
  90114. render(): void;
  90115. /**
  90116. * Release associated resources
  90117. */
  90118. dispose(): void;
  90119. /**
  90120. * Serializes the sprite manager to a JSON object
  90121. * @param serializeTexture defines if the texture must be serialized as well
  90122. * @returns the JSON object
  90123. */
  90124. serialize(serializeTexture?: boolean): any;
  90125. /**
  90126. * Parses a JSON object to create a new sprite manager.
  90127. * @param parsedManager The JSON object to parse
  90128. * @param scene The scene to create the sprite managerin
  90129. * @param rootUrl The root url to use to load external dependencies like texture
  90130. * @returns the new sprite manager
  90131. */
  90132. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90133. /**
  90134. * Creates a sprite manager from a snippet saved in a remote file
  90135. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90136. * @param url defines the url to load from
  90137. * @param scene defines the hosting scene
  90138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90139. * @returns a promise that will resolve to the new sprite manager
  90140. */
  90141. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90142. /**
  90143. * Creates a sprite manager from a snippet saved by the sprite editor
  90144. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90145. * @param scene defines the hosting scene
  90146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90147. * @returns a promise that will resolve to the new sprite manager
  90148. */
  90149. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90150. }
  90151. }
  90152. declare module BABYLON {
  90153. /** Interface used by value gradients (color, factor, ...) */
  90154. export interface IValueGradient {
  90155. /**
  90156. * Gets or sets the gradient value (between 0 and 1)
  90157. */
  90158. gradient: number;
  90159. }
  90160. /** Class used to store color4 gradient */
  90161. export class ColorGradient implements IValueGradient {
  90162. /**
  90163. * Gets or sets the gradient value (between 0 and 1)
  90164. */
  90165. gradient: number;
  90166. /**
  90167. * Gets or sets first associated color
  90168. */
  90169. color1: Color4;
  90170. /**
  90171. * Gets or sets second associated color
  90172. */
  90173. color2?: Color4 | undefined;
  90174. /**
  90175. * Creates a new color4 gradient
  90176. * @param gradient gets or sets the gradient value (between 0 and 1)
  90177. * @param color1 gets or sets first associated color
  90178. * @param color2 gets or sets first second color
  90179. */
  90180. constructor(
  90181. /**
  90182. * Gets or sets the gradient value (between 0 and 1)
  90183. */
  90184. gradient: number,
  90185. /**
  90186. * Gets or sets first associated color
  90187. */
  90188. color1: Color4,
  90189. /**
  90190. * Gets or sets second associated color
  90191. */
  90192. color2?: Color4 | undefined);
  90193. /**
  90194. * Will get a color picked randomly between color1 and color2.
  90195. * If color2 is undefined then color1 will be used
  90196. * @param result defines the target Color4 to store the result in
  90197. */
  90198. getColorToRef(result: Color4): void;
  90199. }
  90200. /** Class used to store color 3 gradient */
  90201. export class Color3Gradient implements IValueGradient {
  90202. /**
  90203. * Gets or sets the gradient value (between 0 and 1)
  90204. */
  90205. gradient: number;
  90206. /**
  90207. * Gets or sets the associated color
  90208. */
  90209. color: Color3;
  90210. /**
  90211. * Creates a new color3 gradient
  90212. * @param gradient gets or sets the gradient value (between 0 and 1)
  90213. * @param color gets or sets associated color
  90214. */
  90215. constructor(
  90216. /**
  90217. * Gets or sets the gradient value (between 0 and 1)
  90218. */
  90219. gradient: number,
  90220. /**
  90221. * Gets or sets the associated color
  90222. */
  90223. color: Color3);
  90224. }
  90225. /** Class used to store factor gradient */
  90226. export class FactorGradient implements IValueGradient {
  90227. /**
  90228. * Gets or sets the gradient value (between 0 and 1)
  90229. */
  90230. gradient: number;
  90231. /**
  90232. * Gets or sets first associated factor
  90233. */
  90234. factor1: number;
  90235. /**
  90236. * Gets or sets second associated factor
  90237. */
  90238. factor2?: number | undefined;
  90239. /**
  90240. * Creates a new factor gradient
  90241. * @param gradient gets or sets the gradient value (between 0 and 1)
  90242. * @param factor1 gets or sets first associated factor
  90243. * @param factor2 gets or sets second associated factor
  90244. */
  90245. constructor(
  90246. /**
  90247. * Gets or sets the gradient value (between 0 and 1)
  90248. */
  90249. gradient: number,
  90250. /**
  90251. * Gets or sets first associated factor
  90252. */
  90253. factor1: number,
  90254. /**
  90255. * Gets or sets second associated factor
  90256. */
  90257. factor2?: number | undefined);
  90258. /**
  90259. * Will get a number picked randomly between factor1 and factor2.
  90260. * If factor2 is undefined then factor1 will be used
  90261. * @returns the picked number
  90262. */
  90263. getFactor(): number;
  90264. }
  90265. /**
  90266. * Helper used to simplify some generic gradient tasks
  90267. */
  90268. export class GradientHelper {
  90269. /**
  90270. * Gets the current gradient from an array of IValueGradient
  90271. * @param ratio defines the current ratio to get
  90272. * @param gradients defines the array of IValueGradient
  90273. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90274. */
  90275. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90276. }
  90277. }
  90278. declare module BABYLON {
  90279. interface ThinEngine {
  90280. /**
  90281. * Creates a raw texture
  90282. * @param data defines the data to store in the texture
  90283. * @param width defines the width of the texture
  90284. * @param height defines the height of the texture
  90285. * @param format defines the format of the data
  90286. * @param generateMipMaps defines if the engine should generate the mip levels
  90287. * @param invertY defines if data must be stored with Y axis inverted
  90288. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90289. * @param compression defines the compression used (null by default)
  90290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90291. * @returns the raw texture inside an InternalTexture
  90292. */
  90293. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90294. /**
  90295. * Update a raw texture
  90296. * @param texture defines the texture to update
  90297. * @param data defines the data to store in the texture
  90298. * @param format defines the format of the data
  90299. * @param invertY defines if data must be stored with Y axis inverted
  90300. */
  90301. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90302. /**
  90303. * Update a raw texture
  90304. * @param texture defines the texture to update
  90305. * @param data defines the data to store in the texture
  90306. * @param format defines the format of the data
  90307. * @param invertY defines if data must be stored with Y axis inverted
  90308. * @param compression defines the compression used (null by default)
  90309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90310. */
  90311. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90312. /**
  90313. * Creates a new raw cube texture
  90314. * @param data defines the array of data to use to create each face
  90315. * @param size defines the size of the textures
  90316. * @param format defines the format of the data
  90317. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90318. * @param generateMipMaps defines if the engine should generate the mip levels
  90319. * @param invertY defines if data must be stored with Y axis inverted
  90320. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90321. * @param compression defines the compression used (null by default)
  90322. * @returns the cube texture as an InternalTexture
  90323. */
  90324. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90325. /**
  90326. * Update a raw cube texture
  90327. * @param texture defines the texture to udpdate
  90328. * @param data defines the data to store
  90329. * @param format defines the data format
  90330. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90331. * @param invertY defines if data must be stored with Y axis inverted
  90332. */
  90333. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90334. /**
  90335. * Update a raw cube texture
  90336. * @param texture defines the texture to udpdate
  90337. * @param data defines the data to store
  90338. * @param format defines the data format
  90339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90340. * @param invertY defines if data must be stored with Y axis inverted
  90341. * @param compression defines the compression used (null by default)
  90342. */
  90343. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90344. /**
  90345. * Update a raw cube texture
  90346. * @param texture defines the texture to udpdate
  90347. * @param data defines the data to store
  90348. * @param format defines the data format
  90349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90350. * @param invertY defines if data must be stored with Y axis inverted
  90351. * @param compression defines the compression used (null by default)
  90352. * @param level defines which level of the texture to update
  90353. */
  90354. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90355. /**
  90356. * Creates a new raw cube texture from a specified url
  90357. * @param url defines the url where the data is located
  90358. * @param scene defines the current scene
  90359. * @param size defines the size of the textures
  90360. * @param format defines the format of the data
  90361. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90362. * @param noMipmap defines if the engine should avoid generating the mip levels
  90363. * @param callback defines a callback used to extract texture data from loaded data
  90364. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90365. * @param onLoad defines a callback called when texture is loaded
  90366. * @param onError defines a callback called if there is an error
  90367. * @returns the cube texture as an InternalTexture
  90368. */
  90369. 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;
  90370. /**
  90371. * Creates a new raw cube texture from a specified url
  90372. * @param url defines the url where the data is located
  90373. * @param scene defines the current scene
  90374. * @param size defines the size of the textures
  90375. * @param format defines the format of the data
  90376. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90377. * @param noMipmap defines if the engine should avoid generating the mip levels
  90378. * @param callback defines a callback used to extract texture data from loaded data
  90379. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90380. * @param onLoad defines a callback called when texture is loaded
  90381. * @param onError defines a callback called if there is an error
  90382. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90383. * @param invertY defines if data must be stored with Y axis inverted
  90384. * @returns the cube texture as an InternalTexture
  90385. */
  90386. 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;
  90387. /**
  90388. * Creates a new raw 3D texture
  90389. * @param data defines the data used to create the texture
  90390. * @param width defines the width of the texture
  90391. * @param height defines the height of the texture
  90392. * @param depth defines the depth of the texture
  90393. * @param format defines the format of the texture
  90394. * @param generateMipMaps defines if the engine must generate mip levels
  90395. * @param invertY defines if data must be stored with Y axis inverted
  90396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90397. * @param compression defines the compressed used (can be null)
  90398. * @param textureType defines the compressed used (can be null)
  90399. * @returns a new raw 3D texture (stored in an InternalTexture)
  90400. */
  90401. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90402. /**
  90403. * Update a raw 3D texture
  90404. * @param texture defines the texture to update
  90405. * @param data defines the data to store
  90406. * @param format defines the data format
  90407. * @param invertY defines if data must be stored with Y axis inverted
  90408. */
  90409. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90410. /**
  90411. * Update a raw 3D texture
  90412. * @param texture defines the texture to update
  90413. * @param data defines the data to store
  90414. * @param format defines the data format
  90415. * @param invertY defines if data must be stored with Y axis inverted
  90416. * @param compression defines the used compression (can be null)
  90417. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90418. */
  90419. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90420. /**
  90421. * Creates a new raw 2D array texture
  90422. * @param data defines the data used to create the texture
  90423. * @param width defines the width of the texture
  90424. * @param height defines the height of the texture
  90425. * @param depth defines the number of layers of the texture
  90426. * @param format defines the format of the texture
  90427. * @param generateMipMaps defines if the engine must generate mip levels
  90428. * @param invertY defines if data must be stored with Y axis inverted
  90429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90430. * @param compression defines the compressed used (can be null)
  90431. * @param textureType defines the compressed used (can be null)
  90432. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90433. */
  90434. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90435. /**
  90436. * Update a raw 2D array texture
  90437. * @param texture defines the texture to update
  90438. * @param data defines the data to store
  90439. * @param format defines the data format
  90440. * @param invertY defines if data must be stored with Y axis inverted
  90441. */
  90442. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90443. /**
  90444. * Update a raw 2D array texture
  90445. * @param texture defines the texture to update
  90446. * @param data defines the data to store
  90447. * @param format defines the data format
  90448. * @param invertY defines if data must be stored with Y axis inverted
  90449. * @param compression defines the used compression (can be null)
  90450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90451. */
  90452. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90453. }
  90454. }
  90455. declare module BABYLON {
  90456. /**
  90457. * Raw texture can help creating a texture directly from an array of data.
  90458. * This can be super useful if you either get the data from an uncompressed source or
  90459. * if you wish to create your texture pixel by pixel.
  90460. */
  90461. export class RawTexture extends Texture {
  90462. /**
  90463. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90464. */
  90465. format: number;
  90466. /**
  90467. * Instantiates a new RawTexture.
  90468. * Raw texture can help creating a texture directly from an array of data.
  90469. * This can be super useful if you either get the data from an uncompressed source or
  90470. * if you wish to create your texture pixel by pixel.
  90471. * @param data define the array of data to use to create the texture
  90472. * @param width define the width of the texture
  90473. * @param height define the height of the texture
  90474. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90475. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90476. * @param generateMipMaps define whether mip maps should be generated or not
  90477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90480. */
  90481. constructor(data: ArrayBufferView, width: number, height: number,
  90482. /**
  90483. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90484. */
  90485. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90486. /**
  90487. * Updates the texture underlying data.
  90488. * @param data Define the new data of the texture
  90489. */
  90490. update(data: ArrayBufferView): void;
  90491. /**
  90492. * Creates a luminance texture from some data.
  90493. * @param data Define the texture data
  90494. * @param width Define the width of the texture
  90495. * @param height Define the height of the texture
  90496. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90497. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90498. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90499. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90500. * @returns the luminance texture
  90501. */
  90502. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90503. /**
  90504. * Creates a luminance alpha texture from some data.
  90505. * @param data Define the texture data
  90506. * @param width Define the width of the texture
  90507. * @param height Define the height of the texture
  90508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90512. * @returns the luminance alpha texture
  90513. */
  90514. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90515. /**
  90516. * Creates an alpha texture from some data.
  90517. * @param data Define the texture data
  90518. * @param width Define the width of the texture
  90519. * @param height Define the height of the texture
  90520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90524. * @returns the alpha texture
  90525. */
  90526. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90527. /**
  90528. * Creates a RGB texture from some data.
  90529. * @param data Define the texture data
  90530. * @param width Define the width of the texture
  90531. * @param height Define the height of the texture
  90532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90536. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90537. * @returns the RGB alpha texture
  90538. */
  90539. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90540. /**
  90541. * Creates a RGBA texture from some data.
  90542. * @param data Define the texture data
  90543. * @param width Define the width of the texture
  90544. * @param height Define the height of the texture
  90545. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90546. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90550. * @returns the RGBA texture
  90551. */
  90552. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90553. /**
  90554. * Creates a R texture from some data.
  90555. * @param data Define the texture data
  90556. * @param width Define the width of the texture
  90557. * @param height Define the height of the texture
  90558. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90559. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90560. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90561. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90562. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90563. * @returns the R texture
  90564. */
  90565. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90566. }
  90567. }
  90568. declare module BABYLON {
  90569. interface AbstractScene {
  90570. /**
  90571. * The list of procedural textures added to the scene
  90572. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90573. */
  90574. proceduralTextures: Array<ProceduralTexture>;
  90575. }
  90576. /**
  90577. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90578. * in a given scene.
  90579. */
  90580. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90581. /**
  90582. * The component name helpfull to identify the component in the list of scene components.
  90583. */
  90584. readonly name: string;
  90585. /**
  90586. * The scene the component belongs to.
  90587. */
  90588. scene: Scene;
  90589. /**
  90590. * Creates a new instance of the component for the given scene
  90591. * @param scene Defines the scene to register the component in
  90592. */
  90593. constructor(scene: Scene);
  90594. /**
  90595. * Registers the component in a given scene
  90596. */
  90597. register(): void;
  90598. /**
  90599. * Rebuilds the elements related to this component in case of
  90600. * context lost for instance.
  90601. */
  90602. rebuild(): void;
  90603. /**
  90604. * Disposes the component and the associated ressources.
  90605. */
  90606. dispose(): void;
  90607. private _beforeClear;
  90608. }
  90609. }
  90610. declare module BABYLON {
  90611. interface ThinEngine {
  90612. /**
  90613. * Creates a new render target cube texture
  90614. * @param size defines the size of the texture
  90615. * @param options defines the options used to create the texture
  90616. * @returns a new render target cube texture stored in an InternalTexture
  90617. */
  90618. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90619. }
  90620. }
  90621. declare module BABYLON {
  90622. /** @hidden */
  90623. export var proceduralVertexShader: {
  90624. name: string;
  90625. shader: string;
  90626. };
  90627. }
  90628. declare module BABYLON {
  90629. /**
  90630. * 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.
  90631. * This is the base class of any Procedural texture and contains most of the shareable code.
  90632. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90633. */
  90634. export class ProceduralTexture extends Texture {
  90635. isCube: boolean;
  90636. /**
  90637. * Define if the texture is enabled or not (disabled texture will not render)
  90638. */
  90639. isEnabled: boolean;
  90640. /**
  90641. * Define if the texture must be cleared before rendering (default is true)
  90642. */
  90643. autoClear: boolean;
  90644. /**
  90645. * Callback called when the texture is generated
  90646. */
  90647. onGenerated: () => void;
  90648. /**
  90649. * Event raised when the texture is generated
  90650. */
  90651. onGeneratedObservable: Observable<ProceduralTexture>;
  90652. /** @hidden */
  90653. _generateMipMaps: boolean;
  90654. /** @hidden **/
  90655. _effect: Effect;
  90656. /** @hidden */
  90657. _textures: {
  90658. [key: string]: Texture;
  90659. };
  90660. /** @hidden */
  90661. protected _fallbackTexture: Nullable<Texture>;
  90662. private _size;
  90663. private _currentRefreshId;
  90664. private _frameId;
  90665. private _refreshRate;
  90666. private _vertexBuffers;
  90667. private _indexBuffer;
  90668. private _uniforms;
  90669. private _samplers;
  90670. private _fragment;
  90671. private _floats;
  90672. private _ints;
  90673. private _floatsArrays;
  90674. private _colors3;
  90675. private _colors4;
  90676. private _vectors2;
  90677. private _vectors3;
  90678. private _matrices;
  90679. private _fallbackTextureUsed;
  90680. private _fullEngine;
  90681. private _cachedDefines;
  90682. private _contentUpdateId;
  90683. private _contentData;
  90684. /**
  90685. * Instantiates a new procedural texture.
  90686. * 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.
  90687. * This is the base class of any Procedural texture and contains most of the shareable code.
  90688. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90689. * @param name Define the name of the texture
  90690. * @param size Define the size of the texture to create
  90691. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90692. * @param scene Define the scene the texture belongs to
  90693. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90694. * @param generateMipMaps Define if the texture should creates mip maps or not
  90695. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90696. */
  90697. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90698. /**
  90699. * The effect that is created when initializing the post process.
  90700. * @returns The created effect corresponding the the postprocess.
  90701. */
  90702. getEffect(): Effect;
  90703. /**
  90704. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90705. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90706. */
  90707. getContent(): Nullable<ArrayBufferView>;
  90708. private _createIndexBuffer;
  90709. /** @hidden */
  90710. _rebuild(): void;
  90711. /**
  90712. * Resets the texture in order to recreate its associated resources.
  90713. * This can be called in case of context loss
  90714. */
  90715. reset(): void;
  90716. protected _getDefines(): string;
  90717. /**
  90718. * Is the texture ready to be used ? (rendered at least once)
  90719. * @returns true if ready, otherwise, false.
  90720. */
  90721. isReady(): boolean;
  90722. /**
  90723. * Resets the refresh counter of the texture and start bak from scratch.
  90724. * Could be useful to regenerate the texture if it is setup to render only once.
  90725. */
  90726. resetRefreshCounter(): void;
  90727. /**
  90728. * Set the fragment shader to use in order to render the texture.
  90729. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90730. */
  90731. setFragment(fragment: any): void;
  90732. /**
  90733. * Define the refresh rate of the texture or the rendering frequency.
  90734. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90735. */
  90736. get refreshRate(): number;
  90737. set refreshRate(value: number);
  90738. /** @hidden */
  90739. _shouldRender(): boolean;
  90740. /**
  90741. * Get the size the texture is rendering at.
  90742. * @returns the size (texture is always squared)
  90743. */
  90744. getRenderSize(): number;
  90745. /**
  90746. * Resize the texture to new value.
  90747. * @param size Define the new size the texture should have
  90748. * @param generateMipMaps Define whether the new texture should create mip maps
  90749. */
  90750. resize(size: number, generateMipMaps: boolean): void;
  90751. private _checkUniform;
  90752. /**
  90753. * Set a texture in the shader program used to render.
  90754. * @param name Define the name of the uniform samplers as defined in the shader
  90755. * @param texture Define the texture to bind to this sampler
  90756. * @return the texture itself allowing "fluent" like uniform updates
  90757. */
  90758. setTexture(name: string, texture: Texture): ProceduralTexture;
  90759. /**
  90760. * Set a float in the shader.
  90761. * @param name Define the name of the uniform as defined in the shader
  90762. * @param value Define the value to give to the uniform
  90763. * @return the texture itself allowing "fluent" like uniform updates
  90764. */
  90765. setFloat(name: string, value: number): ProceduralTexture;
  90766. /**
  90767. * Set a int in the shader.
  90768. * @param name Define the name of the uniform as defined in the shader
  90769. * @param value Define the value to give to the uniform
  90770. * @return the texture itself allowing "fluent" like uniform updates
  90771. */
  90772. setInt(name: string, value: number): ProceduralTexture;
  90773. /**
  90774. * Set an array of floats in the shader.
  90775. * @param name Define the name of the uniform as defined in the shader
  90776. * @param value Define the value to give to the uniform
  90777. * @return the texture itself allowing "fluent" like uniform updates
  90778. */
  90779. setFloats(name: string, value: number[]): ProceduralTexture;
  90780. /**
  90781. * Set a vec3 in the shader from a Color3.
  90782. * @param name Define the name of the uniform as defined in the shader
  90783. * @param value Define the value to give to the uniform
  90784. * @return the texture itself allowing "fluent" like uniform updates
  90785. */
  90786. setColor3(name: string, value: Color3): ProceduralTexture;
  90787. /**
  90788. * Set a vec4 in the shader from a Color4.
  90789. * @param name Define the name of the uniform as defined in the shader
  90790. * @param value Define the value to give to the uniform
  90791. * @return the texture itself allowing "fluent" like uniform updates
  90792. */
  90793. setColor4(name: string, value: Color4): ProceduralTexture;
  90794. /**
  90795. * Set a vec2 in the shader from a Vector2.
  90796. * @param name Define the name of the uniform as defined in the shader
  90797. * @param value Define the value to give to the uniform
  90798. * @return the texture itself allowing "fluent" like uniform updates
  90799. */
  90800. setVector2(name: string, value: Vector2): ProceduralTexture;
  90801. /**
  90802. * Set a vec3 in the shader from a Vector3.
  90803. * @param name Define the name of the uniform as defined in the shader
  90804. * @param value Define the value to give to the uniform
  90805. * @return the texture itself allowing "fluent" like uniform updates
  90806. */
  90807. setVector3(name: string, value: Vector3): ProceduralTexture;
  90808. /**
  90809. * Set a mat4 in the shader from a MAtrix.
  90810. * @param name Define the name of the uniform as defined in the shader
  90811. * @param value Define the value to give to the uniform
  90812. * @return the texture itself allowing "fluent" like uniform updates
  90813. */
  90814. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90815. /**
  90816. * Render the texture to its associated render target.
  90817. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90818. */
  90819. render(useCameraPostProcess?: boolean): void;
  90820. /**
  90821. * Clone the texture.
  90822. * @returns the cloned texture
  90823. */
  90824. clone(): ProceduralTexture;
  90825. /**
  90826. * Dispose the texture and release its asoociated resources.
  90827. */
  90828. dispose(): void;
  90829. }
  90830. }
  90831. declare module BABYLON {
  90832. /**
  90833. * This represents the base class for particle system in Babylon.
  90834. * 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.
  90835. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90836. * @example https://doc.babylonjs.com/babylon101/particles
  90837. */
  90838. export class BaseParticleSystem {
  90839. /**
  90840. * Source color is added to the destination color without alpha affecting the result
  90841. */
  90842. static BLENDMODE_ONEONE: number;
  90843. /**
  90844. * Blend current color and particle color using particle’s alpha
  90845. */
  90846. static BLENDMODE_STANDARD: number;
  90847. /**
  90848. * Add current color and particle color multiplied by particle’s alpha
  90849. */
  90850. static BLENDMODE_ADD: number;
  90851. /**
  90852. * Multiply current color with particle color
  90853. */
  90854. static BLENDMODE_MULTIPLY: number;
  90855. /**
  90856. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90857. */
  90858. static BLENDMODE_MULTIPLYADD: number;
  90859. /**
  90860. * List of animations used by the particle system.
  90861. */
  90862. animations: Animation[];
  90863. /**
  90864. * Gets or sets the unique id of the particle system
  90865. */
  90866. uniqueId: number;
  90867. /**
  90868. * The id of the Particle system.
  90869. */
  90870. id: string;
  90871. /**
  90872. * The friendly name of the Particle system.
  90873. */
  90874. name: string;
  90875. /**
  90876. * Snippet ID if the particle system was created from the snippet server
  90877. */
  90878. snippetId: string;
  90879. /**
  90880. * The rendering group used by the Particle system to chose when to render.
  90881. */
  90882. renderingGroupId: number;
  90883. /**
  90884. * The emitter represents the Mesh or position we are attaching the particle system to.
  90885. */
  90886. emitter: Nullable<AbstractMesh | Vector3>;
  90887. /**
  90888. * The maximum number of particles to emit per frame
  90889. */
  90890. emitRate: number;
  90891. /**
  90892. * If you want to launch only a few particles at once, that can be done, as well.
  90893. */
  90894. manualEmitCount: number;
  90895. /**
  90896. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90897. */
  90898. updateSpeed: number;
  90899. /**
  90900. * The amount of time the particle system is running (depends of the overall update speed).
  90901. */
  90902. targetStopDuration: number;
  90903. /**
  90904. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90905. */
  90906. disposeOnStop: boolean;
  90907. /**
  90908. * Minimum power of emitting particles.
  90909. */
  90910. minEmitPower: number;
  90911. /**
  90912. * Maximum power of emitting particles.
  90913. */
  90914. maxEmitPower: number;
  90915. /**
  90916. * Minimum life time of emitting particles.
  90917. */
  90918. minLifeTime: number;
  90919. /**
  90920. * Maximum life time of emitting particles.
  90921. */
  90922. maxLifeTime: number;
  90923. /**
  90924. * Minimum Size of emitting particles.
  90925. */
  90926. minSize: number;
  90927. /**
  90928. * Maximum Size of emitting particles.
  90929. */
  90930. maxSize: number;
  90931. /**
  90932. * Minimum scale of emitting particles on X axis.
  90933. */
  90934. minScaleX: number;
  90935. /**
  90936. * Maximum scale of emitting particles on X axis.
  90937. */
  90938. maxScaleX: number;
  90939. /**
  90940. * Minimum scale of emitting particles on Y axis.
  90941. */
  90942. minScaleY: number;
  90943. /**
  90944. * Maximum scale of emitting particles on Y axis.
  90945. */
  90946. maxScaleY: number;
  90947. /**
  90948. * Gets or sets the minimal initial rotation in radians.
  90949. */
  90950. minInitialRotation: number;
  90951. /**
  90952. * Gets or sets the maximal initial rotation in radians.
  90953. */
  90954. maxInitialRotation: number;
  90955. /**
  90956. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90957. */
  90958. minAngularSpeed: number;
  90959. /**
  90960. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90961. */
  90962. maxAngularSpeed: number;
  90963. /**
  90964. * The texture used to render each particle. (this can be a spritesheet)
  90965. */
  90966. particleTexture: Nullable<Texture>;
  90967. /**
  90968. * The layer mask we are rendering the particles through.
  90969. */
  90970. layerMask: number;
  90971. /**
  90972. * This can help using your own shader to render the particle system.
  90973. * The according effect will be created
  90974. */
  90975. customShader: any;
  90976. /**
  90977. * By default particle system starts as soon as they are created. This prevents the
  90978. * automatic start to happen and let you decide when to start emitting particles.
  90979. */
  90980. preventAutoStart: boolean;
  90981. private _noiseTexture;
  90982. /**
  90983. * Gets or sets a texture used to add random noise to particle positions
  90984. */
  90985. get noiseTexture(): Nullable<ProceduralTexture>;
  90986. set noiseTexture(value: Nullable<ProceduralTexture>);
  90987. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90988. noiseStrength: Vector3;
  90989. /**
  90990. * Callback triggered when the particle animation is ending.
  90991. */
  90992. onAnimationEnd: Nullable<() => void>;
  90993. /**
  90994. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90995. */
  90996. blendMode: number;
  90997. /**
  90998. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90999. * to override the particles.
  91000. */
  91001. forceDepthWrite: boolean;
  91002. /** 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 */
  91003. preWarmCycles: number;
  91004. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91005. preWarmStepOffset: number;
  91006. /**
  91007. * 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)
  91008. */
  91009. spriteCellChangeSpeed: number;
  91010. /**
  91011. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91012. */
  91013. startSpriteCellID: number;
  91014. /**
  91015. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91016. */
  91017. endSpriteCellID: number;
  91018. /**
  91019. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91020. */
  91021. spriteCellWidth: number;
  91022. /**
  91023. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91024. */
  91025. spriteCellHeight: number;
  91026. /**
  91027. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91028. */
  91029. spriteRandomStartCell: boolean;
  91030. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91031. translationPivot: Vector2;
  91032. /** @hidden */
  91033. protected _isAnimationSheetEnabled: boolean;
  91034. /**
  91035. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91036. */
  91037. beginAnimationOnStart: boolean;
  91038. /**
  91039. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91040. */
  91041. beginAnimationFrom: number;
  91042. /**
  91043. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91044. */
  91045. beginAnimationTo: number;
  91046. /**
  91047. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91048. */
  91049. beginAnimationLoop: boolean;
  91050. /**
  91051. * Gets or sets a world offset applied to all particles
  91052. */
  91053. worldOffset: Vector3;
  91054. /**
  91055. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91056. */
  91057. get isAnimationSheetEnabled(): boolean;
  91058. set isAnimationSheetEnabled(value: boolean);
  91059. /**
  91060. * Get hosting scene
  91061. * @returns the scene
  91062. */
  91063. getScene(): Nullable<Scene>;
  91064. /**
  91065. * You can use gravity if you want to give an orientation to your particles.
  91066. */
  91067. gravity: Vector3;
  91068. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91069. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91070. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91071. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91072. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91073. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91074. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91075. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91076. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91077. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91078. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91079. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91080. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91081. /**
  91082. * Defines the delay in milliseconds before starting the system (0 by default)
  91083. */
  91084. startDelay: number;
  91085. /**
  91086. * Gets the current list of drag gradients.
  91087. * You must use addDragGradient and removeDragGradient to udpate this list
  91088. * @returns the list of drag gradients
  91089. */
  91090. getDragGradients(): Nullable<Array<FactorGradient>>;
  91091. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91092. limitVelocityDamping: number;
  91093. /**
  91094. * Gets the current list of limit velocity gradients.
  91095. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91096. * @returns the list of limit velocity gradients
  91097. */
  91098. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91099. /**
  91100. * Gets the current list of color gradients.
  91101. * You must use addColorGradient and removeColorGradient to udpate this list
  91102. * @returns the list of color gradients
  91103. */
  91104. getColorGradients(): Nullable<Array<ColorGradient>>;
  91105. /**
  91106. * Gets the current list of size gradients.
  91107. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91108. * @returns the list of size gradients
  91109. */
  91110. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91111. /**
  91112. * Gets the current list of color remap gradients.
  91113. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91114. * @returns the list of color remap gradients
  91115. */
  91116. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91117. /**
  91118. * Gets the current list of alpha remap gradients.
  91119. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91120. * @returns the list of alpha remap gradients
  91121. */
  91122. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91123. /**
  91124. * Gets the current list of life time gradients.
  91125. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91126. * @returns the list of life time gradients
  91127. */
  91128. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91129. /**
  91130. * Gets the current list of angular speed gradients.
  91131. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91132. * @returns the list of angular speed gradients
  91133. */
  91134. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91135. /**
  91136. * Gets the current list of velocity gradients.
  91137. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91138. * @returns the list of velocity gradients
  91139. */
  91140. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91141. /**
  91142. * Gets the current list of start size gradients.
  91143. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91144. * @returns the list of start size gradients
  91145. */
  91146. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91147. /**
  91148. * Gets the current list of emit rate gradients.
  91149. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91150. * @returns the list of emit rate gradients
  91151. */
  91152. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91153. /**
  91154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91155. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91156. */
  91157. get direction1(): Vector3;
  91158. set direction1(value: Vector3);
  91159. /**
  91160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91161. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91162. */
  91163. get direction2(): Vector3;
  91164. set direction2(value: Vector3);
  91165. /**
  91166. * 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.
  91167. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91168. */
  91169. get minEmitBox(): Vector3;
  91170. set minEmitBox(value: Vector3);
  91171. /**
  91172. * 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.
  91173. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91174. */
  91175. get maxEmitBox(): Vector3;
  91176. set maxEmitBox(value: Vector3);
  91177. /**
  91178. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91179. */
  91180. color1: Color4;
  91181. /**
  91182. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91183. */
  91184. color2: Color4;
  91185. /**
  91186. * Color the particle will have at the end of its lifetime
  91187. */
  91188. colorDead: Color4;
  91189. /**
  91190. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91191. */
  91192. textureMask: Color4;
  91193. /**
  91194. * The particle emitter type defines the emitter used by the particle system.
  91195. * It can be for example box, sphere, or cone...
  91196. */
  91197. particleEmitterType: IParticleEmitterType;
  91198. /** @hidden */
  91199. _isSubEmitter: boolean;
  91200. /**
  91201. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91202. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91203. */
  91204. billboardMode: number;
  91205. protected _isBillboardBased: boolean;
  91206. /**
  91207. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91208. */
  91209. get isBillboardBased(): boolean;
  91210. set isBillboardBased(value: boolean);
  91211. /**
  91212. * The scene the particle system belongs to.
  91213. */
  91214. protected _scene: Nullable<Scene>;
  91215. /**
  91216. * The engine the particle system belongs to.
  91217. */
  91218. protected _engine: ThinEngine;
  91219. /**
  91220. * Local cache of defines for image processing.
  91221. */
  91222. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91223. /**
  91224. * Default configuration related to image processing available in the standard Material.
  91225. */
  91226. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91227. /**
  91228. * Gets the image processing configuration used either in this material.
  91229. */
  91230. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91231. /**
  91232. * Sets the Default image processing configuration used either in the this material.
  91233. *
  91234. * If sets to null, the scene one is in use.
  91235. */
  91236. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91237. /**
  91238. * Attaches a new image processing configuration to the Standard Material.
  91239. * @param configuration
  91240. */
  91241. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91242. /** @hidden */
  91243. protected _reset(): void;
  91244. /** @hidden */
  91245. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91246. /**
  91247. * Instantiates a particle system.
  91248. * 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.
  91249. * @param name The name of the particle system
  91250. */
  91251. constructor(name: string);
  91252. /**
  91253. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91256. * @returns the emitter
  91257. */
  91258. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91259. /**
  91260. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91261. * @param radius The radius of the hemisphere to emit from
  91262. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91263. * @returns the emitter
  91264. */
  91265. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91266. /**
  91267. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91268. * @param radius The radius of the sphere to emit from
  91269. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91270. * @returns the emitter
  91271. */
  91272. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91273. /**
  91274. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91275. * @param radius The radius of the sphere to emit from
  91276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91278. * @returns the emitter
  91279. */
  91280. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91281. /**
  91282. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91283. * @param radius The radius of the emission cylinder
  91284. * @param height The height of the emission cylinder
  91285. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91286. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91287. * @returns the emitter
  91288. */
  91289. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91290. /**
  91291. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91292. * @param radius The radius of the cylinder to emit from
  91293. * @param height The height of the emission cylinder
  91294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91295. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91296. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91297. * @returns the emitter
  91298. */
  91299. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91300. /**
  91301. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91302. * @param radius The radius of the cone to emit from
  91303. * @param angle The base angle of the cone
  91304. * @returns the emitter
  91305. */
  91306. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91307. /**
  91308. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91309. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91310. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91311. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91312. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91313. * @returns the emitter
  91314. */
  91315. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91316. }
  91317. }
  91318. declare module BABYLON {
  91319. /**
  91320. * Type of sub emitter
  91321. */
  91322. export enum SubEmitterType {
  91323. /**
  91324. * Attached to the particle over it's lifetime
  91325. */
  91326. ATTACHED = 0,
  91327. /**
  91328. * Created when the particle dies
  91329. */
  91330. END = 1
  91331. }
  91332. /**
  91333. * Sub emitter class used to emit particles from an existing particle
  91334. */
  91335. export class SubEmitter {
  91336. /**
  91337. * the particle system to be used by the sub emitter
  91338. */
  91339. particleSystem: ParticleSystem;
  91340. /**
  91341. * Type of the submitter (Default: END)
  91342. */
  91343. type: SubEmitterType;
  91344. /**
  91345. * 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)
  91346. * Note: This only is supported when using an emitter of type Mesh
  91347. */
  91348. inheritDirection: boolean;
  91349. /**
  91350. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91351. */
  91352. inheritedVelocityAmount: number;
  91353. /**
  91354. * Creates a sub emitter
  91355. * @param particleSystem the particle system to be used by the sub emitter
  91356. */
  91357. constructor(
  91358. /**
  91359. * the particle system to be used by the sub emitter
  91360. */
  91361. particleSystem: ParticleSystem);
  91362. /**
  91363. * Clones the sub emitter
  91364. * @returns the cloned sub emitter
  91365. */
  91366. clone(): SubEmitter;
  91367. /**
  91368. * Serialize current object to a JSON object
  91369. * @returns the serialized object
  91370. */
  91371. serialize(): any;
  91372. /** @hidden */
  91373. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  91374. /**
  91375. * Creates a new SubEmitter from a serialized JSON version
  91376. * @param serializationObject defines the JSON object to read from
  91377. * @param sceneOrEngine defines the hosting scene or the hosting engine
  91378. * @param rootUrl defines the rootUrl for data loading
  91379. * @returns a new SubEmitter
  91380. */
  91381. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  91382. /** Release associated resources */
  91383. dispose(): void;
  91384. }
  91385. }
  91386. declare module BABYLON {
  91387. /** @hidden */
  91388. export var imageProcessingDeclaration: {
  91389. name: string;
  91390. shader: string;
  91391. };
  91392. }
  91393. declare module BABYLON {
  91394. /** @hidden */
  91395. export var imageProcessingFunctions: {
  91396. name: string;
  91397. shader: string;
  91398. };
  91399. }
  91400. declare module BABYLON {
  91401. /** @hidden */
  91402. export var particlesPixelShader: {
  91403. name: string;
  91404. shader: string;
  91405. };
  91406. }
  91407. declare module BABYLON {
  91408. /** @hidden */
  91409. export var particlesVertexShader: {
  91410. name: string;
  91411. shader: string;
  91412. };
  91413. }
  91414. declare module BABYLON {
  91415. /**
  91416. * Interface used to define entities containing multiple clip planes
  91417. */
  91418. export interface IClipPlanesHolder {
  91419. /**
  91420. * Gets or sets the active clipplane 1
  91421. */
  91422. clipPlane: Nullable<Plane>;
  91423. /**
  91424. * Gets or sets the active clipplane 2
  91425. */
  91426. clipPlane2: Nullable<Plane>;
  91427. /**
  91428. * Gets or sets the active clipplane 3
  91429. */
  91430. clipPlane3: Nullable<Plane>;
  91431. /**
  91432. * Gets or sets the active clipplane 4
  91433. */
  91434. clipPlane4: Nullable<Plane>;
  91435. /**
  91436. * Gets or sets the active clipplane 5
  91437. */
  91438. clipPlane5: Nullable<Plane>;
  91439. /**
  91440. * Gets or sets the active clipplane 6
  91441. */
  91442. clipPlane6: Nullable<Plane>;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /**
  91447. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  91448. *
  91449. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  91450. *
  91451. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  91452. */
  91453. export class ThinMaterialHelper {
  91454. /**
  91455. * Binds the clip plane information from the holder to the effect.
  91456. * @param effect The effect we are binding the data to
  91457. * @param holder The entity containing the clip plane information
  91458. */
  91459. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  91460. }
  91461. }
  91462. declare module BABYLON {
  91463. /**
  91464. * This represents a particle system in Babylon.
  91465. * 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.
  91466. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91467. * @example https://doc.babylonjs.com/babylon101/particles
  91468. */
  91469. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91470. /**
  91471. * Billboard mode will only apply to Y axis
  91472. */
  91473. static readonly BILLBOARDMODE_Y: number;
  91474. /**
  91475. * Billboard mode will apply to all axes
  91476. */
  91477. static readonly BILLBOARDMODE_ALL: number;
  91478. /**
  91479. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91480. */
  91481. static readonly BILLBOARDMODE_STRETCHED: number;
  91482. /**
  91483. * This function can be defined to provide custom update for active particles.
  91484. * This function will be called instead of regular update (age, position, color, etc.).
  91485. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91486. */
  91487. updateFunction: (particles: Particle[]) => void;
  91488. private _emitterWorldMatrix;
  91489. /**
  91490. * This function can be defined to specify initial direction for every new particle.
  91491. * It by default use the emitterType defined function
  91492. */
  91493. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91494. /**
  91495. * This function can be defined to specify initial position for every new particle.
  91496. * It by default use the emitterType defined function
  91497. */
  91498. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91499. /**
  91500. * @hidden
  91501. */
  91502. _inheritedVelocityOffset: Vector3;
  91503. /**
  91504. * An event triggered when the system is disposed
  91505. */
  91506. onDisposeObservable: Observable<IParticleSystem>;
  91507. private _onDisposeObserver;
  91508. /**
  91509. * Sets a callback that will be triggered when the system is disposed
  91510. */
  91511. set onDispose(callback: () => void);
  91512. private _particles;
  91513. private _epsilon;
  91514. private _capacity;
  91515. private _stockParticles;
  91516. private _newPartsExcess;
  91517. private _vertexData;
  91518. private _vertexBuffer;
  91519. private _vertexBuffers;
  91520. private _spriteBuffer;
  91521. private _indexBuffer;
  91522. private _effect;
  91523. private _customEffect;
  91524. private _cachedDefines;
  91525. private _scaledColorStep;
  91526. private _colorDiff;
  91527. private _scaledDirection;
  91528. private _scaledGravity;
  91529. private _currentRenderId;
  91530. private _alive;
  91531. private _useInstancing;
  91532. private _started;
  91533. private _stopped;
  91534. private _actualFrame;
  91535. private _scaledUpdateSpeed;
  91536. private _vertexBufferSize;
  91537. /** @hidden */
  91538. _currentEmitRateGradient: Nullable<FactorGradient>;
  91539. /** @hidden */
  91540. _currentEmitRate1: number;
  91541. /** @hidden */
  91542. _currentEmitRate2: number;
  91543. /** @hidden */
  91544. _currentStartSizeGradient: Nullable<FactorGradient>;
  91545. /** @hidden */
  91546. _currentStartSize1: number;
  91547. /** @hidden */
  91548. _currentStartSize2: number;
  91549. private readonly _rawTextureWidth;
  91550. private _rampGradientsTexture;
  91551. private _useRampGradients;
  91552. /** Gets or sets a matrix to use to compute projection */
  91553. defaultProjectionMatrix: Matrix;
  91554. /** Gets or sets a boolean indicating that ramp gradients must be used
  91555. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91556. */
  91557. get useRampGradients(): boolean;
  91558. set useRampGradients(value: boolean);
  91559. /**
  91560. * 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.
  91561. * 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: [])
  91562. */
  91563. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91564. private _subEmitters;
  91565. /**
  91566. * @hidden
  91567. * If the particle systems emitter should be disposed when the particle system is disposed
  91568. */
  91569. _disposeEmitterOnDispose: boolean;
  91570. /**
  91571. * The current active Sub-systems, this property is used by the root particle system only.
  91572. */
  91573. activeSubSystems: Array<ParticleSystem>;
  91574. /**
  91575. * Specifies if the particles are updated in emitter local space or world space
  91576. */
  91577. isLocal: boolean;
  91578. private _rootParticleSystem;
  91579. /**
  91580. * Gets the current list of active particles
  91581. */
  91582. get particles(): Particle[];
  91583. /**
  91584. * Gets the number of particles active at the same time.
  91585. * @returns The number of active particles.
  91586. */
  91587. getActiveCount(): number;
  91588. /**
  91589. * Returns the string "ParticleSystem"
  91590. * @returns a string containing the class name
  91591. */
  91592. getClassName(): string;
  91593. /**
  91594. * Gets a boolean indicating that the system is stopping
  91595. * @returns true if the system is currently stopping
  91596. */
  91597. isStopping(): boolean;
  91598. /**
  91599. * Gets the custom effect used to render the particles
  91600. * @param blendMode Blend mode for which the effect should be retrieved
  91601. * @returns The effect
  91602. */
  91603. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91604. /**
  91605. * Sets the custom effect used to render the particles
  91606. * @param effect The effect to set
  91607. * @param blendMode Blend mode for which the effect should be set
  91608. */
  91609. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91610. /** @hidden */
  91611. private _onBeforeDrawParticlesObservable;
  91612. /**
  91613. * Observable that will be called just before the particles are drawn
  91614. */
  91615. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91616. /**
  91617. * Gets the name of the particle vertex shader
  91618. */
  91619. get vertexShaderName(): string;
  91620. /**
  91621. * Instantiates a particle system.
  91622. * 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.
  91623. * @param name The name of the particle system
  91624. * @param capacity The max number of particles alive at the same time
  91625. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  91626. * @param customEffect a custom effect used to change the way particles are rendered by default
  91627. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91628. * @param epsilon Offset used to render the particles
  91629. */
  91630. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91631. private _addFactorGradient;
  91632. private _removeFactorGradient;
  91633. /**
  91634. * Adds a new life time gradient
  91635. * @param gradient defines the gradient to use (between 0 and 1)
  91636. * @param factor defines the life time factor to affect to the specified gradient
  91637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91638. * @returns the current particle system
  91639. */
  91640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91641. /**
  91642. * Remove a specific life time gradient
  91643. * @param gradient defines the gradient to remove
  91644. * @returns the current particle system
  91645. */
  91646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91647. /**
  91648. * Adds a new size gradient
  91649. * @param gradient defines the gradient to use (between 0 and 1)
  91650. * @param factor defines the size factor to affect to the specified gradient
  91651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91652. * @returns the current particle system
  91653. */
  91654. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91655. /**
  91656. * Remove a specific size gradient
  91657. * @param gradient defines the gradient to remove
  91658. * @returns the current particle system
  91659. */
  91660. removeSizeGradient(gradient: number): IParticleSystem;
  91661. /**
  91662. * Adds a new color remap gradient
  91663. * @param gradient defines the gradient to use (between 0 and 1)
  91664. * @param min defines the color remap minimal range
  91665. * @param max defines the color remap maximal range
  91666. * @returns the current particle system
  91667. */
  91668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91669. /**
  91670. * Remove a specific color remap gradient
  91671. * @param gradient defines the gradient to remove
  91672. * @returns the current particle system
  91673. */
  91674. removeColorRemapGradient(gradient: number): IParticleSystem;
  91675. /**
  91676. * Adds a new alpha remap gradient
  91677. * @param gradient defines the gradient to use (between 0 and 1)
  91678. * @param min defines the alpha remap minimal range
  91679. * @param max defines the alpha remap maximal range
  91680. * @returns the current particle system
  91681. */
  91682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91683. /**
  91684. * Remove a specific alpha remap gradient
  91685. * @param gradient defines the gradient to remove
  91686. * @returns the current particle system
  91687. */
  91688. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91689. /**
  91690. * Adds a new angular speed gradient
  91691. * @param gradient defines the gradient to use (between 0 and 1)
  91692. * @param factor defines the angular speed to affect to the specified gradient
  91693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91694. * @returns the current particle system
  91695. */
  91696. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91697. /**
  91698. * Remove a specific angular speed gradient
  91699. * @param gradient defines the gradient to remove
  91700. * @returns the current particle system
  91701. */
  91702. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91703. /**
  91704. * Adds a new velocity gradient
  91705. * @param gradient defines the gradient to use (between 0 and 1)
  91706. * @param factor defines the velocity to affect to the specified gradient
  91707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91708. * @returns the current particle system
  91709. */
  91710. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91711. /**
  91712. * Remove a specific velocity gradient
  91713. * @param gradient defines the gradient to remove
  91714. * @returns the current particle system
  91715. */
  91716. removeVelocityGradient(gradient: number): IParticleSystem;
  91717. /**
  91718. * Adds a new limit velocity gradient
  91719. * @param gradient defines the gradient to use (between 0 and 1)
  91720. * @param factor defines the limit velocity value to affect to the specified gradient
  91721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91722. * @returns the current particle system
  91723. */
  91724. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91725. /**
  91726. * Remove a specific limit velocity gradient
  91727. * @param gradient defines the gradient to remove
  91728. * @returns the current particle system
  91729. */
  91730. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91731. /**
  91732. * Adds a new drag gradient
  91733. * @param gradient defines the gradient to use (between 0 and 1)
  91734. * @param factor defines the drag value to affect to the specified gradient
  91735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91736. * @returns the current particle system
  91737. */
  91738. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91739. /**
  91740. * Remove a specific drag gradient
  91741. * @param gradient defines the gradient to remove
  91742. * @returns the current particle system
  91743. */
  91744. removeDragGradient(gradient: number): IParticleSystem;
  91745. /**
  91746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91747. * @param gradient defines the gradient to use (between 0 and 1)
  91748. * @param factor defines the emit rate value to affect to the specified gradient
  91749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91750. * @returns the current particle system
  91751. */
  91752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91753. /**
  91754. * Remove a specific emit rate gradient
  91755. * @param gradient defines the gradient to remove
  91756. * @returns the current particle system
  91757. */
  91758. removeEmitRateGradient(gradient: number): IParticleSystem;
  91759. /**
  91760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91761. * @param gradient defines the gradient to use (between 0 and 1)
  91762. * @param factor defines the start size value to affect to the specified gradient
  91763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91764. * @returns the current particle system
  91765. */
  91766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91767. /**
  91768. * Remove a specific start size gradient
  91769. * @param gradient defines the gradient to remove
  91770. * @returns the current particle system
  91771. */
  91772. removeStartSizeGradient(gradient: number): IParticleSystem;
  91773. private _createRampGradientTexture;
  91774. /**
  91775. * Gets the current list of ramp gradients.
  91776. * You must use addRampGradient and removeRampGradient to udpate this list
  91777. * @returns the list of ramp gradients
  91778. */
  91779. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91780. /** Force the system to rebuild all gradients that need to be resync */
  91781. forceRefreshGradients(): void;
  91782. private _syncRampGradientTexture;
  91783. /**
  91784. * Adds a new ramp gradient used to remap particle colors
  91785. * @param gradient defines the gradient to use (between 0 and 1)
  91786. * @param color defines the color to affect to the specified gradient
  91787. * @returns the current particle system
  91788. */
  91789. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91790. /**
  91791. * Remove a specific ramp gradient
  91792. * @param gradient defines the gradient to remove
  91793. * @returns the current particle system
  91794. */
  91795. removeRampGradient(gradient: number): ParticleSystem;
  91796. /**
  91797. * Adds a new color gradient
  91798. * @param gradient defines the gradient to use (between 0 and 1)
  91799. * @param color1 defines the color to affect to the specified gradient
  91800. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91801. * @returns this particle system
  91802. */
  91803. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91804. /**
  91805. * Remove a specific color gradient
  91806. * @param gradient defines the gradient to remove
  91807. * @returns this particle system
  91808. */
  91809. removeColorGradient(gradient: number): IParticleSystem;
  91810. private _fetchR;
  91811. protected _reset(): void;
  91812. private _resetEffect;
  91813. private _createVertexBuffers;
  91814. private _createIndexBuffer;
  91815. /**
  91816. * Gets the maximum number of particles active at the same time.
  91817. * @returns The max number of active particles.
  91818. */
  91819. getCapacity(): number;
  91820. /**
  91821. * Gets whether there are still active particles in the system.
  91822. * @returns True if it is alive, otherwise false.
  91823. */
  91824. isAlive(): boolean;
  91825. /**
  91826. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91827. * @returns True if it has been started, otherwise false.
  91828. */
  91829. isStarted(): boolean;
  91830. private _prepareSubEmitterInternalArray;
  91831. /**
  91832. * Starts the particle system and begins to emit
  91833. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91834. */
  91835. start(delay?: number): void;
  91836. /**
  91837. * Stops the particle system.
  91838. * @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.
  91839. */
  91840. stop(stopSubEmitters?: boolean): void;
  91841. /**
  91842. * Remove all active particles
  91843. */
  91844. reset(): void;
  91845. /**
  91846. * @hidden (for internal use only)
  91847. */
  91848. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91849. /**
  91850. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91851. * Its lifetime will start back at 0.
  91852. */
  91853. recycleParticle: (particle: Particle) => void;
  91854. private _stopSubEmitters;
  91855. private _createParticle;
  91856. private _removeFromRoot;
  91857. private _emitFromParticle;
  91858. private _update;
  91859. /** @hidden */
  91860. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91861. /** @hidden */
  91862. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91863. /**
  91864. * Fill the defines array according to the current settings of the particle system
  91865. * @param defines Array to be updated
  91866. * @param blendMode blend mode to take into account when updating the array
  91867. */
  91868. fillDefines(defines: Array<string>, blendMode: number): void;
  91869. /**
  91870. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91871. * @param uniforms Uniforms array to fill
  91872. * @param attributes Attributes array to fill
  91873. * @param samplers Samplers array to fill
  91874. */
  91875. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91876. /** @hidden */
  91877. private _getEffect;
  91878. /**
  91879. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91880. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91881. */
  91882. animate(preWarmOnly?: boolean): void;
  91883. private _appendParticleVertices;
  91884. /**
  91885. * Rebuilds the particle system.
  91886. */
  91887. rebuild(): void;
  91888. /**
  91889. * Is this system ready to be used/rendered
  91890. * @return true if the system is ready
  91891. */
  91892. isReady(): boolean;
  91893. private _render;
  91894. /**
  91895. * Renders the particle system in its current state.
  91896. * @returns the current number of particles
  91897. */
  91898. render(): number;
  91899. /**
  91900. * Disposes the particle system and free the associated resources
  91901. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91902. */
  91903. dispose(disposeTexture?: boolean): void;
  91904. /**
  91905. * Clones the particle system.
  91906. * @param name The name of the cloned object
  91907. * @param newEmitter The new emitter to use
  91908. * @returns the cloned particle system
  91909. */
  91910. clone(name: string, newEmitter: any): ParticleSystem;
  91911. /**
  91912. * Serializes the particle system to a JSON object
  91913. * @param serializeTexture defines if the texture must be serialized as well
  91914. * @returns the JSON object
  91915. */
  91916. serialize(serializeTexture?: boolean): any;
  91917. /** @hidden */
  91918. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91919. /** @hidden */
  91920. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  91921. /**
  91922. * Parses a JSON object to create a particle system.
  91923. * @param parsedParticleSystem The JSON object to parse
  91924. * @param sceneOrEngine The scene or the engine to create the particle system in
  91925. * @param rootUrl The root url to use to load external dependencies like texture
  91926. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91927. * @returns the Parsed particle system
  91928. */
  91929. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91930. }
  91931. }
  91932. declare module BABYLON {
  91933. /**
  91934. * A particle represents one of the element emitted by a particle system.
  91935. * This is mainly define by its coordinates, direction, velocity and age.
  91936. */
  91937. export class Particle {
  91938. /**
  91939. * The particle system the particle belongs to.
  91940. */
  91941. particleSystem: ParticleSystem;
  91942. private static _Count;
  91943. /**
  91944. * Unique ID of the particle
  91945. */
  91946. id: number;
  91947. /**
  91948. * The world position of the particle in the scene.
  91949. */
  91950. position: Vector3;
  91951. /**
  91952. * The world direction of the particle in the scene.
  91953. */
  91954. direction: Vector3;
  91955. /**
  91956. * The color of the particle.
  91957. */
  91958. color: Color4;
  91959. /**
  91960. * The color change of the particle per step.
  91961. */
  91962. colorStep: Color4;
  91963. /**
  91964. * Defines how long will the life of the particle be.
  91965. */
  91966. lifeTime: number;
  91967. /**
  91968. * The current age of the particle.
  91969. */
  91970. age: number;
  91971. /**
  91972. * The current size of the particle.
  91973. */
  91974. size: number;
  91975. /**
  91976. * The current scale of the particle.
  91977. */
  91978. scale: Vector2;
  91979. /**
  91980. * The current angle of the particle.
  91981. */
  91982. angle: number;
  91983. /**
  91984. * Defines how fast is the angle changing.
  91985. */
  91986. angularSpeed: number;
  91987. /**
  91988. * Defines the cell index used by the particle to be rendered from a sprite.
  91989. */
  91990. cellIndex: number;
  91991. /**
  91992. * The information required to support color remapping
  91993. */
  91994. remapData: Vector4;
  91995. /** @hidden */
  91996. _randomCellOffset?: number;
  91997. /** @hidden */
  91998. _initialDirection: Nullable<Vector3>;
  91999. /** @hidden */
  92000. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92001. /** @hidden */
  92002. _initialStartSpriteCellID: number;
  92003. /** @hidden */
  92004. _initialEndSpriteCellID: number;
  92005. /** @hidden */
  92006. _currentColorGradient: Nullable<ColorGradient>;
  92007. /** @hidden */
  92008. _currentColor1: Color4;
  92009. /** @hidden */
  92010. _currentColor2: Color4;
  92011. /** @hidden */
  92012. _currentSizeGradient: Nullable<FactorGradient>;
  92013. /** @hidden */
  92014. _currentSize1: number;
  92015. /** @hidden */
  92016. _currentSize2: number;
  92017. /** @hidden */
  92018. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92019. /** @hidden */
  92020. _currentAngularSpeed1: number;
  92021. /** @hidden */
  92022. _currentAngularSpeed2: number;
  92023. /** @hidden */
  92024. _currentVelocityGradient: Nullable<FactorGradient>;
  92025. /** @hidden */
  92026. _currentVelocity1: number;
  92027. /** @hidden */
  92028. _currentVelocity2: number;
  92029. /** @hidden */
  92030. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92031. /** @hidden */
  92032. _currentLimitVelocity1: number;
  92033. /** @hidden */
  92034. _currentLimitVelocity2: number;
  92035. /** @hidden */
  92036. _currentDragGradient: Nullable<FactorGradient>;
  92037. /** @hidden */
  92038. _currentDrag1: number;
  92039. /** @hidden */
  92040. _currentDrag2: number;
  92041. /** @hidden */
  92042. _randomNoiseCoordinates1: Vector3;
  92043. /** @hidden */
  92044. _randomNoiseCoordinates2: Vector3;
  92045. /** @hidden */
  92046. _localPosition?: Vector3;
  92047. /**
  92048. * Creates a new instance Particle
  92049. * @param particleSystem the particle system the particle belongs to
  92050. */
  92051. constructor(
  92052. /**
  92053. * The particle system the particle belongs to.
  92054. */
  92055. particleSystem: ParticleSystem);
  92056. private updateCellInfoFromSystem;
  92057. /**
  92058. * Defines how the sprite cell index is updated for the particle
  92059. */
  92060. updateCellIndex(): void;
  92061. /** @hidden */
  92062. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92063. /** @hidden */
  92064. _inheritParticleInfoToSubEmitters(): void;
  92065. /** @hidden */
  92066. _reset(): void;
  92067. /**
  92068. * Copy the properties of particle to another one.
  92069. * @param other the particle to copy the information to.
  92070. */
  92071. copyTo(other: Particle): void;
  92072. }
  92073. }
  92074. declare module BABYLON {
  92075. /**
  92076. * Particle emitter represents a volume emitting particles.
  92077. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92078. */
  92079. export interface IParticleEmitterType {
  92080. /**
  92081. * Called by the particle System when the direction is computed for the created particle.
  92082. * @param worldMatrix is the world matrix of the particle system
  92083. * @param directionToUpdate is the direction vector to update with the result
  92084. * @param particle is the particle we are computed the direction for
  92085. * @param isLocal defines if the direction should be set in local space
  92086. */
  92087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92088. /**
  92089. * Called by the particle System when the position is computed for the created particle.
  92090. * @param worldMatrix is the world matrix of the particle system
  92091. * @param positionToUpdate is the position vector to update with the result
  92092. * @param particle is the particle we are computed the position for
  92093. * @param isLocal defines if the position should be set in local space
  92094. */
  92095. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92096. /**
  92097. * Clones the current emitter and returns a copy of it
  92098. * @returns the new emitter
  92099. */
  92100. clone(): IParticleEmitterType;
  92101. /**
  92102. * Called by the GPUParticleSystem to setup the update shader
  92103. * @param effect defines the update shader
  92104. */
  92105. applyToShader(effect: Effect): void;
  92106. /**
  92107. * Returns a string to use to update the GPU particles update shader
  92108. * @returns the effect defines string
  92109. */
  92110. getEffectDefines(): string;
  92111. /**
  92112. * Returns a string representing the class name
  92113. * @returns a string containing the class name
  92114. */
  92115. getClassName(): string;
  92116. /**
  92117. * Serializes the particle system to a JSON object.
  92118. * @returns the JSON object
  92119. */
  92120. serialize(): any;
  92121. /**
  92122. * Parse properties from a JSON object
  92123. * @param serializationObject defines the JSON object
  92124. * @param scene defines the hosting scene
  92125. */
  92126. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92127. }
  92128. }
  92129. declare module BABYLON {
  92130. /**
  92131. * Particle emitter emitting particles from the inside of a box.
  92132. * It emits the particles randomly between 2 given directions.
  92133. */
  92134. export class BoxParticleEmitter implements IParticleEmitterType {
  92135. /**
  92136. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92137. */
  92138. direction1: Vector3;
  92139. /**
  92140. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92141. */
  92142. direction2: Vector3;
  92143. /**
  92144. * 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.
  92145. */
  92146. minEmitBox: Vector3;
  92147. /**
  92148. * 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.
  92149. */
  92150. maxEmitBox: Vector3;
  92151. /**
  92152. * Creates a new instance BoxParticleEmitter
  92153. */
  92154. constructor();
  92155. /**
  92156. * Called by the particle System when the direction is computed for the created particle.
  92157. * @param worldMatrix is the world matrix of the particle system
  92158. * @param directionToUpdate is the direction vector to update with the result
  92159. * @param particle is the particle we are computed the direction for
  92160. * @param isLocal defines if the direction should be set in local space
  92161. */
  92162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92163. /**
  92164. * Called by the particle System when the position is computed for the created particle.
  92165. * @param worldMatrix is the world matrix of the particle system
  92166. * @param positionToUpdate is the position vector to update with the result
  92167. * @param particle is the particle we are computed the position for
  92168. * @param isLocal defines if the position should be set in local space
  92169. */
  92170. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92171. /**
  92172. * Clones the current emitter and returns a copy of it
  92173. * @returns the new emitter
  92174. */
  92175. clone(): BoxParticleEmitter;
  92176. /**
  92177. * Called by the GPUParticleSystem to setup the update shader
  92178. * @param effect defines the update shader
  92179. */
  92180. applyToShader(effect: Effect): void;
  92181. /**
  92182. * Returns a string to use to update the GPU particles update shader
  92183. * @returns a string containng the defines string
  92184. */
  92185. getEffectDefines(): string;
  92186. /**
  92187. * Returns the string "BoxParticleEmitter"
  92188. * @returns a string containing the class name
  92189. */
  92190. getClassName(): string;
  92191. /**
  92192. * Serializes the particle system to a JSON object.
  92193. * @returns the JSON object
  92194. */
  92195. serialize(): any;
  92196. /**
  92197. * Parse properties from a JSON object
  92198. * @param serializationObject defines the JSON object
  92199. */
  92200. parse(serializationObject: any): void;
  92201. }
  92202. }
  92203. declare module BABYLON {
  92204. /**
  92205. * Particle emitter emitting particles from the inside of a cone.
  92206. * It emits the particles alongside the cone volume from the base to the particle.
  92207. * The emission direction might be randomized.
  92208. */
  92209. export class ConeParticleEmitter implements IParticleEmitterType {
  92210. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92211. directionRandomizer: number;
  92212. private _radius;
  92213. private _angle;
  92214. private _height;
  92215. /**
  92216. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92217. */
  92218. radiusRange: number;
  92219. /**
  92220. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92221. */
  92222. heightRange: number;
  92223. /**
  92224. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92225. */
  92226. emitFromSpawnPointOnly: boolean;
  92227. /**
  92228. * Gets or sets the radius of the emission cone
  92229. */
  92230. get radius(): number;
  92231. set radius(value: number);
  92232. /**
  92233. * Gets or sets the angle of the emission cone
  92234. */
  92235. get angle(): number;
  92236. set angle(value: number);
  92237. private _buildHeight;
  92238. /**
  92239. * Creates a new instance ConeParticleEmitter
  92240. * @param radius the radius of the emission cone (1 by default)
  92241. * @param angle the cone base angle (PI by default)
  92242. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92243. */
  92244. constructor(radius?: number, angle?: number,
  92245. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92246. directionRandomizer?: number);
  92247. /**
  92248. * Called by the particle System when the direction is computed for the created particle.
  92249. * @param worldMatrix is the world matrix of the particle system
  92250. * @param directionToUpdate is the direction vector to update with the result
  92251. * @param particle is the particle we are computed the direction for
  92252. * @param isLocal defines if the direction should be set in local space
  92253. */
  92254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92255. /**
  92256. * Called by the particle System when the position is computed for the created particle.
  92257. * @param worldMatrix is the world matrix of the particle system
  92258. * @param positionToUpdate is the position vector to update with the result
  92259. * @param particle is the particle we are computed the position for
  92260. * @param isLocal defines if the position should be set in local space
  92261. */
  92262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92263. /**
  92264. * Clones the current emitter and returns a copy of it
  92265. * @returns the new emitter
  92266. */
  92267. clone(): ConeParticleEmitter;
  92268. /**
  92269. * Called by the GPUParticleSystem to setup the update shader
  92270. * @param effect defines the update shader
  92271. */
  92272. applyToShader(effect: Effect): void;
  92273. /**
  92274. * Returns a string to use to update the GPU particles update shader
  92275. * @returns a string containng the defines string
  92276. */
  92277. getEffectDefines(): string;
  92278. /**
  92279. * Returns the string "ConeParticleEmitter"
  92280. * @returns a string containing the class name
  92281. */
  92282. getClassName(): string;
  92283. /**
  92284. * Serializes the particle system to a JSON object.
  92285. * @returns the JSON object
  92286. */
  92287. serialize(): any;
  92288. /**
  92289. * Parse properties from a JSON object
  92290. * @param serializationObject defines the JSON object
  92291. */
  92292. parse(serializationObject: any): void;
  92293. }
  92294. }
  92295. declare module BABYLON {
  92296. /**
  92297. * Particle emitter emitting particles from the inside of a cylinder.
  92298. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92299. */
  92300. export class CylinderParticleEmitter implements IParticleEmitterType {
  92301. /**
  92302. * The radius of the emission cylinder.
  92303. */
  92304. radius: number;
  92305. /**
  92306. * The height of the emission cylinder.
  92307. */
  92308. height: number;
  92309. /**
  92310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92311. */
  92312. radiusRange: number;
  92313. /**
  92314. * How much to randomize the particle direction [0-1].
  92315. */
  92316. directionRandomizer: number;
  92317. /**
  92318. * Creates a new instance CylinderParticleEmitter
  92319. * @param radius the radius of the emission cylinder (1 by default)
  92320. * @param height the height of the emission cylinder (1 by default)
  92321. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92322. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92323. */
  92324. constructor(
  92325. /**
  92326. * The radius of the emission cylinder.
  92327. */
  92328. radius?: number,
  92329. /**
  92330. * The height of the emission cylinder.
  92331. */
  92332. height?: number,
  92333. /**
  92334. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92335. */
  92336. radiusRange?: number,
  92337. /**
  92338. * How much to randomize the particle direction [0-1].
  92339. */
  92340. directionRandomizer?: number);
  92341. /**
  92342. * Called by the particle System when the direction is computed for the created particle.
  92343. * @param worldMatrix is the world matrix of the particle system
  92344. * @param directionToUpdate is the direction vector to update with the result
  92345. * @param particle is the particle we are computed the direction for
  92346. * @param isLocal defines if the direction should be set in local space
  92347. */
  92348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92349. /**
  92350. * Called by the particle System when the position is computed for the created particle.
  92351. * @param worldMatrix is the world matrix of the particle system
  92352. * @param positionToUpdate is the position vector to update with the result
  92353. * @param particle is the particle we are computed the position for
  92354. * @param isLocal defines if the position should be set in local space
  92355. */
  92356. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92357. /**
  92358. * Clones the current emitter and returns a copy of it
  92359. * @returns the new emitter
  92360. */
  92361. clone(): CylinderParticleEmitter;
  92362. /**
  92363. * Called by the GPUParticleSystem to setup the update shader
  92364. * @param effect defines the update shader
  92365. */
  92366. applyToShader(effect: Effect): void;
  92367. /**
  92368. * Returns a string to use to update the GPU particles update shader
  92369. * @returns a string containng the defines string
  92370. */
  92371. getEffectDefines(): string;
  92372. /**
  92373. * Returns the string "CylinderParticleEmitter"
  92374. * @returns a string containing the class name
  92375. */
  92376. getClassName(): string;
  92377. /**
  92378. * Serializes the particle system to a JSON object.
  92379. * @returns the JSON object
  92380. */
  92381. serialize(): any;
  92382. /**
  92383. * Parse properties from a JSON object
  92384. * @param serializationObject defines the JSON object
  92385. */
  92386. parse(serializationObject: any): void;
  92387. }
  92388. /**
  92389. * Particle emitter emitting particles from the inside of a cylinder.
  92390. * It emits the particles randomly between two vectors.
  92391. */
  92392. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92393. /**
  92394. * The min limit of the emission direction.
  92395. */
  92396. direction1: Vector3;
  92397. /**
  92398. * The max limit of the emission direction.
  92399. */
  92400. direction2: Vector3;
  92401. /**
  92402. * Creates a new instance CylinderDirectedParticleEmitter
  92403. * @param radius the radius of the emission cylinder (1 by default)
  92404. * @param height the height of the emission cylinder (1 by default)
  92405. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92406. * @param direction1 the min limit of the emission direction (up vector by default)
  92407. * @param direction2 the max limit of the emission direction (up vector by default)
  92408. */
  92409. constructor(radius?: number, height?: number, radiusRange?: number,
  92410. /**
  92411. * The min limit of the emission direction.
  92412. */
  92413. direction1?: Vector3,
  92414. /**
  92415. * The max limit of the emission direction.
  92416. */
  92417. direction2?: Vector3);
  92418. /**
  92419. * Called by the particle System when the direction is computed for the created particle.
  92420. * @param worldMatrix is the world matrix of the particle system
  92421. * @param directionToUpdate is the direction vector to update with the result
  92422. * @param particle is the particle we are computed the direction for
  92423. */
  92424. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92425. /**
  92426. * Clones the current emitter and returns a copy of it
  92427. * @returns the new emitter
  92428. */
  92429. clone(): CylinderDirectedParticleEmitter;
  92430. /**
  92431. * Called by the GPUParticleSystem to setup the update shader
  92432. * @param effect defines the update shader
  92433. */
  92434. applyToShader(effect: Effect): void;
  92435. /**
  92436. * Returns a string to use to update the GPU particles update shader
  92437. * @returns a string containng the defines string
  92438. */
  92439. getEffectDefines(): string;
  92440. /**
  92441. * Returns the string "CylinderDirectedParticleEmitter"
  92442. * @returns a string containing the class name
  92443. */
  92444. getClassName(): string;
  92445. /**
  92446. * Serializes the particle system to a JSON object.
  92447. * @returns the JSON object
  92448. */
  92449. serialize(): any;
  92450. /**
  92451. * Parse properties from a JSON object
  92452. * @param serializationObject defines the JSON object
  92453. */
  92454. parse(serializationObject: any): void;
  92455. }
  92456. }
  92457. declare module BABYLON {
  92458. /**
  92459. * Particle emitter emitting particles from the inside of a hemisphere.
  92460. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92461. */
  92462. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92463. /**
  92464. * The radius of the emission hemisphere.
  92465. */
  92466. radius: number;
  92467. /**
  92468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92469. */
  92470. radiusRange: number;
  92471. /**
  92472. * How much to randomize the particle direction [0-1].
  92473. */
  92474. directionRandomizer: number;
  92475. /**
  92476. * Creates a new instance HemisphericParticleEmitter
  92477. * @param radius the radius of the emission hemisphere (1 by default)
  92478. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92479. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92480. */
  92481. constructor(
  92482. /**
  92483. * The radius of the emission hemisphere.
  92484. */
  92485. radius?: number,
  92486. /**
  92487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92488. */
  92489. radiusRange?: number,
  92490. /**
  92491. * How much to randomize the particle direction [0-1].
  92492. */
  92493. directionRandomizer?: number);
  92494. /**
  92495. * Called by the particle System when the direction is computed for the created particle.
  92496. * @param worldMatrix is the world matrix of the particle system
  92497. * @param directionToUpdate is the direction vector to update with the result
  92498. * @param particle is the particle we are computed the direction for
  92499. * @param isLocal defines if the direction should be set in local space
  92500. */
  92501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92502. /**
  92503. * Called by the particle System when the position is computed for the created particle.
  92504. * @param worldMatrix is the world matrix of the particle system
  92505. * @param positionToUpdate is the position vector to update with the result
  92506. * @param particle is the particle we are computed the position for
  92507. * @param isLocal defines if the position should be set in local space
  92508. */
  92509. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92510. /**
  92511. * Clones the current emitter and returns a copy of it
  92512. * @returns the new emitter
  92513. */
  92514. clone(): HemisphericParticleEmitter;
  92515. /**
  92516. * Called by the GPUParticleSystem to setup the update shader
  92517. * @param effect defines the update shader
  92518. */
  92519. applyToShader(effect: Effect): void;
  92520. /**
  92521. * Returns a string to use to update the GPU particles update shader
  92522. * @returns a string containng the defines string
  92523. */
  92524. getEffectDefines(): string;
  92525. /**
  92526. * Returns the string "HemisphericParticleEmitter"
  92527. * @returns a string containing the class name
  92528. */
  92529. getClassName(): string;
  92530. /**
  92531. * Serializes the particle system to a JSON object.
  92532. * @returns the JSON object
  92533. */
  92534. serialize(): any;
  92535. /**
  92536. * Parse properties from a JSON object
  92537. * @param serializationObject defines the JSON object
  92538. */
  92539. parse(serializationObject: any): void;
  92540. }
  92541. }
  92542. declare module BABYLON {
  92543. /**
  92544. * Particle emitter emitting particles from a point.
  92545. * It emits the particles randomly between 2 given directions.
  92546. */
  92547. export class PointParticleEmitter implements IParticleEmitterType {
  92548. /**
  92549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92550. */
  92551. direction1: Vector3;
  92552. /**
  92553. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92554. */
  92555. direction2: Vector3;
  92556. /**
  92557. * Creates a new instance PointParticleEmitter
  92558. */
  92559. constructor();
  92560. /**
  92561. * Called by the particle System when the direction is computed for the created particle.
  92562. * @param worldMatrix is the world matrix of the particle system
  92563. * @param directionToUpdate is the direction vector to update with the result
  92564. * @param particle is the particle we are computed the direction for
  92565. * @param isLocal defines if the direction should be set in local space
  92566. */
  92567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92568. /**
  92569. * Called by the particle System when the position is computed for the created particle.
  92570. * @param worldMatrix is the world matrix of the particle system
  92571. * @param positionToUpdate is the position vector to update with the result
  92572. * @param particle is the particle we are computed the position for
  92573. * @param isLocal defines if the position should be set in local space
  92574. */
  92575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92576. /**
  92577. * Clones the current emitter and returns a copy of it
  92578. * @returns the new emitter
  92579. */
  92580. clone(): PointParticleEmitter;
  92581. /**
  92582. * Called by the GPUParticleSystem to setup the update shader
  92583. * @param effect defines the update shader
  92584. */
  92585. applyToShader(effect: Effect): void;
  92586. /**
  92587. * Returns a string to use to update the GPU particles update shader
  92588. * @returns a string containng the defines string
  92589. */
  92590. getEffectDefines(): string;
  92591. /**
  92592. * Returns the string "PointParticleEmitter"
  92593. * @returns a string containing the class name
  92594. */
  92595. getClassName(): string;
  92596. /**
  92597. * Serializes the particle system to a JSON object.
  92598. * @returns the JSON object
  92599. */
  92600. serialize(): any;
  92601. /**
  92602. * Parse properties from a JSON object
  92603. * @param serializationObject defines the JSON object
  92604. */
  92605. parse(serializationObject: any): void;
  92606. }
  92607. }
  92608. declare module BABYLON {
  92609. /**
  92610. * Particle emitter emitting particles from the inside of a sphere.
  92611. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92612. */
  92613. export class SphereParticleEmitter implements IParticleEmitterType {
  92614. /**
  92615. * The radius of the emission sphere.
  92616. */
  92617. radius: number;
  92618. /**
  92619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92620. */
  92621. radiusRange: number;
  92622. /**
  92623. * How much to randomize the particle direction [0-1].
  92624. */
  92625. directionRandomizer: number;
  92626. /**
  92627. * Creates a new instance SphereParticleEmitter
  92628. * @param radius the radius of the emission sphere (1 by default)
  92629. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92630. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92631. */
  92632. constructor(
  92633. /**
  92634. * The radius of the emission sphere.
  92635. */
  92636. radius?: number,
  92637. /**
  92638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92639. */
  92640. radiusRange?: number,
  92641. /**
  92642. * How much to randomize the particle direction [0-1].
  92643. */
  92644. directionRandomizer?: number);
  92645. /**
  92646. * Called by the particle System when the direction is computed for the created particle.
  92647. * @param worldMatrix is the world matrix of the particle system
  92648. * @param directionToUpdate is the direction vector to update with the result
  92649. * @param particle is the particle we are computed the direction for
  92650. * @param isLocal defines if the direction should be set in local space
  92651. */
  92652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92653. /**
  92654. * Called by the particle System when the position is computed for the created particle.
  92655. * @param worldMatrix is the world matrix of the particle system
  92656. * @param positionToUpdate is the position vector to update with the result
  92657. * @param particle is the particle we are computed the position for
  92658. * @param isLocal defines if the position should be set in local space
  92659. */
  92660. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92661. /**
  92662. * Clones the current emitter and returns a copy of it
  92663. * @returns the new emitter
  92664. */
  92665. clone(): SphereParticleEmitter;
  92666. /**
  92667. * Called by the GPUParticleSystem to setup the update shader
  92668. * @param effect defines the update shader
  92669. */
  92670. applyToShader(effect: Effect): void;
  92671. /**
  92672. * Returns a string to use to update the GPU particles update shader
  92673. * @returns a string containng the defines string
  92674. */
  92675. getEffectDefines(): string;
  92676. /**
  92677. * Returns the string "SphereParticleEmitter"
  92678. * @returns a string containing the class name
  92679. */
  92680. getClassName(): string;
  92681. /**
  92682. * Serializes the particle system to a JSON object.
  92683. * @returns the JSON object
  92684. */
  92685. serialize(): any;
  92686. /**
  92687. * Parse properties from a JSON object
  92688. * @param serializationObject defines the JSON object
  92689. */
  92690. parse(serializationObject: any): void;
  92691. }
  92692. /**
  92693. * Particle emitter emitting particles from the inside of a sphere.
  92694. * It emits the particles randomly between two vectors.
  92695. */
  92696. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92697. /**
  92698. * The min limit of the emission direction.
  92699. */
  92700. direction1: Vector3;
  92701. /**
  92702. * The max limit of the emission direction.
  92703. */
  92704. direction2: Vector3;
  92705. /**
  92706. * Creates a new instance SphereDirectedParticleEmitter
  92707. * @param radius the radius of the emission sphere (1 by default)
  92708. * @param direction1 the min limit of the emission direction (up vector by default)
  92709. * @param direction2 the max limit of the emission direction (up vector by default)
  92710. */
  92711. constructor(radius?: number,
  92712. /**
  92713. * The min limit of the emission direction.
  92714. */
  92715. direction1?: Vector3,
  92716. /**
  92717. * The max limit of the emission direction.
  92718. */
  92719. direction2?: Vector3);
  92720. /**
  92721. * Called by the particle System when the direction is computed for the created particle.
  92722. * @param worldMatrix is the world matrix of the particle system
  92723. * @param directionToUpdate is the direction vector to update with the result
  92724. * @param particle is the particle we are computed the direction for
  92725. */
  92726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92727. /**
  92728. * Clones the current emitter and returns a copy of it
  92729. * @returns the new emitter
  92730. */
  92731. clone(): SphereDirectedParticleEmitter;
  92732. /**
  92733. * Called by the GPUParticleSystem to setup the update shader
  92734. * @param effect defines the update shader
  92735. */
  92736. applyToShader(effect: Effect): void;
  92737. /**
  92738. * Returns a string to use to update the GPU particles update shader
  92739. * @returns a string containng the defines string
  92740. */
  92741. getEffectDefines(): string;
  92742. /**
  92743. * Returns the string "SphereDirectedParticleEmitter"
  92744. * @returns a string containing the class name
  92745. */
  92746. getClassName(): string;
  92747. /**
  92748. * Serializes the particle system to a JSON object.
  92749. * @returns the JSON object
  92750. */
  92751. serialize(): any;
  92752. /**
  92753. * Parse properties from a JSON object
  92754. * @param serializationObject defines the JSON object
  92755. */
  92756. parse(serializationObject: any): void;
  92757. }
  92758. }
  92759. declare module BABYLON {
  92760. /**
  92761. * Particle emitter emitting particles from a custom list of positions.
  92762. */
  92763. export class CustomParticleEmitter implements IParticleEmitterType {
  92764. /**
  92765. * Gets or sets the position generator that will create the inital position of each particle.
  92766. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92767. */
  92768. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92769. /**
  92770. * Gets or sets the destination generator that will create the final destination of each particle.
  92771. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92772. */
  92773. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92774. /**
  92775. * Creates a new instance CustomParticleEmitter
  92776. */
  92777. constructor();
  92778. /**
  92779. * Called by the particle System when the direction is computed for the created particle.
  92780. * @param worldMatrix is the world matrix of the particle system
  92781. * @param directionToUpdate is the direction vector to update with the result
  92782. * @param particle is the particle we are computed the direction for
  92783. * @param isLocal defines if the direction should be set in local space
  92784. */
  92785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92786. /**
  92787. * Called by the particle System when the position is computed for the created particle.
  92788. * @param worldMatrix is the world matrix of the particle system
  92789. * @param positionToUpdate is the position vector to update with the result
  92790. * @param particle is the particle we are computed the position for
  92791. * @param isLocal defines if the position should be set in local space
  92792. */
  92793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92794. /**
  92795. * Clones the current emitter and returns a copy of it
  92796. * @returns the new emitter
  92797. */
  92798. clone(): CustomParticleEmitter;
  92799. /**
  92800. * Called by the GPUParticleSystem to setup the update shader
  92801. * @param effect defines the update shader
  92802. */
  92803. applyToShader(effect: Effect): void;
  92804. /**
  92805. * Returns a string to use to update the GPU particles update shader
  92806. * @returns a string containng the defines string
  92807. */
  92808. getEffectDefines(): string;
  92809. /**
  92810. * Returns the string "PointParticleEmitter"
  92811. * @returns a string containing the class name
  92812. */
  92813. getClassName(): string;
  92814. /**
  92815. * Serializes the particle system to a JSON object.
  92816. * @returns the JSON object
  92817. */
  92818. serialize(): any;
  92819. /**
  92820. * Parse properties from a JSON object
  92821. * @param serializationObject defines the JSON object
  92822. */
  92823. parse(serializationObject: any): void;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /**
  92828. * Particle emitter emitting particles from the inside of a box.
  92829. * It emits the particles randomly between 2 given directions.
  92830. */
  92831. export class MeshParticleEmitter implements IParticleEmitterType {
  92832. private _indices;
  92833. private _positions;
  92834. private _normals;
  92835. private _storedNormal;
  92836. private _mesh;
  92837. /**
  92838. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92839. */
  92840. direction1: Vector3;
  92841. /**
  92842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92843. */
  92844. direction2: Vector3;
  92845. /**
  92846. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92847. */
  92848. useMeshNormalsForDirection: boolean;
  92849. /** Defines the mesh to use as source */
  92850. get mesh(): Nullable<AbstractMesh>;
  92851. set mesh(value: Nullable<AbstractMesh>);
  92852. /**
  92853. * Creates a new instance MeshParticleEmitter
  92854. * @param mesh defines the mesh to use as source
  92855. */
  92856. constructor(mesh?: Nullable<AbstractMesh>);
  92857. /**
  92858. * Called by the particle System when the direction is computed for the created particle.
  92859. * @param worldMatrix is the world matrix of the particle system
  92860. * @param directionToUpdate is the direction vector to update with the result
  92861. * @param particle is the particle we are computed the direction for
  92862. * @param isLocal defines if the direction should be set in local space
  92863. */
  92864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92865. /**
  92866. * Called by the particle System when the position is computed for the created particle.
  92867. * @param worldMatrix is the world matrix of the particle system
  92868. * @param positionToUpdate is the position vector to update with the result
  92869. * @param particle is the particle we are computed the position for
  92870. * @param isLocal defines if the position should be set in local space
  92871. */
  92872. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92873. /**
  92874. * Clones the current emitter and returns a copy of it
  92875. * @returns the new emitter
  92876. */
  92877. clone(): MeshParticleEmitter;
  92878. /**
  92879. * Called by the GPUParticleSystem to setup the update shader
  92880. * @param effect defines the update shader
  92881. */
  92882. applyToShader(effect: Effect): void;
  92883. /**
  92884. * Returns a string to use to update the GPU particles update shader
  92885. * @returns a string containng the defines string
  92886. */
  92887. getEffectDefines(): string;
  92888. /**
  92889. * Returns the string "BoxParticleEmitter"
  92890. * @returns a string containing the class name
  92891. */
  92892. getClassName(): string;
  92893. /**
  92894. * Serializes the particle system to a JSON object.
  92895. * @returns the JSON object
  92896. */
  92897. serialize(): any;
  92898. /**
  92899. * Parse properties from a JSON object
  92900. * @param serializationObject defines the JSON object
  92901. * @param scene defines the hosting scene
  92902. */
  92903. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92904. }
  92905. }
  92906. declare module BABYLON {
  92907. /**
  92908. * Interface representing a particle system in Babylon.js.
  92909. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92910. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92911. */
  92912. export interface IParticleSystem {
  92913. /**
  92914. * List of animations used by the particle system.
  92915. */
  92916. animations: Animation[];
  92917. /**
  92918. * The id of the Particle system.
  92919. */
  92920. id: string;
  92921. /**
  92922. * The name of the Particle system.
  92923. */
  92924. name: string;
  92925. /**
  92926. * The emitter represents the Mesh or position we are attaching the particle system to.
  92927. */
  92928. emitter: Nullable<AbstractMesh | Vector3>;
  92929. /**
  92930. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92931. */
  92932. isBillboardBased: boolean;
  92933. /**
  92934. * The rendering group used by the Particle system to chose when to render.
  92935. */
  92936. renderingGroupId: number;
  92937. /**
  92938. * The layer mask we are rendering the particles through.
  92939. */
  92940. layerMask: number;
  92941. /**
  92942. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92943. */
  92944. updateSpeed: number;
  92945. /**
  92946. * The amount of time the particle system is running (depends of the overall update speed).
  92947. */
  92948. targetStopDuration: number;
  92949. /**
  92950. * The texture used to render each particle. (this can be a spritesheet)
  92951. */
  92952. particleTexture: Nullable<BaseTexture>;
  92953. /**
  92954. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92955. */
  92956. blendMode: number;
  92957. /**
  92958. * Minimum life time of emitting particles.
  92959. */
  92960. minLifeTime: number;
  92961. /**
  92962. * Maximum life time of emitting particles.
  92963. */
  92964. maxLifeTime: number;
  92965. /**
  92966. * Minimum Size of emitting particles.
  92967. */
  92968. minSize: number;
  92969. /**
  92970. * Maximum Size of emitting particles.
  92971. */
  92972. maxSize: number;
  92973. /**
  92974. * Minimum scale of emitting particles on X axis.
  92975. */
  92976. minScaleX: number;
  92977. /**
  92978. * Maximum scale of emitting particles on X axis.
  92979. */
  92980. maxScaleX: number;
  92981. /**
  92982. * Minimum scale of emitting particles on Y axis.
  92983. */
  92984. minScaleY: number;
  92985. /**
  92986. * Maximum scale of emitting particles on Y axis.
  92987. */
  92988. maxScaleY: number;
  92989. /**
  92990. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92991. */
  92992. color1: Color4;
  92993. /**
  92994. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92995. */
  92996. color2: Color4;
  92997. /**
  92998. * Color the particle will have at the end of its lifetime.
  92999. */
  93000. colorDead: Color4;
  93001. /**
  93002. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93003. */
  93004. emitRate: number;
  93005. /**
  93006. * You can use gravity if you want to give an orientation to your particles.
  93007. */
  93008. gravity: Vector3;
  93009. /**
  93010. * Minimum power of emitting particles.
  93011. */
  93012. minEmitPower: number;
  93013. /**
  93014. * Maximum power of emitting particles.
  93015. */
  93016. maxEmitPower: number;
  93017. /**
  93018. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93019. */
  93020. minAngularSpeed: number;
  93021. /**
  93022. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93023. */
  93024. maxAngularSpeed: number;
  93025. /**
  93026. * Gets or sets the minimal initial rotation in radians.
  93027. */
  93028. minInitialRotation: number;
  93029. /**
  93030. * Gets or sets the maximal initial rotation in radians.
  93031. */
  93032. maxInitialRotation: number;
  93033. /**
  93034. * The particle emitter type defines the emitter used by the particle system.
  93035. * It can be for example box, sphere, or cone...
  93036. */
  93037. particleEmitterType: Nullable<IParticleEmitterType>;
  93038. /**
  93039. * Defines the delay in milliseconds before starting the system (0 by default)
  93040. */
  93041. startDelay: number;
  93042. /**
  93043. * 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
  93044. */
  93045. preWarmCycles: number;
  93046. /**
  93047. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93048. */
  93049. preWarmStepOffset: number;
  93050. /**
  93051. * 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)
  93052. */
  93053. spriteCellChangeSpeed: number;
  93054. /**
  93055. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93056. */
  93057. startSpriteCellID: number;
  93058. /**
  93059. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93060. */
  93061. endSpriteCellID: number;
  93062. /**
  93063. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93064. */
  93065. spriteCellWidth: number;
  93066. /**
  93067. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93068. */
  93069. spriteCellHeight: number;
  93070. /**
  93071. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93072. */
  93073. spriteRandomStartCell: boolean;
  93074. /**
  93075. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93076. */
  93077. isAnimationSheetEnabled: boolean;
  93078. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93079. translationPivot: Vector2;
  93080. /**
  93081. * Gets or sets a texture used to add random noise to particle positions
  93082. */
  93083. noiseTexture: Nullable<BaseTexture>;
  93084. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93085. noiseStrength: Vector3;
  93086. /**
  93087. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93088. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93089. */
  93090. billboardMode: number;
  93091. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93092. limitVelocityDamping: number;
  93093. /**
  93094. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93095. */
  93096. beginAnimationOnStart: boolean;
  93097. /**
  93098. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93099. */
  93100. beginAnimationFrom: number;
  93101. /**
  93102. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93103. */
  93104. beginAnimationTo: number;
  93105. /**
  93106. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93107. */
  93108. beginAnimationLoop: boolean;
  93109. /**
  93110. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93111. */
  93112. disposeOnStop: boolean;
  93113. /**
  93114. * Specifies if the particles are updated in emitter local space or world space
  93115. */
  93116. isLocal: boolean;
  93117. /** Snippet ID if the particle system was created from the snippet server */
  93118. snippetId: string;
  93119. /** Gets or sets a matrix to use to compute projection */
  93120. defaultProjectionMatrix: Matrix;
  93121. /**
  93122. * Gets the maximum number of particles active at the same time.
  93123. * @returns The max number of active particles.
  93124. */
  93125. getCapacity(): number;
  93126. /**
  93127. * Gets the number of particles active at the same time.
  93128. * @returns The number of active particles.
  93129. */
  93130. getActiveCount(): number;
  93131. /**
  93132. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93133. * @returns True if it has been started, otherwise false.
  93134. */
  93135. isStarted(): boolean;
  93136. /**
  93137. * Animates the particle system for this frame.
  93138. */
  93139. animate(): void;
  93140. /**
  93141. * Renders the particle system in its current state.
  93142. * @returns the current number of particles
  93143. */
  93144. render(): number;
  93145. /**
  93146. * Dispose the particle system and frees its associated resources.
  93147. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93148. */
  93149. dispose(disposeTexture?: boolean): void;
  93150. /**
  93151. * An event triggered when the system is disposed
  93152. */
  93153. onDisposeObservable: Observable<IParticleSystem>;
  93154. /**
  93155. * Clones the particle system.
  93156. * @param name The name of the cloned object
  93157. * @param newEmitter The new emitter to use
  93158. * @returns the cloned particle system
  93159. */
  93160. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93161. /**
  93162. * Serializes the particle system to a JSON object
  93163. * @param serializeTexture defines if the texture must be serialized as well
  93164. * @returns the JSON object
  93165. */
  93166. serialize(serializeTexture: boolean): any;
  93167. /**
  93168. * Rebuild the particle system
  93169. */
  93170. rebuild(): void;
  93171. /** Force the system to rebuild all gradients that need to be resync */
  93172. forceRefreshGradients(): void;
  93173. /**
  93174. * Starts the particle system and begins to emit
  93175. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93176. */
  93177. start(delay?: number): void;
  93178. /**
  93179. * Stops the particle system.
  93180. */
  93181. stop(): void;
  93182. /**
  93183. * Remove all active particles
  93184. */
  93185. reset(): void;
  93186. /**
  93187. * Gets a boolean indicating that the system is stopping
  93188. * @returns true if the system is currently stopping
  93189. */
  93190. isStopping(): boolean;
  93191. /**
  93192. * Is this system ready to be used/rendered
  93193. * @return true if the system is ready
  93194. */
  93195. isReady(): boolean;
  93196. /**
  93197. * Returns the string "ParticleSystem"
  93198. * @returns a string containing the class name
  93199. */
  93200. getClassName(): string;
  93201. /**
  93202. * Gets the custom effect used to render the particles
  93203. * @param blendMode Blend mode for which the effect should be retrieved
  93204. * @returns The effect
  93205. */
  93206. getCustomEffect(blendMode: number): Nullable<Effect>;
  93207. /**
  93208. * Sets the custom effect used to render the particles
  93209. * @param effect The effect to set
  93210. * @param blendMode Blend mode for which the effect should be set
  93211. */
  93212. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93213. /**
  93214. * Fill the defines array according to the current settings of the particle system
  93215. * @param defines Array to be updated
  93216. * @param blendMode blend mode to take into account when updating the array
  93217. */
  93218. fillDefines(defines: Array<string>, blendMode: number): void;
  93219. /**
  93220. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93221. * @param uniforms Uniforms array to fill
  93222. * @param attributes Attributes array to fill
  93223. * @param samplers Samplers array to fill
  93224. */
  93225. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93226. /**
  93227. * Observable that will be called just before the particles are drawn
  93228. */
  93229. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93230. /**
  93231. * Gets the name of the particle vertex shader
  93232. */
  93233. vertexShaderName: string;
  93234. /**
  93235. * Adds a new color gradient
  93236. * @param gradient defines the gradient to use (between 0 and 1)
  93237. * @param color1 defines the color to affect to the specified gradient
  93238. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93239. * @returns the current particle system
  93240. */
  93241. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93242. /**
  93243. * Remove a specific color gradient
  93244. * @param gradient defines the gradient to remove
  93245. * @returns the current particle system
  93246. */
  93247. removeColorGradient(gradient: number): IParticleSystem;
  93248. /**
  93249. * Adds a new size gradient
  93250. * @param gradient defines the gradient to use (between 0 and 1)
  93251. * @param factor defines the size factor to affect to the specified gradient
  93252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93253. * @returns the current particle system
  93254. */
  93255. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93256. /**
  93257. * Remove a specific size gradient
  93258. * @param gradient defines the gradient to remove
  93259. * @returns the current particle system
  93260. */
  93261. removeSizeGradient(gradient: number): IParticleSystem;
  93262. /**
  93263. * Gets the current list of color gradients.
  93264. * You must use addColorGradient and removeColorGradient to udpate this list
  93265. * @returns the list of color gradients
  93266. */
  93267. getColorGradients(): Nullable<Array<ColorGradient>>;
  93268. /**
  93269. * Gets the current list of size gradients.
  93270. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93271. * @returns the list of size gradients
  93272. */
  93273. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93274. /**
  93275. * Gets the current list of angular speed gradients.
  93276. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93277. * @returns the list of angular speed gradients
  93278. */
  93279. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93280. /**
  93281. * Adds a new angular speed gradient
  93282. * @param gradient defines the gradient to use (between 0 and 1)
  93283. * @param factor defines the angular speed to affect to the specified gradient
  93284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93285. * @returns the current particle system
  93286. */
  93287. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93288. /**
  93289. * Remove a specific angular speed gradient
  93290. * @param gradient defines the gradient to remove
  93291. * @returns the current particle system
  93292. */
  93293. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93294. /**
  93295. * Gets the current list of velocity gradients.
  93296. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93297. * @returns the list of velocity gradients
  93298. */
  93299. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93300. /**
  93301. * Adds a new velocity gradient
  93302. * @param gradient defines the gradient to use (between 0 and 1)
  93303. * @param factor defines the velocity to affect to the specified gradient
  93304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93305. * @returns the current particle system
  93306. */
  93307. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93308. /**
  93309. * Remove a specific velocity gradient
  93310. * @param gradient defines the gradient to remove
  93311. * @returns the current particle system
  93312. */
  93313. removeVelocityGradient(gradient: number): IParticleSystem;
  93314. /**
  93315. * Gets the current list of limit velocity gradients.
  93316. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93317. * @returns the list of limit velocity gradients
  93318. */
  93319. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93320. /**
  93321. * Adds a new limit velocity gradient
  93322. * @param gradient defines the gradient to use (between 0 and 1)
  93323. * @param factor defines the limit velocity to affect to the specified gradient
  93324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93325. * @returns the current particle system
  93326. */
  93327. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93328. /**
  93329. * Remove a specific limit velocity gradient
  93330. * @param gradient defines the gradient to remove
  93331. * @returns the current particle system
  93332. */
  93333. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93334. /**
  93335. * Adds a new drag gradient
  93336. * @param gradient defines the gradient to use (between 0 and 1)
  93337. * @param factor defines the drag to affect to the specified gradient
  93338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93339. * @returns the current particle system
  93340. */
  93341. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93342. /**
  93343. * Remove a specific drag gradient
  93344. * @param gradient defines the gradient to remove
  93345. * @returns the current particle system
  93346. */
  93347. removeDragGradient(gradient: number): IParticleSystem;
  93348. /**
  93349. * Gets the current list of drag gradients.
  93350. * You must use addDragGradient and removeDragGradient to udpate this list
  93351. * @returns the list of drag gradients
  93352. */
  93353. getDragGradients(): Nullable<Array<FactorGradient>>;
  93354. /**
  93355. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93356. * @param gradient defines the gradient to use (between 0 and 1)
  93357. * @param factor defines the emit rate to affect to the specified gradient
  93358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93359. * @returns the current particle system
  93360. */
  93361. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93362. /**
  93363. * Remove a specific emit rate gradient
  93364. * @param gradient defines the gradient to remove
  93365. * @returns the current particle system
  93366. */
  93367. removeEmitRateGradient(gradient: number): IParticleSystem;
  93368. /**
  93369. * Gets the current list of emit rate gradients.
  93370. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93371. * @returns the list of emit rate gradients
  93372. */
  93373. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93374. /**
  93375. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93376. * @param gradient defines the gradient to use (between 0 and 1)
  93377. * @param factor defines the start size to affect to the specified gradient
  93378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93379. * @returns the current particle system
  93380. */
  93381. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93382. /**
  93383. * Remove a specific start size gradient
  93384. * @param gradient defines the gradient to remove
  93385. * @returns the current particle system
  93386. */
  93387. removeStartSizeGradient(gradient: number): IParticleSystem;
  93388. /**
  93389. * Gets the current list of start size gradients.
  93390. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93391. * @returns the list of start size gradients
  93392. */
  93393. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93394. /**
  93395. * Adds a new life time gradient
  93396. * @param gradient defines the gradient to use (between 0 and 1)
  93397. * @param factor defines the life time factor to affect to the specified gradient
  93398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93399. * @returns the current particle system
  93400. */
  93401. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93402. /**
  93403. * Remove a specific life time gradient
  93404. * @param gradient defines the gradient to remove
  93405. * @returns the current particle system
  93406. */
  93407. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93408. /**
  93409. * Gets the current list of life time gradients.
  93410. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93411. * @returns the list of life time gradients
  93412. */
  93413. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93414. /**
  93415. * Gets the current list of color gradients.
  93416. * You must use addColorGradient and removeColorGradient to udpate this list
  93417. * @returns the list of color gradients
  93418. */
  93419. getColorGradients(): Nullable<Array<ColorGradient>>;
  93420. /**
  93421. * Adds a new ramp gradient used to remap particle colors
  93422. * @param gradient defines the gradient to use (between 0 and 1)
  93423. * @param color defines the color to affect to the specified gradient
  93424. * @returns the current particle system
  93425. */
  93426. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93427. /**
  93428. * Gets the current list of ramp gradients.
  93429. * You must use addRampGradient and removeRampGradient to udpate this list
  93430. * @returns the list of ramp gradients
  93431. */
  93432. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93433. /** Gets or sets a boolean indicating that ramp gradients must be used
  93434. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93435. */
  93436. useRampGradients: boolean;
  93437. /**
  93438. * Adds a new color remap gradient
  93439. * @param gradient defines the gradient to use (between 0 and 1)
  93440. * @param min defines the color remap minimal range
  93441. * @param max defines the color remap maximal range
  93442. * @returns the current particle system
  93443. */
  93444. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93445. /**
  93446. * Gets the current list of color remap gradients.
  93447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93448. * @returns the list of color remap gradients
  93449. */
  93450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93451. /**
  93452. * Adds a new alpha remap gradient
  93453. * @param gradient defines the gradient to use (between 0 and 1)
  93454. * @param min defines the alpha remap minimal range
  93455. * @param max defines the alpha remap maximal range
  93456. * @returns the current particle system
  93457. */
  93458. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93459. /**
  93460. * Gets the current list of alpha remap gradients.
  93461. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93462. * @returns the list of alpha remap gradients
  93463. */
  93464. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93465. /**
  93466. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93467. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93468. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93469. * @returns the emitter
  93470. */
  93471. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93472. /**
  93473. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93474. * @param radius The radius of the hemisphere to emit from
  93475. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93476. * @returns the emitter
  93477. */
  93478. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93479. /**
  93480. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93481. * @param radius The radius of the sphere to emit from
  93482. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93483. * @returns the emitter
  93484. */
  93485. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93486. /**
  93487. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93488. * @param radius The radius of the sphere to emit from
  93489. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93490. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93491. * @returns the emitter
  93492. */
  93493. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93494. /**
  93495. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93496. * @param radius The radius of the emission cylinder
  93497. * @param height The height of the emission cylinder
  93498. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93499. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93500. * @returns the emitter
  93501. */
  93502. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93503. /**
  93504. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93505. * @param radius The radius of the cylinder to emit from
  93506. * @param height The height of the emission cylinder
  93507. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93510. * @returns the emitter
  93511. */
  93512. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93513. /**
  93514. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93515. * @param radius The radius of the cone to emit from
  93516. * @param angle The base angle of the cone
  93517. * @returns the emitter
  93518. */
  93519. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93520. /**
  93521. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93524. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93525. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93526. * @returns the emitter
  93527. */
  93528. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93529. /**
  93530. * Get hosting scene
  93531. * @returns the scene
  93532. */
  93533. getScene(): Nullable<Scene>;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /**
  93538. * 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.
  93539. * @see https://doc.babylonjs.com/how_to/transformnode
  93540. */
  93541. export class TransformNode extends Node {
  93542. /**
  93543. * Object will not rotate to face the camera
  93544. */
  93545. static BILLBOARDMODE_NONE: number;
  93546. /**
  93547. * Object will rotate to face the camera but only on the x axis
  93548. */
  93549. static BILLBOARDMODE_X: number;
  93550. /**
  93551. * Object will rotate to face the camera but only on the y axis
  93552. */
  93553. static BILLBOARDMODE_Y: number;
  93554. /**
  93555. * Object will rotate to face the camera but only on the z axis
  93556. */
  93557. static BILLBOARDMODE_Z: number;
  93558. /**
  93559. * Object will rotate to face the camera
  93560. */
  93561. static BILLBOARDMODE_ALL: number;
  93562. /**
  93563. * Object will rotate to face the camera's position instead of orientation
  93564. */
  93565. static BILLBOARDMODE_USE_POSITION: number;
  93566. private static _TmpRotation;
  93567. private static _TmpScaling;
  93568. private static _TmpTranslation;
  93569. private _forward;
  93570. private _forwardInverted;
  93571. private _up;
  93572. private _right;
  93573. private _rightInverted;
  93574. private _position;
  93575. private _rotation;
  93576. private _rotationQuaternion;
  93577. protected _scaling: Vector3;
  93578. protected _isDirty: boolean;
  93579. private _transformToBoneReferal;
  93580. private _isAbsoluteSynced;
  93581. private _billboardMode;
  93582. /**
  93583. * Gets or sets the billboard mode. Default is 0.
  93584. *
  93585. * | Value | Type | Description |
  93586. * | --- | --- | --- |
  93587. * | 0 | BILLBOARDMODE_NONE | |
  93588. * | 1 | BILLBOARDMODE_X | |
  93589. * | 2 | BILLBOARDMODE_Y | |
  93590. * | 4 | BILLBOARDMODE_Z | |
  93591. * | 7 | BILLBOARDMODE_ALL | |
  93592. *
  93593. */
  93594. get billboardMode(): number;
  93595. set billboardMode(value: number);
  93596. private _preserveParentRotationForBillboard;
  93597. /**
  93598. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93599. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93600. */
  93601. get preserveParentRotationForBillboard(): boolean;
  93602. set preserveParentRotationForBillboard(value: boolean);
  93603. /**
  93604. * 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
  93605. */
  93606. scalingDeterminant: number;
  93607. private _infiniteDistance;
  93608. /**
  93609. * Gets or sets the distance of the object to max, often used by skybox
  93610. */
  93611. get infiniteDistance(): boolean;
  93612. set infiniteDistance(value: boolean);
  93613. /**
  93614. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93615. * By default the system will update normals to compensate
  93616. */
  93617. ignoreNonUniformScaling: boolean;
  93618. /**
  93619. * 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
  93620. */
  93621. reIntegrateRotationIntoRotationQuaternion: boolean;
  93622. /** @hidden */
  93623. _poseMatrix: Nullable<Matrix>;
  93624. /** @hidden */
  93625. _localMatrix: Matrix;
  93626. private _usePivotMatrix;
  93627. private _absolutePosition;
  93628. private _absoluteScaling;
  93629. private _absoluteRotationQuaternion;
  93630. private _pivotMatrix;
  93631. private _pivotMatrixInverse;
  93632. protected _postMultiplyPivotMatrix: boolean;
  93633. protected _isWorldMatrixFrozen: boolean;
  93634. /** @hidden */
  93635. _indexInSceneTransformNodesArray: number;
  93636. /**
  93637. * An event triggered after the world matrix is updated
  93638. */
  93639. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93640. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93641. /**
  93642. * Gets a string identifying the name of the class
  93643. * @returns "TransformNode" string
  93644. */
  93645. getClassName(): string;
  93646. /**
  93647. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93648. */
  93649. get position(): Vector3;
  93650. set position(newPosition: Vector3);
  93651. /**
  93652. * 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)).
  93653. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93654. */
  93655. get rotation(): Vector3;
  93656. set rotation(newRotation: Vector3);
  93657. /**
  93658. * 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)).
  93659. */
  93660. get scaling(): Vector3;
  93661. set scaling(newScaling: Vector3);
  93662. /**
  93663. * 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).
  93664. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93665. */
  93666. get rotationQuaternion(): Nullable<Quaternion>;
  93667. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93668. /**
  93669. * The forward direction of that transform in world space.
  93670. */
  93671. get forward(): Vector3;
  93672. /**
  93673. * The up direction of that transform in world space.
  93674. */
  93675. get up(): Vector3;
  93676. /**
  93677. * The right direction of that transform in world space.
  93678. */
  93679. get right(): Vector3;
  93680. /**
  93681. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93682. * @param matrix the matrix to copy the pose from
  93683. * @returns this TransformNode.
  93684. */
  93685. updatePoseMatrix(matrix: Matrix): TransformNode;
  93686. /**
  93687. * Returns the mesh Pose matrix.
  93688. * @returns the pose matrix
  93689. */
  93690. getPoseMatrix(): Matrix;
  93691. /** @hidden */
  93692. _isSynchronized(): boolean;
  93693. /** @hidden */
  93694. _initCache(): void;
  93695. /**
  93696. * Flag the transform node as dirty (Forcing it to update everything)
  93697. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93698. * @returns this transform node
  93699. */
  93700. markAsDirty(property: string): TransformNode;
  93701. /**
  93702. * Returns the current mesh absolute position.
  93703. * Returns a Vector3.
  93704. */
  93705. get absolutePosition(): Vector3;
  93706. /**
  93707. * Returns the current mesh absolute scaling.
  93708. * Returns a Vector3.
  93709. */
  93710. get absoluteScaling(): Vector3;
  93711. /**
  93712. * Returns the current mesh absolute rotation.
  93713. * Returns a Quaternion.
  93714. */
  93715. get absoluteRotationQuaternion(): Quaternion;
  93716. /**
  93717. * Sets a new matrix to apply before all other transformation
  93718. * @param matrix defines the transform matrix
  93719. * @returns the current TransformNode
  93720. */
  93721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93722. /**
  93723. * Sets a new pivot matrix to the current node
  93724. * @param matrix defines the new pivot matrix to use
  93725. * @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
  93726. * @returns the current TransformNode
  93727. */
  93728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93729. /**
  93730. * Returns the mesh pivot matrix.
  93731. * Default : Identity.
  93732. * @returns the matrix
  93733. */
  93734. getPivotMatrix(): Matrix;
  93735. /**
  93736. * Instantiate (when possible) or clone that node with its hierarchy
  93737. * @param newParent defines the new parent to use for the instance (or clone)
  93738. * @param options defines options to configure how copy is done
  93739. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93740. * @returns an instance (or a clone) of the current node with its hiearchy
  93741. */
  93742. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93743. doNotInstantiate: boolean;
  93744. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93745. /**
  93746. * Prevents the World matrix to be computed any longer
  93747. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93748. * @returns the TransformNode.
  93749. */
  93750. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93751. /**
  93752. * Allows back the World matrix computation.
  93753. * @returns the TransformNode.
  93754. */
  93755. unfreezeWorldMatrix(): this;
  93756. /**
  93757. * True if the World matrix has been frozen.
  93758. */
  93759. get isWorldMatrixFrozen(): boolean;
  93760. /**
  93761. * Retuns the mesh absolute position in the World.
  93762. * @returns a Vector3.
  93763. */
  93764. getAbsolutePosition(): Vector3;
  93765. /**
  93766. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93767. * @param absolutePosition the absolute position to set
  93768. * @returns the TransformNode.
  93769. */
  93770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93771. /**
  93772. * Sets the mesh position in its local space.
  93773. * @param vector3 the position to set in localspace
  93774. * @returns the TransformNode.
  93775. */
  93776. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93777. /**
  93778. * Returns the mesh position in the local space from the current World matrix values.
  93779. * @returns a new Vector3.
  93780. */
  93781. getPositionExpressedInLocalSpace(): Vector3;
  93782. /**
  93783. * Translates the mesh along the passed Vector3 in its local space.
  93784. * @param vector3 the distance to translate in localspace
  93785. * @returns the TransformNode.
  93786. */
  93787. locallyTranslate(vector3: Vector3): TransformNode;
  93788. private static _lookAtVectorCache;
  93789. /**
  93790. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93791. * @param targetPoint the position (must be in same space as current mesh) to look at
  93792. * @param yawCor optional yaw (y-axis) correction in radians
  93793. * @param pitchCor optional pitch (x-axis) correction in radians
  93794. * @param rollCor optional roll (z-axis) correction in radians
  93795. * @param space the choosen space of the target
  93796. * @returns the TransformNode.
  93797. */
  93798. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93799. /**
  93800. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93801. * This Vector3 is expressed in the World space.
  93802. * @param localAxis axis to rotate
  93803. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93804. */
  93805. getDirection(localAxis: Vector3): Vector3;
  93806. /**
  93807. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93808. * localAxis is expressed in the mesh local space.
  93809. * result is computed in the Wordl space from the mesh World matrix.
  93810. * @param localAxis axis to rotate
  93811. * @param result the resulting transformnode
  93812. * @returns this TransformNode.
  93813. */
  93814. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93815. /**
  93816. * Sets this transform node rotation to the given local axis.
  93817. * @param localAxis the axis in local space
  93818. * @param yawCor optional yaw (y-axis) correction in radians
  93819. * @param pitchCor optional pitch (x-axis) correction in radians
  93820. * @param rollCor optional roll (z-axis) correction in radians
  93821. * @returns this TransformNode
  93822. */
  93823. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93824. /**
  93825. * Sets a new pivot point to the current node
  93826. * @param point defines the new pivot point to use
  93827. * @param space defines if the point is in world or local space (local by default)
  93828. * @returns the current TransformNode
  93829. */
  93830. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93831. /**
  93832. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93833. * @returns the pivot point
  93834. */
  93835. getPivotPoint(): Vector3;
  93836. /**
  93837. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93838. * @param result the vector3 to store the result
  93839. * @returns this TransformNode.
  93840. */
  93841. getPivotPointToRef(result: Vector3): TransformNode;
  93842. /**
  93843. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93844. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93845. */
  93846. getAbsolutePivotPoint(): Vector3;
  93847. /**
  93848. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93849. * @param result vector3 to store the result
  93850. * @returns this TransformNode.
  93851. */
  93852. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93853. /**
  93854. * Defines the passed node as the parent of the current node.
  93855. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93856. * @see https://doc.babylonjs.com/how_to/parenting
  93857. * @param node the node ot set as the parent
  93858. * @returns this TransformNode.
  93859. */
  93860. setParent(node: Nullable<Node>): TransformNode;
  93861. private _nonUniformScaling;
  93862. /**
  93863. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93864. */
  93865. get nonUniformScaling(): boolean;
  93866. /** @hidden */
  93867. _updateNonUniformScalingState(value: boolean): boolean;
  93868. /**
  93869. * Attach the current TransformNode to another TransformNode associated with a bone
  93870. * @param bone Bone affecting the TransformNode
  93871. * @param affectedTransformNode TransformNode associated with the bone
  93872. * @returns this object
  93873. */
  93874. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93875. /**
  93876. * Detach the transform node if its associated with a bone
  93877. * @returns this object
  93878. */
  93879. detachFromBone(): TransformNode;
  93880. private static _rotationAxisCache;
  93881. /**
  93882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93883. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93885. * The passed axis is also normalized.
  93886. * @param axis the axis to rotate around
  93887. * @param amount the amount to rotate in radians
  93888. * @param space Space to rotate in (Default: local)
  93889. * @returns the TransformNode.
  93890. */
  93891. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93892. /**
  93893. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93894. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93895. * The passed axis is also normalized. .
  93896. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93897. * @param point the point to rotate around
  93898. * @param axis the axis to rotate around
  93899. * @param amount the amount to rotate in radians
  93900. * @returns the TransformNode
  93901. */
  93902. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93903. /**
  93904. * Translates the mesh along the axis vector for the passed distance in the given space.
  93905. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93906. * @param axis the axis to translate in
  93907. * @param distance the distance to translate
  93908. * @param space Space to rotate in (Default: local)
  93909. * @returns the TransformNode.
  93910. */
  93911. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93912. /**
  93913. * Adds a rotation step to the mesh current rotation.
  93914. * x, y, z are Euler angles expressed in radians.
  93915. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93916. * This means this rotation is made in the mesh local space only.
  93917. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93918. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93919. * ```javascript
  93920. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93921. * ```
  93922. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93923. * 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.
  93924. * @param x Rotation to add
  93925. * @param y Rotation to add
  93926. * @param z Rotation to add
  93927. * @returns the TransformNode.
  93928. */
  93929. addRotation(x: number, y: number, z: number): TransformNode;
  93930. /**
  93931. * @hidden
  93932. */
  93933. protected _getEffectiveParent(): Nullable<Node>;
  93934. /**
  93935. * Computes the world matrix of the node
  93936. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93937. * @returns the world matrix
  93938. */
  93939. computeWorldMatrix(force?: boolean): Matrix;
  93940. /**
  93941. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93942. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93943. */
  93944. resetLocalMatrix(independentOfChildren?: boolean): void;
  93945. protected _afterComputeWorldMatrix(): void;
  93946. /**
  93947. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93948. * @param func callback function to add
  93949. *
  93950. * @returns the TransformNode.
  93951. */
  93952. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93953. /**
  93954. * Removes a registered callback function.
  93955. * @param func callback function to remove
  93956. * @returns the TransformNode.
  93957. */
  93958. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93959. /**
  93960. * Gets the position of the current mesh in camera space
  93961. * @param camera defines the camera to use
  93962. * @returns a position
  93963. */
  93964. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93965. /**
  93966. * Returns the distance from the mesh to the active camera
  93967. * @param camera defines the camera to use
  93968. * @returns the distance
  93969. */
  93970. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93971. /**
  93972. * Clone the current transform node
  93973. * @param name Name of the new clone
  93974. * @param newParent New parent for the clone
  93975. * @param doNotCloneChildren Do not clone children hierarchy
  93976. * @returns the new transform node
  93977. */
  93978. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93979. /**
  93980. * Serializes the objects information.
  93981. * @param currentSerializationObject defines the object to serialize in
  93982. * @returns the serialized object
  93983. */
  93984. serialize(currentSerializationObject?: any): any;
  93985. /**
  93986. * Returns a new TransformNode object parsed from the source provided.
  93987. * @param parsedTransformNode is the source.
  93988. * @param scene the scne the object belongs to
  93989. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93990. * @returns a new TransformNode object parsed from the source provided.
  93991. */
  93992. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93993. /**
  93994. * Get all child-transformNodes of this node
  93995. * @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
  93996. * @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
  93997. * @returns an array of TransformNode
  93998. */
  93999. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94000. /**
  94001. * Releases resources associated with this transform node.
  94002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94004. */
  94005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94006. /**
  94007. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94008. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94009. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94010. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94011. * @returns the current mesh
  94012. */
  94013. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94014. private _syncAbsoluteScalingAndRotation;
  94015. }
  94016. }
  94017. declare module BABYLON {
  94018. /**
  94019. * Class used to override all child animations of a given target
  94020. */
  94021. export class AnimationPropertiesOverride {
  94022. /**
  94023. * Gets or sets a value indicating if animation blending must be used
  94024. */
  94025. enableBlending: boolean;
  94026. /**
  94027. * Gets or sets the blending speed to use when enableBlending is true
  94028. */
  94029. blendingSpeed: number;
  94030. /**
  94031. * Gets or sets the default loop mode to use
  94032. */
  94033. loopMode: number;
  94034. }
  94035. }
  94036. declare module BABYLON {
  94037. /**
  94038. * Class used to store bone information
  94039. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94040. */
  94041. export class Bone extends Node {
  94042. /**
  94043. * defines the bone name
  94044. */
  94045. name: string;
  94046. private static _tmpVecs;
  94047. private static _tmpQuat;
  94048. private static _tmpMats;
  94049. /**
  94050. * Gets the list of child bones
  94051. */
  94052. children: Bone[];
  94053. /** Gets the animations associated with this bone */
  94054. animations: Animation[];
  94055. /**
  94056. * Gets or sets bone length
  94057. */
  94058. length: number;
  94059. /**
  94060. * @hidden Internal only
  94061. * Set this value to map this bone to a different index in the transform matrices
  94062. * Set this value to -1 to exclude the bone from the transform matrices
  94063. */
  94064. _index: Nullable<number>;
  94065. private _skeleton;
  94066. private _localMatrix;
  94067. private _restPose;
  94068. private _bindPose;
  94069. private _baseMatrix;
  94070. private _absoluteTransform;
  94071. private _invertedAbsoluteTransform;
  94072. private _parent;
  94073. private _scalingDeterminant;
  94074. private _worldTransform;
  94075. private _localScaling;
  94076. private _localRotation;
  94077. private _localPosition;
  94078. private _needToDecompose;
  94079. private _needToCompose;
  94080. /** @hidden */
  94081. _linkedTransformNode: Nullable<TransformNode>;
  94082. /** @hidden */
  94083. _waitingTransformNodeId: Nullable<string>;
  94084. /** @hidden */
  94085. get _matrix(): Matrix;
  94086. /** @hidden */
  94087. set _matrix(value: Matrix);
  94088. /**
  94089. * Create a new bone
  94090. * @param name defines the bone name
  94091. * @param skeleton defines the parent skeleton
  94092. * @param parentBone defines the parent (can be null if the bone is the root)
  94093. * @param localMatrix defines the local matrix
  94094. * @param restPose defines the rest pose matrix
  94095. * @param baseMatrix defines the base matrix
  94096. * @param index defines index of the bone in the hiearchy
  94097. */
  94098. constructor(
  94099. /**
  94100. * defines the bone name
  94101. */
  94102. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94103. /**
  94104. * Gets the current object class name.
  94105. * @return the class name
  94106. */
  94107. getClassName(): string;
  94108. /**
  94109. * Gets the parent skeleton
  94110. * @returns a skeleton
  94111. */
  94112. getSkeleton(): Skeleton;
  94113. /**
  94114. * Gets parent bone
  94115. * @returns a bone or null if the bone is the root of the bone hierarchy
  94116. */
  94117. getParent(): Nullable<Bone>;
  94118. /**
  94119. * Returns an array containing the root bones
  94120. * @returns an array containing the root bones
  94121. */
  94122. getChildren(): Array<Bone>;
  94123. /**
  94124. * Gets the node index in matrix array generated for rendering
  94125. * @returns the node index
  94126. */
  94127. getIndex(): number;
  94128. /**
  94129. * Sets the parent bone
  94130. * @param parent defines the parent (can be null if the bone is the root)
  94131. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94132. */
  94133. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94134. /**
  94135. * Gets the local matrix
  94136. * @returns a matrix
  94137. */
  94138. getLocalMatrix(): Matrix;
  94139. /**
  94140. * Gets the base matrix (initial matrix which remains unchanged)
  94141. * @returns a matrix
  94142. */
  94143. getBaseMatrix(): Matrix;
  94144. /**
  94145. * Gets the rest pose matrix
  94146. * @returns a matrix
  94147. */
  94148. getRestPose(): Matrix;
  94149. /**
  94150. * Sets the rest pose matrix
  94151. * @param matrix the local-space rest pose to set for this bone
  94152. */
  94153. setRestPose(matrix: Matrix): void;
  94154. /**
  94155. * Gets the bind pose matrix
  94156. * @returns the bind pose matrix
  94157. */
  94158. getBindPose(): Matrix;
  94159. /**
  94160. * Sets the bind pose matrix
  94161. * @param matrix the local-space bind pose to set for this bone
  94162. */
  94163. setBindPose(matrix: Matrix): void;
  94164. /**
  94165. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94166. */
  94167. getWorldMatrix(): Matrix;
  94168. /**
  94169. * Sets the local matrix to rest pose matrix
  94170. */
  94171. returnToRest(): void;
  94172. /**
  94173. * Gets the inverse of the absolute transform matrix.
  94174. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94175. * @returns a matrix
  94176. */
  94177. getInvertedAbsoluteTransform(): Matrix;
  94178. /**
  94179. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94180. * @returns a matrix
  94181. */
  94182. getAbsoluteTransform(): Matrix;
  94183. /**
  94184. * Links with the given transform node.
  94185. * The local matrix of this bone is copied from the transform node every frame.
  94186. * @param transformNode defines the transform node to link to
  94187. */
  94188. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94189. /**
  94190. * Gets the node used to drive the bone's transformation
  94191. * @returns a transform node or null
  94192. */
  94193. getTransformNode(): Nullable<TransformNode>;
  94194. /** Gets or sets current position (in local space) */
  94195. get position(): Vector3;
  94196. set position(newPosition: Vector3);
  94197. /** Gets or sets current rotation (in local space) */
  94198. get rotation(): Vector3;
  94199. set rotation(newRotation: Vector3);
  94200. /** Gets or sets current rotation quaternion (in local space) */
  94201. get rotationQuaternion(): Quaternion;
  94202. set rotationQuaternion(newRotation: Quaternion);
  94203. /** Gets or sets current scaling (in local space) */
  94204. get scaling(): Vector3;
  94205. set scaling(newScaling: Vector3);
  94206. /**
  94207. * Gets the animation properties override
  94208. */
  94209. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94210. private _decompose;
  94211. private _compose;
  94212. /**
  94213. * Update the base and local matrices
  94214. * @param matrix defines the new base or local matrix
  94215. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94216. * @param updateLocalMatrix defines if the local matrix should be updated
  94217. */
  94218. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94219. /** @hidden */
  94220. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94221. /**
  94222. * Flag the bone as dirty (Forcing it to update everything)
  94223. */
  94224. markAsDirty(): void;
  94225. /** @hidden */
  94226. _markAsDirtyAndCompose(): void;
  94227. private _markAsDirtyAndDecompose;
  94228. /**
  94229. * Translate the bone in local or world space
  94230. * @param vec The amount to translate the bone
  94231. * @param space The space that the translation is in
  94232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94233. */
  94234. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94235. /**
  94236. * Set the postion of the bone in local or world space
  94237. * @param position The position to set the bone
  94238. * @param space The space that the position is in
  94239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94240. */
  94241. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94242. /**
  94243. * Set the absolute position of the bone (world space)
  94244. * @param position The position to set the bone
  94245. * @param mesh The mesh that this bone is attached to
  94246. */
  94247. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94248. /**
  94249. * Scale the bone on the x, y and z axes (in local space)
  94250. * @param x The amount to scale the bone on the x axis
  94251. * @param y The amount to scale the bone on the y axis
  94252. * @param z The amount to scale the bone on the z axis
  94253. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94254. */
  94255. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94256. /**
  94257. * Set the bone scaling in local space
  94258. * @param scale defines the scaling vector
  94259. */
  94260. setScale(scale: Vector3): void;
  94261. /**
  94262. * Gets the current scaling in local space
  94263. * @returns the current scaling vector
  94264. */
  94265. getScale(): Vector3;
  94266. /**
  94267. * Gets the current scaling in local space and stores it in a target vector
  94268. * @param result defines the target vector
  94269. */
  94270. getScaleToRef(result: Vector3): void;
  94271. /**
  94272. * Set the yaw, pitch, and roll of the bone in local or world space
  94273. * @param yaw The rotation of the bone on the y axis
  94274. * @param pitch The rotation of the bone on the x axis
  94275. * @param roll The rotation of the bone on the z axis
  94276. * @param space The space that the axes of rotation are in
  94277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94278. */
  94279. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94280. /**
  94281. * Add a rotation to the bone on an axis in local or world space
  94282. * @param axis The axis to rotate the bone on
  94283. * @param amount The amount to rotate the bone
  94284. * @param space The space that the axis is in
  94285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94286. */
  94287. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94288. /**
  94289. * Set the rotation of the bone to a particular axis angle in local or world space
  94290. * @param axis The axis to rotate the bone on
  94291. * @param angle The angle that the bone should be rotated to
  94292. * @param space The space that the axis is in
  94293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94294. */
  94295. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94296. /**
  94297. * Set the euler rotation of the bone in local of world space
  94298. * @param rotation The euler rotation that the bone should be set to
  94299. * @param space The space that the rotation is in
  94300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94301. */
  94302. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94303. /**
  94304. * Set the quaternion rotation of the bone in local of world space
  94305. * @param quat The quaternion rotation that the bone should be set to
  94306. * @param space The space that the rotation is in
  94307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94308. */
  94309. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94310. /**
  94311. * Set the rotation matrix of the bone in local of world space
  94312. * @param rotMat The rotation matrix that the bone should be set to
  94313. * @param space The space that the rotation is in
  94314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94315. */
  94316. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94317. private _rotateWithMatrix;
  94318. private _getNegativeRotationToRef;
  94319. /**
  94320. * Get the position of the bone in local or world space
  94321. * @param space The space that the returned position is in
  94322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94323. * @returns The position of the bone
  94324. */
  94325. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94326. /**
  94327. * Copy the position of the bone to a vector3 in local or world space
  94328. * @param space The space that the returned position is in
  94329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94330. * @param result The vector3 to copy the position to
  94331. */
  94332. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94333. /**
  94334. * Get the absolute position of the bone (world space)
  94335. * @param mesh The mesh that this bone is attached to
  94336. * @returns The absolute position of the bone
  94337. */
  94338. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94339. /**
  94340. * Copy the absolute position of the bone (world space) to the result param
  94341. * @param mesh The mesh that this bone is attached to
  94342. * @param result The vector3 to copy the absolute position to
  94343. */
  94344. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94345. /**
  94346. * Compute the absolute transforms of this bone and its children
  94347. */
  94348. computeAbsoluteTransforms(): void;
  94349. /**
  94350. * Get the world direction from an axis that is in the local space of the bone
  94351. * @param localAxis The local direction that is used to compute the world direction
  94352. * @param mesh The mesh that this bone is attached to
  94353. * @returns The world direction
  94354. */
  94355. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94356. /**
  94357. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94358. * @param localAxis The local direction that is used to compute the world direction
  94359. * @param mesh The mesh that this bone is attached to
  94360. * @param result The vector3 that the world direction will be copied to
  94361. */
  94362. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94363. /**
  94364. * Get the euler rotation of the bone in local or world space
  94365. * @param space The space that the rotation should be in
  94366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94367. * @returns The euler rotation
  94368. */
  94369. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94370. /**
  94371. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94372. * @param space The space that the rotation should be in
  94373. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94374. * @param result The vector3 that the rotation should be copied to
  94375. */
  94376. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94377. /**
  94378. * Get the quaternion rotation of the bone in either local or world space
  94379. * @param space The space that the rotation should be in
  94380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94381. * @returns The quaternion rotation
  94382. */
  94383. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94384. /**
  94385. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94386. * @param space The space that the rotation should be in
  94387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94388. * @param result The quaternion that the rotation should be copied to
  94389. */
  94390. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94391. /**
  94392. * Get the rotation matrix of the bone in local or world space
  94393. * @param space The space that the rotation should be in
  94394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94395. * @returns The rotation matrix
  94396. */
  94397. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94398. /**
  94399. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94400. * @param space The space that the rotation should be in
  94401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94402. * @param result The quaternion that the rotation should be copied to
  94403. */
  94404. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94405. /**
  94406. * Get the world position of a point that is in the local space of the bone
  94407. * @param position The local position
  94408. * @param mesh The mesh that this bone is attached to
  94409. * @returns The world position
  94410. */
  94411. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94412. /**
  94413. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94414. * @param position The local position
  94415. * @param mesh The mesh that this bone is attached to
  94416. * @param result The vector3 that the world position should be copied to
  94417. */
  94418. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94419. /**
  94420. * Get the local position of a point that is in world space
  94421. * @param position The world position
  94422. * @param mesh The mesh that this bone is attached to
  94423. * @returns The local position
  94424. */
  94425. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94426. /**
  94427. * Get the local position of a point that is in world space and copy it to the result param
  94428. * @param position The world position
  94429. * @param mesh The mesh that this bone is attached to
  94430. * @param result The vector3 that the local position should be copied to
  94431. */
  94432. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94433. }
  94434. }
  94435. declare module BABYLON {
  94436. /**
  94437. * Defines a runtime animation
  94438. */
  94439. export class RuntimeAnimation {
  94440. private _events;
  94441. /**
  94442. * The current frame of the runtime animation
  94443. */
  94444. private _currentFrame;
  94445. /**
  94446. * The animation used by the runtime animation
  94447. */
  94448. private _animation;
  94449. /**
  94450. * The target of the runtime animation
  94451. */
  94452. private _target;
  94453. /**
  94454. * The initiating animatable
  94455. */
  94456. private _host;
  94457. /**
  94458. * The original value of the runtime animation
  94459. */
  94460. private _originalValue;
  94461. /**
  94462. * The original blend value of the runtime animation
  94463. */
  94464. private _originalBlendValue;
  94465. /**
  94466. * The offsets cache of the runtime animation
  94467. */
  94468. private _offsetsCache;
  94469. /**
  94470. * The high limits cache of the runtime animation
  94471. */
  94472. private _highLimitsCache;
  94473. /**
  94474. * Specifies if the runtime animation has been stopped
  94475. */
  94476. private _stopped;
  94477. /**
  94478. * The blending factor of the runtime animation
  94479. */
  94480. private _blendingFactor;
  94481. /**
  94482. * The BabylonJS scene
  94483. */
  94484. private _scene;
  94485. /**
  94486. * The current value of the runtime animation
  94487. */
  94488. private _currentValue;
  94489. /** @hidden */
  94490. _animationState: _IAnimationState;
  94491. /**
  94492. * The active target of the runtime animation
  94493. */
  94494. private _activeTargets;
  94495. private _currentActiveTarget;
  94496. private _directTarget;
  94497. /**
  94498. * The target path of the runtime animation
  94499. */
  94500. private _targetPath;
  94501. /**
  94502. * The weight of the runtime animation
  94503. */
  94504. private _weight;
  94505. /**
  94506. * The ratio offset of the runtime animation
  94507. */
  94508. private _ratioOffset;
  94509. /**
  94510. * The previous delay of the runtime animation
  94511. */
  94512. private _previousDelay;
  94513. /**
  94514. * The previous ratio of the runtime animation
  94515. */
  94516. private _previousRatio;
  94517. private _enableBlending;
  94518. private _keys;
  94519. private _minFrame;
  94520. private _maxFrame;
  94521. private _minValue;
  94522. private _maxValue;
  94523. private _targetIsArray;
  94524. /**
  94525. * Gets the current frame of the runtime animation
  94526. */
  94527. get currentFrame(): number;
  94528. /**
  94529. * Gets the weight of the runtime animation
  94530. */
  94531. get weight(): number;
  94532. /**
  94533. * Gets the current value of the runtime animation
  94534. */
  94535. get currentValue(): any;
  94536. /**
  94537. * Gets the target path of the runtime animation
  94538. */
  94539. get targetPath(): string;
  94540. /**
  94541. * Gets the actual target of the runtime animation
  94542. */
  94543. get target(): any;
  94544. /**
  94545. * Gets the additive state of the runtime animation
  94546. */
  94547. get isAdditive(): boolean;
  94548. /** @hidden */
  94549. _onLoop: () => void;
  94550. /**
  94551. * Create a new RuntimeAnimation object
  94552. * @param target defines the target of the animation
  94553. * @param animation defines the source animation object
  94554. * @param scene defines the hosting scene
  94555. * @param host defines the initiating Animatable
  94556. */
  94557. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94558. private _preparePath;
  94559. /**
  94560. * Gets the animation from the runtime animation
  94561. */
  94562. get animation(): Animation;
  94563. /**
  94564. * Resets the runtime animation to the beginning
  94565. * @param restoreOriginal defines whether to restore the target property to the original value
  94566. */
  94567. reset(restoreOriginal?: boolean): void;
  94568. /**
  94569. * Specifies if the runtime animation is stopped
  94570. * @returns Boolean specifying if the runtime animation is stopped
  94571. */
  94572. isStopped(): boolean;
  94573. /**
  94574. * Disposes of the runtime animation
  94575. */
  94576. dispose(): void;
  94577. /**
  94578. * Apply the interpolated value to the target
  94579. * @param currentValue defines the value computed by the animation
  94580. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94581. */
  94582. setValue(currentValue: any, weight: number): void;
  94583. private _getOriginalValues;
  94584. private _setValue;
  94585. /**
  94586. * Gets the loop pmode of the runtime animation
  94587. * @returns Loop Mode
  94588. */
  94589. private _getCorrectLoopMode;
  94590. /**
  94591. * Move the current animation to a given frame
  94592. * @param frame defines the frame to move to
  94593. */
  94594. goToFrame(frame: number): void;
  94595. /**
  94596. * @hidden Internal use only
  94597. */
  94598. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94599. /**
  94600. * Execute the current animation
  94601. * @param delay defines the delay to add to the current frame
  94602. * @param from defines the lower bound of the animation range
  94603. * @param to defines the upper bound of the animation range
  94604. * @param loop defines if the current animation must loop
  94605. * @param speedRatio defines the current speed ratio
  94606. * @param weight defines the weight of the animation (default is -1 so no weight)
  94607. * @param onLoop optional callback called when animation loops
  94608. * @returns a boolean indicating if the animation is running
  94609. */
  94610. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94611. }
  94612. }
  94613. declare module BABYLON {
  94614. /**
  94615. * Class used to store an actual running animation
  94616. */
  94617. export class Animatable {
  94618. /** defines the target object */
  94619. target: any;
  94620. /** defines the starting frame number (default is 0) */
  94621. fromFrame: number;
  94622. /** defines the ending frame number (default is 100) */
  94623. toFrame: number;
  94624. /** defines if the animation must loop (default is false) */
  94625. loopAnimation: boolean;
  94626. /** defines a callback to call when animation ends if it is not looping */
  94627. onAnimationEnd?: (() => void) | null | undefined;
  94628. /** defines a callback to call when animation loops */
  94629. onAnimationLoop?: (() => void) | null | undefined;
  94630. /** defines whether the animation should be evaluated additively */
  94631. isAdditive: boolean;
  94632. private _localDelayOffset;
  94633. private _pausedDelay;
  94634. private _runtimeAnimations;
  94635. private _paused;
  94636. private _scene;
  94637. private _speedRatio;
  94638. private _weight;
  94639. private _syncRoot;
  94640. /**
  94641. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94642. * This will only apply for non looping animation (default is true)
  94643. */
  94644. disposeOnEnd: boolean;
  94645. /**
  94646. * Gets a boolean indicating if the animation has started
  94647. */
  94648. animationStarted: boolean;
  94649. /**
  94650. * Observer raised when the animation ends
  94651. */
  94652. onAnimationEndObservable: Observable<Animatable>;
  94653. /**
  94654. * Observer raised when the animation loops
  94655. */
  94656. onAnimationLoopObservable: Observable<Animatable>;
  94657. /**
  94658. * Gets the root Animatable used to synchronize and normalize animations
  94659. */
  94660. get syncRoot(): Nullable<Animatable>;
  94661. /**
  94662. * Gets the current frame of the first RuntimeAnimation
  94663. * Used to synchronize Animatables
  94664. */
  94665. get masterFrame(): number;
  94666. /**
  94667. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94668. */
  94669. get weight(): number;
  94670. set weight(value: number);
  94671. /**
  94672. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94673. */
  94674. get speedRatio(): number;
  94675. set speedRatio(value: number);
  94676. /**
  94677. * Creates a new Animatable
  94678. * @param scene defines the hosting scene
  94679. * @param target defines the target object
  94680. * @param fromFrame defines the starting frame number (default is 0)
  94681. * @param toFrame defines the ending frame number (default is 100)
  94682. * @param loopAnimation defines if the animation must loop (default is false)
  94683. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94684. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94685. * @param animations defines a group of animation to add to the new Animatable
  94686. * @param onAnimationLoop defines a callback to call when animation loops
  94687. * @param isAdditive defines whether the animation should be evaluated additively
  94688. */
  94689. constructor(scene: Scene,
  94690. /** defines the target object */
  94691. target: any,
  94692. /** defines the starting frame number (default is 0) */
  94693. fromFrame?: number,
  94694. /** defines the ending frame number (default is 100) */
  94695. toFrame?: number,
  94696. /** defines if the animation must loop (default is false) */
  94697. loopAnimation?: boolean, speedRatio?: number,
  94698. /** defines a callback to call when animation ends if it is not looping */
  94699. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94700. /** defines a callback to call when animation loops */
  94701. onAnimationLoop?: (() => void) | null | undefined,
  94702. /** defines whether the animation should be evaluated additively */
  94703. isAdditive?: boolean);
  94704. /**
  94705. * Synchronize and normalize current Animatable with a source Animatable
  94706. * This is useful when using animation weights and when animations are not of the same length
  94707. * @param root defines the root Animatable to synchronize with
  94708. * @returns the current Animatable
  94709. */
  94710. syncWith(root: Animatable): Animatable;
  94711. /**
  94712. * Gets the list of runtime animations
  94713. * @returns an array of RuntimeAnimation
  94714. */
  94715. getAnimations(): RuntimeAnimation[];
  94716. /**
  94717. * Adds more animations to the current animatable
  94718. * @param target defines the target of the animations
  94719. * @param animations defines the new animations to add
  94720. */
  94721. appendAnimations(target: any, animations: Animation[]): void;
  94722. /**
  94723. * Gets the source animation for a specific property
  94724. * @param property defines the propertyu to look for
  94725. * @returns null or the source animation for the given property
  94726. */
  94727. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94728. /**
  94729. * Gets the runtime animation for a specific property
  94730. * @param property defines the propertyu to look for
  94731. * @returns null or the runtime animation for the given property
  94732. */
  94733. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94734. /**
  94735. * Resets the animatable to its original state
  94736. */
  94737. reset(): void;
  94738. /**
  94739. * Allows the animatable to blend with current running animations
  94740. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94741. * @param blendingSpeed defines the blending speed to use
  94742. */
  94743. enableBlending(blendingSpeed: number): void;
  94744. /**
  94745. * Disable animation blending
  94746. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94747. */
  94748. disableBlending(): void;
  94749. /**
  94750. * Jump directly to a given frame
  94751. * @param frame defines the frame to jump to
  94752. */
  94753. goToFrame(frame: number): void;
  94754. /**
  94755. * Pause the animation
  94756. */
  94757. pause(): void;
  94758. /**
  94759. * Restart the animation
  94760. */
  94761. restart(): void;
  94762. private _raiseOnAnimationEnd;
  94763. /**
  94764. * Stop and delete the current animation
  94765. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94766. * @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)
  94767. */
  94768. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94769. /**
  94770. * Wait asynchronously for the animation to end
  94771. * @returns a promise which will be fullfilled when the animation ends
  94772. */
  94773. waitAsync(): Promise<Animatable>;
  94774. /** @hidden */
  94775. _animate(delay: number): boolean;
  94776. }
  94777. interface Scene {
  94778. /** @hidden */
  94779. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94780. /** @hidden */
  94781. _processLateAnimationBindingsForMatrices(holder: {
  94782. totalWeight: number;
  94783. totalAdditiveWeight: number;
  94784. animations: RuntimeAnimation[];
  94785. additiveAnimations: RuntimeAnimation[];
  94786. originalValue: Matrix;
  94787. }): any;
  94788. /** @hidden */
  94789. _processLateAnimationBindingsForQuaternions(holder: {
  94790. totalWeight: number;
  94791. totalAdditiveWeight: number;
  94792. animations: RuntimeAnimation[];
  94793. additiveAnimations: RuntimeAnimation[];
  94794. originalValue: Quaternion;
  94795. }, refQuaternion: Quaternion): Quaternion;
  94796. /** @hidden */
  94797. _processLateAnimationBindings(): void;
  94798. /**
  94799. * Will start the animation sequence of a given target
  94800. * @param target defines the target
  94801. * @param from defines from which frame should animation start
  94802. * @param to defines until which frame should animation run.
  94803. * @param weight defines the weight to apply to the animation (1.0 by default)
  94804. * @param loop defines if the animation loops
  94805. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94806. * @param onAnimationEnd defines the function to be executed when the animation ends
  94807. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94808. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94809. * @param onAnimationLoop defines the callback to call when an animation loops
  94810. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94811. * @returns the animatable object created for this animation
  94812. */
  94813. 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;
  94814. /**
  94815. * Will start the animation sequence of a given target
  94816. * @param target defines the target
  94817. * @param from defines from which frame should animation start
  94818. * @param to defines until which frame should animation run.
  94819. * @param loop defines if the animation loops
  94820. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94821. * @param onAnimationEnd defines the function to be executed when the animation ends
  94822. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94823. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94824. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94825. * @param onAnimationLoop defines the callback to call when an animation loops
  94826. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94827. * @returns the animatable object created for this animation
  94828. */
  94829. 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;
  94830. /**
  94831. * Will start the animation sequence of a given target and its hierarchy
  94832. * @param target defines the target
  94833. * @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.
  94834. * @param from defines from which frame should animation start
  94835. * @param to defines until which frame should animation run.
  94836. * @param loop defines if the animation loops
  94837. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94838. * @param onAnimationEnd defines the function to be executed when the animation ends
  94839. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94840. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94841. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94842. * @param onAnimationLoop defines the callback to call when an animation loops
  94843. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94844. * @returns the list of created animatables
  94845. */
  94846. 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[];
  94847. /**
  94848. * Begin a new animation on a given node
  94849. * @param target defines the target where the animation will take place
  94850. * @param animations defines the list of animations to start
  94851. * @param from defines the initial value
  94852. * @param to defines the final value
  94853. * @param loop defines if you want animation to loop (off by default)
  94854. * @param speedRatio defines the speed ratio to apply to all animations
  94855. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94856. * @param onAnimationLoop defines the callback to call when an animation loops
  94857. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94858. * @returns the list of created animatables
  94859. */
  94860. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94861. /**
  94862. * Begin a new animation on a given node and its hierarchy
  94863. * @param target defines the root node where the animation will take place
  94864. * @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.
  94865. * @param animations defines the list of animations to start
  94866. * @param from defines the initial value
  94867. * @param to defines the final value
  94868. * @param loop defines if you want animation to loop (off by default)
  94869. * @param speedRatio defines the speed ratio to apply to all animations
  94870. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94871. * @param onAnimationLoop defines the callback to call when an animation loops
  94872. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94873. * @returns the list of animatables created for all nodes
  94874. */
  94875. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94876. /**
  94877. * Gets the animatable associated with a specific target
  94878. * @param target defines the target of the animatable
  94879. * @returns the required animatable if found
  94880. */
  94881. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94882. /**
  94883. * Gets all animatables associated with a given target
  94884. * @param target defines the target to look animatables for
  94885. * @returns an array of Animatables
  94886. */
  94887. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94888. /**
  94889. * Stops and removes all animations that have been applied to the scene
  94890. */
  94891. stopAllAnimations(): void;
  94892. /**
  94893. * Gets the current delta time used by animation engine
  94894. */
  94895. deltaTime: number;
  94896. }
  94897. interface Bone {
  94898. /**
  94899. * Copy an animation range from another bone
  94900. * @param source defines the source bone
  94901. * @param rangeName defines the range name to copy
  94902. * @param frameOffset defines the frame offset
  94903. * @param rescaleAsRequired defines if rescaling must be applied if required
  94904. * @param skelDimensionsRatio defines the scaling ratio
  94905. * @returns true if operation was successful
  94906. */
  94907. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /**
  94912. * Class used to handle skinning animations
  94913. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94914. */
  94915. export class Skeleton implements IAnimatable {
  94916. /** defines the skeleton name */
  94917. name: string;
  94918. /** defines the skeleton Id */
  94919. id: string;
  94920. /**
  94921. * Defines the list of child bones
  94922. */
  94923. bones: Bone[];
  94924. /**
  94925. * Defines an estimate of the dimension of the skeleton at rest
  94926. */
  94927. dimensionsAtRest: Vector3;
  94928. /**
  94929. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94930. */
  94931. needInitialSkinMatrix: boolean;
  94932. /**
  94933. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94934. */
  94935. overrideMesh: Nullable<AbstractMesh>;
  94936. /**
  94937. * Gets the list of animations attached to this skeleton
  94938. */
  94939. animations: Array<Animation>;
  94940. private _scene;
  94941. private _isDirty;
  94942. private _transformMatrices;
  94943. private _transformMatrixTexture;
  94944. private _meshesWithPoseMatrix;
  94945. private _animatables;
  94946. private _identity;
  94947. private _synchronizedWithMesh;
  94948. private _ranges;
  94949. private _lastAbsoluteTransformsUpdateId;
  94950. private _canUseTextureForBones;
  94951. private _uniqueId;
  94952. /** @hidden */
  94953. _numBonesWithLinkedTransformNode: number;
  94954. /** @hidden */
  94955. _hasWaitingData: Nullable<boolean>;
  94956. /**
  94957. * Specifies if the skeleton should be serialized
  94958. */
  94959. doNotSerialize: boolean;
  94960. private _useTextureToStoreBoneMatrices;
  94961. /**
  94962. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94963. * Please note that this option is not available if the hardware does not support it
  94964. */
  94965. get useTextureToStoreBoneMatrices(): boolean;
  94966. set useTextureToStoreBoneMatrices(value: boolean);
  94967. private _animationPropertiesOverride;
  94968. /**
  94969. * Gets or sets the animation properties override
  94970. */
  94971. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94972. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94973. /**
  94974. * List of inspectable custom properties (used by the Inspector)
  94975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94976. */
  94977. inspectableCustomProperties: IInspectable[];
  94978. /**
  94979. * An observable triggered before computing the skeleton's matrices
  94980. */
  94981. onBeforeComputeObservable: Observable<Skeleton>;
  94982. /**
  94983. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94984. */
  94985. get isUsingTextureForMatrices(): boolean;
  94986. /**
  94987. * Gets the unique ID of this skeleton
  94988. */
  94989. get uniqueId(): number;
  94990. /**
  94991. * Creates a new skeleton
  94992. * @param name defines the skeleton name
  94993. * @param id defines the skeleton Id
  94994. * @param scene defines the hosting scene
  94995. */
  94996. constructor(
  94997. /** defines the skeleton name */
  94998. name: string,
  94999. /** defines the skeleton Id */
  95000. id: string, scene: Scene);
  95001. /**
  95002. * Gets the current object class name.
  95003. * @return the class name
  95004. */
  95005. getClassName(): string;
  95006. /**
  95007. * Returns an array containing the root bones
  95008. * @returns an array containing the root bones
  95009. */
  95010. getChildren(): Array<Bone>;
  95011. /**
  95012. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95013. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95014. * @returns a Float32Array containing matrices data
  95015. */
  95016. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95017. /**
  95018. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95019. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95020. * @returns a raw texture containing the data
  95021. */
  95022. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95023. /**
  95024. * Gets the current hosting scene
  95025. * @returns a scene object
  95026. */
  95027. getScene(): Scene;
  95028. /**
  95029. * Gets a string representing the current skeleton data
  95030. * @param fullDetails defines a boolean indicating if we want a verbose version
  95031. * @returns a string representing the current skeleton data
  95032. */
  95033. toString(fullDetails?: boolean): string;
  95034. /**
  95035. * Get bone's index searching by name
  95036. * @param name defines bone's name to search for
  95037. * @return the indice of the bone. Returns -1 if not found
  95038. */
  95039. getBoneIndexByName(name: string): number;
  95040. /**
  95041. * Creater a new animation range
  95042. * @param name defines the name of the range
  95043. * @param from defines the start key
  95044. * @param to defines the end key
  95045. */
  95046. createAnimationRange(name: string, from: number, to: number): void;
  95047. /**
  95048. * Delete a specific animation range
  95049. * @param name defines the name of the range
  95050. * @param deleteFrames defines if frames must be removed as well
  95051. */
  95052. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95053. /**
  95054. * Gets a specific animation range
  95055. * @param name defines the name of the range to look for
  95056. * @returns the requested animation range or null if not found
  95057. */
  95058. getAnimationRange(name: string): Nullable<AnimationRange>;
  95059. /**
  95060. * Gets the list of all animation ranges defined on this skeleton
  95061. * @returns an array
  95062. */
  95063. getAnimationRanges(): Nullable<AnimationRange>[];
  95064. /**
  95065. * Copy animation range from a source skeleton.
  95066. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95067. * @param source defines the source skeleton
  95068. * @param name defines the name of the range to copy
  95069. * @param rescaleAsRequired defines if rescaling must be applied if required
  95070. * @returns true if operation was successful
  95071. */
  95072. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95073. /**
  95074. * Forces the skeleton to go to rest pose
  95075. */
  95076. returnToRest(): void;
  95077. private _getHighestAnimationFrame;
  95078. /**
  95079. * Begin a specific animation range
  95080. * @param name defines the name of the range to start
  95081. * @param loop defines if looping must be turned on (false by default)
  95082. * @param speedRatio defines the speed ratio to apply (1 by default)
  95083. * @param onAnimationEnd defines a callback which will be called when animation will end
  95084. * @returns a new animatable
  95085. */
  95086. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95087. /**
  95088. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95089. * @param skeleton defines the Skeleton containing the animation range to convert
  95090. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95091. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95092. * @returns the original skeleton
  95093. */
  95094. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95095. /** @hidden */
  95096. _markAsDirty(): void;
  95097. /** @hidden */
  95098. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95099. /** @hidden */
  95100. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95101. private _computeTransformMatrices;
  95102. /**
  95103. * Build all resources required to render a skeleton
  95104. */
  95105. prepare(): void;
  95106. /**
  95107. * Gets the list of animatables currently running for this skeleton
  95108. * @returns an array of animatables
  95109. */
  95110. getAnimatables(): IAnimatable[];
  95111. /**
  95112. * Clone the current skeleton
  95113. * @param name defines the name of the new skeleton
  95114. * @param id defines the id of the new skeleton
  95115. * @returns the new skeleton
  95116. */
  95117. clone(name: string, id?: string): Skeleton;
  95118. /**
  95119. * Enable animation blending for this skeleton
  95120. * @param blendingSpeed defines the blending speed to apply
  95121. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95122. */
  95123. enableBlending(blendingSpeed?: number): void;
  95124. /**
  95125. * Releases all resources associated with the current skeleton
  95126. */
  95127. dispose(): void;
  95128. /**
  95129. * Serialize the skeleton in a JSON object
  95130. * @returns a JSON object
  95131. */
  95132. serialize(): any;
  95133. /**
  95134. * Creates a new skeleton from serialized data
  95135. * @param parsedSkeleton defines the serialized data
  95136. * @param scene defines the hosting scene
  95137. * @returns a new skeleton
  95138. */
  95139. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95140. /**
  95141. * Compute all node absolute transforms
  95142. * @param forceUpdate defines if computation must be done even if cache is up to date
  95143. */
  95144. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95145. /**
  95146. * Gets the root pose matrix
  95147. * @returns a matrix
  95148. */
  95149. getPoseMatrix(): Nullable<Matrix>;
  95150. /**
  95151. * Sorts bones per internal index
  95152. */
  95153. sortBones(): void;
  95154. private _sortBones;
  95155. }
  95156. }
  95157. declare module BABYLON {
  95158. /**
  95159. * Creates an instance based on a source mesh.
  95160. */
  95161. export class InstancedMesh extends AbstractMesh {
  95162. private _sourceMesh;
  95163. private _currentLOD;
  95164. /** @hidden */
  95165. _indexInSourceMeshInstanceArray: number;
  95166. constructor(name: string, source: Mesh);
  95167. /**
  95168. * Returns the string "InstancedMesh".
  95169. */
  95170. getClassName(): string;
  95171. /** Gets the list of lights affecting that mesh */
  95172. get lightSources(): Light[];
  95173. _resyncLightSources(): void;
  95174. _resyncLightSource(light: Light): void;
  95175. _removeLightSource(light: Light, dispose: boolean): void;
  95176. /**
  95177. * If the source mesh receives shadows
  95178. */
  95179. get receiveShadows(): boolean;
  95180. /**
  95181. * The material of the source mesh
  95182. */
  95183. get material(): Nullable<Material>;
  95184. /**
  95185. * Visibility of the source mesh
  95186. */
  95187. get visibility(): number;
  95188. /**
  95189. * Skeleton of the source mesh
  95190. */
  95191. get skeleton(): Nullable<Skeleton>;
  95192. /**
  95193. * Rendering ground id of the source mesh
  95194. */
  95195. get renderingGroupId(): number;
  95196. set renderingGroupId(value: number);
  95197. /**
  95198. * Returns the total number of vertices (integer).
  95199. */
  95200. getTotalVertices(): number;
  95201. /**
  95202. * Returns a positive integer : the total number of indices in this mesh geometry.
  95203. * @returns the numner of indices or zero if the mesh has no geometry.
  95204. */
  95205. getTotalIndices(): number;
  95206. /**
  95207. * The source mesh of the instance
  95208. */
  95209. get sourceMesh(): Mesh;
  95210. /**
  95211. * Creates a new InstancedMesh object from the mesh model.
  95212. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95213. * @param name defines the name of the new instance
  95214. * @returns a new InstancedMesh
  95215. */
  95216. createInstance(name: string): InstancedMesh;
  95217. /**
  95218. * Is this node ready to be used/rendered
  95219. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95220. * @return {boolean} is it ready
  95221. */
  95222. isReady(completeCheck?: boolean): boolean;
  95223. /**
  95224. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95225. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95226. * @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.
  95227. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95228. */
  95229. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95230. /**
  95231. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95232. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95233. * The `data` are either a numeric array either a Float32Array.
  95234. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95235. * 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).
  95236. * Note that a new underlying VertexBuffer object is created each call.
  95237. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95238. *
  95239. * Possible `kind` values :
  95240. * - VertexBuffer.PositionKind
  95241. * - VertexBuffer.UVKind
  95242. * - VertexBuffer.UV2Kind
  95243. * - VertexBuffer.UV3Kind
  95244. * - VertexBuffer.UV4Kind
  95245. * - VertexBuffer.UV5Kind
  95246. * - VertexBuffer.UV6Kind
  95247. * - VertexBuffer.ColorKind
  95248. * - VertexBuffer.MatricesIndicesKind
  95249. * - VertexBuffer.MatricesIndicesExtraKind
  95250. * - VertexBuffer.MatricesWeightsKind
  95251. * - VertexBuffer.MatricesWeightsExtraKind
  95252. *
  95253. * Returns the Mesh.
  95254. */
  95255. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95256. /**
  95257. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95258. * If the mesh has no geometry, it is simply returned as it is.
  95259. * The `data` are either a numeric array either a Float32Array.
  95260. * No new underlying VertexBuffer object is created.
  95261. * 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.
  95262. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95263. *
  95264. * Possible `kind` values :
  95265. * - VertexBuffer.PositionKind
  95266. * - VertexBuffer.UVKind
  95267. * - VertexBuffer.UV2Kind
  95268. * - VertexBuffer.UV3Kind
  95269. * - VertexBuffer.UV4Kind
  95270. * - VertexBuffer.UV5Kind
  95271. * - VertexBuffer.UV6Kind
  95272. * - VertexBuffer.ColorKind
  95273. * - VertexBuffer.MatricesIndicesKind
  95274. * - VertexBuffer.MatricesIndicesExtraKind
  95275. * - VertexBuffer.MatricesWeightsKind
  95276. * - VertexBuffer.MatricesWeightsExtraKind
  95277. *
  95278. * Returns the Mesh.
  95279. */
  95280. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95281. /**
  95282. * Sets the mesh indices.
  95283. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95284. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95285. * This method creates a new index buffer each call.
  95286. * Returns the Mesh.
  95287. */
  95288. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95289. /**
  95290. * Boolean : True if the mesh owns the requested kind of data.
  95291. */
  95292. isVerticesDataPresent(kind: string): boolean;
  95293. /**
  95294. * Returns an array of indices (IndicesArray).
  95295. */
  95296. getIndices(): Nullable<IndicesArray>;
  95297. get _positions(): Nullable<Vector3[]>;
  95298. /**
  95299. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95300. * This means the mesh underlying bounding box and sphere are recomputed.
  95301. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95302. * @returns the current mesh
  95303. */
  95304. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95305. /** @hidden */
  95306. _preActivate(): InstancedMesh;
  95307. /** @hidden */
  95308. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95309. /** @hidden */
  95310. _postActivate(): void;
  95311. getWorldMatrix(): Matrix;
  95312. get isAnInstance(): boolean;
  95313. /**
  95314. * Returns the current associated LOD AbstractMesh.
  95315. */
  95316. getLOD(camera: Camera): AbstractMesh;
  95317. /** @hidden */
  95318. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95319. /** @hidden */
  95320. _syncSubMeshes(): InstancedMesh;
  95321. /** @hidden */
  95322. _generatePointsArray(): boolean;
  95323. /**
  95324. * Creates a new InstancedMesh from the current mesh.
  95325. * - name (string) : the cloned mesh name
  95326. * - newParent (optional Node) : the optional Node to parent the clone to.
  95327. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95328. *
  95329. * Returns the clone.
  95330. */
  95331. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95332. /**
  95333. * Disposes the InstancedMesh.
  95334. * Returns nothing.
  95335. */
  95336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95337. }
  95338. interface Mesh {
  95339. /**
  95340. * Register a custom buffer that will be instanced
  95341. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95342. * @param kind defines the buffer kind
  95343. * @param stride defines the stride in floats
  95344. */
  95345. registerInstancedBuffer(kind: string, stride: number): void;
  95346. /**
  95347. * true to use the edge renderer for all instances of this mesh
  95348. */
  95349. edgesShareWithInstances: boolean;
  95350. /** @hidden */
  95351. _userInstancedBuffersStorage: {
  95352. data: {
  95353. [key: string]: Float32Array;
  95354. };
  95355. sizes: {
  95356. [key: string]: number;
  95357. };
  95358. vertexBuffers: {
  95359. [key: string]: Nullable<VertexBuffer>;
  95360. };
  95361. strides: {
  95362. [key: string]: number;
  95363. };
  95364. };
  95365. }
  95366. interface AbstractMesh {
  95367. /**
  95368. * Object used to store instanced buffers defined by user
  95369. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95370. */
  95371. instancedBuffers: {
  95372. [key: string]: any;
  95373. };
  95374. }
  95375. }
  95376. declare module BABYLON {
  95377. /**
  95378. * Defines the options associated with the creation of a shader material.
  95379. */
  95380. export interface IShaderMaterialOptions {
  95381. /**
  95382. * Does the material work in alpha blend mode
  95383. */
  95384. needAlphaBlending: boolean;
  95385. /**
  95386. * Does the material work in alpha test mode
  95387. */
  95388. needAlphaTesting: boolean;
  95389. /**
  95390. * The list of attribute names used in the shader
  95391. */
  95392. attributes: string[];
  95393. /**
  95394. * The list of unifrom names used in the shader
  95395. */
  95396. uniforms: string[];
  95397. /**
  95398. * The list of UBO names used in the shader
  95399. */
  95400. uniformBuffers: string[];
  95401. /**
  95402. * The list of sampler names used in the shader
  95403. */
  95404. samplers: string[];
  95405. /**
  95406. * The list of defines used in the shader
  95407. */
  95408. defines: string[];
  95409. }
  95410. /**
  95411. * 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.
  95412. *
  95413. * This returned material effects how the mesh will look based on the code in the shaders.
  95414. *
  95415. * @see https://doc.babylonjs.com/how_to/shader_material
  95416. */
  95417. export class ShaderMaterial extends Material {
  95418. private _shaderPath;
  95419. private _options;
  95420. private _textures;
  95421. private _textureArrays;
  95422. private _floats;
  95423. private _ints;
  95424. private _floatsArrays;
  95425. private _colors3;
  95426. private _colors3Arrays;
  95427. private _colors4;
  95428. private _colors4Arrays;
  95429. private _vectors2;
  95430. private _vectors3;
  95431. private _vectors4;
  95432. private _matrices;
  95433. private _matrixArrays;
  95434. private _matrices3x3;
  95435. private _matrices2x2;
  95436. private _vectors2Arrays;
  95437. private _vectors3Arrays;
  95438. private _vectors4Arrays;
  95439. private _cachedWorldViewMatrix;
  95440. private _cachedWorldViewProjectionMatrix;
  95441. private _renderId;
  95442. private _multiview;
  95443. private _cachedDefines;
  95444. /** Define the Url to load snippets */
  95445. static SnippetUrl: string;
  95446. /** Snippet ID if the material was created from the snippet server */
  95447. snippetId: string;
  95448. /**
  95449. * Instantiate a new shader material.
  95450. * 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.
  95451. * This returned material effects how the mesh will look based on the code in the shaders.
  95452. * @see https://doc.babylonjs.com/how_to/shader_material
  95453. * @param name Define the name of the material in the scene
  95454. * @param scene Define the scene the material belongs to
  95455. * @param shaderPath Defines the route to the shader code in one of three ways:
  95456. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95457. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95458. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95459. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95460. * @param options Define the options used to create the shader
  95461. */
  95462. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95463. /**
  95464. * Gets the shader path used to define the shader code
  95465. * It can be modified to trigger a new compilation
  95466. */
  95467. get shaderPath(): any;
  95468. /**
  95469. * Sets the shader path used to define the shader code
  95470. * It can be modified to trigger a new compilation
  95471. */
  95472. set shaderPath(shaderPath: any);
  95473. /**
  95474. * Gets the options used to compile the shader.
  95475. * They can be modified to trigger a new compilation
  95476. */
  95477. get options(): IShaderMaterialOptions;
  95478. /**
  95479. * Gets the current class name of the material e.g. "ShaderMaterial"
  95480. * Mainly use in serialization.
  95481. * @returns the class name
  95482. */
  95483. getClassName(): string;
  95484. /**
  95485. * Specifies if the material will require alpha blending
  95486. * @returns a boolean specifying if alpha blending is needed
  95487. */
  95488. needAlphaBlending(): boolean;
  95489. /**
  95490. * Specifies if this material should be rendered in alpha test mode
  95491. * @returns a boolean specifying if an alpha test is needed.
  95492. */
  95493. needAlphaTesting(): boolean;
  95494. private _checkUniform;
  95495. /**
  95496. * Set a texture in the shader.
  95497. * @param name Define the name of the uniform samplers as defined in the shader
  95498. * @param texture Define the texture to bind to this sampler
  95499. * @return the material itself allowing "fluent" like uniform updates
  95500. */
  95501. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95502. /**
  95503. * Set a texture array in the shader.
  95504. * @param name Define the name of the uniform sampler array as defined in the shader
  95505. * @param textures Define the list of textures to bind to this sampler
  95506. * @return the material itself allowing "fluent" like uniform updates
  95507. */
  95508. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95509. /**
  95510. * Set a float in the shader.
  95511. * @param name Define the name of the uniform as defined in the shader
  95512. * @param value Define the value to give to the uniform
  95513. * @return the material itself allowing "fluent" like uniform updates
  95514. */
  95515. setFloat(name: string, value: number): ShaderMaterial;
  95516. /**
  95517. * Set a int in the shader.
  95518. * @param name Define the name of the uniform as defined in the shader
  95519. * @param value Define the value to give to the uniform
  95520. * @return the material itself allowing "fluent" like uniform updates
  95521. */
  95522. setInt(name: string, value: number): ShaderMaterial;
  95523. /**
  95524. * Set an array of floats in the shader.
  95525. * @param name Define the name of the uniform as defined in the shader
  95526. * @param value Define the value to give to the uniform
  95527. * @return the material itself allowing "fluent" like uniform updates
  95528. */
  95529. setFloats(name: string, value: number[]): ShaderMaterial;
  95530. /**
  95531. * Set a vec3 in the shader from a Color3.
  95532. * @param name Define the name of the uniform as defined in the shader
  95533. * @param value Define the value to give to the uniform
  95534. * @return the material itself allowing "fluent" like uniform updates
  95535. */
  95536. setColor3(name: string, value: Color3): ShaderMaterial;
  95537. /**
  95538. * Set a vec3 array in the shader from a Color3 array.
  95539. * @param name Define the name of the uniform as defined in the shader
  95540. * @param value Define the value to give to the uniform
  95541. * @return the material itself allowing "fluent" like uniform updates
  95542. */
  95543. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95544. /**
  95545. * Set a vec4 in the shader from a Color4.
  95546. * @param name Define the name of the uniform as defined in the shader
  95547. * @param value Define the value to give to the uniform
  95548. * @return the material itself allowing "fluent" like uniform updates
  95549. */
  95550. setColor4(name: string, value: Color4): ShaderMaterial;
  95551. /**
  95552. * Set a vec4 array in the shader from a Color4 array.
  95553. * @param name Define the name of the uniform as defined in the shader
  95554. * @param value Define the value to give to the uniform
  95555. * @return the material itself allowing "fluent" like uniform updates
  95556. */
  95557. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95558. /**
  95559. * Set a vec2 in the shader from a Vector2.
  95560. * @param name Define the name of the uniform as defined in the shader
  95561. * @param value Define the value to give to the uniform
  95562. * @return the material itself allowing "fluent" like uniform updates
  95563. */
  95564. setVector2(name: string, value: Vector2): ShaderMaterial;
  95565. /**
  95566. * Set a vec3 in the shader from a Vector3.
  95567. * @param name Define the name of the uniform as defined in the shader
  95568. * @param value Define the value to give to the uniform
  95569. * @return the material itself allowing "fluent" like uniform updates
  95570. */
  95571. setVector3(name: string, value: Vector3): ShaderMaterial;
  95572. /**
  95573. * Set a vec4 in the shader from a Vector4.
  95574. * @param name Define the name of the uniform as defined in the shader
  95575. * @param value Define the value to give to the uniform
  95576. * @return the material itself allowing "fluent" like uniform updates
  95577. */
  95578. setVector4(name: string, value: Vector4): ShaderMaterial;
  95579. /**
  95580. * Set a mat4 in the shader from a Matrix.
  95581. * @param name Define the name of the uniform as defined in the shader
  95582. * @param value Define the value to give to the uniform
  95583. * @return the material itself allowing "fluent" like uniform updates
  95584. */
  95585. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95586. /**
  95587. * Set a float32Array in the shader from a matrix array.
  95588. * @param name Define the name of the uniform as defined in the shader
  95589. * @param value Define the value to give to the uniform
  95590. * @return the material itself allowing "fluent" like uniform updates
  95591. */
  95592. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95593. /**
  95594. * Set a mat3 in the shader from a Float32Array.
  95595. * @param name Define the name of the uniform as defined in the shader
  95596. * @param value Define the value to give to the uniform
  95597. * @return the material itself allowing "fluent" like uniform updates
  95598. */
  95599. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95600. /**
  95601. * Set a mat2 in the shader from a Float32Array.
  95602. * @param name Define the name of the uniform as defined in the shader
  95603. * @param value Define the value to give to the uniform
  95604. * @return the material itself allowing "fluent" like uniform updates
  95605. */
  95606. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95607. /**
  95608. * Set a vec2 array in the shader from a number array.
  95609. * @param name Define the name of the uniform as defined in the shader
  95610. * @param value Define the value to give to the uniform
  95611. * @return the material itself allowing "fluent" like uniform updates
  95612. */
  95613. setArray2(name: string, value: number[]): ShaderMaterial;
  95614. /**
  95615. * Set a vec3 array in the shader from a number array.
  95616. * @param name Define the name of the uniform as defined in the shader
  95617. * @param value Define the value to give to the uniform
  95618. * @return the material itself allowing "fluent" like uniform updates
  95619. */
  95620. setArray3(name: string, value: number[]): ShaderMaterial;
  95621. /**
  95622. * Set a vec4 array in the shader from a number array.
  95623. * @param name Define the name of the uniform as defined in the shader
  95624. * @param value Define the value to give to the uniform
  95625. * @return the material itself allowing "fluent" like uniform updates
  95626. */
  95627. setArray4(name: string, value: number[]): ShaderMaterial;
  95628. private _checkCache;
  95629. /**
  95630. * Specifies that the submesh is ready to be used
  95631. * @param mesh defines the mesh to check
  95632. * @param subMesh defines which submesh to check
  95633. * @param useInstances specifies that instances should be used
  95634. * @returns a boolean indicating that the submesh is ready or not
  95635. */
  95636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95637. /**
  95638. * Checks if the material is ready to render the requested mesh
  95639. * @param mesh Define the mesh to render
  95640. * @param useInstances Define whether or not the material is used with instances
  95641. * @returns true if ready, otherwise false
  95642. */
  95643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95644. /**
  95645. * Binds the world matrix to the material
  95646. * @param world defines the world transformation matrix
  95647. * @param effectOverride - If provided, use this effect instead of internal effect
  95648. */
  95649. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95650. /**
  95651. * Binds the submesh to this material by preparing the effect and shader to draw
  95652. * @param world defines the world transformation matrix
  95653. * @param mesh defines the mesh containing the submesh
  95654. * @param subMesh defines the submesh to bind the material to
  95655. */
  95656. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95657. /**
  95658. * Binds the material to the mesh
  95659. * @param world defines the world transformation matrix
  95660. * @param mesh defines the mesh to bind the material to
  95661. * @param effectOverride - If provided, use this effect instead of internal effect
  95662. */
  95663. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95664. protected _afterBind(mesh?: Mesh): void;
  95665. /**
  95666. * Gets the active textures from the material
  95667. * @returns an array of textures
  95668. */
  95669. getActiveTextures(): BaseTexture[];
  95670. /**
  95671. * Specifies if the material uses a texture
  95672. * @param texture defines the texture to check against the material
  95673. * @returns a boolean specifying if the material uses the texture
  95674. */
  95675. hasTexture(texture: BaseTexture): boolean;
  95676. /**
  95677. * Makes a duplicate of the material, and gives it a new name
  95678. * @param name defines the new name for the duplicated material
  95679. * @returns the cloned material
  95680. */
  95681. clone(name: string): ShaderMaterial;
  95682. /**
  95683. * Disposes the material
  95684. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95685. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95686. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95687. */
  95688. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95689. /**
  95690. * Serializes this material in a JSON representation
  95691. * @returns the serialized material object
  95692. */
  95693. serialize(): any;
  95694. /**
  95695. * Creates a shader material from parsed shader material data
  95696. * @param source defines the JSON represnetation of the material
  95697. * @param scene defines the hosting scene
  95698. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95699. * @returns a new material
  95700. */
  95701. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95702. /**
  95703. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95704. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95705. * @param url defines the url to load from
  95706. * @param scene defines the hosting scene
  95707. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95708. * @returns a promise that will resolve to the new ShaderMaterial
  95709. */
  95710. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95711. /**
  95712. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95713. * @param snippetId defines the snippet to load
  95714. * @param scene defines the hosting scene
  95715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95716. * @returns a promise that will resolve to the new ShaderMaterial
  95717. */
  95718. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95719. }
  95720. }
  95721. declare module BABYLON {
  95722. /** @hidden */
  95723. export var colorPixelShader: {
  95724. name: string;
  95725. shader: string;
  95726. };
  95727. }
  95728. declare module BABYLON {
  95729. /** @hidden */
  95730. export var colorVertexShader: {
  95731. name: string;
  95732. shader: string;
  95733. };
  95734. }
  95735. declare module BABYLON {
  95736. /**
  95737. * Line mesh
  95738. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95739. */
  95740. export class LinesMesh extends Mesh {
  95741. /**
  95742. * If vertex color should be applied to the mesh
  95743. */
  95744. readonly useVertexColor?: boolean | undefined;
  95745. /**
  95746. * If vertex alpha should be applied to the mesh
  95747. */
  95748. readonly useVertexAlpha?: boolean | undefined;
  95749. /**
  95750. * Color of the line (Default: White)
  95751. */
  95752. color: Color3;
  95753. /**
  95754. * Alpha of the line (Default: 1)
  95755. */
  95756. alpha: number;
  95757. /**
  95758. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95759. * This margin is expressed in world space coordinates, so its value may vary.
  95760. * Default value is 0.1
  95761. */
  95762. intersectionThreshold: number;
  95763. private _colorShader;
  95764. private color4;
  95765. /**
  95766. * Creates a new LinesMesh
  95767. * @param name defines the name
  95768. * @param scene defines the hosting scene
  95769. * @param parent defines the parent mesh if any
  95770. * @param source defines the optional source LinesMesh used to clone data from
  95771. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95772. * When false, achieved by calling a clone(), also passing False.
  95773. * This will make creation of children, recursive.
  95774. * @param useVertexColor defines if this LinesMesh supports vertex color
  95775. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95776. */
  95777. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95778. /**
  95779. * If vertex color should be applied to the mesh
  95780. */
  95781. useVertexColor?: boolean | undefined,
  95782. /**
  95783. * If vertex alpha should be applied to the mesh
  95784. */
  95785. useVertexAlpha?: boolean | undefined);
  95786. private _addClipPlaneDefine;
  95787. private _removeClipPlaneDefine;
  95788. isReady(): boolean;
  95789. /**
  95790. * Returns the string "LineMesh"
  95791. */
  95792. getClassName(): string;
  95793. /**
  95794. * @hidden
  95795. */
  95796. get material(): Material;
  95797. /**
  95798. * @hidden
  95799. */
  95800. set material(value: Material);
  95801. /**
  95802. * @hidden
  95803. */
  95804. get checkCollisions(): boolean;
  95805. /** @hidden */
  95806. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95807. /** @hidden */
  95808. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95809. /**
  95810. * Disposes of the line mesh
  95811. * @param doNotRecurse If children should be disposed
  95812. */
  95813. dispose(doNotRecurse?: boolean): void;
  95814. /**
  95815. * Returns a new LineMesh object cloned from the current one.
  95816. */
  95817. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95818. /**
  95819. * Creates a new InstancedLinesMesh object from the mesh model.
  95820. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95821. * @param name defines the name of the new instance
  95822. * @returns a new InstancedLinesMesh
  95823. */
  95824. createInstance(name: string): InstancedLinesMesh;
  95825. }
  95826. /**
  95827. * Creates an instance based on a source LinesMesh
  95828. */
  95829. export class InstancedLinesMesh extends InstancedMesh {
  95830. /**
  95831. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95832. * This margin is expressed in world space coordinates, so its value may vary.
  95833. * Initilized with the intersectionThreshold value of the source LinesMesh
  95834. */
  95835. intersectionThreshold: number;
  95836. constructor(name: string, source: LinesMesh);
  95837. /**
  95838. * Returns the string "InstancedLinesMesh".
  95839. */
  95840. getClassName(): string;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /** @hidden */
  95845. export var linePixelShader: {
  95846. name: string;
  95847. shader: string;
  95848. };
  95849. }
  95850. declare module BABYLON {
  95851. /** @hidden */
  95852. export var lineVertexShader: {
  95853. name: string;
  95854. shader: string;
  95855. };
  95856. }
  95857. declare module BABYLON {
  95858. interface Scene {
  95859. /** @hidden */
  95860. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95861. }
  95862. interface AbstractMesh {
  95863. /**
  95864. * Gets the edgesRenderer associated with the mesh
  95865. */
  95866. edgesRenderer: Nullable<EdgesRenderer>;
  95867. }
  95868. interface LinesMesh {
  95869. /**
  95870. * Enables the edge rendering mode on the mesh.
  95871. * This mode makes the mesh edges visible
  95872. * @param epsilon defines the maximal distance between two angles to detect a face
  95873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95874. * @returns the currentAbstractMesh
  95875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95876. */
  95877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95878. }
  95879. interface InstancedLinesMesh {
  95880. /**
  95881. * Enables the edge rendering mode on the mesh.
  95882. * This mode makes the mesh edges visible
  95883. * @param epsilon defines the maximal distance between two angles to detect a face
  95884. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95885. * @returns the current InstancedLinesMesh
  95886. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95887. */
  95888. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95889. }
  95890. /**
  95891. * Defines the minimum contract an Edges renderer should follow.
  95892. */
  95893. export interface IEdgesRenderer extends IDisposable {
  95894. /**
  95895. * Gets or sets a boolean indicating if the edgesRenderer is active
  95896. */
  95897. isEnabled: boolean;
  95898. /**
  95899. * Renders the edges of the attached mesh,
  95900. */
  95901. render(): void;
  95902. /**
  95903. * Checks wether or not the edges renderer is ready to render.
  95904. * @return true if ready, otherwise false.
  95905. */
  95906. isReady(): boolean;
  95907. /**
  95908. * List of instances to render in case the source mesh has instances
  95909. */
  95910. customInstances: SmartArray<Matrix>;
  95911. }
  95912. /**
  95913. * Defines the additional options of the edges renderer
  95914. */
  95915. export interface IEdgesRendererOptions {
  95916. /**
  95917. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95918. * If not defined, the default value is true
  95919. */
  95920. useAlternateEdgeFinder?: boolean;
  95921. /**
  95922. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95923. * If not defined, the default value is true.
  95924. * 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)
  95925. * This option is used only if useAlternateEdgeFinder = true
  95926. */
  95927. useFastVertexMerger?: boolean;
  95928. /**
  95929. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95930. * The default value is 1e-6
  95931. * This option is used only if useAlternateEdgeFinder = true
  95932. */
  95933. epsilonVertexMerge?: number;
  95934. /**
  95935. * 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
  95936. * 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.
  95937. * This option is used only if useAlternateEdgeFinder = true
  95938. */
  95939. applyTessellation?: boolean;
  95940. /**
  95941. * 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
  95942. * The default value is 1e-6
  95943. * This option is used only if useAlternateEdgeFinder = true
  95944. */
  95945. epsilonVertexAligned?: number;
  95946. }
  95947. /**
  95948. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95949. */
  95950. export class EdgesRenderer implements IEdgesRenderer {
  95951. /**
  95952. * Define the size of the edges with an orthographic camera
  95953. */
  95954. edgesWidthScalerForOrthographic: number;
  95955. /**
  95956. * Define the size of the edges with a perspective camera
  95957. */
  95958. edgesWidthScalerForPerspective: number;
  95959. protected _source: AbstractMesh;
  95960. protected _linesPositions: number[];
  95961. protected _linesNormals: number[];
  95962. protected _linesIndices: number[];
  95963. protected _epsilon: number;
  95964. protected _indicesCount: number;
  95965. protected _lineShader: ShaderMaterial;
  95966. protected _ib: DataBuffer;
  95967. protected _buffers: {
  95968. [key: string]: Nullable<VertexBuffer>;
  95969. };
  95970. protected _buffersForInstances: {
  95971. [key: string]: Nullable<VertexBuffer>;
  95972. };
  95973. protected _checkVerticesInsteadOfIndices: boolean;
  95974. protected _options: Nullable<IEdgesRendererOptions>;
  95975. private _meshRebuildObserver;
  95976. private _meshDisposeObserver;
  95977. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95978. isEnabled: boolean;
  95979. /**
  95980. * List of instances to render in case the source mesh has instances
  95981. */
  95982. customInstances: SmartArray<Matrix>;
  95983. private static GetShader;
  95984. /**
  95985. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95986. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95987. * @param source Mesh used to create edges
  95988. * @param epsilon sum of angles in adjacency to check for edge
  95989. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95990. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95991. * @param options The options to apply when generating the edges
  95992. */
  95993. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95994. protected _prepareRessources(): void;
  95995. /** @hidden */
  95996. _rebuild(): void;
  95997. /**
  95998. * Releases the required resources for the edges renderer
  95999. */
  96000. dispose(): void;
  96001. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96002. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96003. /**
  96004. * Checks if the pair of p0 and p1 is en edge
  96005. * @param faceIndex
  96006. * @param edge
  96007. * @param faceNormals
  96008. * @param p0
  96009. * @param p1
  96010. * @private
  96011. */
  96012. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96013. /**
  96014. * push line into the position, normal and index buffer
  96015. * @protected
  96016. */
  96017. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96018. /**
  96019. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96020. */
  96021. private _tessellateTriangle;
  96022. private _generateEdgesLinesAlternate;
  96023. /**
  96024. * Generates lines edges from adjacencjes
  96025. * @private
  96026. */
  96027. _generateEdgesLines(): void;
  96028. /**
  96029. * Checks wether or not the edges renderer is ready to render.
  96030. * @return true if ready, otherwise false.
  96031. */
  96032. isReady(): boolean;
  96033. /**
  96034. * Renders the edges of the attached mesh,
  96035. */
  96036. render(): void;
  96037. }
  96038. /**
  96039. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96040. */
  96041. export class LineEdgesRenderer extends EdgesRenderer {
  96042. /**
  96043. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96044. * @param source LineMesh used to generate edges
  96045. * @param epsilon not important (specified angle for edge detection)
  96046. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96047. */
  96048. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96049. /**
  96050. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96051. */
  96052. _generateEdgesLines(): void;
  96053. }
  96054. }
  96055. declare module BABYLON {
  96056. /**
  96057. * This represents the object necessary to create a rendering group.
  96058. * This is exclusively used and created by the rendering manager.
  96059. * To modify the behavior, you use the available helpers in your scene or meshes.
  96060. * @hidden
  96061. */
  96062. export class RenderingGroup {
  96063. index: number;
  96064. private static _zeroVector;
  96065. private _scene;
  96066. private _opaqueSubMeshes;
  96067. private _transparentSubMeshes;
  96068. private _alphaTestSubMeshes;
  96069. private _depthOnlySubMeshes;
  96070. private _particleSystems;
  96071. private _spriteManagers;
  96072. private _opaqueSortCompareFn;
  96073. private _alphaTestSortCompareFn;
  96074. private _transparentSortCompareFn;
  96075. private _renderOpaque;
  96076. private _renderAlphaTest;
  96077. private _renderTransparent;
  96078. /** @hidden */
  96079. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96080. onBeforeTransparentRendering: () => void;
  96081. /**
  96082. * Set the opaque sort comparison function.
  96083. * If null the sub meshes will be render in the order they were created
  96084. */
  96085. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96086. /**
  96087. * Set the alpha test sort comparison function.
  96088. * If null the sub meshes will be render in the order they were created
  96089. */
  96090. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96091. /**
  96092. * Set the transparent sort comparison function.
  96093. * If null the sub meshes will be render in the order they were created
  96094. */
  96095. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96096. /**
  96097. * Creates a new rendering group.
  96098. * @param index The rendering group index
  96099. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96100. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96101. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96102. */
  96103. 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>);
  96104. /**
  96105. * Render all the sub meshes contained in the group.
  96106. * @param customRenderFunction Used to override the default render behaviour of the group.
  96107. * @returns true if rendered some submeshes.
  96108. */
  96109. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96110. /**
  96111. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96112. * @param subMeshes The submeshes to render
  96113. */
  96114. private renderOpaqueSorted;
  96115. /**
  96116. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96117. * @param subMeshes The submeshes to render
  96118. */
  96119. private renderAlphaTestSorted;
  96120. /**
  96121. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96122. * @param subMeshes The submeshes to render
  96123. */
  96124. private renderTransparentSorted;
  96125. /**
  96126. * Renders the submeshes in a specified order.
  96127. * @param subMeshes The submeshes to sort before render
  96128. * @param sortCompareFn The comparison function use to sort
  96129. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96130. * @param transparent Specifies to activate blending if true
  96131. */
  96132. private static renderSorted;
  96133. /**
  96134. * Renders the submeshes in the order they were dispatched (no sort applied).
  96135. * @param subMeshes The submeshes to render
  96136. */
  96137. private static renderUnsorted;
  96138. /**
  96139. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96140. * are rendered back to front if in the same alpha index.
  96141. *
  96142. * @param a The first submesh
  96143. * @param b The second submesh
  96144. * @returns The result of the comparison
  96145. */
  96146. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96147. /**
  96148. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96149. * are rendered back to front.
  96150. *
  96151. * @param a The first submesh
  96152. * @param b The second submesh
  96153. * @returns The result of the comparison
  96154. */
  96155. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96156. /**
  96157. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96158. * are rendered front to back (prevent overdraw).
  96159. *
  96160. * @param a The first submesh
  96161. * @param b The second submesh
  96162. * @returns The result of the comparison
  96163. */
  96164. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96165. /**
  96166. * Resets the different lists of submeshes to prepare a new frame.
  96167. */
  96168. prepare(): void;
  96169. dispose(): void;
  96170. /**
  96171. * Inserts the submesh in its correct queue depending on its material.
  96172. * @param subMesh The submesh to dispatch
  96173. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96174. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96175. */
  96176. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96177. dispatchSprites(spriteManager: ISpriteManager): void;
  96178. dispatchParticles(particleSystem: IParticleSystem): void;
  96179. private _renderParticles;
  96180. private _renderSprites;
  96181. }
  96182. }
  96183. declare module BABYLON {
  96184. /**
  96185. * Interface describing the different options available in the rendering manager
  96186. * regarding Auto Clear between groups.
  96187. */
  96188. export interface IRenderingManagerAutoClearSetup {
  96189. /**
  96190. * Defines whether or not autoclear is enable.
  96191. */
  96192. autoClear: boolean;
  96193. /**
  96194. * Defines whether or not to autoclear the depth buffer.
  96195. */
  96196. depth: boolean;
  96197. /**
  96198. * Defines whether or not to autoclear the stencil buffer.
  96199. */
  96200. stencil: boolean;
  96201. }
  96202. /**
  96203. * This class is used by the onRenderingGroupObservable
  96204. */
  96205. export class RenderingGroupInfo {
  96206. /**
  96207. * The Scene that being rendered
  96208. */
  96209. scene: Scene;
  96210. /**
  96211. * The camera currently used for the rendering pass
  96212. */
  96213. camera: Nullable<Camera>;
  96214. /**
  96215. * The ID of the renderingGroup being processed
  96216. */
  96217. renderingGroupId: number;
  96218. }
  96219. /**
  96220. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96221. * It is enable to manage the different groups as well as the different necessary sort functions.
  96222. * This should not be used directly aside of the few static configurations
  96223. */
  96224. export class RenderingManager {
  96225. /**
  96226. * The max id used for rendering groups (not included)
  96227. */
  96228. static MAX_RENDERINGGROUPS: number;
  96229. /**
  96230. * The min id used for rendering groups (included)
  96231. */
  96232. static MIN_RENDERINGGROUPS: number;
  96233. /**
  96234. * Used to globally prevent autoclearing scenes.
  96235. */
  96236. static AUTOCLEAR: boolean;
  96237. /**
  96238. * @hidden
  96239. */
  96240. _useSceneAutoClearSetup: boolean;
  96241. private _scene;
  96242. private _renderingGroups;
  96243. private _depthStencilBufferAlreadyCleaned;
  96244. private _autoClearDepthStencil;
  96245. private _customOpaqueSortCompareFn;
  96246. private _customAlphaTestSortCompareFn;
  96247. private _customTransparentSortCompareFn;
  96248. private _renderingGroupInfo;
  96249. /**
  96250. * Instantiates a new rendering group for a particular scene
  96251. * @param scene Defines the scene the groups belongs to
  96252. */
  96253. constructor(scene: Scene);
  96254. private _clearDepthStencilBuffer;
  96255. /**
  96256. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96257. * @hidden
  96258. */
  96259. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96260. /**
  96261. * Resets the different information of the group to prepare a new frame
  96262. * @hidden
  96263. */
  96264. reset(): void;
  96265. /**
  96266. * Dispose and release the group and its associated resources.
  96267. * @hidden
  96268. */
  96269. dispose(): void;
  96270. /**
  96271. * Clear the info related to rendering groups preventing retention points during dispose.
  96272. */
  96273. freeRenderingGroups(): void;
  96274. private _prepareRenderingGroup;
  96275. /**
  96276. * Add a sprite manager to the rendering manager in order to render it this frame.
  96277. * @param spriteManager Define the sprite manager to render
  96278. */
  96279. dispatchSprites(spriteManager: ISpriteManager): void;
  96280. /**
  96281. * Add a particle system to the rendering manager in order to render it this frame.
  96282. * @param particleSystem Define the particle system to render
  96283. */
  96284. dispatchParticles(particleSystem: IParticleSystem): void;
  96285. /**
  96286. * Add a submesh to the manager in order to render it this frame
  96287. * @param subMesh The submesh to dispatch
  96288. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96289. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96290. */
  96291. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96292. /**
  96293. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96294. * This allowed control for front to back rendering or reversly depending of the special needs.
  96295. *
  96296. * @param renderingGroupId The rendering group id corresponding to its index
  96297. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96298. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96299. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96300. */
  96301. 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;
  96302. /**
  96303. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96304. *
  96305. * @param renderingGroupId The rendering group id corresponding to its index
  96306. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96307. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96308. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96309. */
  96310. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96311. /**
  96312. * Gets the current auto clear configuration for one rendering group of the rendering
  96313. * manager.
  96314. * @param index the rendering group index to get the information for
  96315. * @returns The auto clear setup for the requested rendering group
  96316. */
  96317. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96318. }
  96319. }
  96320. declare module BABYLON {
  96321. /**
  96322. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96323. */
  96324. export interface ICustomShaderOptions {
  96325. /**
  96326. * Gets or sets the custom shader name to use
  96327. */
  96328. shaderName: string;
  96329. /**
  96330. * The list of attribute names used in the shader
  96331. */
  96332. attributes?: string[];
  96333. /**
  96334. * The list of unifrom names used in the shader
  96335. */
  96336. uniforms?: string[];
  96337. /**
  96338. * The list of sampler names used in the shader
  96339. */
  96340. samplers?: string[];
  96341. /**
  96342. * The list of defines used in the shader
  96343. */
  96344. defines?: string[];
  96345. }
  96346. /**
  96347. * Interface to implement to create a shadow generator compatible with BJS.
  96348. */
  96349. export interface IShadowGenerator {
  96350. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96351. id: string;
  96352. /**
  96353. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96354. * @returns The render target texture if present otherwise, null
  96355. */
  96356. getShadowMap(): Nullable<RenderTargetTexture>;
  96357. /**
  96358. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96359. * @param subMesh The submesh we want to render in the shadow map
  96360. * @param useInstances Defines wether will draw in the map using instances
  96361. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96362. * @returns true if ready otherwise, false
  96363. */
  96364. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96365. /**
  96366. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96367. * @param defines Defines of the material we want to update
  96368. * @param lightIndex Index of the light in the enabled light list of the material
  96369. */
  96370. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96371. /**
  96372. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96373. * defined in the generator but impacting the effect).
  96374. * It implies the unifroms available on the materials are the standard BJS ones.
  96375. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96376. * @param effect The effect we are binfing the information for
  96377. */
  96378. bindShadowLight(lightIndex: string, effect: Effect): void;
  96379. /**
  96380. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96381. * (eq to shadow prjection matrix * light transform matrix)
  96382. * @returns The transform matrix used to create the shadow map
  96383. */
  96384. getTransformMatrix(): Matrix;
  96385. /**
  96386. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96387. * Cube and 2D textures for instance.
  96388. */
  96389. recreateShadowMap(): void;
  96390. /**
  96391. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96392. * @param onCompiled Callback triggered at the and of the effects compilation
  96393. * @param options Sets of optional options forcing the compilation with different modes
  96394. */
  96395. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96396. useInstances: boolean;
  96397. }>): void;
  96398. /**
  96399. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96400. * @param options Sets of optional options forcing the compilation with different modes
  96401. * @returns A promise that resolves when the compilation completes
  96402. */
  96403. forceCompilationAsync(options?: Partial<{
  96404. useInstances: boolean;
  96405. }>): Promise<void>;
  96406. /**
  96407. * Serializes the shadow generator setup to a json object.
  96408. * @returns The serialized JSON object
  96409. */
  96410. serialize(): any;
  96411. /**
  96412. * Disposes the Shadow map and related Textures and effects.
  96413. */
  96414. dispose(): void;
  96415. }
  96416. /**
  96417. * Default implementation IShadowGenerator.
  96418. * This is the main object responsible of generating shadows in the framework.
  96419. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96420. */
  96421. export class ShadowGenerator implements IShadowGenerator {
  96422. /**
  96423. * Name of the shadow generator class
  96424. */
  96425. static CLASSNAME: string;
  96426. /**
  96427. * Shadow generator mode None: no filtering applied.
  96428. */
  96429. static readonly FILTER_NONE: number;
  96430. /**
  96431. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96432. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96433. */
  96434. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96435. /**
  96436. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96437. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96438. */
  96439. static readonly FILTER_POISSONSAMPLING: number;
  96440. /**
  96441. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96442. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96443. */
  96444. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96445. /**
  96446. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96447. * edge artifacts on steep falloff.
  96448. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96449. */
  96450. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96451. /**
  96452. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96453. * edge artifacts on steep falloff.
  96454. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96455. */
  96456. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96457. /**
  96458. * Shadow generator mode PCF: Percentage Closer Filtering
  96459. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96460. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96461. */
  96462. static readonly FILTER_PCF: number;
  96463. /**
  96464. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96465. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96466. * Contact Hardening
  96467. */
  96468. static readonly FILTER_PCSS: number;
  96469. /**
  96470. * Reserved for PCF and PCSS
  96471. * Highest Quality.
  96472. *
  96473. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96474. *
  96475. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96476. */
  96477. static readonly QUALITY_HIGH: number;
  96478. /**
  96479. * Reserved for PCF and PCSS
  96480. * Good tradeoff for quality/perf cross devices
  96481. *
  96482. * Execute PCF on a 3*3 kernel.
  96483. *
  96484. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96485. */
  96486. static readonly QUALITY_MEDIUM: number;
  96487. /**
  96488. * Reserved for PCF and PCSS
  96489. * The lowest quality but the fastest.
  96490. *
  96491. * Execute PCF on a 1*1 kernel.
  96492. *
  96493. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96494. */
  96495. static readonly QUALITY_LOW: number;
  96496. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96497. id: string;
  96498. /** Gets or sets the custom shader name to use */
  96499. customShaderOptions: ICustomShaderOptions;
  96500. /**
  96501. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96502. */
  96503. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96504. /**
  96505. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96506. */
  96507. onAfterShadowMapRenderObservable: Observable<Effect>;
  96508. /**
  96509. * Observable triggered before a mesh is rendered in the shadow map.
  96510. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96511. */
  96512. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96513. /**
  96514. * Observable triggered after a mesh is rendered in the shadow map.
  96515. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96516. */
  96517. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96518. protected _bias: number;
  96519. /**
  96520. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96521. */
  96522. get bias(): number;
  96523. /**
  96524. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96525. */
  96526. set bias(bias: number);
  96527. protected _normalBias: number;
  96528. /**
  96529. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96530. */
  96531. get normalBias(): number;
  96532. /**
  96533. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96534. */
  96535. set normalBias(normalBias: number);
  96536. protected _blurBoxOffset: number;
  96537. /**
  96538. * Gets the blur box offset: offset applied during the blur pass.
  96539. * Only useful if useKernelBlur = false
  96540. */
  96541. get blurBoxOffset(): number;
  96542. /**
  96543. * Sets the blur box offset: offset applied during the blur pass.
  96544. * Only useful if useKernelBlur = false
  96545. */
  96546. set blurBoxOffset(value: number);
  96547. protected _blurScale: number;
  96548. /**
  96549. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96550. * 2 means half of the size.
  96551. */
  96552. get blurScale(): number;
  96553. /**
  96554. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96555. * 2 means half of the size.
  96556. */
  96557. set blurScale(value: number);
  96558. protected _blurKernel: number;
  96559. /**
  96560. * Gets the blur kernel: kernel size of the blur pass.
  96561. * Only useful if useKernelBlur = true
  96562. */
  96563. get blurKernel(): number;
  96564. /**
  96565. * Sets the blur kernel: kernel size of the blur pass.
  96566. * Only useful if useKernelBlur = true
  96567. */
  96568. set blurKernel(value: number);
  96569. protected _useKernelBlur: boolean;
  96570. /**
  96571. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96572. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96573. */
  96574. get useKernelBlur(): boolean;
  96575. /**
  96576. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96577. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96578. */
  96579. set useKernelBlur(value: boolean);
  96580. protected _depthScale: number;
  96581. /**
  96582. * Gets the depth scale used in ESM mode.
  96583. */
  96584. get depthScale(): number;
  96585. /**
  96586. * Sets the depth scale used in ESM mode.
  96587. * This can override the scale stored on the light.
  96588. */
  96589. set depthScale(value: number);
  96590. protected _validateFilter(filter: number): number;
  96591. protected _filter: number;
  96592. /**
  96593. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96594. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96595. */
  96596. get filter(): number;
  96597. /**
  96598. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96599. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96600. */
  96601. set filter(value: number);
  96602. /**
  96603. * Gets if the current filter is set to Poisson Sampling.
  96604. */
  96605. get usePoissonSampling(): boolean;
  96606. /**
  96607. * Sets the current filter to Poisson Sampling.
  96608. */
  96609. set usePoissonSampling(value: boolean);
  96610. /**
  96611. * Gets if the current filter is set to ESM.
  96612. */
  96613. get useExponentialShadowMap(): boolean;
  96614. /**
  96615. * Sets the current filter is to ESM.
  96616. */
  96617. set useExponentialShadowMap(value: boolean);
  96618. /**
  96619. * Gets if the current filter is set to filtered ESM.
  96620. */
  96621. get useBlurExponentialShadowMap(): boolean;
  96622. /**
  96623. * Gets if the current filter is set to filtered ESM.
  96624. */
  96625. set useBlurExponentialShadowMap(value: boolean);
  96626. /**
  96627. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96628. * exponential to prevent steep falloff artifacts).
  96629. */
  96630. get useCloseExponentialShadowMap(): boolean;
  96631. /**
  96632. * Sets the current filter to "close ESM" (using the inverse of the
  96633. * exponential to prevent steep falloff artifacts).
  96634. */
  96635. set useCloseExponentialShadowMap(value: boolean);
  96636. /**
  96637. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96638. * exponential to prevent steep falloff artifacts).
  96639. */
  96640. get useBlurCloseExponentialShadowMap(): boolean;
  96641. /**
  96642. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96643. * exponential to prevent steep falloff artifacts).
  96644. */
  96645. set useBlurCloseExponentialShadowMap(value: boolean);
  96646. /**
  96647. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96648. */
  96649. get usePercentageCloserFiltering(): boolean;
  96650. /**
  96651. * Sets the current filter to "PCF" (percentage closer filtering).
  96652. */
  96653. set usePercentageCloserFiltering(value: boolean);
  96654. protected _filteringQuality: number;
  96655. /**
  96656. * Gets the PCF or PCSS Quality.
  96657. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96658. */
  96659. get filteringQuality(): number;
  96660. /**
  96661. * Sets the PCF or PCSS Quality.
  96662. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96663. */
  96664. set filteringQuality(filteringQuality: number);
  96665. /**
  96666. * Gets if the current filter is set to "PCSS" (contact hardening).
  96667. */
  96668. get useContactHardeningShadow(): boolean;
  96669. /**
  96670. * Sets the current filter to "PCSS" (contact hardening).
  96671. */
  96672. set useContactHardeningShadow(value: boolean);
  96673. protected _contactHardeningLightSizeUVRatio: number;
  96674. /**
  96675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96676. * Using a ratio helps keeping shape stability independently of the map size.
  96677. *
  96678. * It does not account for the light projection as it was having too much
  96679. * instability during the light setup or during light position changes.
  96680. *
  96681. * Only valid if useContactHardeningShadow is true.
  96682. */
  96683. get contactHardeningLightSizeUVRatio(): number;
  96684. /**
  96685. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96686. * Using a ratio helps keeping shape stability independently of the map size.
  96687. *
  96688. * It does not account for the light projection as it was having too much
  96689. * instability during the light setup or during light position changes.
  96690. *
  96691. * Only valid if useContactHardeningShadow is true.
  96692. */
  96693. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96694. protected _darkness: number;
  96695. /** Gets or sets the actual darkness of a shadow */
  96696. get darkness(): number;
  96697. set darkness(value: number);
  96698. /**
  96699. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96700. * 0 means strongest and 1 would means no shadow.
  96701. * @returns the darkness.
  96702. */
  96703. getDarkness(): number;
  96704. /**
  96705. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96706. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96707. * @returns the shadow generator allowing fluent coding.
  96708. */
  96709. setDarkness(darkness: number): ShadowGenerator;
  96710. protected _transparencyShadow: boolean;
  96711. /** Gets or sets the ability to have transparent shadow */
  96712. get transparencyShadow(): boolean;
  96713. set transparencyShadow(value: boolean);
  96714. /**
  96715. * Sets the ability to have transparent shadow (boolean).
  96716. * @param transparent True if transparent else False
  96717. * @returns the shadow generator allowing fluent coding
  96718. */
  96719. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96720. /**
  96721. * Enables or disables shadows with varying strength based on the transparency
  96722. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96723. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96724. * mesh.visibility * alphaTexture.a
  96725. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96726. */
  96727. enableSoftTransparentShadow: boolean;
  96728. protected _shadowMap: Nullable<RenderTargetTexture>;
  96729. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96730. /**
  96731. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96732. * @returns The render target texture if present otherwise, null
  96733. */
  96734. getShadowMap(): Nullable<RenderTargetTexture>;
  96735. /**
  96736. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96737. * @returns The render target texture if the shadow map is present otherwise, null
  96738. */
  96739. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96740. /**
  96741. * Gets the class name of that object
  96742. * @returns "ShadowGenerator"
  96743. */
  96744. getClassName(): string;
  96745. /**
  96746. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96747. * @param mesh Mesh to add
  96748. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96749. * @returns the Shadow Generator itself
  96750. */
  96751. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96752. /**
  96753. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96754. * @param mesh Mesh to remove
  96755. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96756. * @returns the Shadow Generator itself
  96757. */
  96758. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96759. /**
  96760. * Controls the extent to which the shadows fade out at the edge of the frustum
  96761. */
  96762. frustumEdgeFalloff: number;
  96763. protected _light: IShadowLight;
  96764. /**
  96765. * Returns the associated light object.
  96766. * @returns the light generating the shadow
  96767. */
  96768. getLight(): IShadowLight;
  96769. /**
  96770. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96771. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96772. * It might on the other hand introduce peter panning.
  96773. */
  96774. forceBackFacesOnly: boolean;
  96775. protected _scene: Scene;
  96776. protected _lightDirection: Vector3;
  96777. protected _effect: Effect;
  96778. protected _viewMatrix: Matrix;
  96779. protected _projectionMatrix: Matrix;
  96780. protected _transformMatrix: Matrix;
  96781. protected _cachedPosition: Vector3;
  96782. protected _cachedDirection: Vector3;
  96783. protected _cachedDefines: string;
  96784. protected _currentRenderID: number;
  96785. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96786. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96787. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96788. protected _blurPostProcesses: PostProcess[];
  96789. protected _mapSize: number;
  96790. protected _currentFaceIndex: number;
  96791. protected _currentFaceIndexCache: number;
  96792. protected _textureType: number;
  96793. protected _defaultTextureMatrix: Matrix;
  96794. protected _storedUniqueId: Nullable<number>;
  96795. /** @hidden */
  96796. static _SceneComponentInitialization: (scene: Scene) => void;
  96797. /**
  96798. * Creates a ShadowGenerator object.
  96799. * A ShadowGenerator is the required tool to use the shadows.
  96800. * Each light casting shadows needs to use its own ShadowGenerator.
  96801. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96802. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96803. * @param light The light object generating the shadows.
  96804. * @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.
  96805. */
  96806. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96807. protected _initializeGenerator(): void;
  96808. protected _createTargetRenderTexture(): void;
  96809. protected _initializeShadowMap(): void;
  96810. protected _initializeBlurRTTAndPostProcesses(): void;
  96811. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96812. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96813. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96814. protected _applyFilterValues(): void;
  96815. /**
  96816. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96817. * @param onCompiled Callback triggered at the and of the effects compilation
  96818. * @param options Sets of optional options forcing the compilation with different modes
  96819. */
  96820. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96821. useInstances: boolean;
  96822. }>): void;
  96823. /**
  96824. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96825. * @param options Sets of optional options forcing the compilation with different modes
  96826. * @returns A promise that resolves when the compilation completes
  96827. */
  96828. forceCompilationAsync(options?: Partial<{
  96829. useInstances: boolean;
  96830. }>): Promise<void>;
  96831. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96832. private _prepareShadowDefines;
  96833. /**
  96834. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96835. * @param subMesh The submesh we want to render in the shadow map
  96836. * @param useInstances Defines wether will draw in the map using instances
  96837. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96838. * @returns true if ready otherwise, false
  96839. */
  96840. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96841. /**
  96842. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96843. * @param defines Defines of the material we want to update
  96844. * @param lightIndex Index of the light in the enabled light list of the material
  96845. */
  96846. prepareDefines(defines: any, lightIndex: number): void;
  96847. /**
  96848. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96849. * defined in the generator but impacting the effect).
  96850. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96851. * @param effect The effect we are binfing the information for
  96852. */
  96853. bindShadowLight(lightIndex: string, effect: Effect): void;
  96854. /**
  96855. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96856. * (eq to shadow prjection matrix * light transform matrix)
  96857. * @returns The transform matrix used to create the shadow map
  96858. */
  96859. getTransformMatrix(): Matrix;
  96860. /**
  96861. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96862. * Cube and 2D textures for instance.
  96863. */
  96864. recreateShadowMap(): void;
  96865. protected _disposeBlurPostProcesses(): void;
  96866. protected _disposeRTTandPostProcesses(): void;
  96867. /**
  96868. * Disposes the ShadowGenerator.
  96869. * Returns nothing.
  96870. */
  96871. dispose(): void;
  96872. /**
  96873. * Serializes the shadow generator setup to a json object.
  96874. * @returns The serialized JSON object
  96875. */
  96876. serialize(): any;
  96877. /**
  96878. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96879. * @param parsedShadowGenerator The JSON object to parse
  96880. * @param scene The scene to create the shadow map for
  96881. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96882. * @returns The parsed shadow generator
  96883. */
  96884. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96885. }
  96886. }
  96887. declare module BABYLON {
  96888. /**
  96889. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96890. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96891. * 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.
  96892. */
  96893. export abstract class Light extends Node {
  96894. /**
  96895. * Falloff Default: light is falling off following the material specification:
  96896. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96897. */
  96898. static readonly FALLOFF_DEFAULT: number;
  96899. /**
  96900. * Falloff Physical: light is falling off following the inverse squared distance law.
  96901. */
  96902. static readonly FALLOFF_PHYSICAL: number;
  96903. /**
  96904. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96905. * to enhance interoperability with other engines.
  96906. */
  96907. static readonly FALLOFF_GLTF: number;
  96908. /**
  96909. * Falloff Standard: light is falling off like in the standard material
  96910. * to enhance interoperability with other materials.
  96911. */
  96912. static readonly FALLOFF_STANDARD: number;
  96913. /**
  96914. * If every light affecting the material is in this lightmapMode,
  96915. * material.lightmapTexture adds or multiplies
  96916. * (depends on material.useLightmapAsShadowmap)
  96917. * after every other light calculations.
  96918. */
  96919. static readonly LIGHTMAP_DEFAULT: number;
  96920. /**
  96921. * material.lightmapTexture as only diffuse lighting from this light
  96922. * adds only specular lighting from this light
  96923. * adds dynamic shadows
  96924. */
  96925. static readonly LIGHTMAP_SPECULAR: number;
  96926. /**
  96927. * material.lightmapTexture as only lighting
  96928. * no light calculation from this light
  96929. * only adds dynamic shadows from this light
  96930. */
  96931. static readonly LIGHTMAP_SHADOWSONLY: number;
  96932. /**
  96933. * Each light type uses the default quantity according to its type:
  96934. * point/spot lights use luminous intensity
  96935. * directional lights use illuminance
  96936. */
  96937. static readonly INTENSITYMODE_AUTOMATIC: number;
  96938. /**
  96939. * lumen (lm)
  96940. */
  96941. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96942. /**
  96943. * candela (lm/sr)
  96944. */
  96945. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96946. /**
  96947. * lux (lm/m^2)
  96948. */
  96949. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96950. /**
  96951. * nit (cd/m^2)
  96952. */
  96953. static readonly INTENSITYMODE_LUMINANCE: number;
  96954. /**
  96955. * Light type const id of the point light.
  96956. */
  96957. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96958. /**
  96959. * Light type const id of the directional light.
  96960. */
  96961. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96962. /**
  96963. * Light type const id of the spot light.
  96964. */
  96965. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96966. /**
  96967. * Light type const id of the hemispheric light.
  96968. */
  96969. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96970. /**
  96971. * Diffuse gives the basic color to an object.
  96972. */
  96973. diffuse: Color3;
  96974. /**
  96975. * Specular produces a highlight color on an object.
  96976. * Note: This is note affecting PBR materials.
  96977. */
  96978. specular: Color3;
  96979. /**
  96980. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96981. * falling off base on range or angle.
  96982. * This can be set to any values in Light.FALLOFF_x.
  96983. *
  96984. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96985. * other types of materials.
  96986. */
  96987. falloffType: number;
  96988. /**
  96989. * Strength of the light.
  96990. * Note: By default it is define in the framework own unit.
  96991. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96992. */
  96993. intensity: number;
  96994. private _range;
  96995. protected _inverseSquaredRange: number;
  96996. /**
  96997. * Defines how far from the source the light is impacting in scene units.
  96998. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96999. */
  97000. get range(): number;
  97001. /**
  97002. * Defines how far from the source the light is impacting in scene units.
  97003. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97004. */
  97005. set range(value: number);
  97006. /**
  97007. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97008. * of light.
  97009. */
  97010. private _photometricScale;
  97011. private _intensityMode;
  97012. /**
  97013. * Gets the photometric scale used to interpret the intensity.
  97014. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97015. */
  97016. get intensityMode(): number;
  97017. /**
  97018. * Sets the photometric scale used to interpret the intensity.
  97019. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97020. */
  97021. set intensityMode(value: number);
  97022. private _radius;
  97023. /**
  97024. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97025. */
  97026. get radius(): number;
  97027. /**
  97028. * sets the light radius used by PBR Materials to simulate soft area lights.
  97029. */
  97030. set radius(value: number);
  97031. private _renderPriority;
  97032. /**
  97033. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97034. * exceeding the number allowed of the materials.
  97035. */
  97036. renderPriority: number;
  97037. private _shadowEnabled;
  97038. /**
  97039. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97040. * the current shadow generator.
  97041. */
  97042. get shadowEnabled(): boolean;
  97043. /**
  97044. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97045. * the current shadow generator.
  97046. */
  97047. set shadowEnabled(value: boolean);
  97048. private _includedOnlyMeshes;
  97049. /**
  97050. * Gets the only meshes impacted by this light.
  97051. */
  97052. get includedOnlyMeshes(): AbstractMesh[];
  97053. /**
  97054. * Sets the only meshes impacted by this light.
  97055. */
  97056. set includedOnlyMeshes(value: AbstractMesh[]);
  97057. private _excludedMeshes;
  97058. /**
  97059. * Gets the meshes not impacted by this light.
  97060. */
  97061. get excludedMeshes(): AbstractMesh[];
  97062. /**
  97063. * Sets the meshes not impacted by this light.
  97064. */
  97065. set excludedMeshes(value: AbstractMesh[]);
  97066. private _excludeWithLayerMask;
  97067. /**
  97068. * Gets the layer id use to find what meshes are not impacted by the light.
  97069. * Inactive if 0
  97070. */
  97071. get excludeWithLayerMask(): number;
  97072. /**
  97073. * Sets the layer id use to find what meshes are not impacted by the light.
  97074. * Inactive if 0
  97075. */
  97076. set excludeWithLayerMask(value: number);
  97077. private _includeOnlyWithLayerMask;
  97078. /**
  97079. * Gets the layer id use to find what meshes are impacted by the light.
  97080. * Inactive if 0
  97081. */
  97082. get includeOnlyWithLayerMask(): number;
  97083. /**
  97084. * Sets the layer id use to find what meshes are impacted by the light.
  97085. * Inactive if 0
  97086. */
  97087. set includeOnlyWithLayerMask(value: number);
  97088. private _lightmapMode;
  97089. /**
  97090. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97091. */
  97092. get lightmapMode(): number;
  97093. /**
  97094. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97095. */
  97096. set lightmapMode(value: number);
  97097. /**
  97098. * Shadow generator associted to the light.
  97099. * @hidden Internal use only.
  97100. */
  97101. _shadowGenerator: Nullable<IShadowGenerator>;
  97102. /**
  97103. * @hidden Internal use only.
  97104. */
  97105. _excludedMeshesIds: string[];
  97106. /**
  97107. * @hidden Internal use only.
  97108. */
  97109. _includedOnlyMeshesIds: string[];
  97110. /**
  97111. * The current light unifom buffer.
  97112. * @hidden Internal use only.
  97113. */
  97114. _uniformBuffer: UniformBuffer;
  97115. /** @hidden */
  97116. _renderId: number;
  97117. /**
  97118. * Creates a Light object in the scene.
  97119. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97120. * @param name The firendly name of the light
  97121. * @param scene The scene the light belongs too
  97122. */
  97123. constructor(name: string, scene: Scene);
  97124. protected abstract _buildUniformLayout(): void;
  97125. /**
  97126. * Sets the passed Effect "effect" with the Light information.
  97127. * @param effect The effect to update
  97128. * @param lightIndex The index of the light in the effect to update
  97129. * @returns The light
  97130. */
  97131. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97132. /**
  97133. * Sets the passed Effect "effect" with the Light textures.
  97134. * @param effect The effect to update
  97135. * @param lightIndex The index of the light in the effect to update
  97136. * @returns The light
  97137. */
  97138. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97139. /**
  97140. * Binds the lights information from the scene to the effect for the given mesh.
  97141. * @param lightIndex Light index
  97142. * @param scene The scene where the light belongs to
  97143. * @param effect The effect we are binding the data to
  97144. * @param useSpecular Defines if specular is supported
  97145. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97146. */
  97147. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97148. /**
  97149. * Sets the passed Effect "effect" with the Light information.
  97150. * @param effect The effect to update
  97151. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97152. * @returns The light
  97153. */
  97154. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97155. /**
  97156. * Returns the string "Light".
  97157. * @returns the class name
  97158. */
  97159. getClassName(): string;
  97160. /** @hidden */
  97161. readonly _isLight: boolean;
  97162. /**
  97163. * Converts the light information to a readable string for debug purpose.
  97164. * @param fullDetails Supports for multiple levels of logging within scene loading
  97165. * @returns the human readable light info
  97166. */
  97167. toString(fullDetails?: boolean): string;
  97168. /** @hidden */
  97169. protected _syncParentEnabledState(): void;
  97170. /**
  97171. * Set the enabled state of this node.
  97172. * @param value - the new enabled state
  97173. */
  97174. setEnabled(value: boolean): void;
  97175. /**
  97176. * Returns the Light associated shadow generator if any.
  97177. * @return the associated shadow generator.
  97178. */
  97179. getShadowGenerator(): Nullable<IShadowGenerator>;
  97180. /**
  97181. * Returns a Vector3, the absolute light position in the World.
  97182. * @returns the world space position of the light
  97183. */
  97184. getAbsolutePosition(): Vector3;
  97185. /**
  97186. * Specifies if the light will affect the passed mesh.
  97187. * @param mesh The mesh to test against the light
  97188. * @return true the mesh is affected otherwise, false.
  97189. */
  97190. canAffectMesh(mesh: AbstractMesh): boolean;
  97191. /**
  97192. * Sort function to order lights for rendering.
  97193. * @param a First Light object to compare to second.
  97194. * @param b Second Light object to compare first.
  97195. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97196. */
  97197. static CompareLightsPriority(a: Light, b: Light): number;
  97198. /**
  97199. * Releases resources associated with this node.
  97200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97202. */
  97203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97204. /**
  97205. * Returns the light type ID (integer).
  97206. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97207. */
  97208. getTypeID(): number;
  97209. /**
  97210. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97211. * @returns the scaled intensity in intensity mode unit
  97212. */
  97213. getScaledIntensity(): number;
  97214. /**
  97215. * Returns a new Light object, named "name", from the current one.
  97216. * @param name The name of the cloned light
  97217. * @param newParent The parent of this light, if it has one
  97218. * @returns the new created light
  97219. */
  97220. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97221. /**
  97222. * Serializes the current light into a Serialization object.
  97223. * @returns the serialized object.
  97224. */
  97225. serialize(): any;
  97226. /**
  97227. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97228. * This new light is named "name" and added to the passed scene.
  97229. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97230. * @param name The friendly name of the light
  97231. * @param scene The scene the new light will belong to
  97232. * @returns the constructor function
  97233. */
  97234. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97235. /**
  97236. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97237. * @param parsedLight The JSON representation of the light
  97238. * @param scene The scene to create the parsed light in
  97239. * @returns the created light after parsing
  97240. */
  97241. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97242. private _hookArrayForExcluded;
  97243. private _hookArrayForIncludedOnly;
  97244. private _resyncMeshes;
  97245. /**
  97246. * Forces the meshes to update their light related information in their rendering used effects
  97247. * @hidden Internal Use Only
  97248. */
  97249. _markMeshesAsLightDirty(): void;
  97250. /**
  97251. * Recomputes the cached photometric scale if needed.
  97252. */
  97253. private _computePhotometricScale;
  97254. /**
  97255. * Returns the Photometric Scale according to the light type and intensity mode.
  97256. */
  97257. private _getPhotometricScale;
  97258. /**
  97259. * Reorder the light in the scene according to their defined priority.
  97260. * @hidden Internal Use Only
  97261. */
  97262. _reorderLightsInScene(): void;
  97263. /**
  97264. * Prepares the list of defines specific to the light type.
  97265. * @param defines the list of defines
  97266. * @param lightIndex defines the index of the light for the effect
  97267. */
  97268. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97269. }
  97270. }
  97271. declare module BABYLON {
  97272. /**
  97273. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97274. * This is the base of the follow, arc rotate cameras and Free camera
  97275. * @see https://doc.babylonjs.com/features/cameras
  97276. */
  97277. export class TargetCamera extends Camera {
  97278. private static _RigCamTransformMatrix;
  97279. private static _TargetTransformMatrix;
  97280. private static _TargetFocalPoint;
  97281. private _tmpUpVector;
  97282. private _tmpTargetVector;
  97283. /**
  97284. * Define the current direction the camera is moving to
  97285. */
  97286. cameraDirection: Vector3;
  97287. /**
  97288. * Define the current rotation the camera is rotating to
  97289. */
  97290. cameraRotation: Vector2;
  97291. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97292. ignoreParentScaling: boolean;
  97293. /**
  97294. * When set, the up vector of the camera will be updated by the rotation of the camera
  97295. */
  97296. updateUpVectorFromRotation: boolean;
  97297. private _tmpQuaternion;
  97298. /**
  97299. * Define the current rotation of the camera
  97300. */
  97301. rotation: Vector3;
  97302. /**
  97303. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97304. */
  97305. rotationQuaternion: Quaternion;
  97306. /**
  97307. * Define the current speed of the camera
  97308. */
  97309. speed: number;
  97310. /**
  97311. * Add constraint to the camera to prevent it to move freely in all directions and
  97312. * around all axis.
  97313. */
  97314. noRotationConstraint: boolean;
  97315. /**
  97316. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97317. * panning
  97318. */
  97319. invertRotation: boolean;
  97320. /**
  97321. * Speed multiplier for inverse camera panning
  97322. */
  97323. inverseRotationSpeed: number;
  97324. /**
  97325. * Define the current target of the camera as an object or a position.
  97326. */
  97327. lockedTarget: any;
  97328. /** @hidden */
  97329. _currentTarget: Vector3;
  97330. /** @hidden */
  97331. _initialFocalDistance: number;
  97332. /** @hidden */
  97333. _viewMatrix: Matrix;
  97334. /** @hidden */
  97335. _camMatrix: Matrix;
  97336. /** @hidden */
  97337. _cameraTransformMatrix: Matrix;
  97338. /** @hidden */
  97339. _cameraRotationMatrix: Matrix;
  97340. /** @hidden */
  97341. _referencePoint: Vector3;
  97342. /** @hidden */
  97343. _transformedReferencePoint: Vector3;
  97344. /** @hidden */
  97345. _reset: () => void;
  97346. private _defaultUp;
  97347. /**
  97348. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97349. * This is the base of the follow, arc rotate cameras and Free camera
  97350. * @see https://doc.babylonjs.com/features/cameras
  97351. * @param name Defines the name of the camera in the scene
  97352. * @param position Defines the start position of the camera in the scene
  97353. * @param scene Defines the scene the camera belongs to
  97354. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97355. */
  97356. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97357. /**
  97358. * Gets the position in front of the camera at a given distance.
  97359. * @param distance The distance from the camera we want the position to be
  97360. * @returns the position
  97361. */
  97362. getFrontPosition(distance: number): Vector3;
  97363. /** @hidden */
  97364. _getLockedTargetPosition(): Nullable<Vector3>;
  97365. private _storedPosition;
  97366. private _storedRotation;
  97367. private _storedRotationQuaternion;
  97368. /**
  97369. * Store current camera state of the camera (fov, position, rotation, etc..)
  97370. * @returns the camera
  97371. */
  97372. storeState(): Camera;
  97373. /**
  97374. * Restored camera state. You must call storeState() first
  97375. * @returns whether it was successful or not
  97376. * @hidden
  97377. */
  97378. _restoreStateValues(): boolean;
  97379. /** @hidden */
  97380. _initCache(): void;
  97381. /** @hidden */
  97382. _updateCache(ignoreParentClass?: boolean): void;
  97383. /** @hidden */
  97384. _isSynchronizedViewMatrix(): boolean;
  97385. /** @hidden */
  97386. _computeLocalCameraSpeed(): number;
  97387. /**
  97388. * Defines the target the camera should look at.
  97389. * @param target Defines the new target as a Vector or a mesh
  97390. */
  97391. setTarget(target: Vector3): void;
  97392. /**
  97393. * Defines the target point of the camera.
  97394. * The camera looks towards it form the radius distance.
  97395. */
  97396. get target(): Vector3;
  97397. set target(value: Vector3);
  97398. /**
  97399. * Return the current target position of the camera. This value is expressed in local space.
  97400. * @returns the target position
  97401. */
  97402. getTarget(): Vector3;
  97403. /** @hidden */
  97404. _decideIfNeedsToMove(): boolean;
  97405. /** @hidden */
  97406. _updatePosition(): void;
  97407. /** @hidden */
  97408. _checkInputs(): void;
  97409. protected _updateCameraRotationMatrix(): void;
  97410. /**
  97411. * 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)
  97412. * @returns the current camera
  97413. */
  97414. private _rotateUpVectorWithCameraRotationMatrix;
  97415. private _cachedRotationZ;
  97416. private _cachedQuaternionRotationZ;
  97417. /** @hidden */
  97418. _getViewMatrix(): Matrix;
  97419. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97420. /**
  97421. * @hidden
  97422. */
  97423. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97424. /**
  97425. * @hidden
  97426. */
  97427. _updateRigCameras(): void;
  97428. private _getRigCamPositionAndTarget;
  97429. /**
  97430. * Gets the current object class name.
  97431. * @return the class name
  97432. */
  97433. getClassName(): string;
  97434. }
  97435. }
  97436. declare module BABYLON {
  97437. /**
  97438. * Gather the list of keyboard event types as constants.
  97439. */
  97440. export class KeyboardEventTypes {
  97441. /**
  97442. * The keydown event is fired when a key becomes active (pressed).
  97443. */
  97444. static readonly KEYDOWN: number;
  97445. /**
  97446. * The keyup event is fired when a key has been released.
  97447. */
  97448. static readonly KEYUP: number;
  97449. }
  97450. /**
  97451. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97452. */
  97453. export class KeyboardInfo {
  97454. /**
  97455. * Defines the type of event (KeyboardEventTypes)
  97456. */
  97457. type: number;
  97458. /**
  97459. * Defines the related dom event
  97460. */
  97461. event: KeyboardEvent;
  97462. /**
  97463. * Instantiates a new keyboard info.
  97464. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97465. * @param type Defines the type of event (KeyboardEventTypes)
  97466. * @param event Defines the related dom event
  97467. */
  97468. constructor(
  97469. /**
  97470. * Defines the type of event (KeyboardEventTypes)
  97471. */
  97472. type: number,
  97473. /**
  97474. * Defines the related dom event
  97475. */
  97476. event: KeyboardEvent);
  97477. }
  97478. /**
  97479. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97480. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97481. */
  97482. export class KeyboardInfoPre extends KeyboardInfo {
  97483. /**
  97484. * Defines the type of event (KeyboardEventTypes)
  97485. */
  97486. type: number;
  97487. /**
  97488. * Defines the related dom event
  97489. */
  97490. event: KeyboardEvent;
  97491. /**
  97492. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97493. */
  97494. skipOnPointerObservable: boolean;
  97495. /**
  97496. * Instantiates a new keyboard pre info.
  97497. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97498. * @param type Defines the type of event (KeyboardEventTypes)
  97499. * @param event Defines the related dom event
  97500. */
  97501. constructor(
  97502. /**
  97503. * Defines the type of event (KeyboardEventTypes)
  97504. */
  97505. type: number,
  97506. /**
  97507. * Defines the related dom event
  97508. */
  97509. event: KeyboardEvent);
  97510. }
  97511. }
  97512. declare module BABYLON {
  97513. /**
  97514. * Manage the keyboard inputs to control the movement of a free camera.
  97515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97516. */
  97517. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97518. /**
  97519. * Defines the camera the input is attached to.
  97520. */
  97521. camera: FreeCamera;
  97522. /**
  97523. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97524. */
  97525. keysUp: number[];
  97526. /**
  97527. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97528. */
  97529. keysUpward: number[];
  97530. /**
  97531. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97532. */
  97533. keysDown: number[];
  97534. /**
  97535. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97536. */
  97537. keysDownward: number[];
  97538. /**
  97539. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97540. */
  97541. keysLeft: number[];
  97542. /**
  97543. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97544. */
  97545. keysRight: number[];
  97546. private _keys;
  97547. private _onCanvasBlurObserver;
  97548. private _onKeyboardObserver;
  97549. private _engine;
  97550. private _scene;
  97551. /**
  97552. * Attach the input controls to a specific dom element to get the input from.
  97553. * @param element Defines the element the controls should be listened from
  97554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97555. */
  97556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97557. /**
  97558. * Detach the current controls from the specified dom element.
  97559. * @param element Defines the element to stop listening the inputs from
  97560. */
  97561. detachControl(element: Nullable<HTMLElement>): void;
  97562. /**
  97563. * Update the current camera state depending on the inputs that have been used this frame.
  97564. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97565. */
  97566. checkInputs(): void;
  97567. /**
  97568. * Gets the class name of the current intput.
  97569. * @returns the class name
  97570. */
  97571. getClassName(): string;
  97572. /** @hidden */
  97573. _onLostFocus(): void;
  97574. /**
  97575. * Get the friendly name associated with the input class.
  97576. * @returns the input friendly name
  97577. */
  97578. getSimpleName(): string;
  97579. }
  97580. }
  97581. declare module BABYLON {
  97582. /**
  97583. * Gather the list of pointer event types as constants.
  97584. */
  97585. export class PointerEventTypes {
  97586. /**
  97587. * 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.
  97588. */
  97589. static readonly POINTERDOWN: number;
  97590. /**
  97591. * The pointerup event is fired when a pointer is no longer active.
  97592. */
  97593. static readonly POINTERUP: number;
  97594. /**
  97595. * The pointermove event is fired when a pointer changes coordinates.
  97596. */
  97597. static readonly POINTERMOVE: number;
  97598. /**
  97599. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97600. */
  97601. static readonly POINTERWHEEL: number;
  97602. /**
  97603. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97604. */
  97605. static readonly POINTERPICK: number;
  97606. /**
  97607. * The pointertap event is fired when a the object has been touched and released without drag.
  97608. */
  97609. static readonly POINTERTAP: number;
  97610. /**
  97611. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97612. */
  97613. static readonly POINTERDOUBLETAP: number;
  97614. }
  97615. /**
  97616. * Base class of pointer info types.
  97617. */
  97618. export class PointerInfoBase {
  97619. /**
  97620. * Defines the type of event (PointerEventTypes)
  97621. */
  97622. type: number;
  97623. /**
  97624. * Defines the related dom event
  97625. */
  97626. event: PointerEvent | MouseWheelEvent;
  97627. /**
  97628. * Instantiates the base class of pointers info.
  97629. * @param type Defines the type of event (PointerEventTypes)
  97630. * @param event Defines the related dom event
  97631. */
  97632. constructor(
  97633. /**
  97634. * Defines the type of event (PointerEventTypes)
  97635. */
  97636. type: number,
  97637. /**
  97638. * Defines the related dom event
  97639. */
  97640. event: PointerEvent | MouseWheelEvent);
  97641. }
  97642. /**
  97643. * This class is used to store pointer related info for the onPrePointerObservable event.
  97644. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97645. */
  97646. export class PointerInfoPre extends PointerInfoBase {
  97647. /**
  97648. * Ray from a pointer if availible (eg. 6dof controller)
  97649. */
  97650. ray: Nullable<Ray>;
  97651. /**
  97652. * Defines the local position of the pointer on the canvas.
  97653. */
  97654. localPosition: Vector2;
  97655. /**
  97656. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97657. */
  97658. skipOnPointerObservable: boolean;
  97659. /**
  97660. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97661. * @param type Defines the type of event (PointerEventTypes)
  97662. * @param event Defines the related dom event
  97663. * @param localX Defines the local x coordinates of the pointer when the event occured
  97664. * @param localY Defines the local y coordinates of the pointer when the event occured
  97665. */
  97666. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97667. }
  97668. /**
  97669. * This type contains all the data related to a pointer event in Babylon.js.
  97670. * 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.
  97671. */
  97672. export class PointerInfo extends PointerInfoBase {
  97673. /**
  97674. * Defines the picking info associated to the info (if any)\
  97675. */
  97676. pickInfo: Nullable<PickingInfo>;
  97677. /**
  97678. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97679. * @param type Defines the type of event (PointerEventTypes)
  97680. * @param event Defines the related dom event
  97681. * @param pickInfo Defines the picking info associated to the info (if any)\
  97682. */
  97683. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97684. /**
  97685. * Defines the picking info associated to the info (if any)\
  97686. */
  97687. pickInfo: Nullable<PickingInfo>);
  97688. }
  97689. /**
  97690. * Data relating to a touch event on the screen.
  97691. */
  97692. export interface PointerTouch {
  97693. /**
  97694. * X coordinate of touch.
  97695. */
  97696. x: number;
  97697. /**
  97698. * Y coordinate of touch.
  97699. */
  97700. y: number;
  97701. /**
  97702. * Id of touch. Unique for each finger.
  97703. */
  97704. pointerId: number;
  97705. /**
  97706. * Event type passed from DOM.
  97707. */
  97708. type: any;
  97709. }
  97710. }
  97711. declare module BABYLON {
  97712. /**
  97713. * Manage the mouse inputs to control the movement of a free camera.
  97714. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97715. */
  97716. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97717. /**
  97718. * Define if touch is enabled in the mouse input
  97719. */
  97720. touchEnabled: boolean;
  97721. /**
  97722. * Defines the camera the input is attached to.
  97723. */
  97724. camera: FreeCamera;
  97725. /**
  97726. * Defines the buttons associated with the input to handle camera move.
  97727. */
  97728. buttons: number[];
  97729. /**
  97730. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97731. */
  97732. angularSensibility: number;
  97733. private _pointerInput;
  97734. private _onMouseMove;
  97735. private _observer;
  97736. private previousPosition;
  97737. /**
  97738. * Observable for when a pointer move event occurs containing the move offset
  97739. */
  97740. onPointerMovedObservable: Observable<{
  97741. offsetX: number;
  97742. offsetY: number;
  97743. }>;
  97744. /**
  97745. * @hidden
  97746. * If the camera should be rotated automatically based on pointer movement
  97747. */
  97748. _allowCameraRotation: boolean;
  97749. /**
  97750. * Manage the mouse inputs to control the movement of a free camera.
  97751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97752. * @param touchEnabled Defines if touch is enabled or not
  97753. */
  97754. constructor(
  97755. /**
  97756. * Define if touch is enabled in the mouse input
  97757. */
  97758. touchEnabled?: boolean);
  97759. /**
  97760. * Attach the input controls to a specific dom element to get the input from.
  97761. * @param element Defines the element the controls should be listened from
  97762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97763. */
  97764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97765. /**
  97766. * Called on JS contextmenu event.
  97767. * Override this method to provide functionality.
  97768. */
  97769. protected onContextMenu(evt: PointerEvent): void;
  97770. /**
  97771. * Detach the current controls from the specified dom element.
  97772. * @param element Defines the element to stop listening the inputs from
  97773. */
  97774. detachControl(element: Nullable<HTMLElement>): void;
  97775. /**
  97776. * Gets the class name of the current intput.
  97777. * @returns the class name
  97778. */
  97779. getClassName(): string;
  97780. /**
  97781. * Get the friendly name associated with the input class.
  97782. * @returns the input friendly name
  97783. */
  97784. getSimpleName(): string;
  97785. }
  97786. }
  97787. declare module BABYLON {
  97788. /**
  97789. * Manage the touch inputs to control the movement of a free camera.
  97790. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97791. */
  97792. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97793. /**
  97794. * Defines the camera the input is attached to.
  97795. */
  97796. camera: FreeCamera;
  97797. /**
  97798. * Defines the touch sensibility for rotation.
  97799. * The higher the faster.
  97800. */
  97801. touchAngularSensibility: number;
  97802. /**
  97803. * Defines the touch sensibility for move.
  97804. * The higher the faster.
  97805. */
  97806. touchMoveSensibility: number;
  97807. private _offsetX;
  97808. private _offsetY;
  97809. private _pointerPressed;
  97810. private _pointerInput;
  97811. private _observer;
  97812. private _onLostFocus;
  97813. /**
  97814. * Attach the input controls to a specific dom element to get the input from.
  97815. * @param element Defines the element the controls should be listened from
  97816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97817. */
  97818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97819. /**
  97820. * Detach the current controls from the specified dom element.
  97821. * @param element Defines the element to stop listening the inputs from
  97822. */
  97823. detachControl(element: Nullable<HTMLElement>): void;
  97824. /**
  97825. * Update the current camera state depending on the inputs that have been used this frame.
  97826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97827. */
  97828. checkInputs(): void;
  97829. /**
  97830. * Gets the class name of the current intput.
  97831. * @returns the class name
  97832. */
  97833. getClassName(): string;
  97834. /**
  97835. * Get the friendly name associated with the input class.
  97836. * @returns the input friendly name
  97837. */
  97838. getSimpleName(): string;
  97839. }
  97840. }
  97841. declare module BABYLON {
  97842. /**
  97843. * Default Inputs manager for the FreeCamera.
  97844. * It groups all the default supported inputs for ease of use.
  97845. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97846. */
  97847. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97848. /**
  97849. * @hidden
  97850. */
  97851. _mouseInput: Nullable<FreeCameraMouseInput>;
  97852. /**
  97853. * Instantiates a new FreeCameraInputsManager.
  97854. * @param camera Defines the camera the inputs belong to
  97855. */
  97856. constructor(camera: FreeCamera);
  97857. /**
  97858. * Add keyboard input support to the input manager.
  97859. * @returns the current input manager
  97860. */
  97861. addKeyboard(): FreeCameraInputsManager;
  97862. /**
  97863. * Add mouse input support to the input manager.
  97864. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97865. * @returns the current input manager
  97866. */
  97867. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97868. /**
  97869. * Removes the mouse input support from the manager
  97870. * @returns the current input manager
  97871. */
  97872. removeMouse(): FreeCameraInputsManager;
  97873. /**
  97874. * Add touch input support to the input manager.
  97875. * @returns the current input manager
  97876. */
  97877. addTouch(): FreeCameraInputsManager;
  97878. /**
  97879. * Remove all attached input methods from a camera
  97880. */
  97881. clear(): void;
  97882. }
  97883. }
  97884. declare module BABYLON {
  97885. /**
  97886. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97887. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97888. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97889. */
  97890. export class FreeCamera extends TargetCamera {
  97891. /**
  97892. * Define the collision ellipsoid of the camera.
  97893. * This is helpful to simulate a camera body like the player body around the camera
  97894. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97895. */
  97896. ellipsoid: Vector3;
  97897. /**
  97898. * Define an offset for the position of the ellipsoid around the camera.
  97899. * This can be helpful to determine the center of the body near the gravity center of the body
  97900. * instead of its head.
  97901. */
  97902. ellipsoidOffset: Vector3;
  97903. /**
  97904. * Enable or disable collisions of the camera with the rest of the scene objects.
  97905. */
  97906. checkCollisions: boolean;
  97907. /**
  97908. * Enable or disable gravity on the camera.
  97909. */
  97910. applyGravity: boolean;
  97911. /**
  97912. * Define the input manager associated to the camera.
  97913. */
  97914. inputs: FreeCameraInputsManager;
  97915. /**
  97916. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97917. * Higher values reduce sensitivity.
  97918. */
  97919. get angularSensibility(): number;
  97920. /**
  97921. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97922. * Higher values reduce sensitivity.
  97923. */
  97924. set angularSensibility(value: number);
  97925. /**
  97926. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97927. */
  97928. get keysUp(): number[];
  97929. set keysUp(value: number[]);
  97930. /**
  97931. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97932. */
  97933. get keysUpward(): number[];
  97934. set keysUpward(value: number[]);
  97935. /**
  97936. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97937. */
  97938. get keysDown(): number[];
  97939. set keysDown(value: number[]);
  97940. /**
  97941. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97942. */
  97943. get keysDownward(): number[];
  97944. set keysDownward(value: number[]);
  97945. /**
  97946. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97947. */
  97948. get keysLeft(): number[];
  97949. set keysLeft(value: number[]);
  97950. /**
  97951. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97952. */
  97953. get keysRight(): number[];
  97954. set keysRight(value: number[]);
  97955. /**
  97956. * Event raised when the camera collide with a mesh in the scene.
  97957. */
  97958. onCollide: (collidedMesh: AbstractMesh) => void;
  97959. private _collider;
  97960. private _needMoveForGravity;
  97961. private _oldPosition;
  97962. private _diffPosition;
  97963. private _newPosition;
  97964. /** @hidden */
  97965. _localDirection: Vector3;
  97966. /** @hidden */
  97967. _transformedDirection: Vector3;
  97968. /**
  97969. * Instantiates a Free Camera.
  97970. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97971. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97973. * @param name Define the name of the camera in the scene
  97974. * @param position Define the start position of the camera in the scene
  97975. * @param scene Define the scene the camera belongs to
  97976. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97977. */
  97978. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97979. /**
  97980. * Attached controls to the current camera.
  97981. * @param element Defines the element the controls should be listened from
  97982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97983. */
  97984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97985. /**
  97986. * Detach the current controls from the camera.
  97987. * The camera will stop reacting to inputs.
  97988. * @param element Defines the element to stop listening the inputs from
  97989. */
  97990. detachControl(element: HTMLElement): void;
  97991. private _collisionMask;
  97992. /**
  97993. * Define a collision mask to limit the list of object the camera can collide with
  97994. */
  97995. get collisionMask(): number;
  97996. set collisionMask(mask: number);
  97997. /** @hidden */
  97998. _collideWithWorld(displacement: Vector3): void;
  97999. private _onCollisionPositionChange;
  98000. /** @hidden */
  98001. _checkInputs(): void;
  98002. /** @hidden */
  98003. _decideIfNeedsToMove(): boolean;
  98004. /** @hidden */
  98005. _updatePosition(): void;
  98006. /**
  98007. * Destroy the camera and release the current resources hold by it.
  98008. */
  98009. dispose(): void;
  98010. /**
  98011. * Gets the current object class name.
  98012. * @return the class name
  98013. */
  98014. getClassName(): string;
  98015. }
  98016. }
  98017. declare module BABYLON {
  98018. /**
  98019. * Represents a gamepad control stick position
  98020. */
  98021. export class StickValues {
  98022. /**
  98023. * The x component of the control stick
  98024. */
  98025. x: number;
  98026. /**
  98027. * The y component of the control stick
  98028. */
  98029. y: number;
  98030. /**
  98031. * Initializes the gamepad x and y control stick values
  98032. * @param x The x component of the gamepad control stick value
  98033. * @param y The y component of the gamepad control stick value
  98034. */
  98035. constructor(
  98036. /**
  98037. * The x component of the control stick
  98038. */
  98039. x: number,
  98040. /**
  98041. * The y component of the control stick
  98042. */
  98043. y: number);
  98044. }
  98045. /**
  98046. * An interface which manages callbacks for gamepad button changes
  98047. */
  98048. export interface GamepadButtonChanges {
  98049. /**
  98050. * Called when a gamepad has been changed
  98051. */
  98052. changed: boolean;
  98053. /**
  98054. * Called when a gamepad press event has been triggered
  98055. */
  98056. pressChanged: boolean;
  98057. /**
  98058. * Called when a touch event has been triggered
  98059. */
  98060. touchChanged: boolean;
  98061. /**
  98062. * Called when a value has changed
  98063. */
  98064. valueChanged: boolean;
  98065. }
  98066. /**
  98067. * Represents a gamepad
  98068. */
  98069. export class Gamepad {
  98070. /**
  98071. * The id of the gamepad
  98072. */
  98073. id: string;
  98074. /**
  98075. * The index of the gamepad
  98076. */
  98077. index: number;
  98078. /**
  98079. * The browser gamepad
  98080. */
  98081. browserGamepad: any;
  98082. /**
  98083. * Specifies what type of gamepad this represents
  98084. */
  98085. type: number;
  98086. private _leftStick;
  98087. private _rightStick;
  98088. /** @hidden */
  98089. _isConnected: boolean;
  98090. private _leftStickAxisX;
  98091. private _leftStickAxisY;
  98092. private _rightStickAxisX;
  98093. private _rightStickAxisY;
  98094. /**
  98095. * Triggered when the left control stick has been changed
  98096. */
  98097. private _onleftstickchanged;
  98098. /**
  98099. * Triggered when the right control stick has been changed
  98100. */
  98101. private _onrightstickchanged;
  98102. /**
  98103. * Represents a gamepad controller
  98104. */
  98105. static GAMEPAD: number;
  98106. /**
  98107. * Represents a generic controller
  98108. */
  98109. static GENERIC: number;
  98110. /**
  98111. * Represents an XBox controller
  98112. */
  98113. static XBOX: number;
  98114. /**
  98115. * Represents a pose-enabled controller
  98116. */
  98117. static POSE_ENABLED: number;
  98118. /**
  98119. * Represents an Dual Shock controller
  98120. */
  98121. static DUALSHOCK: number;
  98122. /**
  98123. * Specifies whether the left control stick should be Y-inverted
  98124. */
  98125. protected _invertLeftStickY: boolean;
  98126. /**
  98127. * Specifies if the gamepad has been connected
  98128. */
  98129. get isConnected(): boolean;
  98130. /**
  98131. * Initializes the gamepad
  98132. * @param id The id of the gamepad
  98133. * @param index The index of the gamepad
  98134. * @param browserGamepad The browser gamepad
  98135. * @param leftStickX The x component of the left joystick
  98136. * @param leftStickY The y component of the left joystick
  98137. * @param rightStickX The x component of the right joystick
  98138. * @param rightStickY The y component of the right joystick
  98139. */
  98140. constructor(
  98141. /**
  98142. * The id of the gamepad
  98143. */
  98144. id: string,
  98145. /**
  98146. * The index of the gamepad
  98147. */
  98148. index: number,
  98149. /**
  98150. * The browser gamepad
  98151. */
  98152. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98153. /**
  98154. * Callback triggered when the left joystick has changed
  98155. * @param callback
  98156. */
  98157. onleftstickchanged(callback: (values: StickValues) => void): void;
  98158. /**
  98159. * Callback triggered when the right joystick has changed
  98160. * @param callback
  98161. */
  98162. onrightstickchanged(callback: (values: StickValues) => void): void;
  98163. /**
  98164. * Gets the left joystick
  98165. */
  98166. get leftStick(): StickValues;
  98167. /**
  98168. * Sets the left joystick values
  98169. */
  98170. set leftStick(newValues: StickValues);
  98171. /**
  98172. * Gets the right joystick
  98173. */
  98174. get rightStick(): StickValues;
  98175. /**
  98176. * Sets the right joystick value
  98177. */
  98178. set rightStick(newValues: StickValues);
  98179. /**
  98180. * Updates the gamepad joystick positions
  98181. */
  98182. update(): void;
  98183. /**
  98184. * Disposes the gamepad
  98185. */
  98186. dispose(): void;
  98187. }
  98188. /**
  98189. * Represents a generic gamepad
  98190. */
  98191. export class GenericPad extends Gamepad {
  98192. private _buttons;
  98193. private _onbuttondown;
  98194. private _onbuttonup;
  98195. /**
  98196. * Observable triggered when a button has been pressed
  98197. */
  98198. onButtonDownObservable: Observable<number>;
  98199. /**
  98200. * Observable triggered when a button has been released
  98201. */
  98202. onButtonUpObservable: Observable<number>;
  98203. /**
  98204. * Callback triggered when a button has been pressed
  98205. * @param callback Called when a button has been pressed
  98206. */
  98207. onbuttondown(callback: (buttonPressed: number) => void): void;
  98208. /**
  98209. * Callback triggered when a button has been released
  98210. * @param callback Called when a button has been released
  98211. */
  98212. onbuttonup(callback: (buttonReleased: number) => void): void;
  98213. /**
  98214. * Initializes the generic gamepad
  98215. * @param id The id of the generic gamepad
  98216. * @param index The index of the generic gamepad
  98217. * @param browserGamepad The browser gamepad
  98218. */
  98219. constructor(id: string, index: number, browserGamepad: any);
  98220. private _setButtonValue;
  98221. /**
  98222. * Updates the generic gamepad
  98223. */
  98224. update(): void;
  98225. /**
  98226. * Disposes the generic gamepad
  98227. */
  98228. dispose(): void;
  98229. }
  98230. }
  98231. declare module BABYLON {
  98232. /**
  98233. * Defines the types of pose enabled controllers that are supported
  98234. */
  98235. export enum PoseEnabledControllerType {
  98236. /**
  98237. * HTC Vive
  98238. */
  98239. VIVE = 0,
  98240. /**
  98241. * Oculus Rift
  98242. */
  98243. OCULUS = 1,
  98244. /**
  98245. * Windows mixed reality
  98246. */
  98247. WINDOWS = 2,
  98248. /**
  98249. * Samsung gear VR
  98250. */
  98251. GEAR_VR = 3,
  98252. /**
  98253. * Google Daydream
  98254. */
  98255. DAYDREAM = 4,
  98256. /**
  98257. * Generic
  98258. */
  98259. GENERIC = 5
  98260. }
  98261. /**
  98262. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98263. */
  98264. export interface MutableGamepadButton {
  98265. /**
  98266. * Value of the button/trigger
  98267. */
  98268. value: number;
  98269. /**
  98270. * If the button/trigger is currently touched
  98271. */
  98272. touched: boolean;
  98273. /**
  98274. * If the button/trigger is currently pressed
  98275. */
  98276. pressed: boolean;
  98277. }
  98278. /**
  98279. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98280. * @hidden
  98281. */
  98282. export interface ExtendedGamepadButton extends GamepadButton {
  98283. /**
  98284. * If the button/trigger is currently pressed
  98285. */
  98286. readonly pressed: boolean;
  98287. /**
  98288. * If the button/trigger is currently touched
  98289. */
  98290. readonly touched: boolean;
  98291. /**
  98292. * Value of the button/trigger
  98293. */
  98294. readonly value: number;
  98295. }
  98296. /** @hidden */
  98297. export interface _GamePadFactory {
  98298. /**
  98299. * Returns whether or not the current gamepad can be created for this type of controller.
  98300. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98301. * @returns true if it can be created, otherwise false
  98302. */
  98303. canCreate(gamepadInfo: any): boolean;
  98304. /**
  98305. * Creates a new instance of the Gamepad.
  98306. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98307. * @returns the new gamepad instance
  98308. */
  98309. create(gamepadInfo: any): Gamepad;
  98310. }
  98311. /**
  98312. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98313. */
  98314. export class PoseEnabledControllerHelper {
  98315. /** @hidden */
  98316. static _ControllerFactories: _GamePadFactory[];
  98317. /** @hidden */
  98318. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98319. /**
  98320. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98321. * @param vrGamepad the gamepad to initialized
  98322. * @returns a vr controller of the type the gamepad identified as
  98323. */
  98324. static InitiateController(vrGamepad: any): Gamepad;
  98325. }
  98326. /**
  98327. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98328. */
  98329. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98330. /**
  98331. * If the controller is used in a webXR session
  98332. */
  98333. isXR: boolean;
  98334. private _deviceRoomPosition;
  98335. private _deviceRoomRotationQuaternion;
  98336. /**
  98337. * The device position in babylon space
  98338. */
  98339. devicePosition: Vector3;
  98340. /**
  98341. * The device rotation in babylon space
  98342. */
  98343. deviceRotationQuaternion: Quaternion;
  98344. /**
  98345. * The scale factor of the device in babylon space
  98346. */
  98347. deviceScaleFactor: number;
  98348. /**
  98349. * (Likely devicePosition should be used instead) The device position in its room space
  98350. */
  98351. position: Vector3;
  98352. /**
  98353. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98354. */
  98355. rotationQuaternion: Quaternion;
  98356. /**
  98357. * The type of controller (Eg. Windows mixed reality)
  98358. */
  98359. controllerType: PoseEnabledControllerType;
  98360. protected _calculatedPosition: Vector3;
  98361. private _calculatedRotation;
  98362. /**
  98363. * The raw pose from the device
  98364. */
  98365. rawPose: DevicePose;
  98366. private _trackPosition;
  98367. private _maxRotationDistFromHeadset;
  98368. private _draggedRoomRotation;
  98369. /**
  98370. * @hidden
  98371. */
  98372. _disableTrackPosition(fixedPosition: Vector3): void;
  98373. /**
  98374. * Internal, the mesh attached to the controller
  98375. * @hidden
  98376. */
  98377. _mesh: Nullable<AbstractMesh>;
  98378. private _poseControlledCamera;
  98379. private _leftHandSystemQuaternion;
  98380. /**
  98381. * Internal, matrix used to convert room space to babylon space
  98382. * @hidden
  98383. */
  98384. _deviceToWorld: Matrix;
  98385. /**
  98386. * Node to be used when casting a ray from the controller
  98387. * @hidden
  98388. */
  98389. _pointingPoseNode: Nullable<TransformNode>;
  98390. /**
  98391. * Name of the child mesh that can be used to cast a ray from the controller
  98392. */
  98393. static readonly POINTING_POSE: string;
  98394. /**
  98395. * Creates a new PoseEnabledController from a gamepad
  98396. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98397. */
  98398. constructor(browserGamepad: any);
  98399. private _workingMatrix;
  98400. /**
  98401. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98402. */
  98403. update(): void;
  98404. /**
  98405. * Updates only the pose device and mesh without doing any button event checking
  98406. */
  98407. protected _updatePoseAndMesh(): void;
  98408. /**
  98409. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98410. * @param poseData raw pose fromthe device
  98411. */
  98412. updateFromDevice(poseData: DevicePose): void;
  98413. /**
  98414. * @hidden
  98415. */
  98416. _meshAttachedObservable: Observable<AbstractMesh>;
  98417. /**
  98418. * Attaches a mesh to the controller
  98419. * @param mesh the mesh to be attached
  98420. */
  98421. attachToMesh(mesh: AbstractMesh): void;
  98422. /**
  98423. * Attaches the controllers mesh to a camera
  98424. * @param camera the camera the mesh should be attached to
  98425. */
  98426. attachToPoseControlledCamera(camera: TargetCamera): void;
  98427. /**
  98428. * Disposes of the controller
  98429. */
  98430. dispose(): void;
  98431. /**
  98432. * The mesh that is attached to the controller
  98433. */
  98434. get mesh(): Nullable<AbstractMesh>;
  98435. /**
  98436. * Gets the ray of the controller in the direction the controller is pointing
  98437. * @param length the length the resulting ray should be
  98438. * @returns a ray in the direction the controller is pointing
  98439. */
  98440. getForwardRay(length?: number): Ray;
  98441. }
  98442. }
  98443. declare module BABYLON {
  98444. /**
  98445. * Defines the WebVRController object that represents controllers tracked in 3D space
  98446. */
  98447. export abstract class WebVRController extends PoseEnabledController {
  98448. /**
  98449. * Internal, the default controller model for the controller
  98450. */
  98451. protected _defaultModel: Nullable<AbstractMesh>;
  98452. /**
  98453. * Fired when the trigger state has changed
  98454. */
  98455. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98456. /**
  98457. * Fired when the main button state has changed
  98458. */
  98459. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98460. /**
  98461. * Fired when the secondary button state has changed
  98462. */
  98463. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98464. /**
  98465. * Fired when the pad state has changed
  98466. */
  98467. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98468. /**
  98469. * Fired when controllers stick values have changed
  98470. */
  98471. onPadValuesChangedObservable: Observable<StickValues>;
  98472. /**
  98473. * Array of button availible on the controller
  98474. */
  98475. protected _buttons: Array<MutableGamepadButton>;
  98476. private _onButtonStateChange;
  98477. /**
  98478. * Fired when a controller button's state has changed
  98479. * @param callback the callback containing the button that was modified
  98480. */
  98481. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98482. /**
  98483. * X and Y axis corresponding to the controllers joystick
  98484. */
  98485. pad: StickValues;
  98486. /**
  98487. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98488. */
  98489. hand: string;
  98490. /**
  98491. * The default controller model for the controller
  98492. */
  98493. get defaultModel(): Nullable<AbstractMesh>;
  98494. /**
  98495. * Creates a new WebVRController from a gamepad
  98496. * @param vrGamepad the gamepad that the WebVRController should be created from
  98497. */
  98498. constructor(vrGamepad: any);
  98499. /**
  98500. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98501. */
  98502. update(): void;
  98503. /**
  98504. * Function to be called when a button is modified
  98505. */
  98506. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98507. /**
  98508. * Loads a mesh and attaches it to the controller
  98509. * @param scene the scene the mesh should be added to
  98510. * @param meshLoaded callback for when the mesh has been loaded
  98511. */
  98512. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98513. private _setButtonValue;
  98514. private _changes;
  98515. private _checkChanges;
  98516. /**
  98517. * Disposes of th webVRCOntroller
  98518. */
  98519. dispose(): void;
  98520. }
  98521. }
  98522. declare module BABYLON {
  98523. /**
  98524. * The HemisphericLight simulates the ambient environment light,
  98525. * so the passed direction is the light reflection direction, not the incoming direction.
  98526. */
  98527. export class HemisphericLight extends Light {
  98528. /**
  98529. * The groundColor is the light in the opposite direction to the one specified during creation.
  98530. * 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.
  98531. */
  98532. groundColor: Color3;
  98533. /**
  98534. * The light reflection direction, not the incoming direction.
  98535. */
  98536. direction: Vector3;
  98537. /**
  98538. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98539. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98540. * The HemisphericLight can't cast shadows.
  98541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98542. * @param name The friendly name of the light
  98543. * @param direction The direction of the light reflection
  98544. * @param scene The scene the light belongs to
  98545. */
  98546. constructor(name: string, direction: Vector3, scene: Scene);
  98547. protected _buildUniformLayout(): void;
  98548. /**
  98549. * Returns the string "HemisphericLight".
  98550. * @return The class name
  98551. */
  98552. getClassName(): string;
  98553. /**
  98554. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98555. * Returns the updated direction.
  98556. * @param target The target the direction should point to
  98557. * @return The computed direction
  98558. */
  98559. setDirectionToTarget(target: Vector3): Vector3;
  98560. /**
  98561. * Returns the shadow generator associated to the light.
  98562. * @returns Always null for hemispheric lights because it does not support shadows.
  98563. */
  98564. getShadowGenerator(): Nullable<IShadowGenerator>;
  98565. /**
  98566. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98567. * @param effect The effect to update
  98568. * @param lightIndex The index of the light in the effect to update
  98569. * @returns The hemispheric light
  98570. */
  98571. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98572. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98573. /**
  98574. * Computes the world matrix of the node
  98575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98576. * @param useWasUpdatedFlag defines a reserved property
  98577. * @returns the world matrix
  98578. */
  98579. computeWorldMatrix(): Matrix;
  98580. /**
  98581. * Returns the integer 3.
  98582. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98583. */
  98584. getTypeID(): number;
  98585. /**
  98586. * Prepares the list of defines specific to the light type.
  98587. * @param defines the list of defines
  98588. * @param lightIndex defines the index of the light for the effect
  98589. */
  98590. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98591. }
  98592. }
  98593. declare module BABYLON {
  98594. /** @hidden */
  98595. export var vrMultiviewToSingleviewPixelShader: {
  98596. name: string;
  98597. shader: string;
  98598. };
  98599. }
  98600. declare module BABYLON {
  98601. /**
  98602. * Renders to multiple views with a single draw call
  98603. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98604. */
  98605. export class MultiviewRenderTarget extends RenderTargetTexture {
  98606. /**
  98607. * Creates a multiview render target
  98608. * @param scene scene used with the render target
  98609. * @param size the size of the render target (used for each view)
  98610. */
  98611. constructor(scene: Scene, size?: number | {
  98612. width: number;
  98613. height: number;
  98614. } | {
  98615. ratio: number;
  98616. });
  98617. /**
  98618. * @hidden
  98619. * @param faceIndex the face index, if its a cube texture
  98620. */
  98621. _bindFrameBuffer(faceIndex?: number): void;
  98622. /**
  98623. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98624. * @returns the view count
  98625. */
  98626. getViewCount(): number;
  98627. }
  98628. }
  98629. declare module BABYLON {
  98630. interface Engine {
  98631. /**
  98632. * Creates a new multiview render target
  98633. * @param width defines the width of the texture
  98634. * @param height defines the height of the texture
  98635. * @returns the created multiview texture
  98636. */
  98637. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98638. /**
  98639. * Binds a multiview framebuffer to be drawn to
  98640. * @param multiviewTexture texture to bind
  98641. */
  98642. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98643. }
  98644. interface Camera {
  98645. /**
  98646. * @hidden
  98647. * 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)
  98648. */
  98649. _useMultiviewToSingleView: boolean;
  98650. /**
  98651. * @hidden
  98652. * 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)
  98653. */
  98654. _multiviewTexture: Nullable<RenderTargetTexture>;
  98655. /**
  98656. * @hidden
  98657. * ensures the multiview texture of the camera exists and has the specified width/height
  98658. * @param width height to set on the multiview texture
  98659. * @param height width to set on the multiview texture
  98660. */
  98661. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98662. }
  98663. interface Scene {
  98664. /** @hidden */
  98665. _transformMatrixR: Matrix;
  98666. /** @hidden */
  98667. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98668. /** @hidden */
  98669. _createMultiviewUbo(): void;
  98670. /** @hidden */
  98671. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98672. /** @hidden */
  98673. _renderMultiviewToSingleView(camera: Camera): void;
  98674. }
  98675. }
  98676. declare module BABYLON {
  98677. /**
  98678. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98679. * This will not be used for webXR as it supports displaying texture arrays directly
  98680. */
  98681. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98682. /**
  98683. * Initializes a VRMultiviewToSingleview
  98684. * @param name name of the post process
  98685. * @param camera camera to be applied to
  98686. * @param scaleFactor scaling factor to the size of the output texture
  98687. */
  98688. constructor(name: string, camera: Camera, scaleFactor: number);
  98689. }
  98690. }
  98691. declare module BABYLON {
  98692. /**
  98693. * Interface used to define additional presentation attributes
  98694. */
  98695. export interface IVRPresentationAttributes {
  98696. /**
  98697. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98698. */
  98699. highRefreshRate: boolean;
  98700. /**
  98701. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98702. */
  98703. foveationLevel: number;
  98704. }
  98705. interface Engine {
  98706. /** @hidden */
  98707. _vrDisplay: any;
  98708. /** @hidden */
  98709. _vrSupported: boolean;
  98710. /** @hidden */
  98711. _oldSize: Size;
  98712. /** @hidden */
  98713. _oldHardwareScaleFactor: number;
  98714. /** @hidden */
  98715. _vrExclusivePointerMode: boolean;
  98716. /** @hidden */
  98717. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98718. /** @hidden */
  98719. _onVRDisplayPointerRestricted: () => void;
  98720. /** @hidden */
  98721. _onVRDisplayPointerUnrestricted: () => void;
  98722. /** @hidden */
  98723. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98724. /** @hidden */
  98725. _onVrDisplayDisconnect: Nullable<() => void>;
  98726. /** @hidden */
  98727. _onVrDisplayPresentChange: Nullable<() => void>;
  98728. /**
  98729. * Observable signaled when VR display mode changes
  98730. */
  98731. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98732. /**
  98733. * Observable signaled when VR request present is complete
  98734. */
  98735. onVRRequestPresentComplete: Observable<boolean>;
  98736. /**
  98737. * Observable signaled when VR request present starts
  98738. */
  98739. onVRRequestPresentStart: Observable<Engine>;
  98740. /**
  98741. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98742. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98743. */
  98744. isInVRExclusivePointerMode: boolean;
  98745. /**
  98746. * Gets a boolean indicating if a webVR device was detected
  98747. * @returns true if a webVR device was detected
  98748. */
  98749. isVRDevicePresent(): boolean;
  98750. /**
  98751. * Gets the current webVR device
  98752. * @returns the current webVR device (or null)
  98753. */
  98754. getVRDevice(): any;
  98755. /**
  98756. * Initializes a webVR display and starts listening to display change events
  98757. * The onVRDisplayChangedObservable will be notified upon these changes
  98758. * @returns A promise containing a VRDisplay and if vr is supported
  98759. */
  98760. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98761. /** @hidden */
  98762. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98763. /**
  98764. * Gets or sets the presentation attributes used to configure VR rendering
  98765. */
  98766. vrPresentationAttributes?: IVRPresentationAttributes;
  98767. /**
  98768. * Call this function to switch to webVR mode
  98769. * Will do nothing if webVR is not supported or if there is no webVR device
  98770. * @param options the webvr options provided to the camera. mainly used for multiview
  98771. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98772. */
  98773. enableVR(options: WebVROptions): void;
  98774. /** @hidden */
  98775. _onVRFullScreenTriggered(): void;
  98776. }
  98777. }
  98778. declare module BABYLON {
  98779. /**
  98780. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98781. * IMPORTANT!! The data is right-hand data.
  98782. * @export
  98783. * @interface DevicePose
  98784. */
  98785. export interface DevicePose {
  98786. /**
  98787. * The position of the device, values in array are [x,y,z].
  98788. */
  98789. readonly position: Nullable<Float32Array>;
  98790. /**
  98791. * The linearVelocity of the device, values in array are [x,y,z].
  98792. */
  98793. readonly linearVelocity: Nullable<Float32Array>;
  98794. /**
  98795. * The linearAcceleration of the device, values in array are [x,y,z].
  98796. */
  98797. readonly linearAcceleration: Nullable<Float32Array>;
  98798. /**
  98799. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98800. */
  98801. readonly orientation: Nullable<Float32Array>;
  98802. /**
  98803. * The angularVelocity of the device, values in array are [x,y,z].
  98804. */
  98805. readonly angularVelocity: Nullable<Float32Array>;
  98806. /**
  98807. * The angularAcceleration of the device, values in array are [x,y,z].
  98808. */
  98809. readonly angularAcceleration: Nullable<Float32Array>;
  98810. }
  98811. /**
  98812. * Interface representing a pose controlled object in Babylon.
  98813. * A pose controlled object has both regular pose values as well as pose values
  98814. * from an external device such as a VR head mounted display
  98815. */
  98816. export interface PoseControlled {
  98817. /**
  98818. * The position of the object in babylon space.
  98819. */
  98820. position: Vector3;
  98821. /**
  98822. * The rotation quaternion of the object in babylon space.
  98823. */
  98824. rotationQuaternion: Quaternion;
  98825. /**
  98826. * The position of the device in babylon space.
  98827. */
  98828. devicePosition?: Vector3;
  98829. /**
  98830. * The rotation quaternion of the device in babylon space.
  98831. */
  98832. deviceRotationQuaternion: Quaternion;
  98833. /**
  98834. * The raw pose coming from the device.
  98835. */
  98836. rawPose: Nullable<DevicePose>;
  98837. /**
  98838. * The scale of the device to be used when translating from device space to babylon space.
  98839. */
  98840. deviceScaleFactor: number;
  98841. /**
  98842. * Updates the poseControlled values based on the input device pose.
  98843. * @param poseData the pose data to update the object with
  98844. */
  98845. updateFromDevice(poseData: DevicePose): void;
  98846. }
  98847. /**
  98848. * Set of options to customize the webVRCamera
  98849. */
  98850. export interface WebVROptions {
  98851. /**
  98852. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98853. */
  98854. trackPosition?: boolean;
  98855. /**
  98856. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98857. */
  98858. positionScale?: number;
  98859. /**
  98860. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98861. */
  98862. displayName?: string;
  98863. /**
  98864. * Should the native controller meshes be initialized. (default: true)
  98865. */
  98866. controllerMeshes?: boolean;
  98867. /**
  98868. * Creating a default HemiLight only on controllers. (default: true)
  98869. */
  98870. defaultLightingOnControllers?: boolean;
  98871. /**
  98872. * If you don't want to use the default VR button of the helper. (default: false)
  98873. */
  98874. useCustomVRButton?: boolean;
  98875. /**
  98876. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98877. */
  98878. customVRButton?: HTMLButtonElement;
  98879. /**
  98880. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98881. */
  98882. rayLength?: number;
  98883. /**
  98884. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98885. */
  98886. defaultHeight?: number;
  98887. /**
  98888. * If multiview should be used if availible (default: false)
  98889. */
  98890. useMultiview?: boolean;
  98891. }
  98892. /**
  98893. * This represents a WebVR camera.
  98894. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98895. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98896. */
  98897. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98898. private webVROptions;
  98899. /**
  98900. * @hidden
  98901. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98902. */
  98903. _vrDevice: any;
  98904. /**
  98905. * The rawPose of the vrDevice.
  98906. */
  98907. rawPose: Nullable<DevicePose>;
  98908. private _onVREnabled;
  98909. private _specsVersion;
  98910. private _attached;
  98911. private _frameData;
  98912. protected _descendants: Array<Node>;
  98913. private _deviceRoomPosition;
  98914. /** @hidden */
  98915. _deviceRoomRotationQuaternion: Quaternion;
  98916. private _standingMatrix;
  98917. /**
  98918. * Represents device position in babylon space.
  98919. */
  98920. devicePosition: Vector3;
  98921. /**
  98922. * Represents device rotation in babylon space.
  98923. */
  98924. deviceRotationQuaternion: Quaternion;
  98925. /**
  98926. * The scale of the device to be used when translating from device space to babylon space.
  98927. */
  98928. deviceScaleFactor: number;
  98929. private _deviceToWorld;
  98930. private _worldToDevice;
  98931. /**
  98932. * References to the webVR controllers for the vrDevice.
  98933. */
  98934. controllers: Array<WebVRController>;
  98935. /**
  98936. * Emits an event when a controller is attached.
  98937. */
  98938. onControllersAttachedObservable: Observable<WebVRController[]>;
  98939. /**
  98940. * Emits an event when a controller's mesh has been loaded;
  98941. */
  98942. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98943. /**
  98944. * Emits an event when the HMD's pose has been updated.
  98945. */
  98946. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98947. private _poseSet;
  98948. /**
  98949. * If the rig cameras be used as parent instead of this camera.
  98950. */
  98951. rigParenting: boolean;
  98952. private _lightOnControllers;
  98953. private _defaultHeight?;
  98954. /**
  98955. * Instantiates a WebVRFreeCamera.
  98956. * @param name The name of the WebVRFreeCamera
  98957. * @param position The starting anchor position for the camera
  98958. * @param scene The scene the camera belongs to
  98959. * @param webVROptions a set of customizable options for the webVRCamera
  98960. */
  98961. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98962. /**
  98963. * Gets the device distance from the ground in meters.
  98964. * @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.
  98965. */
  98966. deviceDistanceToRoomGround(): number;
  98967. /**
  98968. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98969. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98970. */
  98971. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98972. /**
  98973. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98974. * @returns A promise with a boolean set to if the standing matrix is supported.
  98975. */
  98976. useStandingMatrixAsync(): Promise<boolean>;
  98977. /**
  98978. * Disposes the camera
  98979. */
  98980. dispose(): void;
  98981. /**
  98982. * Gets a vrController by name.
  98983. * @param name The name of the controller to retreive
  98984. * @returns the controller matching the name specified or null if not found
  98985. */
  98986. getControllerByName(name: string): Nullable<WebVRController>;
  98987. private _leftController;
  98988. /**
  98989. * The controller corresponding to the users left hand.
  98990. */
  98991. get leftController(): Nullable<WebVRController>;
  98992. private _rightController;
  98993. /**
  98994. * The controller corresponding to the users right hand.
  98995. */
  98996. get rightController(): Nullable<WebVRController>;
  98997. /**
  98998. * Casts a ray forward from the vrCamera's gaze.
  98999. * @param length Length of the ray (default: 100)
  99000. * @returns the ray corresponding to the gaze
  99001. */
  99002. getForwardRay(length?: number): Ray;
  99003. /**
  99004. * @hidden
  99005. * Updates the camera based on device's frame data
  99006. */
  99007. _checkInputs(): void;
  99008. /**
  99009. * Updates the poseControlled values based on the input device pose.
  99010. * @param poseData Pose coming from the device
  99011. */
  99012. updateFromDevice(poseData: DevicePose): void;
  99013. private _htmlElementAttached;
  99014. private _detachIfAttached;
  99015. /**
  99016. * WebVR's attach control will start broadcasting frames to the device.
  99017. * Note that in certain browsers (chrome for example) this function must be called
  99018. * within a user-interaction callback. Example:
  99019. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99020. *
  99021. * @param element html element to attach the vrDevice to
  99022. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99023. */
  99024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99025. /**
  99026. * Detaches the camera from the html element and disables VR
  99027. *
  99028. * @param element html element to detach from
  99029. */
  99030. detachControl(element: HTMLElement): void;
  99031. /**
  99032. * @returns the name of this class
  99033. */
  99034. getClassName(): string;
  99035. /**
  99036. * Calls resetPose on the vrDisplay
  99037. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99038. */
  99039. resetToCurrentRotation(): void;
  99040. /**
  99041. * @hidden
  99042. * Updates the rig cameras (left and right eye)
  99043. */
  99044. _updateRigCameras(): void;
  99045. private _workingVector;
  99046. private _oneVector;
  99047. private _workingMatrix;
  99048. private updateCacheCalled;
  99049. private _correctPositionIfNotTrackPosition;
  99050. /**
  99051. * @hidden
  99052. * Updates the cached values of the camera
  99053. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99054. */
  99055. _updateCache(ignoreParentClass?: boolean): void;
  99056. /**
  99057. * @hidden
  99058. * Get current device position in babylon world
  99059. */
  99060. _computeDevicePosition(): void;
  99061. /**
  99062. * Updates the current device position and rotation in the babylon world
  99063. */
  99064. update(): void;
  99065. /**
  99066. * @hidden
  99067. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99068. * @returns an identity matrix
  99069. */
  99070. _getViewMatrix(): Matrix;
  99071. private _tmpMatrix;
  99072. /**
  99073. * This function is called by the two RIG cameras.
  99074. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99075. * @hidden
  99076. */
  99077. _getWebVRViewMatrix(): Matrix;
  99078. /** @hidden */
  99079. _getWebVRProjectionMatrix(): Matrix;
  99080. private _onGamepadConnectedObserver;
  99081. private _onGamepadDisconnectedObserver;
  99082. private _updateCacheWhenTrackingDisabledObserver;
  99083. /**
  99084. * Initializes the controllers and their meshes
  99085. */
  99086. initControllers(): void;
  99087. }
  99088. }
  99089. declare module BABYLON {
  99090. /**
  99091. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99092. *
  99093. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99094. *
  99095. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99096. */
  99097. export class MaterialHelper {
  99098. /**
  99099. * Bind the current view position to an effect.
  99100. * @param effect The effect to be bound
  99101. * @param scene The scene the eyes position is used from
  99102. * @param variableName name of the shader variable that will hold the eye position
  99103. */
  99104. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99105. /**
  99106. * Helps preparing the defines values about the UVs in used in the effect.
  99107. * UVs are shared as much as we can accross channels in the shaders.
  99108. * @param texture The texture we are preparing the UVs for
  99109. * @param defines The defines to update
  99110. * @param key The channel key "diffuse", "specular"... used in the shader
  99111. */
  99112. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99113. /**
  99114. * Binds a texture matrix value to its corrsponding uniform
  99115. * @param texture The texture to bind the matrix for
  99116. * @param uniformBuffer The uniform buffer receivin the data
  99117. * @param key The channel key "diffuse", "specular"... used in the shader
  99118. */
  99119. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99120. /**
  99121. * Gets the current status of the fog (should it be enabled?)
  99122. * @param mesh defines the mesh to evaluate for fog support
  99123. * @param scene defines the hosting scene
  99124. * @returns true if fog must be enabled
  99125. */
  99126. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99127. /**
  99128. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99129. * @param mesh defines the current mesh
  99130. * @param scene defines the current scene
  99131. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99132. * @param pointsCloud defines if point cloud rendering has to be turned on
  99133. * @param fogEnabled defines if fog has to be turned on
  99134. * @param alphaTest defines if alpha testing has to be turned on
  99135. * @param defines defines the current list of defines
  99136. */
  99137. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99138. /**
  99139. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99140. * @param scene defines the current scene
  99141. * @param engine defines the current engine
  99142. * @param defines specifies the list of active defines
  99143. * @param useInstances defines if instances have to be turned on
  99144. * @param useClipPlane defines if clip plane have to be turned on
  99145. * @param useInstances defines if instances have to be turned on
  99146. * @param useThinInstances defines if thin instances have to be turned on
  99147. */
  99148. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99149. /**
  99150. * Prepares the defines for bones
  99151. * @param mesh The mesh containing the geometry data we will draw
  99152. * @param defines The defines to update
  99153. */
  99154. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99155. /**
  99156. * Prepares the defines for morph targets
  99157. * @param mesh The mesh containing the geometry data we will draw
  99158. * @param defines The defines to update
  99159. */
  99160. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99161. /**
  99162. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99163. * @param mesh The mesh containing the geometry data we will draw
  99164. * @param defines The defines to update
  99165. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99166. * @param useBones Precise whether bones should be used or not (override mesh info)
  99167. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99168. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99169. * @returns false if defines are considered not dirty and have not been checked
  99170. */
  99171. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99172. /**
  99173. * Prepares the defines related to multiview
  99174. * @param scene The scene we are intending to draw
  99175. * @param defines The defines to update
  99176. */
  99177. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99178. /**
  99179. * Prepares the defines related to the prepass
  99180. * @param scene The scene we are intending to draw
  99181. * @param defines The defines to update
  99182. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99183. */
  99184. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99185. /**
  99186. * Prepares the defines related to the light information passed in parameter
  99187. * @param scene The scene we are intending to draw
  99188. * @param mesh The mesh the effect is compiling for
  99189. * @param light The light the effect is compiling for
  99190. * @param lightIndex The index of the light
  99191. * @param defines The defines to update
  99192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99193. * @param state Defines the current state regarding what is needed (normals, etc...)
  99194. */
  99195. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99196. needNormals: boolean;
  99197. needRebuild: boolean;
  99198. shadowEnabled: boolean;
  99199. specularEnabled: boolean;
  99200. lightmapMode: boolean;
  99201. }): void;
  99202. /**
  99203. * Prepares the defines related to the light information passed in parameter
  99204. * @param scene The scene we are intending to draw
  99205. * @param mesh The mesh the effect is compiling for
  99206. * @param defines The defines to update
  99207. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99208. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99209. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99210. * @returns true if normals will be required for the rest of the effect
  99211. */
  99212. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99213. /**
  99214. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99215. * @param lightIndex defines the light index
  99216. * @param uniformsList The uniform list
  99217. * @param samplersList The sampler list
  99218. * @param projectedLightTexture defines if projected texture must be used
  99219. * @param uniformBuffersList defines an optional list of uniform buffers
  99220. */
  99221. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99222. /**
  99223. * Prepares the uniforms and samplers list to be used in the effect
  99224. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99225. * @param samplersList The sampler list
  99226. * @param defines The defines helping in the list generation
  99227. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99228. */
  99229. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99230. /**
  99231. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99232. * @param defines The defines to update while falling back
  99233. * @param fallbacks The authorized effect fallbacks
  99234. * @param maxSimultaneousLights The maximum number of lights allowed
  99235. * @param rank the current rank of the Effect
  99236. * @returns The newly affected rank
  99237. */
  99238. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99239. private static _TmpMorphInfluencers;
  99240. /**
  99241. * Prepares the list of attributes required for morph targets according to the effect defines.
  99242. * @param attribs The current list of supported attribs
  99243. * @param mesh The mesh to prepare the morph targets attributes for
  99244. * @param influencers The number of influencers
  99245. */
  99246. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99247. /**
  99248. * Prepares the list of attributes required for morph targets according to the effect defines.
  99249. * @param attribs The current list of supported attribs
  99250. * @param mesh The mesh to prepare the morph targets attributes for
  99251. * @param defines The current Defines of the effect
  99252. */
  99253. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99254. /**
  99255. * Prepares the list of attributes required for bones according to the effect defines.
  99256. * @param attribs The current list of supported attribs
  99257. * @param mesh The mesh to prepare the bones attributes for
  99258. * @param defines The current Defines of the effect
  99259. * @param fallbacks The current efffect fallback strategy
  99260. */
  99261. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99262. /**
  99263. * Check and prepare the list of attributes required for instances according to the effect defines.
  99264. * @param attribs The current list of supported attribs
  99265. * @param defines The current MaterialDefines of the effect
  99266. */
  99267. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99268. /**
  99269. * Add the list of attributes required for instances to the attribs array.
  99270. * @param attribs The current list of supported attribs
  99271. */
  99272. static PushAttributesForInstances(attribs: string[]): void;
  99273. /**
  99274. * Binds the light information to the effect.
  99275. * @param light The light containing the generator
  99276. * @param effect The effect we are binding the data to
  99277. * @param lightIndex The light index in the effect used to render
  99278. */
  99279. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99280. /**
  99281. * Binds the lights information from the scene to the effect for the given mesh.
  99282. * @param light Light to bind
  99283. * @param lightIndex Light index
  99284. * @param scene The scene where the light belongs to
  99285. * @param effect The effect we are binding the data to
  99286. * @param useSpecular Defines if specular is supported
  99287. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99288. */
  99289. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99290. /**
  99291. * Binds the lights information from the scene to the effect for the given mesh.
  99292. * @param scene The scene the lights belongs to
  99293. * @param mesh The mesh we are binding the information to render
  99294. * @param effect The effect we are binding the data to
  99295. * @param defines The generated defines for the effect
  99296. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99297. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99298. */
  99299. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99300. private static _tempFogColor;
  99301. /**
  99302. * Binds the fog information from the scene to the effect for the given mesh.
  99303. * @param scene The scene the lights belongs to
  99304. * @param mesh The mesh we are binding the information to render
  99305. * @param effect The effect we are binding the data to
  99306. * @param linearSpace Defines if the fog effect is applied in linear space
  99307. */
  99308. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99309. /**
  99310. * Binds the bones information from the mesh to the effect.
  99311. * @param mesh The mesh we are binding the information to render
  99312. * @param effect The effect we are binding the data to
  99313. */
  99314. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99315. /**
  99316. * Binds the morph targets information from the mesh to the effect.
  99317. * @param abstractMesh The mesh we are binding the information to render
  99318. * @param effect The effect we are binding the data to
  99319. */
  99320. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99321. /**
  99322. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99323. * @param defines The generated defines used in the effect
  99324. * @param effect The effect we are binding the data to
  99325. * @param scene The scene we are willing to render with logarithmic scale for
  99326. */
  99327. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99328. /**
  99329. * Binds the clip plane information from the scene to the effect.
  99330. * @param scene The scene the clip plane information are extracted from
  99331. * @param effect The effect we are binding the data to
  99332. */
  99333. static BindClipPlane(effect: Effect, scene: Scene): void;
  99334. }
  99335. }
  99336. declare module BABYLON {
  99337. /**
  99338. * Block used to expose an input value
  99339. */
  99340. export class InputBlock extends NodeMaterialBlock {
  99341. private _mode;
  99342. private _associatedVariableName;
  99343. private _storedValue;
  99344. private _valueCallback;
  99345. private _type;
  99346. private _animationType;
  99347. /** Gets or set a value used to limit the range of float values */
  99348. min: number;
  99349. /** Gets or set a value used to limit the range of float values */
  99350. max: number;
  99351. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99352. isBoolean: boolean;
  99353. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99354. matrixMode: number;
  99355. /** @hidden */
  99356. _systemValue: Nullable<NodeMaterialSystemValues>;
  99357. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99358. visibleInInspector: boolean;
  99359. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99360. isConstant: boolean;
  99361. /** Gets or sets the group to use to display this block in the Inspector */
  99362. groupInInspector: string;
  99363. /** Gets an observable raised when the value is changed */
  99364. onValueChangedObservable: Observable<InputBlock>;
  99365. /**
  99366. * Gets or sets the connection point type (default is float)
  99367. */
  99368. get type(): NodeMaterialBlockConnectionPointTypes;
  99369. /**
  99370. * Creates a new InputBlock
  99371. * @param name defines the block name
  99372. * @param target defines the target of that block (Vertex by default)
  99373. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99374. */
  99375. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99376. /**
  99377. * Validates if a name is a reserve word.
  99378. * @param newName the new name to be given to the node.
  99379. * @returns false if the name is a reserve word, else true.
  99380. */
  99381. validateBlockName(newName: string): boolean;
  99382. /**
  99383. * Gets the output component
  99384. */
  99385. get output(): NodeMaterialConnectionPoint;
  99386. /**
  99387. * Set the source of this connection point to a vertex attribute
  99388. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99389. * @returns the current connection point
  99390. */
  99391. setAsAttribute(attributeName?: string): InputBlock;
  99392. /**
  99393. * Set the source of this connection point to a system value
  99394. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99395. * @returns the current connection point
  99396. */
  99397. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99398. /**
  99399. * Gets or sets the value of that point.
  99400. * Please note that this value will be ignored if valueCallback is defined
  99401. */
  99402. get value(): any;
  99403. set value(value: any);
  99404. /**
  99405. * Gets or sets a callback used to get the value of that point.
  99406. * Please note that setting this value will force the connection point to ignore the value property
  99407. */
  99408. get valueCallback(): () => any;
  99409. set valueCallback(value: () => any);
  99410. /**
  99411. * Gets or sets the associated variable name in the shader
  99412. */
  99413. get associatedVariableName(): string;
  99414. set associatedVariableName(value: string);
  99415. /** Gets or sets the type of animation applied to the input */
  99416. get animationType(): AnimatedInputBlockTypes;
  99417. set animationType(value: AnimatedInputBlockTypes);
  99418. /**
  99419. * Gets a boolean indicating that this connection point not defined yet
  99420. */
  99421. get isUndefined(): boolean;
  99422. /**
  99423. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99424. * In this case the connection point name must be the name of the uniform to use.
  99425. * Can only be set on inputs
  99426. */
  99427. get isUniform(): boolean;
  99428. set isUniform(value: boolean);
  99429. /**
  99430. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99431. * In this case the connection point name must be the name of the attribute to use
  99432. * Can only be set on inputs
  99433. */
  99434. get isAttribute(): boolean;
  99435. set isAttribute(value: boolean);
  99436. /**
  99437. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99438. * Can only be set on exit points
  99439. */
  99440. get isVarying(): boolean;
  99441. set isVarying(value: boolean);
  99442. /**
  99443. * Gets a boolean indicating that the current connection point is a system value
  99444. */
  99445. get isSystemValue(): boolean;
  99446. /**
  99447. * Gets or sets the current well known value or null if not defined as a system value
  99448. */
  99449. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99450. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99451. /**
  99452. * Gets the current class name
  99453. * @returns the class name
  99454. */
  99455. getClassName(): string;
  99456. /**
  99457. * Animate the input if animationType !== None
  99458. * @param scene defines the rendering scene
  99459. */
  99460. animate(scene: Scene): void;
  99461. private _emitDefine;
  99462. initialize(state: NodeMaterialBuildState): void;
  99463. /**
  99464. * Set the input block to its default value (based on its type)
  99465. */
  99466. setDefaultValue(): void;
  99467. private _emitConstant;
  99468. /** @hidden */
  99469. get _noContextSwitch(): boolean;
  99470. private _emit;
  99471. /** @hidden */
  99472. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99473. /** @hidden */
  99474. _transmit(effect: Effect, scene: Scene): void;
  99475. protected _buildBlock(state: NodeMaterialBuildState): void;
  99476. protected _dumpPropertiesCode(): string;
  99477. dispose(): void;
  99478. serialize(): any;
  99479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99480. }
  99481. }
  99482. declare module BABYLON {
  99483. /**
  99484. * Enum used to define the compatibility state between two connection points
  99485. */
  99486. export enum NodeMaterialConnectionPointCompatibilityStates {
  99487. /** Points are compatibles */
  99488. Compatible = 0,
  99489. /** Points are incompatible because of their types */
  99490. TypeIncompatible = 1,
  99491. /** Points are incompatible because of their targets (vertex vs fragment) */
  99492. TargetIncompatible = 2
  99493. }
  99494. /**
  99495. * Defines the direction of a connection point
  99496. */
  99497. export enum NodeMaterialConnectionPointDirection {
  99498. /** Input */
  99499. Input = 0,
  99500. /** Output */
  99501. Output = 1
  99502. }
  99503. /**
  99504. * Defines a connection point for a block
  99505. */
  99506. export class NodeMaterialConnectionPoint {
  99507. /** @hidden */
  99508. _ownerBlock: NodeMaterialBlock;
  99509. /** @hidden */
  99510. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99511. private _endpoints;
  99512. private _associatedVariableName;
  99513. private _direction;
  99514. /** @hidden */
  99515. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99516. /** @hidden */
  99517. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99518. private _type;
  99519. /** @hidden */
  99520. _enforceAssociatedVariableName: boolean;
  99521. /** Gets the direction of the point */
  99522. get direction(): NodeMaterialConnectionPointDirection;
  99523. /** Indicates that this connection point needs dual validation before being connected to another point */
  99524. needDualDirectionValidation: boolean;
  99525. /**
  99526. * Gets or sets the additional types supported by this connection point
  99527. */
  99528. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99529. /**
  99530. * Gets or sets the additional types excluded by this connection point
  99531. */
  99532. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99533. /**
  99534. * Observable triggered when this point is connected
  99535. */
  99536. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99537. /**
  99538. * Gets or sets the associated variable name in the shader
  99539. */
  99540. get associatedVariableName(): string;
  99541. set associatedVariableName(value: string);
  99542. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99543. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99544. /**
  99545. * Gets or sets the connection point type (default is float)
  99546. */
  99547. get type(): NodeMaterialBlockConnectionPointTypes;
  99548. set type(value: NodeMaterialBlockConnectionPointTypes);
  99549. /**
  99550. * Gets or sets the connection point name
  99551. */
  99552. name: string;
  99553. /**
  99554. * Gets or sets the connection point name
  99555. */
  99556. displayName: string;
  99557. /**
  99558. * Gets or sets a boolean indicating that this connection point can be omitted
  99559. */
  99560. isOptional: boolean;
  99561. /**
  99562. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99563. */
  99564. isExposedOnFrame: boolean;
  99565. /**
  99566. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99567. */
  99568. define: string;
  99569. /** @hidden */
  99570. _prioritizeVertex: boolean;
  99571. private _target;
  99572. /** Gets or sets the target of that connection point */
  99573. get target(): NodeMaterialBlockTargets;
  99574. set target(value: NodeMaterialBlockTargets);
  99575. /**
  99576. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99577. */
  99578. get isConnected(): boolean;
  99579. /**
  99580. * Gets a boolean indicating that the current point is connected to an input block
  99581. */
  99582. get isConnectedToInputBlock(): boolean;
  99583. /**
  99584. * Gets a the connected input block (if any)
  99585. */
  99586. get connectInputBlock(): Nullable<InputBlock>;
  99587. /** Get the other side of the connection (if any) */
  99588. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99589. /** Get the block that owns this connection point */
  99590. get ownerBlock(): NodeMaterialBlock;
  99591. /** Get the block connected on the other side of this connection (if any) */
  99592. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99593. /** Get the block connected on the endpoints of this connection (if any) */
  99594. get connectedBlocks(): Array<NodeMaterialBlock>;
  99595. /** Gets the list of connected endpoints */
  99596. get endpoints(): NodeMaterialConnectionPoint[];
  99597. /** Gets a boolean indicating if that output point is connected to at least one input */
  99598. get hasEndpoints(): boolean;
  99599. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99600. get isConnectedInVertexShader(): boolean;
  99601. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99602. get isConnectedInFragmentShader(): boolean;
  99603. /**
  99604. * Creates a block suitable to be used as an input for this input point.
  99605. * If null is returned, a block based on the point type will be created.
  99606. * @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
  99607. */
  99608. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99609. /**
  99610. * Creates a new connection point
  99611. * @param name defines the connection point name
  99612. * @param ownerBlock defines the block hosting this connection point
  99613. * @param direction defines the direction of the connection point
  99614. */
  99615. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99616. /**
  99617. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99618. * @returns the class name
  99619. */
  99620. getClassName(): string;
  99621. /**
  99622. * Gets a boolean indicating if the current point can be connected to another point
  99623. * @param connectionPoint defines the other connection point
  99624. * @returns a boolean
  99625. */
  99626. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99627. /**
  99628. * Gets a number indicating if the current point can be connected to another point
  99629. * @param connectionPoint defines the other connection point
  99630. * @returns a number defining the compatibility state
  99631. */
  99632. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99633. /**
  99634. * Connect this point to another connection point
  99635. * @param connectionPoint defines the other connection point
  99636. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99637. * @returns the current connection point
  99638. */
  99639. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99640. /**
  99641. * Disconnect this point from one of his endpoint
  99642. * @param endpoint defines the other connection point
  99643. * @returns the current connection point
  99644. */
  99645. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99646. /**
  99647. * Serializes this point in a JSON representation
  99648. * @param isInput defines if the connection point is an input (default is true)
  99649. * @returns the serialized point object
  99650. */
  99651. serialize(isInput?: boolean): any;
  99652. /**
  99653. * Release resources
  99654. */
  99655. dispose(): void;
  99656. }
  99657. }
  99658. declare module BABYLON {
  99659. /**
  99660. * Enum used to define the material modes
  99661. */
  99662. export enum NodeMaterialModes {
  99663. /** Regular material */
  99664. Material = 0,
  99665. /** For post process */
  99666. PostProcess = 1,
  99667. /** For particle system */
  99668. Particle = 2
  99669. }
  99670. }
  99671. declare module BABYLON {
  99672. /**
  99673. * Block used to read a texture from a sampler
  99674. */
  99675. export class TextureBlock extends NodeMaterialBlock {
  99676. private _defineName;
  99677. private _linearDefineName;
  99678. private _gammaDefineName;
  99679. private _tempTextureRead;
  99680. private _samplerName;
  99681. private _transformedUVName;
  99682. private _textureTransformName;
  99683. private _textureInfoName;
  99684. private _mainUVName;
  99685. private _mainUVDefineName;
  99686. private _fragmentOnly;
  99687. /**
  99688. * Gets or sets the texture associated with the node
  99689. */
  99690. texture: Nullable<Texture>;
  99691. /**
  99692. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99693. */
  99694. convertToGammaSpace: boolean;
  99695. /**
  99696. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99697. */
  99698. convertToLinearSpace: boolean;
  99699. /**
  99700. * Create a new TextureBlock
  99701. * @param name defines the block name
  99702. */
  99703. constructor(name: string, fragmentOnly?: boolean);
  99704. /**
  99705. * Gets the current class name
  99706. * @returns the class name
  99707. */
  99708. getClassName(): string;
  99709. /**
  99710. * Gets the uv input component
  99711. */
  99712. get uv(): NodeMaterialConnectionPoint;
  99713. /**
  99714. * Gets the rgba output component
  99715. */
  99716. get rgba(): NodeMaterialConnectionPoint;
  99717. /**
  99718. * Gets the rgb output component
  99719. */
  99720. get rgb(): NodeMaterialConnectionPoint;
  99721. /**
  99722. * Gets the r output component
  99723. */
  99724. get r(): NodeMaterialConnectionPoint;
  99725. /**
  99726. * Gets the g output component
  99727. */
  99728. get g(): NodeMaterialConnectionPoint;
  99729. /**
  99730. * Gets the b output component
  99731. */
  99732. get b(): NodeMaterialConnectionPoint;
  99733. /**
  99734. * Gets the a output component
  99735. */
  99736. get a(): NodeMaterialConnectionPoint;
  99737. get target(): NodeMaterialBlockTargets;
  99738. autoConfigure(material: NodeMaterial): void;
  99739. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99741. isReady(): boolean;
  99742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99743. private get _isMixed();
  99744. private _injectVertexCode;
  99745. private _writeTextureRead;
  99746. private _writeOutput;
  99747. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99748. protected _dumpPropertiesCode(): string;
  99749. serialize(): any;
  99750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99751. }
  99752. }
  99753. declare module BABYLON {
  99754. /** @hidden */
  99755. export var reflectionFunction: {
  99756. name: string;
  99757. shader: string;
  99758. };
  99759. }
  99760. declare module BABYLON {
  99761. /**
  99762. * Base block used to read a reflection texture from a sampler
  99763. */
  99764. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99765. /** @hidden */
  99766. _define3DName: string;
  99767. /** @hidden */
  99768. _defineCubicName: string;
  99769. /** @hidden */
  99770. _defineExplicitName: string;
  99771. /** @hidden */
  99772. _defineProjectionName: string;
  99773. /** @hidden */
  99774. _defineLocalCubicName: string;
  99775. /** @hidden */
  99776. _defineSphericalName: string;
  99777. /** @hidden */
  99778. _definePlanarName: string;
  99779. /** @hidden */
  99780. _defineEquirectangularName: string;
  99781. /** @hidden */
  99782. _defineMirroredEquirectangularFixedName: string;
  99783. /** @hidden */
  99784. _defineEquirectangularFixedName: string;
  99785. /** @hidden */
  99786. _defineSkyboxName: string;
  99787. /** @hidden */
  99788. _defineOppositeZ: string;
  99789. /** @hidden */
  99790. _cubeSamplerName: string;
  99791. /** @hidden */
  99792. _2DSamplerName: string;
  99793. protected _positionUVWName: string;
  99794. protected _directionWName: string;
  99795. protected _reflectionVectorName: string;
  99796. /** @hidden */
  99797. _reflectionCoordsName: string;
  99798. /** @hidden */
  99799. _reflectionMatrixName: string;
  99800. protected _reflectionColorName: string;
  99801. /**
  99802. * Gets or sets the texture associated with the node
  99803. */
  99804. texture: Nullable<BaseTexture>;
  99805. /**
  99806. * Create a new ReflectionTextureBaseBlock
  99807. * @param name defines the block name
  99808. */
  99809. constructor(name: string);
  99810. /**
  99811. * Gets the current class name
  99812. * @returns the class name
  99813. */
  99814. getClassName(): string;
  99815. /**
  99816. * Gets the world position input component
  99817. */
  99818. abstract get position(): NodeMaterialConnectionPoint;
  99819. /**
  99820. * Gets the world position input component
  99821. */
  99822. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99823. /**
  99824. * Gets the world normal input component
  99825. */
  99826. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99827. /**
  99828. * Gets the world input component
  99829. */
  99830. abstract get world(): NodeMaterialConnectionPoint;
  99831. /**
  99832. * Gets the camera (or eye) position component
  99833. */
  99834. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99835. /**
  99836. * Gets the view input component
  99837. */
  99838. abstract get view(): NodeMaterialConnectionPoint;
  99839. protected _getTexture(): Nullable<BaseTexture>;
  99840. autoConfigure(material: NodeMaterial): void;
  99841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99842. isReady(): boolean;
  99843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99844. /**
  99845. * Gets the code to inject in the vertex shader
  99846. * @param state current state of the node material building
  99847. * @returns the shader code
  99848. */
  99849. handleVertexSide(state: NodeMaterialBuildState): string;
  99850. /**
  99851. * Handles the inits for the fragment code path
  99852. * @param state node material build state
  99853. */
  99854. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99855. /**
  99856. * Generates the reflection coords code for the fragment code path
  99857. * @param worldNormalVarName name of the world normal variable
  99858. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99859. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99860. * @returns the shader code
  99861. */
  99862. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99863. /**
  99864. * Generates the reflection color code for the fragment code path
  99865. * @param lodVarName name of the lod variable
  99866. * @param swizzleLookupTexture swizzle to use for the final color variable
  99867. * @returns the shader code
  99868. */
  99869. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99870. /**
  99871. * Generates the code corresponding to the connected output points
  99872. * @param state node material build state
  99873. * @param varName name of the variable to output
  99874. * @returns the shader code
  99875. */
  99876. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99877. protected _buildBlock(state: NodeMaterialBuildState): this;
  99878. protected _dumpPropertiesCode(): string;
  99879. serialize(): any;
  99880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99881. }
  99882. }
  99883. declare module BABYLON {
  99884. /**
  99885. * Defines a connection point to be used for points with a custom object type
  99886. */
  99887. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99888. private _blockType;
  99889. private _blockName;
  99890. private _nameForCheking?;
  99891. /**
  99892. * Creates a new connection point
  99893. * @param name defines the connection point name
  99894. * @param ownerBlock defines the block hosting this connection point
  99895. * @param direction defines the direction of the connection point
  99896. */
  99897. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99898. /**
  99899. * Gets a number indicating if the current point can be connected to another point
  99900. * @param connectionPoint defines the other connection point
  99901. * @returns a number defining the compatibility state
  99902. */
  99903. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99904. /**
  99905. * Creates a block suitable to be used as an input for this input point.
  99906. * If null is returned, a block based on the point type will be created.
  99907. * @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
  99908. */
  99909. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99910. }
  99911. }
  99912. declare module BABYLON {
  99913. /**
  99914. * Enum defining the type of properties that can be edited in the property pages in the NME
  99915. */
  99916. export enum PropertyTypeForEdition {
  99917. /** property is a boolean */
  99918. Boolean = 0,
  99919. /** property is a float */
  99920. Float = 1,
  99921. /** property is a Vector2 */
  99922. Vector2 = 2,
  99923. /** property is a list of values */
  99924. List = 3
  99925. }
  99926. /**
  99927. * Interface that defines an option in a variable of type list
  99928. */
  99929. export interface IEditablePropertyListOption {
  99930. /** label of the option */
  99931. "label": string;
  99932. /** value of the option */
  99933. "value": number;
  99934. }
  99935. /**
  99936. * Interface that defines the options available for an editable property
  99937. */
  99938. export interface IEditablePropertyOption {
  99939. /** min value */
  99940. "min"?: number;
  99941. /** max value */
  99942. "max"?: number;
  99943. /** notifiers: indicates which actions to take when the property is changed */
  99944. "notifiers"?: {
  99945. /** the material should be rebuilt */
  99946. "rebuild"?: boolean;
  99947. /** the preview should be updated */
  99948. "update"?: boolean;
  99949. };
  99950. /** list of the options for a variable of type list */
  99951. "options"?: IEditablePropertyListOption[];
  99952. }
  99953. /**
  99954. * Interface that describes an editable property
  99955. */
  99956. export interface IPropertyDescriptionForEdition {
  99957. /** name of the property */
  99958. "propertyName": string;
  99959. /** display name of the property */
  99960. "displayName": string;
  99961. /** type of the property */
  99962. "type": PropertyTypeForEdition;
  99963. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99964. "groupName": string;
  99965. /** options for the property */
  99966. "options": IEditablePropertyOption;
  99967. }
  99968. /**
  99969. * Decorator that flags a property in a node material block as being editable
  99970. */
  99971. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99972. }
  99973. declare module BABYLON {
  99974. /**
  99975. * Block used to implement the refraction part of the sub surface module of the PBR material
  99976. */
  99977. export class RefractionBlock extends NodeMaterialBlock {
  99978. /** @hidden */
  99979. _define3DName: string;
  99980. /** @hidden */
  99981. _refractionMatrixName: string;
  99982. /** @hidden */
  99983. _defineLODRefractionAlpha: string;
  99984. /** @hidden */
  99985. _defineLinearSpecularRefraction: string;
  99986. /** @hidden */
  99987. _defineOppositeZ: string;
  99988. /** @hidden */
  99989. _cubeSamplerName: string;
  99990. /** @hidden */
  99991. _2DSamplerName: string;
  99992. /** @hidden */
  99993. _vRefractionMicrosurfaceInfosName: string;
  99994. /** @hidden */
  99995. _vRefractionInfosName: string;
  99996. private _scene;
  99997. /**
  99998. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99999. * Materials half opaque for instance using refraction could benefit from this control.
  100000. */
  100001. linkRefractionWithTransparency: boolean;
  100002. /**
  100003. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100004. */
  100005. invertRefractionY: boolean;
  100006. /**
  100007. * Gets or sets the texture associated with the node
  100008. */
  100009. texture: Nullable<BaseTexture>;
  100010. /**
  100011. * Create a new RefractionBlock
  100012. * @param name defines the block name
  100013. */
  100014. constructor(name: string);
  100015. /**
  100016. * Gets the current class name
  100017. * @returns the class name
  100018. */
  100019. getClassName(): string;
  100020. /**
  100021. * Gets the intensity input component
  100022. */
  100023. get intensity(): NodeMaterialConnectionPoint;
  100024. /**
  100025. * Gets the index of refraction input component
  100026. */
  100027. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100028. /**
  100029. * Gets the tint at distance input component
  100030. */
  100031. get tintAtDistance(): NodeMaterialConnectionPoint;
  100032. /**
  100033. * Gets the view input component
  100034. */
  100035. get view(): NodeMaterialConnectionPoint;
  100036. /**
  100037. * Gets the refraction object output component
  100038. */
  100039. get refraction(): NodeMaterialConnectionPoint;
  100040. /**
  100041. * Returns true if the block has a texture
  100042. */
  100043. get hasTexture(): boolean;
  100044. protected _getTexture(): Nullable<BaseTexture>;
  100045. autoConfigure(material: NodeMaterial): void;
  100046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100047. isReady(): boolean;
  100048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100049. /**
  100050. * Gets the main code of the block (fragment side)
  100051. * @param state current state of the node material building
  100052. * @returns the shader code
  100053. */
  100054. getCode(state: NodeMaterialBuildState): string;
  100055. protected _buildBlock(state: NodeMaterialBuildState): this;
  100056. protected _dumpPropertiesCode(): string;
  100057. serialize(): any;
  100058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100059. }
  100060. }
  100061. declare module BABYLON {
  100062. /**
  100063. * Base block used as input for post process
  100064. */
  100065. export class CurrentScreenBlock extends NodeMaterialBlock {
  100066. private _samplerName;
  100067. private _linearDefineName;
  100068. private _gammaDefineName;
  100069. private _mainUVName;
  100070. private _tempTextureRead;
  100071. /**
  100072. * Gets or sets the texture associated with the node
  100073. */
  100074. texture: Nullable<BaseTexture>;
  100075. /**
  100076. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100077. */
  100078. convertToGammaSpace: boolean;
  100079. /**
  100080. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100081. */
  100082. convertToLinearSpace: boolean;
  100083. /**
  100084. * Create a new CurrentScreenBlock
  100085. * @param name defines the block name
  100086. */
  100087. constructor(name: string);
  100088. /**
  100089. * Gets the current class name
  100090. * @returns the class name
  100091. */
  100092. getClassName(): string;
  100093. /**
  100094. * Gets the uv input component
  100095. */
  100096. get uv(): NodeMaterialConnectionPoint;
  100097. /**
  100098. * Gets the rgba output component
  100099. */
  100100. get rgba(): NodeMaterialConnectionPoint;
  100101. /**
  100102. * Gets the rgb output component
  100103. */
  100104. get rgb(): NodeMaterialConnectionPoint;
  100105. /**
  100106. * Gets the r output component
  100107. */
  100108. get r(): NodeMaterialConnectionPoint;
  100109. /**
  100110. * Gets the g output component
  100111. */
  100112. get g(): NodeMaterialConnectionPoint;
  100113. /**
  100114. * Gets the b output component
  100115. */
  100116. get b(): NodeMaterialConnectionPoint;
  100117. /**
  100118. * Gets the a output component
  100119. */
  100120. get a(): NodeMaterialConnectionPoint;
  100121. /**
  100122. * Initialize the block and prepare the context for build
  100123. * @param state defines the state that will be used for the build
  100124. */
  100125. initialize(state: NodeMaterialBuildState): void;
  100126. get target(): NodeMaterialBlockTargets;
  100127. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100128. isReady(): boolean;
  100129. private _injectVertexCode;
  100130. private _writeTextureRead;
  100131. private _writeOutput;
  100132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100133. serialize(): any;
  100134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * Base block used for the particle texture
  100140. */
  100141. export class ParticleTextureBlock extends NodeMaterialBlock {
  100142. private _samplerName;
  100143. private _linearDefineName;
  100144. private _gammaDefineName;
  100145. private _tempTextureRead;
  100146. /**
  100147. * Gets or sets the texture associated with the node
  100148. */
  100149. texture: Nullable<BaseTexture>;
  100150. /**
  100151. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100152. */
  100153. convertToGammaSpace: boolean;
  100154. /**
  100155. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100156. */
  100157. convertToLinearSpace: boolean;
  100158. /**
  100159. * Create a new ParticleTextureBlock
  100160. * @param name defines the block name
  100161. */
  100162. constructor(name: string);
  100163. /**
  100164. * Gets the current class name
  100165. * @returns the class name
  100166. */
  100167. getClassName(): string;
  100168. /**
  100169. * Gets the uv input component
  100170. */
  100171. get uv(): NodeMaterialConnectionPoint;
  100172. /**
  100173. * Gets the rgba output component
  100174. */
  100175. get rgba(): NodeMaterialConnectionPoint;
  100176. /**
  100177. * Gets the rgb output component
  100178. */
  100179. get rgb(): NodeMaterialConnectionPoint;
  100180. /**
  100181. * Gets the r output component
  100182. */
  100183. get r(): NodeMaterialConnectionPoint;
  100184. /**
  100185. * Gets the g output component
  100186. */
  100187. get g(): NodeMaterialConnectionPoint;
  100188. /**
  100189. * Gets the b output component
  100190. */
  100191. get b(): NodeMaterialConnectionPoint;
  100192. /**
  100193. * Gets the a output component
  100194. */
  100195. get a(): NodeMaterialConnectionPoint;
  100196. /**
  100197. * Initialize the block and prepare the context for build
  100198. * @param state defines the state that will be used for the build
  100199. */
  100200. initialize(state: NodeMaterialBuildState): void;
  100201. autoConfigure(material: NodeMaterial): void;
  100202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100203. isReady(): boolean;
  100204. private _writeOutput;
  100205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100206. serialize(): any;
  100207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100208. }
  100209. }
  100210. declare module BABYLON {
  100211. /**
  100212. * Class used to store shared data between 2 NodeMaterialBuildState
  100213. */
  100214. export class NodeMaterialBuildStateSharedData {
  100215. /**
  100216. * Gets the list of emitted varyings
  100217. */
  100218. temps: string[];
  100219. /**
  100220. * Gets the list of emitted varyings
  100221. */
  100222. varyings: string[];
  100223. /**
  100224. * Gets the varying declaration string
  100225. */
  100226. varyingDeclaration: string;
  100227. /**
  100228. * Input blocks
  100229. */
  100230. inputBlocks: InputBlock[];
  100231. /**
  100232. * Input blocks
  100233. */
  100234. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100235. /**
  100236. * Bindable blocks (Blocks that need to set data to the effect)
  100237. */
  100238. bindableBlocks: NodeMaterialBlock[];
  100239. /**
  100240. * List of blocks that can provide a compilation fallback
  100241. */
  100242. blocksWithFallbacks: NodeMaterialBlock[];
  100243. /**
  100244. * List of blocks that can provide a define update
  100245. */
  100246. blocksWithDefines: NodeMaterialBlock[];
  100247. /**
  100248. * List of blocks that can provide a repeatable content
  100249. */
  100250. repeatableContentBlocks: NodeMaterialBlock[];
  100251. /**
  100252. * List of blocks that can provide a dynamic list of uniforms
  100253. */
  100254. dynamicUniformBlocks: NodeMaterialBlock[];
  100255. /**
  100256. * List of blocks that can block the isReady function for the material
  100257. */
  100258. blockingBlocks: NodeMaterialBlock[];
  100259. /**
  100260. * Gets the list of animated inputs
  100261. */
  100262. animatedInputs: InputBlock[];
  100263. /**
  100264. * Build Id used to avoid multiple recompilations
  100265. */
  100266. buildId: number;
  100267. /** List of emitted variables */
  100268. variableNames: {
  100269. [key: string]: number;
  100270. };
  100271. /** List of emitted defines */
  100272. defineNames: {
  100273. [key: string]: number;
  100274. };
  100275. /** Should emit comments? */
  100276. emitComments: boolean;
  100277. /** Emit build activity */
  100278. verbose: boolean;
  100279. /** Gets or sets the hosting scene */
  100280. scene: Scene;
  100281. /**
  100282. * Gets the compilation hints emitted at compilation time
  100283. */
  100284. hints: {
  100285. needWorldViewMatrix: boolean;
  100286. needWorldViewProjectionMatrix: boolean;
  100287. needAlphaBlending: boolean;
  100288. needAlphaTesting: boolean;
  100289. };
  100290. /**
  100291. * List of compilation checks
  100292. */
  100293. checks: {
  100294. emitVertex: boolean;
  100295. emitFragment: boolean;
  100296. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100297. };
  100298. /**
  100299. * Is vertex program allowed to be empty?
  100300. */
  100301. allowEmptyVertexProgram: boolean;
  100302. /** Creates a new shared data */
  100303. constructor();
  100304. /**
  100305. * Emits console errors and exceptions if there is a failing check
  100306. */
  100307. emitErrors(): void;
  100308. }
  100309. }
  100310. declare module BABYLON {
  100311. /**
  100312. * Class used to store node based material build state
  100313. */
  100314. export class NodeMaterialBuildState {
  100315. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100316. supportUniformBuffers: boolean;
  100317. /**
  100318. * Gets the list of emitted attributes
  100319. */
  100320. attributes: string[];
  100321. /**
  100322. * Gets the list of emitted uniforms
  100323. */
  100324. uniforms: string[];
  100325. /**
  100326. * Gets the list of emitted constants
  100327. */
  100328. constants: string[];
  100329. /**
  100330. * Gets the list of emitted samplers
  100331. */
  100332. samplers: string[];
  100333. /**
  100334. * Gets the list of emitted functions
  100335. */
  100336. functions: {
  100337. [key: string]: string;
  100338. };
  100339. /**
  100340. * Gets the list of emitted extensions
  100341. */
  100342. extensions: {
  100343. [key: string]: string;
  100344. };
  100345. /**
  100346. * Gets the target of the compilation state
  100347. */
  100348. target: NodeMaterialBlockTargets;
  100349. /**
  100350. * Gets the list of emitted counters
  100351. */
  100352. counters: {
  100353. [key: string]: number;
  100354. };
  100355. /**
  100356. * Shared data between multiple NodeMaterialBuildState instances
  100357. */
  100358. sharedData: NodeMaterialBuildStateSharedData;
  100359. /** @hidden */
  100360. _vertexState: NodeMaterialBuildState;
  100361. /** @hidden */
  100362. _attributeDeclaration: string;
  100363. /** @hidden */
  100364. _uniformDeclaration: string;
  100365. /** @hidden */
  100366. _constantDeclaration: string;
  100367. /** @hidden */
  100368. _samplerDeclaration: string;
  100369. /** @hidden */
  100370. _varyingTransfer: string;
  100371. /** @hidden */
  100372. _injectAtEnd: string;
  100373. private _repeatableContentAnchorIndex;
  100374. /** @hidden */
  100375. _builtCompilationString: string;
  100376. /**
  100377. * Gets the emitted compilation strings
  100378. */
  100379. compilationString: string;
  100380. /**
  100381. * Finalize the compilation strings
  100382. * @param state defines the current compilation state
  100383. */
  100384. finalize(state: NodeMaterialBuildState): void;
  100385. /** @hidden */
  100386. get _repeatableContentAnchor(): string;
  100387. /** @hidden */
  100388. _getFreeVariableName(prefix: string): string;
  100389. /** @hidden */
  100390. _getFreeDefineName(prefix: string): string;
  100391. /** @hidden */
  100392. _excludeVariableName(name: string): void;
  100393. /** @hidden */
  100394. _emit2DSampler(name: string): void;
  100395. /** @hidden */
  100396. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100397. /** @hidden */
  100398. _emitExtension(name: string, extension: string, define?: string): void;
  100399. /** @hidden */
  100400. _emitFunction(name: string, code: string, comments: string): void;
  100401. /** @hidden */
  100402. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100403. replaceStrings?: {
  100404. search: RegExp;
  100405. replace: string;
  100406. }[];
  100407. repeatKey?: string;
  100408. }): string;
  100409. /** @hidden */
  100410. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100411. repeatKey?: string;
  100412. removeAttributes?: boolean;
  100413. removeUniforms?: boolean;
  100414. removeVaryings?: boolean;
  100415. removeIfDef?: boolean;
  100416. replaceStrings?: {
  100417. search: RegExp;
  100418. replace: string;
  100419. }[];
  100420. }, storeKey?: string): void;
  100421. /** @hidden */
  100422. _registerTempVariable(name: string): boolean;
  100423. /** @hidden */
  100424. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100425. /** @hidden */
  100426. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100427. /** @hidden */
  100428. _emitFloat(value: number): string;
  100429. }
  100430. }
  100431. declare module BABYLON {
  100432. /**
  100433. * Helper class used to generate session unique ID
  100434. */
  100435. export class UniqueIdGenerator {
  100436. private static _UniqueIdCounter;
  100437. /**
  100438. * Gets an unique (relatively to the current scene) Id
  100439. */
  100440. static get UniqueId(): number;
  100441. }
  100442. }
  100443. declare module BABYLON {
  100444. /**
  100445. * Defines a block that can be used inside a node based material
  100446. */
  100447. export class NodeMaterialBlock {
  100448. private _buildId;
  100449. private _buildTarget;
  100450. private _target;
  100451. private _isFinalMerger;
  100452. private _isInput;
  100453. private _name;
  100454. protected _isUnique: boolean;
  100455. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100456. inputsAreExclusive: boolean;
  100457. /** @hidden */
  100458. _codeVariableName: string;
  100459. /** @hidden */
  100460. _inputs: NodeMaterialConnectionPoint[];
  100461. /** @hidden */
  100462. _outputs: NodeMaterialConnectionPoint[];
  100463. /** @hidden */
  100464. _preparationId: number;
  100465. /**
  100466. * Gets the name of the block
  100467. */
  100468. get name(): string;
  100469. /**
  100470. * Sets the name of the block. Will check if the name is valid.
  100471. */
  100472. set name(newName: string);
  100473. /**
  100474. * Gets or sets the unique id of the node
  100475. */
  100476. uniqueId: number;
  100477. /**
  100478. * Gets or sets the comments associated with this block
  100479. */
  100480. comments: string;
  100481. /**
  100482. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100483. */
  100484. get isUnique(): boolean;
  100485. /**
  100486. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100487. */
  100488. get isFinalMerger(): boolean;
  100489. /**
  100490. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100491. */
  100492. get isInput(): boolean;
  100493. /**
  100494. * Gets or sets the build Id
  100495. */
  100496. get buildId(): number;
  100497. set buildId(value: number);
  100498. /**
  100499. * Gets or sets the target of the block
  100500. */
  100501. get target(): NodeMaterialBlockTargets;
  100502. set target(value: NodeMaterialBlockTargets);
  100503. /**
  100504. * Gets the list of input points
  100505. */
  100506. get inputs(): NodeMaterialConnectionPoint[];
  100507. /** Gets the list of output points */
  100508. get outputs(): NodeMaterialConnectionPoint[];
  100509. /**
  100510. * Find an input by its name
  100511. * @param name defines the name of the input to look for
  100512. * @returns the input or null if not found
  100513. */
  100514. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100515. /**
  100516. * Find an output by its name
  100517. * @param name defines the name of the outputto look for
  100518. * @returns the output or null if not found
  100519. */
  100520. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100521. /**
  100522. * Creates a new NodeMaterialBlock
  100523. * @param name defines the block name
  100524. * @param target defines the target of that block (Vertex by default)
  100525. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100526. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100527. */
  100528. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100529. /**
  100530. * Initialize the block and prepare the context for build
  100531. * @param state defines the state that will be used for the build
  100532. */
  100533. initialize(state: NodeMaterialBuildState): void;
  100534. /**
  100535. * Bind data to effect. Will only be called for blocks with isBindable === true
  100536. * @param effect defines the effect to bind data to
  100537. * @param nodeMaterial defines the hosting NodeMaterial
  100538. * @param mesh defines the mesh that will be rendered
  100539. * @param subMesh defines the submesh that will be rendered
  100540. */
  100541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100542. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100543. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100544. protected _writeFloat(value: number): string;
  100545. /**
  100546. * Gets the current class name e.g. "NodeMaterialBlock"
  100547. * @returns the class name
  100548. */
  100549. getClassName(): string;
  100550. /**
  100551. * Register a new input. Must be called inside a block constructor
  100552. * @param name defines the connection point name
  100553. * @param type defines the connection point type
  100554. * @param isOptional defines a boolean indicating that this input can be omitted
  100555. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100556. * @param point an already created connection point. If not provided, create a new one
  100557. * @returns the current block
  100558. */
  100559. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100560. /**
  100561. * Register a new output. Must be called inside a block constructor
  100562. * @param name defines the connection point name
  100563. * @param type defines the connection point type
  100564. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100565. * @param point an already created connection point. If not provided, create a new one
  100566. * @returns the current block
  100567. */
  100568. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100569. /**
  100570. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100571. * @param forOutput defines an optional connection point to check compatibility with
  100572. * @returns the first available input or null
  100573. */
  100574. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100575. /**
  100576. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100577. * @param forBlock defines an optional block to check compatibility with
  100578. * @returns the first available input or null
  100579. */
  100580. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100581. /**
  100582. * Gets the sibling of the given output
  100583. * @param current defines the current output
  100584. * @returns the next output in the list or null
  100585. */
  100586. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100587. /**
  100588. * Connect current block with another block
  100589. * @param other defines the block to connect with
  100590. * @param options define the various options to help pick the right connections
  100591. * @returns the current block
  100592. */
  100593. connectTo(other: NodeMaterialBlock, options?: {
  100594. input?: string;
  100595. output?: string;
  100596. outputSwizzle?: string;
  100597. }): this | undefined;
  100598. protected _buildBlock(state: NodeMaterialBuildState): void;
  100599. /**
  100600. * Add uniforms, samplers and uniform buffers at compilation time
  100601. * @param state defines the state to update
  100602. * @param nodeMaterial defines the node material requesting the update
  100603. * @param defines defines the material defines to update
  100604. * @param uniformBuffers defines the list of uniform buffer names
  100605. */
  100606. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100607. /**
  100608. * Add potential fallbacks if shader compilation fails
  100609. * @param mesh defines the mesh to be rendered
  100610. * @param fallbacks defines the current prioritized list of fallbacks
  100611. */
  100612. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100613. /**
  100614. * Initialize defines for shader compilation
  100615. * @param mesh defines the mesh to be rendered
  100616. * @param nodeMaterial defines the node material requesting the update
  100617. * @param defines defines the material defines to update
  100618. * @param useInstances specifies that instances should be used
  100619. */
  100620. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100621. /**
  100622. * Update defines for shader compilation
  100623. * @param mesh defines the mesh to be rendered
  100624. * @param nodeMaterial defines the node material requesting the update
  100625. * @param defines defines the material defines to update
  100626. * @param useInstances specifies that instances should be used
  100627. * @param subMesh defines which submesh to render
  100628. */
  100629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100630. /**
  100631. * Lets the block try to connect some inputs automatically
  100632. * @param material defines the hosting NodeMaterial
  100633. */
  100634. autoConfigure(material: NodeMaterial): void;
  100635. /**
  100636. * Function called when a block is declared as repeatable content generator
  100637. * @param vertexShaderState defines the current compilation state for the vertex shader
  100638. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100639. * @param mesh defines the mesh to be rendered
  100640. * @param defines defines the material defines to update
  100641. */
  100642. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100643. /**
  100644. * Checks if the block is ready
  100645. * @param mesh defines the mesh to be rendered
  100646. * @param nodeMaterial defines the node material requesting the update
  100647. * @param defines defines the material defines to update
  100648. * @param useInstances specifies that instances should be used
  100649. * @returns true if the block is ready
  100650. */
  100651. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100652. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100653. private _processBuild;
  100654. /**
  100655. * Validates the new name for the block node.
  100656. * @param newName the new name to be given to the node.
  100657. * @returns false if the name is a reserve word, else true.
  100658. */
  100659. validateBlockName(newName: string): boolean;
  100660. /**
  100661. * Compile the current node and generate the shader code
  100662. * @param state defines the current compilation state (uniforms, samplers, current string)
  100663. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100664. * @returns true if already built
  100665. */
  100666. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100667. protected _inputRename(name: string): string;
  100668. protected _outputRename(name: string): string;
  100669. protected _dumpPropertiesCode(): string;
  100670. /** @hidden */
  100671. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100672. /** @hidden */
  100673. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100674. /**
  100675. * Clone the current block to a new identical block
  100676. * @param scene defines the hosting scene
  100677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100678. * @returns a copy of the current block
  100679. */
  100680. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100681. /**
  100682. * Serializes this block in a JSON representation
  100683. * @returns the serialized block object
  100684. */
  100685. serialize(): any;
  100686. /** @hidden */
  100687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100688. private _deserializePortDisplayNamesAndExposedOnFrame;
  100689. /**
  100690. * Release resources
  100691. */
  100692. dispose(): void;
  100693. }
  100694. }
  100695. declare module BABYLON {
  100696. /**
  100697. * Base class of materials working in push mode in babylon JS
  100698. * @hidden
  100699. */
  100700. export class PushMaterial extends Material {
  100701. protected _activeEffect: Effect;
  100702. protected _normalMatrix: Matrix;
  100703. constructor(name: string, scene: Scene);
  100704. getEffect(): Effect;
  100705. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100706. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100707. /**
  100708. * Binds the given world matrix to the active effect
  100709. *
  100710. * @param world the matrix to bind
  100711. */
  100712. bindOnlyWorldMatrix(world: Matrix): void;
  100713. /**
  100714. * Binds the given normal matrix to the active effect
  100715. *
  100716. * @param normalMatrix the matrix to bind
  100717. */
  100718. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100719. bind(world: Matrix, mesh?: Mesh): void;
  100720. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100721. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100722. }
  100723. }
  100724. declare module BABYLON {
  100725. /**
  100726. * Root class for all node material optimizers
  100727. */
  100728. export class NodeMaterialOptimizer {
  100729. /**
  100730. * Function used to optimize a NodeMaterial graph
  100731. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100732. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100733. */
  100734. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100735. }
  100736. }
  100737. declare module BABYLON {
  100738. /**
  100739. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100740. */
  100741. export class TransformBlock extends NodeMaterialBlock {
  100742. /**
  100743. * Defines the value to use to complement W value to transform it to a Vector4
  100744. */
  100745. complementW: number;
  100746. /**
  100747. * Defines the value to use to complement z value to transform it to a Vector4
  100748. */
  100749. complementZ: number;
  100750. /**
  100751. * Creates a new TransformBlock
  100752. * @param name defines the block name
  100753. */
  100754. constructor(name: string);
  100755. /**
  100756. * Gets the current class name
  100757. * @returns the class name
  100758. */
  100759. getClassName(): string;
  100760. /**
  100761. * Gets the vector input
  100762. */
  100763. get vector(): NodeMaterialConnectionPoint;
  100764. /**
  100765. * Gets the output component
  100766. */
  100767. get output(): NodeMaterialConnectionPoint;
  100768. /**
  100769. * Gets the xyz output component
  100770. */
  100771. get xyz(): NodeMaterialConnectionPoint;
  100772. /**
  100773. * Gets the matrix transform input
  100774. */
  100775. get transform(): NodeMaterialConnectionPoint;
  100776. protected _buildBlock(state: NodeMaterialBuildState): this;
  100777. /**
  100778. * Update defines for shader compilation
  100779. * @param mesh defines the mesh to be rendered
  100780. * @param nodeMaterial defines the node material requesting the update
  100781. * @param defines defines the material defines to update
  100782. * @param useInstances specifies that instances should be used
  100783. * @param subMesh defines which submesh to render
  100784. */
  100785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100786. serialize(): any;
  100787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100788. protected _dumpPropertiesCode(): string;
  100789. }
  100790. }
  100791. declare module BABYLON {
  100792. /**
  100793. * Block used to output the vertex position
  100794. */
  100795. export class VertexOutputBlock extends NodeMaterialBlock {
  100796. /**
  100797. * Creates a new VertexOutputBlock
  100798. * @param name defines the block name
  100799. */
  100800. constructor(name: string);
  100801. /**
  100802. * Gets the current class name
  100803. * @returns the class name
  100804. */
  100805. getClassName(): string;
  100806. /**
  100807. * Gets the vector input component
  100808. */
  100809. get vector(): NodeMaterialConnectionPoint;
  100810. protected _buildBlock(state: NodeMaterialBuildState): this;
  100811. }
  100812. }
  100813. declare module BABYLON {
  100814. /**
  100815. * Block used to output the final color
  100816. */
  100817. export class FragmentOutputBlock extends NodeMaterialBlock {
  100818. /**
  100819. * Create a new FragmentOutputBlock
  100820. * @param name defines the block name
  100821. */
  100822. constructor(name: string);
  100823. /**
  100824. * Gets the current class name
  100825. * @returns the class name
  100826. */
  100827. getClassName(): string;
  100828. /**
  100829. * Gets the rgba input component
  100830. */
  100831. get rgba(): NodeMaterialConnectionPoint;
  100832. /**
  100833. * Gets the rgb input component
  100834. */
  100835. get rgb(): NodeMaterialConnectionPoint;
  100836. /**
  100837. * Gets the a input component
  100838. */
  100839. get a(): NodeMaterialConnectionPoint;
  100840. protected _buildBlock(state: NodeMaterialBuildState): this;
  100841. }
  100842. }
  100843. declare module BABYLON {
  100844. /**
  100845. * Block used for the particle ramp gradient section
  100846. */
  100847. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100848. /**
  100849. * Create a new ParticleRampGradientBlock
  100850. * @param name defines the block name
  100851. */
  100852. constructor(name: string);
  100853. /**
  100854. * Gets the current class name
  100855. * @returns the class name
  100856. */
  100857. getClassName(): string;
  100858. /**
  100859. * Gets the color input component
  100860. */
  100861. get color(): NodeMaterialConnectionPoint;
  100862. /**
  100863. * Gets the rampColor output component
  100864. */
  100865. get rampColor(): NodeMaterialConnectionPoint;
  100866. /**
  100867. * Initialize the block and prepare the context for build
  100868. * @param state defines the state that will be used for the build
  100869. */
  100870. initialize(state: NodeMaterialBuildState): void;
  100871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100872. }
  100873. }
  100874. declare module BABYLON {
  100875. /**
  100876. * Block used for the particle blend multiply section
  100877. */
  100878. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100879. /**
  100880. * Create a new ParticleBlendMultiplyBlock
  100881. * @param name defines the block name
  100882. */
  100883. constructor(name: string);
  100884. /**
  100885. * Gets the current class name
  100886. * @returns the class name
  100887. */
  100888. getClassName(): string;
  100889. /**
  100890. * Gets the color input component
  100891. */
  100892. get color(): NodeMaterialConnectionPoint;
  100893. /**
  100894. * Gets the alphaTexture input component
  100895. */
  100896. get alphaTexture(): NodeMaterialConnectionPoint;
  100897. /**
  100898. * Gets the alphaColor input component
  100899. */
  100900. get alphaColor(): NodeMaterialConnectionPoint;
  100901. /**
  100902. * Gets the blendColor output component
  100903. */
  100904. get blendColor(): NodeMaterialConnectionPoint;
  100905. /**
  100906. * Initialize the block and prepare the context for build
  100907. * @param state defines the state that will be used for the build
  100908. */
  100909. initialize(state: NodeMaterialBuildState): void;
  100910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100911. }
  100912. }
  100913. declare module BABYLON {
  100914. /**
  100915. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100916. */
  100917. export class VectorMergerBlock extends NodeMaterialBlock {
  100918. /**
  100919. * Create a new VectorMergerBlock
  100920. * @param name defines the block name
  100921. */
  100922. constructor(name: string);
  100923. /**
  100924. * Gets the current class name
  100925. * @returns the class name
  100926. */
  100927. getClassName(): string;
  100928. /**
  100929. * Gets the xyz component (input)
  100930. */
  100931. get xyzIn(): NodeMaterialConnectionPoint;
  100932. /**
  100933. * Gets the xy component (input)
  100934. */
  100935. get xyIn(): NodeMaterialConnectionPoint;
  100936. /**
  100937. * Gets the x component (input)
  100938. */
  100939. get x(): NodeMaterialConnectionPoint;
  100940. /**
  100941. * Gets the y component (input)
  100942. */
  100943. get y(): NodeMaterialConnectionPoint;
  100944. /**
  100945. * Gets the z component (input)
  100946. */
  100947. get z(): NodeMaterialConnectionPoint;
  100948. /**
  100949. * Gets the w component (input)
  100950. */
  100951. get w(): NodeMaterialConnectionPoint;
  100952. /**
  100953. * Gets the xyzw component (output)
  100954. */
  100955. get xyzw(): NodeMaterialConnectionPoint;
  100956. /**
  100957. * Gets the xyz component (output)
  100958. */
  100959. get xyzOut(): NodeMaterialConnectionPoint;
  100960. /**
  100961. * Gets the xy component (output)
  100962. */
  100963. get xyOut(): NodeMaterialConnectionPoint;
  100964. /**
  100965. * Gets the xy component (output)
  100966. * @deprecated Please use xyOut instead.
  100967. */
  100968. get xy(): NodeMaterialConnectionPoint;
  100969. /**
  100970. * Gets the xyz component (output)
  100971. * @deprecated Please use xyzOut instead.
  100972. */
  100973. get xyz(): NodeMaterialConnectionPoint;
  100974. protected _buildBlock(state: NodeMaterialBuildState): this;
  100975. }
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * Block used to remap a float from a range to a new one
  100980. */
  100981. export class RemapBlock extends NodeMaterialBlock {
  100982. /**
  100983. * Gets or sets the source range
  100984. */
  100985. sourceRange: Vector2;
  100986. /**
  100987. * Gets or sets the target range
  100988. */
  100989. targetRange: Vector2;
  100990. /**
  100991. * Creates a new RemapBlock
  100992. * @param name defines the block name
  100993. */
  100994. constructor(name: string);
  100995. /**
  100996. * Gets the current class name
  100997. * @returns the class name
  100998. */
  100999. getClassName(): string;
  101000. /**
  101001. * Gets the input component
  101002. */
  101003. get input(): NodeMaterialConnectionPoint;
  101004. /**
  101005. * Gets the source min input component
  101006. */
  101007. get sourceMin(): NodeMaterialConnectionPoint;
  101008. /**
  101009. * Gets the source max input component
  101010. */
  101011. get sourceMax(): NodeMaterialConnectionPoint;
  101012. /**
  101013. * Gets the target min input component
  101014. */
  101015. get targetMin(): NodeMaterialConnectionPoint;
  101016. /**
  101017. * Gets the target max input component
  101018. */
  101019. get targetMax(): NodeMaterialConnectionPoint;
  101020. /**
  101021. * Gets the output component
  101022. */
  101023. get output(): NodeMaterialConnectionPoint;
  101024. protected _buildBlock(state: NodeMaterialBuildState): this;
  101025. protected _dumpPropertiesCode(): string;
  101026. serialize(): any;
  101027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101028. }
  101029. }
  101030. declare module BABYLON {
  101031. /**
  101032. * Block used to multiply 2 values
  101033. */
  101034. export class MultiplyBlock extends NodeMaterialBlock {
  101035. /**
  101036. * Creates a new MultiplyBlock
  101037. * @param name defines the block name
  101038. */
  101039. constructor(name: string);
  101040. /**
  101041. * Gets the current class name
  101042. * @returns the class name
  101043. */
  101044. getClassName(): string;
  101045. /**
  101046. * Gets the left operand input component
  101047. */
  101048. get left(): NodeMaterialConnectionPoint;
  101049. /**
  101050. * Gets the right operand input component
  101051. */
  101052. get right(): NodeMaterialConnectionPoint;
  101053. /**
  101054. * Gets the output component
  101055. */
  101056. get output(): NodeMaterialConnectionPoint;
  101057. protected _buildBlock(state: NodeMaterialBuildState): this;
  101058. }
  101059. }
  101060. declare module BABYLON {
  101061. /**
  101062. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101063. */
  101064. export class ColorSplitterBlock extends NodeMaterialBlock {
  101065. /**
  101066. * Create a new ColorSplitterBlock
  101067. * @param name defines the block name
  101068. */
  101069. constructor(name: string);
  101070. /**
  101071. * Gets the current class name
  101072. * @returns the class name
  101073. */
  101074. getClassName(): string;
  101075. /**
  101076. * Gets the rgba component (input)
  101077. */
  101078. get rgba(): NodeMaterialConnectionPoint;
  101079. /**
  101080. * Gets the rgb component (input)
  101081. */
  101082. get rgbIn(): NodeMaterialConnectionPoint;
  101083. /**
  101084. * Gets the rgb component (output)
  101085. */
  101086. get rgbOut(): NodeMaterialConnectionPoint;
  101087. /**
  101088. * Gets the r component (output)
  101089. */
  101090. get r(): NodeMaterialConnectionPoint;
  101091. /**
  101092. * Gets the g component (output)
  101093. */
  101094. get g(): NodeMaterialConnectionPoint;
  101095. /**
  101096. * Gets the b component (output)
  101097. */
  101098. get b(): NodeMaterialConnectionPoint;
  101099. /**
  101100. * Gets the a component (output)
  101101. */
  101102. get a(): NodeMaterialConnectionPoint;
  101103. protected _inputRename(name: string): string;
  101104. protected _outputRename(name: string): string;
  101105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101106. }
  101107. }
  101108. declare module BABYLON {
  101109. /**
  101110. * Interface used to configure the node material editor
  101111. */
  101112. export interface INodeMaterialEditorOptions {
  101113. /** Define the URl to load node editor script */
  101114. editorURL?: string;
  101115. }
  101116. /** @hidden */
  101117. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101118. NORMAL: boolean;
  101119. TANGENT: boolean;
  101120. UV1: boolean;
  101121. /** BONES */
  101122. NUM_BONE_INFLUENCERS: number;
  101123. BonesPerMesh: number;
  101124. BONETEXTURE: boolean;
  101125. /** MORPH TARGETS */
  101126. MORPHTARGETS: boolean;
  101127. MORPHTARGETS_NORMAL: boolean;
  101128. MORPHTARGETS_TANGENT: boolean;
  101129. MORPHTARGETS_UV: boolean;
  101130. NUM_MORPH_INFLUENCERS: number;
  101131. /** IMAGE PROCESSING */
  101132. IMAGEPROCESSING: boolean;
  101133. VIGNETTE: boolean;
  101134. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101135. VIGNETTEBLENDMODEOPAQUE: boolean;
  101136. TONEMAPPING: boolean;
  101137. TONEMAPPING_ACES: boolean;
  101138. CONTRAST: boolean;
  101139. EXPOSURE: boolean;
  101140. COLORCURVES: boolean;
  101141. COLORGRADING: boolean;
  101142. COLORGRADING3D: boolean;
  101143. SAMPLER3DGREENDEPTH: boolean;
  101144. SAMPLER3DBGRMAP: boolean;
  101145. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101146. /** MISC. */
  101147. BUMPDIRECTUV: number;
  101148. constructor();
  101149. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101150. }
  101151. /**
  101152. * Class used to configure NodeMaterial
  101153. */
  101154. export interface INodeMaterialOptions {
  101155. /**
  101156. * Defines if blocks should emit comments
  101157. */
  101158. emitComments: boolean;
  101159. }
  101160. /**
  101161. * Class used to create a node based material built by assembling shader blocks
  101162. */
  101163. export class NodeMaterial extends PushMaterial {
  101164. private static _BuildIdGenerator;
  101165. private _options;
  101166. private _vertexCompilationState;
  101167. private _fragmentCompilationState;
  101168. private _sharedData;
  101169. private _buildId;
  101170. private _buildWasSuccessful;
  101171. private _cachedWorldViewMatrix;
  101172. private _cachedWorldViewProjectionMatrix;
  101173. private _optimizers;
  101174. private _animationFrame;
  101175. /** Define the Url to load node editor script */
  101176. static EditorURL: string;
  101177. /** Define the Url to load snippets */
  101178. static SnippetUrl: string;
  101179. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101180. static IgnoreTexturesAtLoadTime: boolean;
  101181. private BJSNODEMATERIALEDITOR;
  101182. /** Get the inspector from bundle or global */
  101183. private _getGlobalNodeMaterialEditor;
  101184. /**
  101185. * Snippet ID if the material was created from the snippet server
  101186. */
  101187. snippetId: string;
  101188. /**
  101189. * Gets or sets data used by visual editor
  101190. * @see https://nme.babylonjs.com
  101191. */
  101192. editorData: any;
  101193. /**
  101194. * 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)
  101195. */
  101196. ignoreAlpha: boolean;
  101197. /**
  101198. * Defines the maximum number of lights that can be used in the material
  101199. */
  101200. maxSimultaneousLights: number;
  101201. /**
  101202. * Observable raised when the material is built
  101203. */
  101204. onBuildObservable: Observable<NodeMaterial>;
  101205. /**
  101206. * Gets or sets the root nodes of the material vertex shader
  101207. */
  101208. _vertexOutputNodes: NodeMaterialBlock[];
  101209. /**
  101210. * Gets or sets the root nodes of the material fragment (pixel) shader
  101211. */
  101212. _fragmentOutputNodes: NodeMaterialBlock[];
  101213. /** Gets or sets options to control the node material overall behavior */
  101214. get options(): INodeMaterialOptions;
  101215. set options(options: INodeMaterialOptions);
  101216. /**
  101217. * Default configuration related to image processing available in the standard Material.
  101218. */
  101219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101220. /**
  101221. * Gets the image processing configuration used either in this material.
  101222. */
  101223. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101224. /**
  101225. * Sets the Default image processing configuration used either in the this material.
  101226. *
  101227. * If sets to null, the scene one is in use.
  101228. */
  101229. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101230. /**
  101231. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101232. */
  101233. attachedBlocks: NodeMaterialBlock[];
  101234. /**
  101235. * Specifies the mode of the node material
  101236. * @hidden
  101237. */
  101238. _mode: NodeMaterialModes;
  101239. /**
  101240. * Gets the mode property
  101241. */
  101242. get mode(): NodeMaterialModes;
  101243. /**
  101244. * Create a new node based material
  101245. * @param name defines the material name
  101246. * @param scene defines the hosting scene
  101247. * @param options defines creation option
  101248. */
  101249. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101250. /**
  101251. * Gets the current class name of the material e.g. "NodeMaterial"
  101252. * @returns the class name
  101253. */
  101254. getClassName(): string;
  101255. /**
  101256. * Keep track of the image processing observer to allow dispose and replace.
  101257. */
  101258. private _imageProcessingObserver;
  101259. /**
  101260. * Attaches a new image processing configuration to the Standard Material.
  101261. * @param configuration
  101262. */
  101263. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101264. /**
  101265. * Get a block by its name
  101266. * @param name defines the name of the block to retrieve
  101267. * @returns the required block or null if not found
  101268. */
  101269. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101270. /**
  101271. * Get a block by its name
  101272. * @param predicate defines the predicate used to find the good candidate
  101273. * @returns the required block or null if not found
  101274. */
  101275. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101276. /**
  101277. * Get an input block by its name
  101278. * @param predicate defines the predicate used to find the good candidate
  101279. * @returns the required input block or null if not found
  101280. */
  101281. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101282. /**
  101283. * Gets the list of input blocks attached to this material
  101284. * @returns an array of InputBlocks
  101285. */
  101286. getInputBlocks(): InputBlock[];
  101287. /**
  101288. * Adds a new optimizer to the list of optimizers
  101289. * @param optimizer defines the optimizers to add
  101290. * @returns the current material
  101291. */
  101292. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101293. /**
  101294. * Remove an optimizer from the list of optimizers
  101295. * @param optimizer defines the optimizers to remove
  101296. * @returns the current material
  101297. */
  101298. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101299. /**
  101300. * Add a new block to the list of output nodes
  101301. * @param node defines the node to add
  101302. * @returns the current material
  101303. */
  101304. addOutputNode(node: NodeMaterialBlock): this;
  101305. /**
  101306. * Remove a block from the list of root nodes
  101307. * @param node defines the node to remove
  101308. * @returns the current material
  101309. */
  101310. removeOutputNode(node: NodeMaterialBlock): this;
  101311. private _addVertexOutputNode;
  101312. private _removeVertexOutputNode;
  101313. private _addFragmentOutputNode;
  101314. private _removeFragmentOutputNode;
  101315. /**
  101316. * Specifies if the material will require alpha blending
  101317. * @returns a boolean specifying if alpha blending is needed
  101318. */
  101319. needAlphaBlending(): boolean;
  101320. /**
  101321. * Specifies if this material should be rendered in alpha test mode
  101322. * @returns a boolean specifying if an alpha test is needed.
  101323. */
  101324. needAlphaTesting(): boolean;
  101325. private _initializeBlock;
  101326. private _resetDualBlocks;
  101327. /**
  101328. * Remove a block from the current node material
  101329. * @param block defines the block to remove
  101330. */
  101331. removeBlock(block: NodeMaterialBlock): void;
  101332. /**
  101333. * Build the material and generates the inner effect
  101334. * @param verbose defines if the build should log activity
  101335. */
  101336. build(verbose?: boolean): void;
  101337. /**
  101338. * Runs an otpimization phase to try to improve the shader code
  101339. */
  101340. optimize(): void;
  101341. private _prepareDefinesForAttributes;
  101342. /**
  101343. * Create a post process from the material
  101344. * @param camera The camera to apply the render pass to.
  101345. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101347. * @param engine The engine which the post process will be applied. (default: current engine)
  101348. * @param reusable If the post process can be reused on the same frame. (default: false)
  101349. * @param textureType Type of textures used when performing the post process. (default: 0)
  101350. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101351. * @returns the post process created
  101352. */
  101353. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101354. /**
  101355. * Create the post process effect from the material
  101356. * @param postProcess The post process to create the effect for
  101357. */
  101358. createEffectForPostProcess(postProcess: PostProcess): void;
  101359. private _createEffectOrPostProcess;
  101360. private _createEffectForParticles;
  101361. /**
  101362. * Create the effect to be used as the custom effect for a particle system
  101363. * @param particleSystem Particle system to create the effect for
  101364. * @param onCompiled defines a function to call when the effect creation is successful
  101365. * @param onError defines a function to call when the effect creation has failed
  101366. */
  101367. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101368. private _processDefines;
  101369. /**
  101370. * Get if the submesh is ready to be used and all its information available.
  101371. * Child classes can use it to update shaders
  101372. * @param mesh defines the mesh to check
  101373. * @param subMesh defines which submesh to check
  101374. * @param useInstances specifies that instances should be used
  101375. * @returns a boolean indicating that the submesh is ready or not
  101376. */
  101377. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101378. /**
  101379. * Get a string representing the shaders built by the current node graph
  101380. */
  101381. get compiledShaders(): string;
  101382. /**
  101383. * Binds the world matrix to the material
  101384. * @param world defines the world transformation matrix
  101385. */
  101386. bindOnlyWorldMatrix(world: Matrix): void;
  101387. /**
  101388. * Binds the submesh to this material by preparing the effect and shader to draw
  101389. * @param world defines the world transformation matrix
  101390. * @param mesh defines the mesh containing the submesh
  101391. * @param subMesh defines the submesh to bind the material to
  101392. */
  101393. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101394. /**
  101395. * Gets the active textures from the material
  101396. * @returns an array of textures
  101397. */
  101398. getActiveTextures(): BaseTexture[];
  101399. /**
  101400. * Gets the list of texture blocks
  101401. * @returns an array of texture blocks
  101402. */
  101403. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101404. /**
  101405. * Specifies if the material uses a texture
  101406. * @param texture defines the texture to check against the material
  101407. * @returns a boolean specifying if the material uses the texture
  101408. */
  101409. hasTexture(texture: BaseTexture): boolean;
  101410. /**
  101411. * Disposes the material
  101412. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101413. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101414. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101415. */
  101416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101417. /** Creates the node editor window. */
  101418. private _createNodeEditor;
  101419. /**
  101420. * Launch the node material editor
  101421. * @param config Define the configuration of the editor
  101422. * @return a promise fulfilled when the node editor is visible
  101423. */
  101424. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101425. /**
  101426. * Clear the current material
  101427. */
  101428. clear(): void;
  101429. /**
  101430. * Clear the current material and set it to a default state
  101431. */
  101432. setToDefault(): void;
  101433. /**
  101434. * Clear the current material and set it to a default state for post process
  101435. */
  101436. setToDefaultPostProcess(): void;
  101437. /**
  101438. * Clear the current material and set it to a default state for particle
  101439. */
  101440. setToDefaultParticle(): void;
  101441. /**
  101442. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101443. * @param url defines the url to load from
  101444. * @returns a promise that will fullfil when the material is fully loaded
  101445. */
  101446. loadAsync(url: string): Promise<void>;
  101447. private _gatherBlocks;
  101448. /**
  101449. * Generate a string containing the code declaration required to create an equivalent of this material
  101450. * @returns a string
  101451. */
  101452. generateCode(): string;
  101453. /**
  101454. * Serializes this material in a JSON representation
  101455. * @returns the serialized material object
  101456. */
  101457. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101458. private _restoreConnections;
  101459. /**
  101460. * Clear the current graph and load a new one from a serialization object
  101461. * @param source defines the JSON representation of the material
  101462. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101463. * @param merge defines whether or not the source must be merged or replace the current content
  101464. */
  101465. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101466. /**
  101467. * Makes a duplicate of the current material.
  101468. * @param name - name to use for the new material.
  101469. */
  101470. clone(name: string): NodeMaterial;
  101471. /**
  101472. * Creates a node material from parsed material data
  101473. * @param source defines the JSON representation of the material
  101474. * @param scene defines the hosting scene
  101475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101476. * @returns a new node material
  101477. */
  101478. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101479. /**
  101480. * Creates a node material from a snippet saved in a remote file
  101481. * @param name defines the name of the material to create
  101482. * @param url defines the url to load from
  101483. * @param scene defines the hosting scene
  101484. * @returns a promise that will resolve to the new node material
  101485. */
  101486. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101487. /**
  101488. * Creates a node material from a snippet saved by the node material editor
  101489. * @param snippetId defines the snippet to load
  101490. * @param scene defines the hosting scene
  101491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101492. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101493. * @returns a promise that will resolve to the new node material
  101494. */
  101495. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101496. /**
  101497. * Creates a new node material set to default basic configuration
  101498. * @param name defines the name of the material
  101499. * @param scene defines the hosting scene
  101500. * @returns a new NodeMaterial
  101501. */
  101502. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101503. }
  101504. }
  101505. declare module BABYLON {
  101506. /**
  101507. * Size options for a post process
  101508. */
  101509. export type PostProcessOptions = {
  101510. width: number;
  101511. height: number;
  101512. };
  101513. /**
  101514. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101515. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101516. */
  101517. export class PostProcess {
  101518. /** Name of the PostProcess. */
  101519. name: string;
  101520. /**
  101521. * Gets or sets the unique id of the post process
  101522. */
  101523. uniqueId: number;
  101524. /**
  101525. * Width of the texture to apply the post process on
  101526. */
  101527. width: number;
  101528. /**
  101529. * Height of the texture to apply the post process on
  101530. */
  101531. height: number;
  101532. /**
  101533. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101534. */
  101535. nodeMaterialSource: Nullable<NodeMaterial>;
  101536. /**
  101537. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101538. * @hidden
  101539. */
  101540. _outputTexture: Nullable<InternalTexture>;
  101541. /**
  101542. * Sampling mode used by the shader
  101543. * See https://doc.babylonjs.com/classes/3.1/texture
  101544. */
  101545. renderTargetSamplingMode: number;
  101546. /**
  101547. * Clear color to use when screen clearing
  101548. */
  101549. clearColor: Color4;
  101550. /**
  101551. * If the buffer needs to be cleared before applying the post process. (default: true)
  101552. * Should be set to false if shader will overwrite all previous pixels.
  101553. */
  101554. autoClear: boolean;
  101555. /**
  101556. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101557. */
  101558. alphaMode: number;
  101559. /**
  101560. * Sets the setAlphaBlendConstants of the babylon engine
  101561. */
  101562. alphaConstants: Color4;
  101563. /**
  101564. * Animations to be used for the post processing
  101565. */
  101566. animations: Animation[];
  101567. /**
  101568. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101569. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101570. */
  101571. enablePixelPerfectMode: boolean;
  101572. /**
  101573. * Force the postprocess to be applied without taking in account viewport
  101574. */
  101575. forceFullscreenViewport: boolean;
  101576. /**
  101577. * List of inspectable custom properties (used by the Inspector)
  101578. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101579. */
  101580. inspectableCustomProperties: IInspectable[];
  101581. /**
  101582. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101583. *
  101584. * | Value | Type | Description |
  101585. * | ----- | ----------------------------------- | ----------- |
  101586. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101587. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101588. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101589. *
  101590. */
  101591. scaleMode: number;
  101592. /**
  101593. * Force textures to be a power of two (default: false)
  101594. */
  101595. alwaysForcePOT: boolean;
  101596. private _samples;
  101597. /**
  101598. * Number of sample textures (default: 1)
  101599. */
  101600. get samples(): number;
  101601. set samples(n: number);
  101602. /**
  101603. * Modify the scale of the post process to be the same as the viewport (default: false)
  101604. */
  101605. adaptScaleToCurrentViewport: boolean;
  101606. private _camera;
  101607. protected _scene: Scene;
  101608. private _engine;
  101609. private _options;
  101610. private _reusable;
  101611. private _textureType;
  101612. private _textureFormat;
  101613. /**
  101614. * Smart array of input and output textures for the post process.
  101615. * @hidden
  101616. */
  101617. _textures: SmartArray<InternalTexture>;
  101618. /**
  101619. * The index in _textures that corresponds to the output texture.
  101620. * @hidden
  101621. */
  101622. _currentRenderTextureInd: number;
  101623. private _effect;
  101624. private _samplers;
  101625. private _fragmentUrl;
  101626. private _vertexUrl;
  101627. private _parameters;
  101628. private _scaleRatio;
  101629. protected _indexParameters: any;
  101630. private _shareOutputWithPostProcess;
  101631. private _texelSize;
  101632. private _forcedOutputTexture;
  101633. /**
  101634. * Returns the fragment url or shader name used in the post process.
  101635. * @returns the fragment url or name in the shader store.
  101636. */
  101637. getEffectName(): string;
  101638. /**
  101639. * An event triggered when the postprocess is activated.
  101640. */
  101641. onActivateObservable: Observable<Camera>;
  101642. private _onActivateObserver;
  101643. /**
  101644. * A function that is added to the onActivateObservable
  101645. */
  101646. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101647. /**
  101648. * An event triggered when the postprocess changes its size.
  101649. */
  101650. onSizeChangedObservable: Observable<PostProcess>;
  101651. private _onSizeChangedObserver;
  101652. /**
  101653. * A function that is added to the onSizeChangedObservable
  101654. */
  101655. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101656. /**
  101657. * An event triggered when the postprocess applies its effect.
  101658. */
  101659. onApplyObservable: Observable<Effect>;
  101660. private _onApplyObserver;
  101661. /**
  101662. * A function that is added to the onApplyObservable
  101663. */
  101664. set onApply(callback: (effect: Effect) => void);
  101665. /**
  101666. * An event triggered before rendering the postprocess
  101667. */
  101668. onBeforeRenderObservable: Observable<Effect>;
  101669. private _onBeforeRenderObserver;
  101670. /**
  101671. * A function that is added to the onBeforeRenderObservable
  101672. */
  101673. set onBeforeRender(callback: (effect: Effect) => void);
  101674. /**
  101675. * An event triggered after rendering the postprocess
  101676. */
  101677. onAfterRenderObservable: Observable<Effect>;
  101678. private _onAfterRenderObserver;
  101679. /**
  101680. * A function that is added to the onAfterRenderObservable
  101681. */
  101682. set onAfterRender(callback: (efect: Effect) => void);
  101683. /**
  101684. * 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
  101685. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101686. */
  101687. get inputTexture(): InternalTexture;
  101688. set inputTexture(value: InternalTexture);
  101689. /**
  101690. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101691. * the only way to unset it is to use this function to restore its internal state
  101692. */
  101693. restoreDefaultInputTexture(): void;
  101694. /**
  101695. * Gets the camera which post process is applied to.
  101696. * @returns The camera the post process is applied to.
  101697. */
  101698. getCamera(): Camera;
  101699. /**
  101700. * Gets the texel size of the postprocess.
  101701. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101702. */
  101703. get texelSize(): Vector2;
  101704. /**
  101705. * Creates a new instance PostProcess
  101706. * @param name The name of the PostProcess.
  101707. * @param fragmentUrl The url of the fragment shader to be used.
  101708. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101709. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101710. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101711. * @param camera The camera to apply the render pass to.
  101712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101713. * @param engine The engine which the post process will be applied. (default: current engine)
  101714. * @param reusable If the post process can be reused on the same frame. (default: false)
  101715. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101716. * @param textureType Type of textures used when performing the post process. (default: 0)
  101717. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101718. * @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
  101719. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101720. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101721. */
  101722. constructor(
  101723. /** Name of the PostProcess. */
  101724. 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);
  101725. /**
  101726. * Gets a string idenfifying the name of the class
  101727. * @returns "PostProcess" string
  101728. */
  101729. getClassName(): string;
  101730. /**
  101731. * Gets the engine which this post process belongs to.
  101732. * @returns The engine the post process was enabled with.
  101733. */
  101734. getEngine(): Engine;
  101735. /**
  101736. * The effect that is created when initializing the post process.
  101737. * @returns The created effect corresponding the the postprocess.
  101738. */
  101739. getEffect(): Effect;
  101740. /**
  101741. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101742. * @param postProcess The post process to share the output with.
  101743. * @returns This post process.
  101744. */
  101745. shareOutputWith(postProcess: PostProcess): PostProcess;
  101746. /**
  101747. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101748. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101749. */
  101750. useOwnOutput(): void;
  101751. /**
  101752. * Updates the effect with the current post process compile time values and recompiles the shader.
  101753. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101754. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101755. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101756. * @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
  101757. * @param onCompiled Called when the shader has been compiled.
  101758. * @param onError Called if there is an error when compiling a shader.
  101759. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101760. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101761. */
  101762. 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;
  101763. /**
  101764. * The post process is reusable if it can be used multiple times within one frame.
  101765. * @returns If the post process is reusable
  101766. */
  101767. isReusable(): boolean;
  101768. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101769. markTextureDirty(): void;
  101770. /**
  101771. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101772. * 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.
  101773. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101774. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101775. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101776. * @returns The target texture that was bound to be written to.
  101777. */
  101778. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101779. /**
  101780. * If the post process is supported.
  101781. */
  101782. get isSupported(): boolean;
  101783. /**
  101784. * The aspect ratio of the output texture.
  101785. */
  101786. get aspectRatio(): number;
  101787. /**
  101788. * Get a value indicating if the post-process is ready to be used
  101789. * @returns true if the post-process is ready (shader is compiled)
  101790. */
  101791. isReady(): boolean;
  101792. /**
  101793. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101794. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101795. */
  101796. apply(): Nullable<Effect>;
  101797. private _disposeTextures;
  101798. /**
  101799. * Disposes the post process.
  101800. * @param camera The camera to dispose the post process on.
  101801. */
  101802. dispose(camera?: Camera): void;
  101803. }
  101804. }
  101805. declare module BABYLON {
  101806. /** @hidden */
  101807. export var kernelBlurVaryingDeclaration: {
  101808. name: string;
  101809. shader: string;
  101810. };
  101811. }
  101812. declare module BABYLON {
  101813. /** @hidden */
  101814. export var kernelBlurFragment: {
  101815. name: string;
  101816. shader: string;
  101817. };
  101818. }
  101819. declare module BABYLON {
  101820. /** @hidden */
  101821. export var kernelBlurFragment2: {
  101822. name: string;
  101823. shader: string;
  101824. };
  101825. }
  101826. declare module BABYLON {
  101827. /** @hidden */
  101828. export var kernelBlurPixelShader: {
  101829. name: string;
  101830. shader: string;
  101831. };
  101832. }
  101833. declare module BABYLON {
  101834. /** @hidden */
  101835. export var kernelBlurVertex: {
  101836. name: string;
  101837. shader: string;
  101838. };
  101839. }
  101840. declare module BABYLON {
  101841. /** @hidden */
  101842. export var kernelBlurVertexShader: {
  101843. name: string;
  101844. shader: string;
  101845. };
  101846. }
  101847. declare module BABYLON {
  101848. /**
  101849. * The Blur Post Process which blurs an image based on a kernel and direction.
  101850. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101851. */
  101852. export class BlurPostProcess extends PostProcess {
  101853. /** The direction in which to blur the image. */
  101854. direction: Vector2;
  101855. private blockCompilation;
  101856. protected _kernel: number;
  101857. protected _idealKernel: number;
  101858. protected _packedFloat: boolean;
  101859. private _staticDefines;
  101860. /**
  101861. * Sets the length in pixels of the blur sample region
  101862. */
  101863. set kernel(v: number);
  101864. /**
  101865. * Gets the length in pixels of the blur sample region
  101866. */
  101867. get kernel(): number;
  101868. /**
  101869. * Sets wether or not the blur needs to unpack/repack floats
  101870. */
  101871. set packedFloat(v: boolean);
  101872. /**
  101873. * Gets wether or not the blur is unpacking/repacking floats
  101874. */
  101875. get packedFloat(): boolean;
  101876. /**
  101877. * Creates a new instance BlurPostProcess
  101878. * @param name The name of the effect.
  101879. * @param direction The direction in which to blur the image.
  101880. * @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.
  101881. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101882. * @param camera The camera to apply the render pass to.
  101883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101884. * @param engine The engine which the post process will be applied. (default: current engine)
  101885. * @param reusable If the post process can be reused on the same frame. (default: false)
  101886. * @param textureType Type of textures used when performing the post process. (default: 0)
  101887. * @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)
  101888. */
  101889. constructor(name: string,
  101890. /** The direction in which to blur the image. */
  101891. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101892. /**
  101893. * Updates the effect with the current post process compile time values and recompiles the shader.
  101894. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101895. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101896. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101897. * @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
  101898. * @param onCompiled Called when the shader has been compiled.
  101899. * @param onError Called if there is an error when compiling a shader.
  101900. */
  101901. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101902. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101903. /**
  101904. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101905. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101906. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101907. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101908. * The gaps between physical kernels are compensated for in the weighting of the samples
  101909. * @param idealKernel Ideal blur kernel.
  101910. * @return Nearest best kernel.
  101911. */
  101912. protected _nearestBestKernel(idealKernel: number): number;
  101913. /**
  101914. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101915. * @param x The point on the Gaussian distribution to sample.
  101916. * @return the value of the Gaussian function at x.
  101917. */
  101918. protected _gaussianWeight(x: number): number;
  101919. /**
  101920. * Generates a string that can be used as a floating point number in GLSL.
  101921. * @param x Value to print.
  101922. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101923. * @return GLSL float string.
  101924. */
  101925. protected _glslFloat(x: number, decimalFigures?: number): string;
  101926. }
  101927. }
  101928. declare module BABYLON {
  101929. /**
  101930. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101931. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101932. * You can then easily use it as a reflectionTexture on a flat surface.
  101933. * In case the surface is not a plane, please consider relying on reflection probes.
  101934. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101935. */
  101936. export class MirrorTexture extends RenderTargetTexture {
  101937. private scene;
  101938. /**
  101939. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101940. * 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.
  101941. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101942. */
  101943. mirrorPlane: Plane;
  101944. /**
  101945. * Define the blur ratio used to blur the reflection if needed.
  101946. */
  101947. set blurRatio(value: number);
  101948. get blurRatio(): number;
  101949. /**
  101950. * Define the adaptive blur kernel used to blur the reflection if needed.
  101951. * This will autocompute the closest best match for the `blurKernel`
  101952. */
  101953. set adaptiveBlurKernel(value: number);
  101954. /**
  101955. * Define the blur kernel used to blur the reflection if needed.
  101956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101957. */
  101958. set blurKernel(value: number);
  101959. /**
  101960. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101961. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101962. */
  101963. set blurKernelX(value: number);
  101964. get blurKernelX(): number;
  101965. /**
  101966. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101968. */
  101969. set blurKernelY(value: number);
  101970. get blurKernelY(): number;
  101971. private _autoComputeBlurKernel;
  101972. protected _onRatioRescale(): void;
  101973. private _updateGammaSpace;
  101974. private _imageProcessingConfigChangeObserver;
  101975. private _transformMatrix;
  101976. private _mirrorMatrix;
  101977. private _savedViewMatrix;
  101978. private _blurX;
  101979. private _blurY;
  101980. private _adaptiveBlurKernel;
  101981. private _blurKernelX;
  101982. private _blurKernelY;
  101983. private _blurRatio;
  101984. /**
  101985. * Instantiates a Mirror Texture.
  101986. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101987. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101988. * You can then easily use it as a reflectionTexture on a flat surface.
  101989. * In case the surface is not a plane, please consider relying on reflection probes.
  101990. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101991. * @param name
  101992. * @param size
  101993. * @param scene
  101994. * @param generateMipMaps
  101995. * @param type
  101996. * @param samplingMode
  101997. * @param generateDepthBuffer
  101998. */
  101999. constructor(name: string, size: number | {
  102000. width: number;
  102001. height: number;
  102002. } | {
  102003. ratio: number;
  102004. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102005. private _preparePostProcesses;
  102006. /**
  102007. * Clone the mirror texture.
  102008. * @returns the cloned texture
  102009. */
  102010. clone(): MirrorTexture;
  102011. /**
  102012. * Serialize the texture to a JSON representation you could use in Parse later on
  102013. * @returns the serialized JSON representation
  102014. */
  102015. serialize(): any;
  102016. /**
  102017. * Dispose the texture and release its associated resources.
  102018. */
  102019. dispose(): void;
  102020. }
  102021. }
  102022. declare module BABYLON {
  102023. /**
  102024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102025. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102026. */
  102027. export class Texture extends BaseTexture {
  102028. /**
  102029. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102030. */
  102031. static SerializeBuffers: boolean;
  102032. /** @hidden */
  102033. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102034. /** @hidden */
  102035. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102036. /** @hidden */
  102037. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102038. /** nearest is mag = nearest and min = nearest and mip = linear */
  102039. static readonly NEAREST_SAMPLINGMODE: number;
  102040. /** nearest is mag = nearest and min = nearest and mip = linear */
  102041. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102043. static readonly BILINEAR_SAMPLINGMODE: number;
  102044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102045. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102046. /** Trilinear is mag = linear and min = linear and mip = linear */
  102047. static readonly TRILINEAR_SAMPLINGMODE: number;
  102048. /** Trilinear is mag = linear and min = linear and mip = linear */
  102049. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102050. /** mag = nearest and min = nearest and mip = nearest */
  102051. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102052. /** mag = nearest and min = linear and mip = nearest */
  102053. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102054. /** mag = nearest and min = linear and mip = linear */
  102055. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102056. /** mag = nearest and min = linear and mip = none */
  102057. static readonly NEAREST_LINEAR: number;
  102058. /** mag = nearest and min = nearest and mip = none */
  102059. static readonly NEAREST_NEAREST: number;
  102060. /** mag = linear and min = nearest and mip = nearest */
  102061. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102062. /** mag = linear and min = nearest and mip = linear */
  102063. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102064. /** mag = linear and min = linear and mip = none */
  102065. static readonly LINEAR_LINEAR: number;
  102066. /** mag = linear and min = nearest and mip = none */
  102067. static readonly LINEAR_NEAREST: number;
  102068. /** Explicit coordinates mode */
  102069. static readonly EXPLICIT_MODE: number;
  102070. /** Spherical coordinates mode */
  102071. static readonly SPHERICAL_MODE: number;
  102072. /** Planar coordinates mode */
  102073. static readonly PLANAR_MODE: number;
  102074. /** Cubic coordinates mode */
  102075. static readonly CUBIC_MODE: number;
  102076. /** Projection coordinates mode */
  102077. static readonly PROJECTION_MODE: number;
  102078. /** Inverse Cubic coordinates mode */
  102079. static readonly SKYBOX_MODE: number;
  102080. /** Inverse Cubic coordinates mode */
  102081. static readonly INVCUBIC_MODE: number;
  102082. /** Equirectangular coordinates mode */
  102083. static readonly EQUIRECTANGULAR_MODE: number;
  102084. /** Equirectangular Fixed coordinates mode */
  102085. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102086. /** Equirectangular Fixed Mirrored coordinates mode */
  102087. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102088. /** Texture is not repeating outside of 0..1 UVs */
  102089. static readonly CLAMP_ADDRESSMODE: number;
  102090. /** Texture is repeating outside of 0..1 UVs */
  102091. static readonly WRAP_ADDRESSMODE: number;
  102092. /** Texture is repeating and mirrored */
  102093. static readonly MIRROR_ADDRESSMODE: number;
  102094. /**
  102095. * 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
  102096. */
  102097. static UseSerializedUrlIfAny: boolean;
  102098. /**
  102099. * Define the url of the texture.
  102100. */
  102101. url: Nullable<string>;
  102102. /**
  102103. * Define an offset on the texture to offset the u coordinates of the UVs
  102104. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102105. */
  102106. uOffset: number;
  102107. /**
  102108. * Define an offset on the texture to offset the v coordinates of the UVs
  102109. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102110. */
  102111. vOffset: number;
  102112. /**
  102113. * Define an offset on the texture to scale the u coordinates of the UVs
  102114. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102115. */
  102116. uScale: number;
  102117. /**
  102118. * Define an offset on the texture to scale the v coordinates of the UVs
  102119. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102120. */
  102121. vScale: number;
  102122. /**
  102123. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102124. * @see https://doc.babylonjs.com/how_to/more_materials
  102125. */
  102126. uAng: number;
  102127. /**
  102128. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102129. * @see https://doc.babylonjs.com/how_to/more_materials
  102130. */
  102131. vAng: number;
  102132. /**
  102133. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102134. * @see https://doc.babylonjs.com/how_to/more_materials
  102135. */
  102136. wAng: number;
  102137. /**
  102138. * Defines the center of rotation (U)
  102139. */
  102140. uRotationCenter: number;
  102141. /**
  102142. * Defines the center of rotation (V)
  102143. */
  102144. vRotationCenter: number;
  102145. /**
  102146. * Defines the center of rotation (W)
  102147. */
  102148. wRotationCenter: number;
  102149. /**
  102150. * Are mip maps generated for this texture or not.
  102151. */
  102152. get noMipmap(): boolean;
  102153. /**
  102154. * List of inspectable custom properties (used by the Inspector)
  102155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102156. */
  102157. inspectableCustomProperties: Nullable<IInspectable[]>;
  102158. private _noMipmap;
  102159. /** @hidden */
  102160. _invertY: boolean;
  102161. private _rowGenerationMatrix;
  102162. private _cachedTextureMatrix;
  102163. private _projectionModeMatrix;
  102164. private _t0;
  102165. private _t1;
  102166. private _t2;
  102167. private _cachedUOffset;
  102168. private _cachedVOffset;
  102169. private _cachedUScale;
  102170. private _cachedVScale;
  102171. private _cachedUAng;
  102172. private _cachedVAng;
  102173. private _cachedWAng;
  102174. private _cachedProjectionMatrixId;
  102175. private _cachedCoordinatesMode;
  102176. /** @hidden */
  102177. protected _initialSamplingMode: number;
  102178. /** @hidden */
  102179. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102180. private _deleteBuffer;
  102181. protected _format: Nullable<number>;
  102182. private _delayedOnLoad;
  102183. private _delayedOnError;
  102184. private _mimeType?;
  102185. /**
  102186. * Observable triggered once the texture has been loaded.
  102187. */
  102188. onLoadObservable: Observable<Texture>;
  102189. protected _isBlocking: boolean;
  102190. /**
  102191. * Is the texture preventing material to render while loading.
  102192. * If false, a default texture will be used instead of the loading one during the preparation step.
  102193. */
  102194. set isBlocking(value: boolean);
  102195. get isBlocking(): boolean;
  102196. /**
  102197. * Get the current sampling mode associated with the texture.
  102198. */
  102199. get samplingMode(): number;
  102200. /**
  102201. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102202. */
  102203. get invertY(): boolean;
  102204. /**
  102205. * Instantiates a new texture.
  102206. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102207. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102208. * @param url defines the url of the picture to load as a texture
  102209. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102210. * @param noMipmap defines if the texture will require mip maps or not
  102211. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102212. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102213. * @param onLoad defines a callback triggered when the texture has been loaded
  102214. * @param onError defines a callback triggered when an error occurred during the loading session
  102215. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102216. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102217. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102218. * @param mimeType defines an optional mime type information
  102219. */
  102220. 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);
  102221. /**
  102222. * Update the url (and optional buffer) of this texture if url was null during construction.
  102223. * @param url the url of the texture
  102224. * @param buffer the buffer of the texture (defaults to null)
  102225. * @param onLoad callback called when the texture is loaded (defaults to null)
  102226. */
  102227. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102228. /**
  102229. * Finish the loading sequence of a texture flagged as delayed load.
  102230. * @hidden
  102231. */
  102232. delayLoad(): void;
  102233. private _prepareRowForTextureGeneration;
  102234. /**
  102235. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102236. * @returns the transform matrix of the texture.
  102237. */
  102238. getTextureMatrix(uBase?: number): Matrix;
  102239. /**
  102240. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102241. * @returns The reflection texture transform
  102242. */
  102243. getReflectionTextureMatrix(): Matrix;
  102244. /**
  102245. * Clones the texture.
  102246. * @returns the cloned texture
  102247. */
  102248. clone(): Texture;
  102249. /**
  102250. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102251. * @returns The JSON representation of the texture
  102252. */
  102253. serialize(): any;
  102254. /**
  102255. * Get the current class name of the texture useful for serialization or dynamic coding.
  102256. * @returns "Texture"
  102257. */
  102258. getClassName(): string;
  102259. /**
  102260. * Dispose the texture and release its associated resources.
  102261. */
  102262. dispose(): void;
  102263. /**
  102264. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102265. * @param parsedTexture Define the JSON representation of the texture
  102266. * @param scene Define the scene the parsed texture should be instantiated in
  102267. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102268. * @returns The parsed texture if successful
  102269. */
  102270. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102271. /**
  102272. * Creates a texture from its base 64 representation.
  102273. * @param data Define the base64 payload without the data: prefix
  102274. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102275. * @param scene Define the scene the texture should belong to
  102276. * @param noMipmap Forces the texture to not create mip map information if true
  102277. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102278. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102279. * @param onLoad define a callback triggered when the texture has been loaded
  102280. * @param onError define a callback triggered when an error occurred during the loading session
  102281. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102282. * @returns the created texture
  102283. */
  102284. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102285. /**
  102286. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102287. * @param data Define the base64 payload without the data: prefix
  102288. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102290. * @param scene Define the scene the texture should belong to
  102291. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102292. * @param noMipmap Forces the texture to not create mip map information if true
  102293. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102294. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102295. * @param onLoad define a callback triggered when the texture has been loaded
  102296. * @param onError define a callback triggered when an error occurred during the loading session
  102297. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102298. * @returns the created texture
  102299. */
  102300. 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;
  102301. }
  102302. }
  102303. declare module BABYLON {
  102304. /**
  102305. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102306. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102307. */
  102308. export class PostProcessManager {
  102309. private _scene;
  102310. private _indexBuffer;
  102311. private _vertexBuffers;
  102312. /**
  102313. * Creates a new instance PostProcess
  102314. * @param scene The scene that the post process is associated with.
  102315. */
  102316. constructor(scene: Scene);
  102317. private _prepareBuffers;
  102318. private _buildIndexBuffer;
  102319. /**
  102320. * Rebuilds the vertex buffers of the manager.
  102321. * @hidden
  102322. */
  102323. _rebuild(): void;
  102324. /**
  102325. * Prepares a frame to be run through a post process.
  102326. * @param sourceTexture The input texture to the post procesess. (default: null)
  102327. * @param postProcesses An array of post processes to be run. (default: null)
  102328. * @returns True if the post processes were able to be run.
  102329. * @hidden
  102330. */
  102331. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102332. /**
  102333. * Manually render a set of post processes to a texture.
  102334. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102335. * @param postProcesses An array of post processes to be run.
  102336. * @param targetTexture The target texture to render to.
  102337. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102338. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102339. * @param lodLevel defines which lod of the texture to render to
  102340. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102341. */
  102342. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102343. /**
  102344. * Finalize the result of the output of the postprocesses.
  102345. * @param doNotPresent If true the result will not be displayed to the screen.
  102346. * @param targetTexture The target texture to render to.
  102347. * @param faceIndex The index of the face to bind the target texture to.
  102348. * @param postProcesses The array of post processes to render.
  102349. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102350. * @hidden
  102351. */
  102352. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102353. /**
  102354. * Disposes of the post process manager.
  102355. */
  102356. dispose(): void;
  102357. }
  102358. }
  102359. declare module BABYLON {
  102360. /**
  102361. * This Helps creating a texture that will be created from a camera in your scene.
  102362. * It is basically a dynamic texture that could be used to create special effects for instance.
  102363. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102364. */
  102365. export class RenderTargetTexture extends Texture {
  102366. isCube: boolean;
  102367. /**
  102368. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102369. */
  102370. static readonly REFRESHRATE_RENDER_ONCE: number;
  102371. /**
  102372. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102373. */
  102374. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102375. /**
  102376. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102377. * the central point of your effect and can save a lot of performances.
  102378. */
  102379. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102380. /**
  102381. * Use this predicate to dynamically define the list of mesh you want to render.
  102382. * If set, the renderList property will be overwritten.
  102383. */
  102384. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102385. private _renderList;
  102386. /**
  102387. * Use this list to define the list of mesh you want to render.
  102388. */
  102389. get renderList(): Nullable<Array<AbstractMesh>>;
  102390. set renderList(value: Nullable<Array<AbstractMesh>>);
  102391. /**
  102392. * Use this function to overload the renderList array at rendering time.
  102393. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102394. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102395. * the cube (if the RTT is a cube, else layerOrFace=0).
  102396. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102397. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102398. * hold dummy elements!
  102399. */
  102400. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102401. private _hookArray;
  102402. /**
  102403. * Define if particles should be rendered in your texture.
  102404. */
  102405. renderParticles: boolean;
  102406. /**
  102407. * Define if sprites should be rendered in your texture.
  102408. */
  102409. renderSprites: boolean;
  102410. /**
  102411. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102412. */
  102413. coordinatesMode: number;
  102414. /**
  102415. * Define the camera used to render the texture.
  102416. */
  102417. activeCamera: Nullable<Camera>;
  102418. /**
  102419. * Override the mesh isReady function with your own one.
  102420. */
  102421. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102422. /**
  102423. * Override the render function of the texture with your own one.
  102424. */
  102425. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102426. /**
  102427. * Define if camera post processes should be use while rendering the texture.
  102428. */
  102429. useCameraPostProcesses: boolean;
  102430. /**
  102431. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102432. */
  102433. ignoreCameraViewport: boolean;
  102434. private _postProcessManager;
  102435. private _postProcesses;
  102436. private _resizeObserver;
  102437. /**
  102438. * An event triggered when the texture is unbind.
  102439. */
  102440. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102441. /**
  102442. * An event triggered when the texture is unbind.
  102443. */
  102444. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102445. private _onAfterUnbindObserver;
  102446. /**
  102447. * Set a after unbind callback in the texture.
  102448. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102449. */
  102450. set onAfterUnbind(callback: () => void);
  102451. /**
  102452. * An event triggered before rendering the texture
  102453. */
  102454. onBeforeRenderObservable: Observable<number>;
  102455. private _onBeforeRenderObserver;
  102456. /**
  102457. * Set a before render callback in the texture.
  102458. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102459. */
  102460. set onBeforeRender(callback: (faceIndex: number) => void);
  102461. /**
  102462. * An event triggered after rendering the texture
  102463. */
  102464. onAfterRenderObservable: Observable<number>;
  102465. private _onAfterRenderObserver;
  102466. /**
  102467. * Set a after render callback in the texture.
  102468. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102469. */
  102470. set onAfterRender(callback: (faceIndex: number) => void);
  102471. /**
  102472. * An event triggered after the texture clear
  102473. */
  102474. onClearObservable: Observable<Engine>;
  102475. private _onClearObserver;
  102476. /**
  102477. * Set a clear callback in the texture.
  102478. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102479. */
  102480. set onClear(callback: (Engine: Engine) => void);
  102481. /**
  102482. * An event triggered when the texture is resized.
  102483. */
  102484. onResizeObservable: Observable<RenderTargetTexture>;
  102485. /**
  102486. * Define the clear color of the Render Target if it should be different from the scene.
  102487. */
  102488. clearColor: Color4;
  102489. protected _size: number | {
  102490. width: number;
  102491. height: number;
  102492. layers?: number;
  102493. };
  102494. protected _initialSizeParameter: number | {
  102495. width: number;
  102496. height: number;
  102497. } | {
  102498. ratio: number;
  102499. };
  102500. protected _sizeRatio: Nullable<number>;
  102501. /** @hidden */
  102502. _generateMipMaps: boolean;
  102503. protected _renderingManager: RenderingManager;
  102504. /** @hidden */
  102505. _waitingRenderList: string[];
  102506. protected _doNotChangeAspectRatio: boolean;
  102507. protected _currentRefreshId: number;
  102508. protected _refreshRate: number;
  102509. protected _textureMatrix: Matrix;
  102510. protected _samples: number;
  102511. protected _renderTargetOptions: RenderTargetCreationOptions;
  102512. /**
  102513. * Gets render target creation options that were used.
  102514. */
  102515. get renderTargetOptions(): RenderTargetCreationOptions;
  102516. protected _onRatioRescale(): void;
  102517. /**
  102518. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102519. * It must define where the camera used to render the texture is set
  102520. */
  102521. boundingBoxPosition: Vector3;
  102522. private _boundingBoxSize;
  102523. /**
  102524. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102525. * When defined, the cubemap will switch to local mode
  102526. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102527. * @example https://www.babylonjs-playground.com/#RNASML
  102528. */
  102529. set boundingBoxSize(value: Vector3);
  102530. get boundingBoxSize(): Vector3;
  102531. /**
  102532. * In case the RTT has been created with a depth texture, get the associated
  102533. * depth texture.
  102534. * Otherwise, return null.
  102535. */
  102536. get depthStencilTexture(): Nullable<InternalTexture>;
  102537. /**
  102538. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102539. * or used a shadow, depth texture...
  102540. * @param name The friendly name of the texture
  102541. * @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)
  102542. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102543. * @param generateMipMaps True if mip maps need to be generated after render.
  102544. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102545. * @param type The type of the buffer in the RTT (int, half float, float...)
  102546. * @param isCube True if a cube texture needs to be created
  102547. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102548. * @param generateDepthBuffer True to generate a depth buffer
  102549. * @param generateStencilBuffer True to generate a stencil buffer
  102550. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102551. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102552. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102553. */
  102554. constructor(name: string, size: number | {
  102555. width: number;
  102556. height: number;
  102557. layers?: number;
  102558. } | {
  102559. ratio: number;
  102560. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102561. /**
  102562. * Creates a depth stencil texture.
  102563. * This is only available in WebGL 2 or with the depth texture extension available.
  102564. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102565. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102566. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102567. */
  102568. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102569. private _processSizeParameter;
  102570. /**
  102571. * Define the number of samples to use in case of MSAA.
  102572. * It defaults to one meaning no MSAA has been enabled.
  102573. */
  102574. get samples(): number;
  102575. set samples(value: number);
  102576. /**
  102577. * Resets the refresh counter of the texture and start bak from scratch.
  102578. * Could be useful to regenerate the texture if it is setup to render only once.
  102579. */
  102580. resetRefreshCounter(): void;
  102581. /**
  102582. * Define the refresh rate of the texture or the rendering frequency.
  102583. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102584. */
  102585. get refreshRate(): number;
  102586. set refreshRate(value: number);
  102587. /**
  102588. * Adds a post process to the render target rendering passes.
  102589. * @param postProcess define the post process to add
  102590. */
  102591. addPostProcess(postProcess: PostProcess): void;
  102592. /**
  102593. * Clear all the post processes attached to the render target
  102594. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102595. */
  102596. clearPostProcesses(dispose?: boolean): void;
  102597. /**
  102598. * Remove one of the post process from the list of attached post processes to the texture
  102599. * @param postProcess define the post process to remove from the list
  102600. */
  102601. removePostProcess(postProcess: PostProcess): void;
  102602. /** @hidden */
  102603. _shouldRender(): boolean;
  102604. /**
  102605. * Gets the actual render size of the texture.
  102606. * @returns the width of the render size
  102607. */
  102608. getRenderSize(): number;
  102609. /**
  102610. * Gets the actual render width of the texture.
  102611. * @returns the width of the render size
  102612. */
  102613. getRenderWidth(): number;
  102614. /**
  102615. * Gets the actual render height of the texture.
  102616. * @returns the height of the render size
  102617. */
  102618. getRenderHeight(): number;
  102619. /**
  102620. * Gets the actual number of layers of the texture.
  102621. * @returns the number of layers
  102622. */
  102623. getRenderLayers(): number;
  102624. /**
  102625. * Get if the texture can be rescaled or not.
  102626. */
  102627. get canRescale(): boolean;
  102628. /**
  102629. * Resize the texture using a ratio.
  102630. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102631. */
  102632. scale(ratio: number): void;
  102633. /**
  102634. * Get the texture reflection matrix used to rotate/transform the reflection.
  102635. * @returns the reflection matrix
  102636. */
  102637. getReflectionTextureMatrix(): Matrix;
  102638. /**
  102639. * Resize the texture to a new desired size.
  102640. * Be carrefull as it will recreate all the data in the new texture.
  102641. * @param size Define the new size. It can be:
  102642. * - a number for squared texture,
  102643. * - an object containing { width: number, height: number }
  102644. * - or an object containing a ratio { ratio: number }
  102645. */
  102646. resize(size: number | {
  102647. width: number;
  102648. height: number;
  102649. } | {
  102650. ratio: number;
  102651. }): void;
  102652. private _defaultRenderListPrepared;
  102653. /**
  102654. * Renders all the objects from the render list into the texture.
  102655. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102656. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102657. */
  102658. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102659. private _bestReflectionRenderTargetDimension;
  102660. private _prepareRenderingManager;
  102661. /**
  102662. * @hidden
  102663. * @param faceIndex face index to bind to if this is a cubetexture
  102664. * @param layer defines the index of the texture to bind in the array
  102665. */
  102666. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102667. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102668. private renderToTarget;
  102669. /**
  102670. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102671. * This allowed control for front to back rendering or reversly depending of the special needs.
  102672. *
  102673. * @param renderingGroupId The rendering group id corresponding to its index
  102674. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102675. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102676. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102677. */
  102678. 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;
  102679. /**
  102680. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102681. *
  102682. * @param renderingGroupId The rendering group id corresponding to its index
  102683. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102684. */
  102685. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102686. /**
  102687. * Clones the texture.
  102688. * @returns the cloned texture
  102689. */
  102690. clone(): RenderTargetTexture;
  102691. /**
  102692. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102693. * @returns The JSON representation of the texture
  102694. */
  102695. serialize(): any;
  102696. /**
  102697. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102698. */
  102699. disposeFramebufferObjects(): void;
  102700. /**
  102701. * Dispose the texture and release its associated resources.
  102702. */
  102703. dispose(): void;
  102704. /** @hidden */
  102705. _rebuild(): void;
  102706. /**
  102707. * Clear the info related to rendering groups preventing retention point in material dispose.
  102708. */
  102709. freeRenderingGroups(): void;
  102710. /**
  102711. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102712. * @returns the view count
  102713. */
  102714. getViewCount(): number;
  102715. }
  102716. }
  102717. declare module BABYLON {
  102718. /**
  102719. * Class used to manipulate GUIDs
  102720. */
  102721. export class GUID {
  102722. /**
  102723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102724. * Be aware Math.random() could cause collisions, but:
  102725. * "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"
  102726. * @returns a pseudo random id
  102727. */
  102728. static RandomId(): string;
  102729. }
  102730. }
  102731. declare module BABYLON {
  102732. /**
  102733. * Options to be used when creating a shadow depth material
  102734. */
  102735. export interface IIOptionShadowDepthMaterial {
  102736. /** Variables in the vertex shader code that need to have their names remapped.
  102737. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102738. * "var_name" should be either: worldPos or vNormalW
  102739. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102740. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102741. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102742. */
  102743. remappedVariables?: string[];
  102744. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102745. standalone?: boolean;
  102746. }
  102747. /**
  102748. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102749. */
  102750. export class ShadowDepthWrapper {
  102751. private _scene;
  102752. private _options?;
  102753. private _baseMaterial;
  102754. private _onEffectCreatedObserver;
  102755. private _subMeshToEffect;
  102756. private _subMeshToDepthEffect;
  102757. private _meshes;
  102758. /** @hidden */
  102759. _matriceNames: any;
  102760. /** Gets the standalone status of the wrapper */
  102761. get standalone(): boolean;
  102762. /** Gets the base material the wrapper is built upon */
  102763. get baseMaterial(): Material;
  102764. /**
  102765. * Instantiate a new shadow depth wrapper.
  102766. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102767. * generate the shadow depth map. For more information, please refer to the documentation:
  102768. * https://doc.babylonjs.com/babylon101/shadows
  102769. * @param baseMaterial Material to wrap
  102770. * @param scene Define the scene the material belongs to
  102771. * @param options Options used to create the wrapper
  102772. */
  102773. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102774. /**
  102775. * Gets the effect to use to generate the depth map
  102776. * @param subMesh subMesh to get the effect for
  102777. * @param shadowGenerator shadow generator to get the effect for
  102778. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102779. */
  102780. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102781. /**
  102782. * Specifies that the submesh is ready to be used for depth rendering
  102783. * @param subMesh submesh to check
  102784. * @param defines the list of defines to take into account when checking the effect
  102785. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102786. * @param useInstances specifies that instances should be used
  102787. * @returns a boolean indicating that the submesh is ready or not
  102788. */
  102789. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102790. /**
  102791. * Disposes the resources
  102792. */
  102793. dispose(): void;
  102794. private _makeEffect;
  102795. }
  102796. }
  102797. declare module BABYLON {
  102798. interface ThinEngine {
  102799. /**
  102800. * Unbind a list of render target textures from the webGL context
  102801. * This is used only when drawBuffer extension or webGL2 are active
  102802. * @param textures defines the render target textures to unbind
  102803. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102804. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102805. */
  102806. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102807. /**
  102808. * Create a multi render target texture
  102809. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102810. * @param size defines the size of the texture
  102811. * @param options defines the creation options
  102812. * @returns the cube texture as an InternalTexture
  102813. */
  102814. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102815. /**
  102816. * Update the sample count for a given multiple render target texture
  102817. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102818. * @param textures defines the textures to update
  102819. * @param samples defines the sample count to set
  102820. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102821. */
  102822. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102823. /**
  102824. * Select a subsets of attachments to draw to.
  102825. * @param attachments gl attachments
  102826. */
  102827. bindAttachments(attachments: number[]): void;
  102828. }
  102829. }
  102830. declare module BABYLON {
  102831. /**
  102832. * Creation options of the multi render target texture.
  102833. */
  102834. export interface IMultiRenderTargetOptions {
  102835. /**
  102836. * Define if the texture needs to create mip maps after render.
  102837. */
  102838. generateMipMaps?: boolean;
  102839. /**
  102840. * Define the types of all the draw buffers we want to create
  102841. */
  102842. types?: number[];
  102843. /**
  102844. * Define the sampling modes of all the draw buffers we want to create
  102845. */
  102846. samplingModes?: number[];
  102847. /**
  102848. * Define if a depth buffer is required
  102849. */
  102850. generateDepthBuffer?: boolean;
  102851. /**
  102852. * Define if a stencil buffer is required
  102853. */
  102854. generateStencilBuffer?: boolean;
  102855. /**
  102856. * Define if a depth texture is required instead of a depth buffer
  102857. */
  102858. generateDepthTexture?: boolean;
  102859. /**
  102860. * Define the number of desired draw buffers
  102861. */
  102862. textureCount?: number;
  102863. /**
  102864. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102865. */
  102866. doNotChangeAspectRatio?: boolean;
  102867. /**
  102868. * Define the default type of the buffers we are creating
  102869. */
  102870. defaultType?: number;
  102871. }
  102872. /**
  102873. * A multi render target, like a render target provides the ability to render to a texture.
  102874. * Unlike the render target, it can render to several draw buffers in one draw.
  102875. * This is specially interesting in deferred rendering or for any effects requiring more than
  102876. * just one color from a single pass.
  102877. */
  102878. export class MultiRenderTarget extends RenderTargetTexture {
  102879. private _internalTextures;
  102880. private _textures;
  102881. private _multiRenderTargetOptions;
  102882. private _count;
  102883. /**
  102884. * Get if draw buffers are currently supported by the used hardware and browser.
  102885. */
  102886. get isSupported(): boolean;
  102887. /**
  102888. * Get the list of textures generated by the multi render target.
  102889. */
  102890. get textures(): Texture[];
  102891. /**
  102892. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102893. */
  102894. get count(): number;
  102895. /**
  102896. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102897. */
  102898. get depthTexture(): Texture;
  102899. /**
  102900. * Set the wrapping mode on U of all the textures we are rendering to.
  102901. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102902. */
  102903. set wrapU(wrap: number);
  102904. /**
  102905. * Set the wrapping mode on V of all the textures we are rendering to.
  102906. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102907. */
  102908. set wrapV(wrap: number);
  102909. /**
  102910. * Instantiate a new multi render target texture.
  102911. * A multi render target, like a render target provides the ability to render to a texture.
  102912. * Unlike the render target, it can render to several draw buffers in one draw.
  102913. * This is specially interesting in deferred rendering or for any effects requiring more than
  102914. * just one color from a single pass.
  102915. * @param name Define the name of the texture
  102916. * @param size Define the size of the buffers to render to
  102917. * @param count Define the number of target we are rendering into
  102918. * @param scene Define the scene the texture belongs to
  102919. * @param options Define the options used to create the multi render target
  102920. */
  102921. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102922. /** @hidden */
  102923. _rebuild(): void;
  102924. private _createInternalTextures;
  102925. private _createTextures;
  102926. /**
  102927. * Define the number of samples used if MSAA is enabled.
  102928. */
  102929. get samples(): number;
  102930. set samples(value: number);
  102931. /**
  102932. * Resize all the textures in the multi render target.
  102933. * Be carrefull as it will recreate all the data in the new texture.
  102934. * @param size Define the new size
  102935. */
  102936. resize(size: any): void;
  102937. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102938. /**
  102939. * Dispose the render targets and their associated resources
  102940. */
  102941. dispose(): void;
  102942. /**
  102943. * Release all the underlying texture used as draw buffers.
  102944. */
  102945. releaseInternalTextures(): void;
  102946. }
  102947. }
  102948. declare module BABYLON {
  102949. /** @hidden */
  102950. export var imageProcessingPixelShader: {
  102951. name: string;
  102952. shader: string;
  102953. };
  102954. }
  102955. declare module BABYLON {
  102956. /**
  102957. * ImageProcessingPostProcess
  102958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102959. */
  102960. export class ImageProcessingPostProcess extends PostProcess {
  102961. /**
  102962. * Default configuration related to image processing available in the PBR Material.
  102963. */
  102964. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102965. /**
  102966. * Gets the image processing configuration used either in this material.
  102967. */
  102968. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102969. /**
  102970. * Sets the Default image processing configuration used either in the this material.
  102971. *
  102972. * If sets to null, the scene one is in use.
  102973. */
  102974. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102975. /**
  102976. * Keep track of the image processing observer to allow dispose and replace.
  102977. */
  102978. private _imageProcessingObserver;
  102979. /**
  102980. * Attaches a new image processing configuration to the PBR Material.
  102981. * @param configuration
  102982. */
  102983. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102984. /**
  102985. * If the post process is supported.
  102986. */
  102987. get isSupported(): boolean;
  102988. /**
  102989. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102990. */
  102991. get colorCurves(): Nullable<ColorCurves>;
  102992. /**
  102993. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102994. */
  102995. set colorCurves(value: Nullable<ColorCurves>);
  102996. /**
  102997. * Gets wether the color curves effect is enabled.
  102998. */
  102999. get colorCurvesEnabled(): boolean;
  103000. /**
  103001. * Sets wether the color curves effect is enabled.
  103002. */
  103003. set colorCurvesEnabled(value: boolean);
  103004. /**
  103005. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103006. */
  103007. get colorGradingTexture(): Nullable<BaseTexture>;
  103008. /**
  103009. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103010. */
  103011. set colorGradingTexture(value: Nullable<BaseTexture>);
  103012. /**
  103013. * Gets wether the color grading effect is enabled.
  103014. */
  103015. get colorGradingEnabled(): boolean;
  103016. /**
  103017. * Gets wether the color grading effect is enabled.
  103018. */
  103019. set colorGradingEnabled(value: boolean);
  103020. /**
  103021. * Gets exposure used in the effect.
  103022. */
  103023. get exposure(): number;
  103024. /**
  103025. * Sets exposure used in the effect.
  103026. */
  103027. set exposure(value: number);
  103028. /**
  103029. * Gets wether tonemapping is enabled or not.
  103030. */
  103031. get toneMappingEnabled(): boolean;
  103032. /**
  103033. * Sets wether tonemapping is enabled or not
  103034. */
  103035. set toneMappingEnabled(value: boolean);
  103036. /**
  103037. * Gets the type of tone mapping effect.
  103038. */
  103039. get toneMappingType(): number;
  103040. /**
  103041. * Sets the type of tone mapping effect.
  103042. */
  103043. set toneMappingType(value: number);
  103044. /**
  103045. * Gets contrast used in the effect.
  103046. */
  103047. get contrast(): number;
  103048. /**
  103049. * Sets contrast used in the effect.
  103050. */
  103051. set contrast(value: number);
  103052. /**
  103053. * Gets Vignette stretch size.
  103054. */
  103055. get vignetteStretch(): number;
  103056. /**
  103057. * Sets Vignette stretch size.
  103058. */
  103059. set vignetteStretch(value: number);
  103060. /**
  103061. * Gets Vignette centre X Offset.
  103062. */
  103063. get vignetteCentreX(): number;
  103064. /**
  103065. * Sets Vignette centre X Offset.
  103066. */
  103067. set vignetteCentreX(value: number);
  103068. /**
  103069. * Gets Vignette centre Y Offset.
  103070. */
  103071. get vignetteCentreY(): number;
  103072. /**
  103073. * Sets Vignette centre Y Offset.
  103074. */
  103075. set vignetteCentreY(value: number);
  103076. /**
  103077. * Gets Vignette weight or intensity of the vignette effect.
  103078. */
  103079. get vignetteWeight(): number;
  103080. /**
  103081. * Sets Vignette weight or intensity of the vignette effect.
  103082. */
  103083. set vignetteWeight(value: number);
  103084. /**
  103085. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103086. * if vignetteEnabled is set to true.
  103087. */
  103088. get vignetteColor(): Color4;
  103089. /**
  103090. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103091. * if vignetteEnabled is set to true.
  103092. */
  103093. set vignetteColor(value: Color4);
  103094. /**
  103095. * Gets Camera field of view used by the Vignette effect.
  103096. */
  103097. get vignetteCameraFov(): number;
  103098. /**
  103099. * Sets Camera field of view used by the Vignette effect.
  103100. */
  103101. set vignetteCameraFov(value: number);
  103102. /**
  103103. * Gets the vignette blend mode allowing different kind of effect.
  103104. */
  103105. get vignetteBlendMode(): number;
  103106. /**
  103107. * Sets the vignette blend mode allowing different kind of effect.
  103108. */
  103109. set vignetteBlendMode(value: number);
  103110. /**
  103111. * Gets wether the vignette effect is enabled.
  103112. */
  103113. get vignetteEnabled(): boolean;
  103114. /**
  103115. * Sets wether the vignette effect is enabled.
  103116. */
  103117. set vignetteEnabled(value: boolean);
  103118. private _fromLinearSpace;
  103119. /**
  103120. * Gets wether the input of the processing is in Gamma or Linear Space.
  103121. */
  103122. get fromLinearSpace(): boolean;
  103123. /**
  103124. * Sets wether the input of the processing is in Gamma or Linear Space.
  103125. */
  103126. set fromLinearSpace(value: boolean);
  103127. /**
  103128. * Defines cache preventing GC.
  103129. */
  103130. private _defines;
  103131. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103132. /**
  103133. * "ImageProcessingPostProcess"
  103134. * @returns "ImageProcessingPostProcess"
  103135. */
  103136. getClassName(): string;
  103137. /**
  103138. * @hidden
  103139. */
  103140. _updateParameters(): void;
  103141. dispose(camera?: Camera): void;
  103142. }
  103143. }
  103144. declare module BABYLON {
  103145. /** @hidden */
  103146. export var fibonacci: {
  103147. name: string;
  103148. shader: string;
  103149. };
  103150. }
  103151. declare module BABYLON {
  103152. /** @hidden */
  103153. export var subSurfaceScatteringFunctions: {
  103154. name: string;
  103155. shader: string;
  103156. };
  103157. }
  103158. declare module BABYLON {
  103159. /** @hidden */
  103160. export var diffusionProfile: {
  103161. name: string;
  103162. shader: string;
  103163. };
  103164. }
  103165. declare module BABYLON {
  103166. /** @hidden */
  103167. export var subSurfaceScatteringPixelShader: {
  103168. name: string;
  103169. shader: string;
  103170. };
  103171. }
  103172. declare module BABYLON {
  103173. /**
  103174. * Sub surface scattering post process
  103175. */
  103176. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103177. /** @hidden */
  103178. texelWidth: number;
  103179. /** @hidden */
  103180. texelHeight: number;
  103181. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103182. }
  103183. }
  103184. declare module BABYLON {
  103185. /**
  103186. * Interface for defining prepass effects in the prepass post-process pipeline
  103187. */
  103188. export interface PrePassEffectConfiguration {
  103189. /**
  103190. * Post process to attach for this effect
  103191. */
  103192. postProcess: PostProcess;
  103193. /**
  103194. * Is the effect enabled
  103195. */
  103196. enabled: boolean;
  103197. /**
  103198. * Disposes the effect configuration
  103199. */
  103200. dispose(): void;
  103201. /**
  103202. * Disposes the effect configuration
  103203. */
  103204. createPostProcess: () => PostProcess;
  103205. }
  103206. }
  103207. declare module BABYLON {
  103208. /**
  103209. * Contains all parameters needed for the prepass to perform
  103210. * screen space subsurface scattering
  103211. */
  103212. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103213. private _ssDiffusionS;
  103214. private _ssFilterRadii;
  103215. private _ssDiffusionD;
  103216. /**
  103217. * Post process to attach for screen space subsurface scattering
  103218. */
  103219. postProcess: SubSurfaceScatteringPostProcess;
  103220. /**
  103221. * Diffusion profile color for subsurface scattering
  103222. */
  103223. get ssDiffusionS(): number[];
  103224. /**
  103225. * Diffusion profile max color channel value for subsurface scattering
  103226. */
  103227. get ssDiffusionD(): number[];
  103228. /**
  103229. * Diffusion profile filter radius for subsurface scattering
  103230. */
  103231. get ssFilterRadii(): number[];
  103232. /**
  103233. * Is subsurface enabled
  103234. */
  103235. enabled: boolean;
  103236. /**
  103237. * Diffusion profile colors for subsurface scattering
  103238. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103239. * See ...
  103240. * Note that you can only store up to 5 of them
  103241. */
  103242. ssDiffusionProfileColors: Color3[];
  103243. /**
  103244. * Defines the ratio real world => scene units.
  103245. * Used for subsurface scattering
  103246. */
  103247. metersPerUnit: number;
  103248. private _scene;
  103249. /**
  103250. * Builds a subsurface configuration object
  103251. * @param scene The scene
  103252. */
  103253. constructor(scene: Scene);
  103254. /**
  103255. * Adds a new diffusion profile.
  103256. * Useful for more realistic subsurface scattering on diverse materials.
  103257. * @param color The color of the diffusion profile. Should be the average color of the material.
  103258. * @return The index of the diffusion profile for the material subsurface configuration
  103259. */
  103260. addDiffusionProfile(color: Color3): number;
  103261. /**
  103262. * Creates the sss post process
  103263. * @return The created post process
  103264. */
  103265. createPostProcess(): SubSurfaceScatteringPostProcess;
  103266. /**
  103267. * Deletes all diffusion profiles.
  103268. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103269. */
  103270. clearAllDiffusionProfiles(): void;
  103271. /**
  103272. * Disposes this object
  103273. */
  103274. dispose(): void;
  103275. /**
  103276. * @hidden
  103277. * https://zero-radiance.github.io/post/sampling-diffusion/
  103278. *
  103279. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103280. * ------------------------------------------------------------------------------------
  103281. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103282. * PDF[r, phi, s] = r * R[r, phi, s]
  103283. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103284. * ------------------------------------------------------------------------------------
  103285. * We importance sample the color channel with the widest scattering distance.
  103286. */
  103287. getDiffusionProfileParameters(color: Color3): number;
  103288. /**
  103289. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103290. * 'u' is the random number (the value of the CDF): [0, 1).
  103291. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103292. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103293. */
  103294. private _sampleBurleyDiffusionProfile;
  103295. }
  103296. }
  103297. declare module BABYLON {
  103298. /**
  103299. * Renders a pre pass of the scene
  103300. * This means every mesh in the scene will be rendered to a render target texture
  103301. * And then this texture will be composited to the rendering canvas with post processes
  103302. * It is necessary for effects like subsurface scattering or deferred shading
  103303. */
  103304. export class PrePassRenderer {
  103305. /** @hidden */
  103306. static _SceneComponentInitialization: (scene: Scene) => void;
  103307. private _scene;
  103308. private _engine;
  103309. private _isDirty;
  103310. /**
  103311. * Number of textures in the multi render target texture where the scene is directly rendered
  103312. */
  103313. readonly mrtCount: number;
  103314. /**
  103315. * The render target where the scene is directly rendered
  103316. */
  103317. prePassRT: MultiRenderTarget;
  103318. private _mrtTypes;
  103319. private _multiRenderAttachments;
  103320. private _defaultAttachments;
  103321. private _clearAttachments;
  103322. private _postProcesses;
  103323. private readonly _clearColor;
  103324. /**
  103325. * Image processing post process for composition
  103326. */
  103327. imageProcessingPostProcess: ImageProcessingPostProcess;
  103328. /**
  103329. * Configuration for sub surface scattering post process
  103330. */
  103331. subSurfaceConfiguration: SubSurfaceConfiguration;
  103332. /**
  103333. * Should materials render their geometry on the MRT
  103334. */
  103335. materialsShouldRenderGeometry: boolean;
  103336. /**
  103337. * Should materials render the irradiance information on the MRT
  103338. */
  103339. materialsShouldRenderIrradiance: boolean;
  103340. private _enabled;
  103341. /**
  103342. * Indicates if the prepass is enabled
  103343. */
  103344. get enabled(): boolean;
  103345. /**
  103346. * How many samples are used for MSAA of the scene render target
  103347. */
  103348. get samples(): number;
  103349. set samples(n: number);
  103350. /**
  103351. * Instanciates a prepass renderer
  103352. * @param scene The scene
  103353. */
  103354. constructor(scene: Scene);
  103355. private _initializeAttachments;
  103356. private _createCompositionEffect;
  103357. /**
  103358. * Indicates if rendering a prepass is supported
  103359. */
  103360. get isSupported(): boolean;
  103361. /**
  103362. * Sets the proper output textures to draw in the engine.
  103363. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103364. */
  103365. bindAttachmentsForEffect(effect: Effect): void;
  103366. /**
  103367. * @hidden
  103368. */
  103369. _beforeCameraDraw(): void;
  103370. /**
  103371. * @hidden
  103372. */
  103373. _afterCameraDraw(): void;
  103374. private _checkRTSize;
  103375. private _bindFrameBuffer;
  103376. /**
  103377. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103378. */
  103379. clear(): void;
  103380. private _setState;
  103381. private _enable;
  103382. private _disable;
  103383. private _resetPostProcessChain;
  103384. private _bindPostProcessChain;
  103385. /**
  103386. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103387. */
  103388. markAsDirty(): void;
  103389. private _update;
  103390. /**
  103391. * Disposes the prepass renderer.
  103392. */
  103393. dispose(): void;
  103394. }
  103395. }
  103396. declare module BABYLON {
  103397. /**
  103398. * Options for compiling materials.
  103399. */
  103400. export interface IMaterialCompilationOptions {
  103401. /**
  103402. * Defines whether clip planes are enabled.
  103403. */
  103404. clipPlane: boolean;
  103405. /**
  103406. * Defines whether instances are enabled.
  103407. */
  103408. useInstances: boolean;
  103409. }
  103410. /**
  103411. * Options passed when calling customShaderNameResolve
  103412. */
  103413. export interface ICustomShaderNameResolveOptions {
  103414. /**
  103415. * 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
  103416. */
  103417. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103418. }
  103419. /**
  103420. * Base class for the main features of a material in Babylon.js
  103421. */
  103422. export class Material implements IAnimatable {
  103423. /**
  103424. * Returns the triangle fill mode
  103425. */
  103426. static readonly TriangleFillMode: number;
  103427. /**
  103428. * Returns the wireframe mode
  103429. */
  103430. static readonly WireFrameFillMode: number;
  103431. /**
  103432. * Returns the point fill mode
  103433. */
  103434. static readonly PointFillMode: number;
  103435. /**
  103436. * Returns the point list draw mode
  103437. */
  103438. static readonly PointListDrawMode: number;
  103439. /**
  103440. * Returns the line list draw mode
  103441. */
  103442. static readonly LineListDrawMode: number;
  103443. /**
  103444. * Returns the line loop draw mode
  103445. */
  103446. static readonly LineLoopDrawMode: number;
  103447. /**
  103448. * Returns the line strip draw mode
  103449. */
  103450. static readonly LineStripDrawMode: number;
  103451. /**
  103452. * Returns the triangle strip draw mode
  103453. */
  103454. static readonly TriangleStripDrawMode: number;
  103455. /**
  103456. * Returns the triangle fan draw mode
  103457. */
  103458. static readonly TriangleFanDrawMode: number;
  103459. /**
  103460. * Stores the clock-wise side orientation
  103461. */
  103462. static readonly ClockWiseSideOrientation: number;
  103463. /**
  103464. * Stores the counter clock-wise side orientation
  103465. */
  103466. static readonly CounterClockWiseSideOrientation: number;
  103467. /**
  103468. * The dirty texture flag value
  103469. */
  103470. static readonly TextureDirtyFlag: number;
  103471. /**
  103472. * The dirty light flag value
  103473. */
  103474. static readonly LightDirtyFlag: number;
  103475. /**
  103476. * The dirty fresnel flag value
  103477. */
  103478. static readonly FresnelDirtyFlag: number;
  103479. /**
  103480. * The dirty attribute flag value
  103481. */
  103482. static readonly AttributesDirtyFlag: number;
  103483. /**
  103484. * The dirty misc flag value
  103485. */
  103486. static readonly MiscDirtyFlag: number;
  103487. /**
  103488. * The all dirty flag value
  103489. */
  103490. static readonly AllDirtyFlag: number;
  103491. /**
  103492. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103493. */
  103494. static readonly MATERIAL_OPAQUE: number;
  103495. /**
  103496. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103497. */
  103498. static readonly MATERIAL_ALPHATEST: number;
  103499. /**
  103500. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103501. */
  103502. static readonly MATERIAL_ALPHABLEND: number;
  103503. /**
  103504. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103505. * They are also discarded below the alpha cutoff threshold to improve performances.
  103506. */
  103507. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103508. /**
  103509. * The Whiteout method is used to blend normals.
  103510. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103511. */
  103512. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103513. /**
  103514. * The Reoriented Normal Mapping method is used to blend normals.
  103515. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103516. */
  103517. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103518. /**
  103519. * Custom callback helping to override the default shader used in the material.
  103520. */
  103521. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103522. /**
  103523. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103524. */
  103525. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103526. /**
  103527. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103528. * This means that the material can keep using a previous shader while a new one is being compiled.
  103529. * This is mostly used when shader parallel compilation is supported (true by default)
  103530. */
  103531. allowShaderHotSwapping: boolean;
  103532. /**
  103533. * The ID of the material
  103534. */
  103535. id: string;
  103536. /**
  103537. * Gets or sets the unique id of the material
  103538. */
  103539. uniqueId: number;
  103540. /**
  103541. * The name of the material
  103542. */
  103543. name: string;
  103544. /**
  103545. * Gets or sets user defined metadata
  103546. */
  103547. metadata: any;
  103548. /**
  103549. * For internal use only. Please do not use.
  103550. */
  103551. reservedDataStore: any;
  103552. /**
  103553. * Specifies if the ready state should be checked on each call
  103554. */
  103555. checkReadyOnEveryCall: boolean;
  103556. /**
  103557. * Specifies if the ready state should be checked once
  103558. */
  103559. checkReadyOnlyOnce: boolean;
  103560. /**
  103561. * The state of the material
  103562. */
  103563. state: string;
  103564. /**
  103565. * If the material can be rendered to several textures with MRT extension
  103566. */
  103567. get canRenderToMRT(): boolean;
  103568. /**
  103569. * The alpha value of the material
  103570. */
  103571. protected _alpha: number;
  103572. /**
  103573. * List of inspectable custom properties (used by the Inspector)
  103574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103575. */
  103576. inspectableCustomProperties: IInspectable[];
  103577. /**
  103578. * Sets the alpha value of the material
  103579. */
  103580. set alpha(value: number);
  103581. /**
  103582. * Gets the alpha value of the material
  103583. */
  103584. get alpha(): number;
  103585. /**
  103586. * Specifies if back face culling is enabled
  103587. */
  103588. protected _backFaceCulling: boolean;
  103589. /**
  103590. * Sets the back-face culling state
  103591. */
  103592. set backFaceCulling(value: boolean);
  103593. /**
  103594. * Gets the back-face culling state
  103595. */
  103596. get backFaceCulling(): boolean;
  103597. /**
  103598. * Stores the value for side orientation
  103599. */
  103600. sideOrientation: number;
  103601. /**
  103602. * Callback triggered when the material is compiled
  103603. */
  103604. onCompiled: Nullable<(effect: Effect) => void>;
  103605. /**
  103606. * Callback triggered when an error occurs
  103607. */
  103608. onError: Nullable<(effect: Effect, errors: string) => void>;
  103609. /**
  103610. * Callback triggered to get the render target textures
  103611. */
  103612. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103613. /**
  103614. * Gets a boolean indicating that current material needs to register RTT
  103615. */
  103616. get hasRenderTargetTextures(): boolean;
  103617. /**
  103618. * Specifies if the material should be serialized
  103619. */
  103620. doNotSerialize: boolean;
  103621. /**
  103622. * @hidden
  103623. */
  103624. _storeEffectOnSubMeshes: boolean;
  103625. /**
  103626. * Stores the animations for the material
  103627. */
  103628. animations: Nullable<Array<Animation>>;
  103629. /**
  103630. * An event triggered when the material is disposed
  103631. */
  103632. onDisposeObservable: Observable<Material>;
  103633. /**
  103634. * An observer which watches for dispose events
  103635. */
  103636. private _onDisposeObserver;
  103637. private _onUnBindObservable;
  103638. /**
  103639. * Called during a dispose event
  103640. */
  103641. set onDispose(callback: () => void);
  103642. private _onBindObservable;
  103643. /**
  103644. * An event triggered when the material is bound
  103645. */
  103646. get onBindObservable(): Observable<AbstractMesh>;
  103647. /**
  103648. * An observer which watches for bind events
  103649. */
  103650. private _onBindObserver;
  103651. /**
  103652. * Called during a bind event
  103653. */
  103654. set onBind(callback: (Mesh: AbstractMesh) => void);
  103655. /**
  103656. * An event triggered when the material is unbound
  103657. */
  103658. get onUnBindObservable(): Observable<Material>;
  103659. protected _onEffectCreatedObservable: Nullable<Observable<{
  103660. effect: Effect;
  103661. subMesh: Nullable<SubMesh>;
  103662. }>>;
  103663. /**
  103664. * An event triggered when the effect is (re)created
  103665. */
  103666. get onEffectCreatedObservable(): Observable<{
  103667. effect: Effect;
  103668. subMesh: Nullable<SubMesh>;
  103669. }>;
  103670. /**
  103671. * Stores the value of the alpha mode
  103672. */
  103673. private _alphaMode;
  103674. /**
  103675. * Sets the value of the alpha mode.
  103676. *
  103677. * | Value | Type | Description |
  103678. * | --- | --- | --- |
  103679. * | 0 | ALPHA_DISABLE | |
  103680. * | 1 | ALPHA_ADD | |
  103681. * | 2 | ALPHA_COMBINE | |
  103682. * | 3 | ALPHA_SUBTRACT | |
  103683. * | 4 | ALPHA_MULTIPLY | |
  103684. * | 5 | ALPHA_MAXIMIZED | |
  103685. * | 6 | ALPHA_ONEONE | |
  103686. * | 7 | ALPHA_PREMULTIPLIED | |
  103687. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103688. * | 9 | ALPHA_INTERPOLATE | |
  103689. * | 10 | ALPHA_SCREENMODE | |
  103690. *
  103691. */
  103692. set alphaMode(value: number);
  103693. /**
  103694. * Gets the value of the alpha mode
  103695. */
  103696. get alphaMode(): number;
  103697. /**
  103698. * Stores the state of the need depth pre-pass value
  103699. */
  103700. private _needDepthPrePass;
  103701. /**
  103702. * Sets the need depth pre-pass value
  103703. */
  103704. set needDepthPrePass(value: boolean);
  103705. /**
  103706. * Gets the depth pre-pass value
  103707. */
  103708. get needDepthPrePass(): boolean;
  103709. /**
  103710. * Specifies if depth writing should be disabled
  103711. */
  103712. disableDepthWrite: boolean;
  103713. /**
  103714. * Specifies if color writing should be disabled
  103715. */
  103716. disableColorWrite: boolean;
  103717. /**
  103718. * Specifies if depth writing should be forced
  103719. */
  103720. forceDepthWrite: boolean;
  103721. /**
  103722. * Specifies the depth function that should be used. 0 means the default engine function
  103723. */
  103724. depthFunction: number;
  103725. /**
  103726. * Specifies if there should be a separate pass for culling
  103727. */
  103728. separateCullingPass: boolean;
  103729. /**
  103730. * Stores the state specifing if fog should be enabled
  103731. */
  103732. private _fogEnabled;
  103733. /**
  103734. * Sets the state for enabling fog
  103735. */
  103736. set fogEnabled(value: boolean);
  103737. /**
  103738. * Gets the value of the fog enabled state
  103739. */
  103740. get fogEnabled(): boolean;
  103741. /**
  103742. * Stores the size of points
  103743. */
  103744. pointSize: number;
  103745. /**
  103746. * Stores the z offset value
  103747. */
  103748. zOffset: number;
  103749. get wireframe(): boolean;
  103750. /**
  103751. * Sets the state of wireframe mode
  103752. */
  103753. set wireframe(value: boolean);
  103754. /**
  103755. * Gets the value specifying if point clouds are enabled
  103756. */
  103757. get pointsCloud(): boolean;
  103758. /**
  103759. * Sets the state of point cloud mode
  103760. */
  103761. set pointsCloud(value: boolean);
  103762. /**
  103763. * Gets the material fill mode
  103764. */
  103765. get fillMode(): number;
  103766. /**
  103767. * Sets the material fill mode
  103768. */
  103769. set fillMode(value: number);
  103770. /**
  103771. * @hidden
  103772. * Stores the effects for the material
  103773. */
  103774. _effect: Nullable<Effect>;
  103775. /**
  103776. * Specifies if uniform buffers should be used
  103777. */
  103778. private _useUBO;
  103779. /**
  103780. * Stores a reference to the scene
  103781. */
  103782. private _scene;
  103783. /**
  103784. * Stores the fill mode state
  103785. */
  103786. private _fillMode;
  103787. /**
  103788. * Specifies if the depth write state should be cached
  103789. */
  103790. private _cachedDepthWriteState;
  103791. /**
  103792. * Specifies if the color write state should be cached
  103793. */
  103794. private _cachedColorWriteState;
  103795. /**
  103796. * Specifies if the depth function state should be cached
  103797. */
  103798. private _cachedDepthFunctionState;
  103799. /**
  103800. * Stores the uniform buffer
  103801. */
  103802. protected _uniformBuffer: UniformBuffer;
  103803. /** @hidden */
  103804. _indexInSceneMaterialArray: number;
  103805. /** @hidden */
  103806. meshMap: Nullable<{
  103807. [id: string]: AbstractMesh | undefined;
  103808. }>;
  103809. /**
  103810. * Creates a material instance
  103811. * @param name defines the name of the material
  103812. * @param scene defines the scene to reference
  103813. * @param doNotAdd specifies if the material should be added to the scene
  103814. */
  103815. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103816. /**
  103817. * Returns a string representation of the current material
  103818. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103819. * @returns a string with material information
  103820. */
  103821. toString(fullDetails?: boolean): string;
  103822. /**
  103823. * Gets the class name of the material
  103824. * @returns a string with the class name of the material
  103825. */
  103826. getClassName(): string;
  103827. /**
  103828. * Specifies if updates for the material been locked
  103829. */
  103830. get isFrozen(): boolean;
  103831. /**
  103832. * Locks updates for the material
  103833. */
  103834. freeze(): void;
  103835. /**
  103836. * Unlocks updates for the material
  103837. */
  103838. unfreeze(): void;
  103839. /**
  103840. * Specifies if the material is ready to be used
  103841. * @param mesh defines the mesh to check
  103842. * @param useInstances specifies if instances should be used
  103843. * @returns a boolean indicating if the material is ready to be used
  103844. */
  103845. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103846. /**
  103847. * Specifies that the submesh is ready to be used
  103848. * @param mesh defines the mesh to check
  103849. * @param subMesh defines which submesh to check
  103850. * @param useInstances specifies that instances should be used
  103851. * @returns a boolean indicating that the submesh is ready or not
  103852. */
  103853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103854. /**
  103855. * Returns the material effect
  103856. * @returns the effect associated with the material
  103857. */
  103858. getEffect(): Nullable<Effect>;
  103859. /**
  103860. * Returns the current scene
  103861. * @returns a Scene
  103862. */
  103863. getScene(): Scene;
  103864. /**
  103865. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103866. */
  103867. protected _forceAlphaTest: boolean;
  103868. /**
  103869. * The transparency mode of the material.
  103870. */
  103871. protected _transparencyMode: Nullable<number>;
  103872. /**
  103873. * Gets the current transparency mode.
  103874. */
  103875. get transparencyMode(): Nullable<number>;
  103876. /**
  103877. * Sets the transparency mode of the material.
  103878. *
  103879. * | Value | Type | Description |
  103880. * | ----- | ----------------------------------- | ----------- |
  103881. * | 0 | OPAQUE | |
  103882. * | 1 | ALPHATEST | |
  103883. * | 2 | ALPHABLEND | |
  103884. * | 3 | ALPHATESTANDBLEND | |
  103885. *
  103886. */
  103887. set transparencyMode(value: Nullable<number>);
  103888. /**
  103889. * Returns true if alpha blending should be disabled.
  103890. */
  103891. protected get _disableAlphaBlending(): boolean;
  103892. /**
  103893. * Specifies whether or not this material should be rendered in alpha blend mode.
  103894. * @returns a boolean specifying if alpha blending is needed
  103895. */
  103896. needAlphaBlending(): boolean;
  103897. /**
  103898. * Specifies if the mesh will require alpha blending
  103899. * @param mesh defines the mesh to check
  103900. * @returns a boolean specifying if alpha blending is needed for the mesh
  103901. */
  103902. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103903. /**
  103904. * Specifies whether or not this material should be rendered in alpha test mode.
  103905. * @returns a boolean specifying if an alpha test is needed.
  103906. */
  103907. needAlphaTesting(): boolean;
  103908. /**
  103909. * Specifies if material alpha testing should be turned on for the mesh
  103910. * @param mesh defines the mesh to check
  103911. */
  103912. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103913. /**
  103914. * Gets the texture used for the alpha test
  103915. * @returns the texture to use for alpha testing
  103916. */
  103917. getAlphaTestTexture(): Nullable<BaseTexture>;
  103918. /**
  103919. * Marks the material to indicate that it needs to be re-calculated
  103920. */
  103921. markDirty(): void;
  103922. /** @hidden */
  103923. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103924. /**
  103925. * Binds the material to the mesh
  103926. * @param world defines the world transformation matrix
  103927. * @param mesh defines the mesh to bind the material to
  103928. */
  103929. bind(world: Matrix, mesh?: Mesh): void;
  103930. /**
  103931. * Binds the submesh to the material
  103932. * @param world defines the world transformation matrix
  103933. * @param mesh defines the mesh containing the submesh
  103934. * @param subMesh defines the submesh to bind the material to
  103935. */
  103936. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103937. /**
  103938. * Binds the world matrix to the material
  103939. * @param world defines the world transformation matrix
  103940. */
  103941. bindOnlyWorldMatrix(world: Matrix): void;
  103942. /**
  103943. * Binds the scene's uniform buffer to the effect.
  103944. * @param effect defines the effect to bind to the scene uniform buffer
  103945. * @param sceneUbo defines the uniform buffer storing scene data
  103946. */
  103947. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103948. /**
  103949. * Binds the view matrix to the effect
  103950. * @param effect defines the effect to bind the view matrix to
  103951. */
  103952. bindView(effect: Effect): void;
  103953. /**
  103954. * Binds the view projection matrix to the effect
  103955. * @param effect defines the effect to bind the view projection matrix to
  103956. */
  103957. bindViewProjection(effect: Effect): void;
  103958. /**
  103959. * Processes to execute after binding the material to a mesh
  103960. * @param mesh defines the rendered mesh
  103961. */
  103962. protected _afterBind(mesh?: Mesh): void;
  103963. /**
  103964. * Unbinds the material from the mesh
  103965. */
  103966. unbind(): void;
  103967. /**
  103968. * Gets the active textures from the material
  103969. * @returns an array of textures
  103970. */
  103971. getActiveTextures(): BaseTexture[];
  103972. /**
  103973. * Specifies if the material uses a texture
  103974. * @param texture defines the texture to check against the material
  103975. * @returns a boolean specifying if the material uses the texture
  103976. */
  103977. hasTexture(texture: BaseTexture): boolean;
  103978. /**
  103979. * Makes a duplicate of the material, and gives it a new name
  103980. * @param name defines the new name for the duplicated material
  103981. * @returns the cloned material
  103982. */
  103983. clone(name: string): Nullable<Material>;
  103984. /**
  103985. * Gets the meshes bound to the material
  103986. * @returns an array of meshes bound to the material
  103987. */
  103988. getBindedMeshes(): AbstractMesh[];
  103989. /**
  103990. * Force shader compilation
  103991. * @param mesh defines the mesh associated with this material
  103992. * @param onCompiled defines a function to execute once the material is compiled
  103993. * @param options defines the options to configure the compilation
  103994. * @param onError defines a function to execute if the material fails compiling
  103995. */
  103996. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103997. /**
  103998. * Force shader compilation
  103999. * @param mesh defines the mesh that will use this material
  104000. * @param options defines additional options for compiling the shaders
  104001. * @returns a promise that resolves when the compilation completes
  104002. */
  104003. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104004. private static readonly _AllDirtyCallBack;
  104005. private static readonly _ImageProcessingDirtyCallBack;
  104006. private static readonly _TextureDirtyCallBack;
  104007. private static readonly _FresnelDirtyCallBack;
  104008. private static readonly _MiscDirtyCallBack;
  104009. private static readonly _LightsDirtyCallBack;
  104010. private static readonly _AttributeDirtyCallBack;
  104011. private static _FresnelAndMiscDirtyCallBack;
  104012. private static _TextureAndMiscDirtyCallBack;
  104013. private static readonly _DirtyCallbackArray;
  104014. private static readonly _RunDirtyCallBacks;
  104015. /**
  104016. * Marks a define in the material to indicate that it needs to be re-computed
  104017. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104018. */
  104019. markAsDirty(flag: number): void;
  104020. /**
  104021. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104022. * @param func defines a function which checks material defines against the submeshes
  104023. */
  104024. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104025. /**
  104026. * Indicates that the scene should check if the rendering now needs a prepass
  104027. */
  104028. protected _markScenePrePassDirty(): void;
  104029. /**
  104030. * Indicates that we need to re-calculated for all submeshes
  104031. */
  104032. protected _markAllSubMeshesAsAllDirty(): void;
  104033. /**
  104034. * Indicates that image processing needs to be re-calculated for all submeshes
  104035. */
  104036. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104037. /**
  104038. * Indicates that textures need to be re-calculated for all submeshes
  104039. */
  104040. protected _markAllSubMeshesAsTexturesDirty(): void;
  104041. /**
  104042. * Indicates that fresnel needs to be re-calculated for all submeshes
  104043. */
  104044. protected _markAllSubMeshesAsFresnelDirty(): void;
  104045. /**
  104046. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104047. */
  104048. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104049. /**
  104050. * Indicates that lights need to be re-calculated for all submeshes
  104051. */
  104052. protected _markAllSubMeshesAsLightsDirty(): void;
  104053. /**
  104054. * Indicates that attributes need to be re-calculated for all submeshes
  104055. */
  104056. protected _markAllSubMeshesAsAttributesDirty(): void;
  104057. /**
  104058. * Indicates that misc needs to be re-calculated for all submeshes
  104059. */
  104060. protected _markAllSubMeshesAsMiscDirty(): void;
  104061. /**
  104062. * Indicates that textures and misc need to be re-calculated for all submeshes
  104063. */
  104064. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104065. /**
  104066. * Sets the required values to the prepass renderer.
  104067. * @param prePassRenderer defines the prepass renderer to setup.
  104068. * @returns true if the pre pass is needed.
  104069. */
  104070. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104071. /**
  104072. * Disposes the material
  104073. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104074. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104075. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104076. */
  104077. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104078. /** @hidden */
  104079. private releaseVertexArrayObject;
  104080. /**
  104081. * Serializes this material
  104082. * @returns the serialized material object
  104083. */
  104084. serialize(): any;
  104085. /**
  104086. * Creates a material from parsed material data
  104087. * @param parsedMaterial defines parsed material data
  104088. * @param scene defines the hosting scene
  104089. * @param rootUrl defines the root URL to use to load textures
  104090. * @returns a new material
  104091. */
  104092. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104093. }
  104094. }
  104095. declare module BABYLON {
  104096. /**
  104097. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104098. * separate meshes. This can be use to improve performances.
  104099. * @see https://doc.babylonjs.com/how_to/multi_materials
  104100. */
  104101. export class MultiMaterial extends Material {
  104102. private _subMaterials;
  104103. /**
  104104. * Gets or Sets the list of Materials used within the multi material.
  104105. * They need to be ordered according to the submeshes order in the associated mesh
  104106. */
  104107. get subMaterials(): Nullable<Material>[];
  104108. set subMaterials(value: Nullable<Material>[]);
  104109. /**
  104110. * Function used to align with Node.getChildren()
  104111. * @returns the list of Materials used within the multi material
  104112. */
  104113. getChildren(): Nullable<Material>[];
  104114. /**
  104115. * Instantiates a new Multi Material
  104116. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104117. * separate meshes. This can be use to improve performances.
  104118. * @see https://doc.babylonjs.com/how_to/multi_materials
  104119. * @param name Define the name in the scene
  104120. * @param scene Define the scene the material belongs to
  104121. */
  104122. constructor(name: string, scene: Scene);
  104123. private _hookArray;
  104124. /**
  104125. * Get one of the submaterial by its index in the submaterials array
  104126. * @param index The index to look the sub material at
  104127. * @returns The Material if the index has been defined
  104128. */
  104129. getSubMaterial(index: number): Nullable<Material>;
  104130. /**
  104131. * Get the list of active textures for the whole sub materials list.
  104132. * @returns All the textures that will be used during the rendering
  104133. */
  104134. getActiveTextures(): BaseTexture[];
  104135. /**
  104136. * Gets the current class name of the material e.g. "MultiMaterial"
  104137. * Mainly use in serialization.
  104138. * @returns the class name
  104139. */
  104140. getClassName(): string;
  104141. /**
  104142. * Checks if the material is ready to render the requested sub mesh
  104143. * @param mesh Define the mesh the submesh belongs to
  104144. * @param subMesh Define the sub mesh to look readyness for
  104145. * @param useInstances Define whether or not the material is used with instances
  104146. * @returns true if ready, otherwise false
  104147. */
  104148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104149. /**
  104150. * Clones the current material and its related sub materials
  104151. * @param name Define the name of the newly cloned material
  104152. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104153. * @returns the cloned material
  104154. */
  104155. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104156. /**
  104157. * Serializes the materials into a JSON representation.
  104158. * @returns the JSON representation
  104159. */
  104160. serialize(): any;
  104161. /**
  104162. * Dispose the material and release its associated resources
  104163. * @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)
  104164. * @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)
  104165. * @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)
  104166. */
  104167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104168. /**
  104169. * Creates a MultiMaterial from parsed MultiMaterial data.
  104170. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104171. * @param scene defines the hosting scene
  104172. * @returns a new MultiMaterial
  104173. */
  104174. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104175. }
  104176. }
  104177. declare module BABYLON {
  104178. /**
  104179. * Defines a subdivision inside a mesh
  104180. */
  104181. export class SubMesh implements ICullable {
  104182. /** the material index to use */
  104183. materialIndex: number;
  104184. /** vertex index start */
  104185. verticesStart: number;
  104186. /** vertices count */
  104187. verticesCount: number;
  104188. /** index start */
  104189. indexStart: number;
  104190. /** indices count */
  104191. indexCount: number;
  104192. /** @hidden */
  104193. _materialDefines: Nullable<MaterialDefines>;
  104194. /** @hidden */
  104195. _materialEffect: Nullable<Effect>;
  104196. /** @hidden */
  104197. _effectOverride: Nullable<Effect>;
  104198. /**
  104199. * Gets material defines used by the effect associated to the sub mesh
  104200. */
  104201. get materialDefines(): Nullable<MaterialDefines>;
  104202. /**
  104203. * Sets material defines used by the effect associated to the sub mesh
  104204. */
  104205. set materialDefines(defines: Nullable<MaterialDefines>);
  104206. /**
  104207. * Gets associated effect
  104208. */
  104209. get effect(): Nullable<Effect>;
  104210. /**
  104211. * Sets associated effect (effect used to render this submesh)
  104212. * @param effect defines the effect to associate with
  104213. * @param defines defines the set of defines used to compile this effect
  104214. */
  104215. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104216. /** @hidden */
  104217. _linesIndexCount: number;
  104218. private _mesh;
  104219. private _renderingMesh;
  104220. private _boundingInfo;
  104221. private _linesIndexBuffer;
  104222. /** @hidden */
  104223. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104224. /** @hidden */
  104225. _trianglePlanes: Plane[];
  104226. /** @hidden */
  104227. _lastColliderTransformMatrix: Nullable<Matrix>;
  104228. /** @hidden */
  104229. _renderId: number;
  104230. /** @hidden */
  104231. _alphaIndex: number;
  104232. /** @hidden */
  104233. _distanceToCamera: number;
  104234. /** @hidden */
  104235. _id: number;
  104236. private _currentMaterial;
  104237. /**
  104238. * Add a new submesh to a mesh
  104239. * @param materialIndex defines the material index to use
  104240. * @param verticesStart defines vertex index start
  104241. * @param verticesCount defines vertices count
  104242. * @param indexStart defines index start
  104243. * @param indexCount defines indices count
  104244. * @param mesh defines the parent mesh
  104245. * @param renderingMesh defines an optional rendering mesh
  104246. * @param createBoundingBox defines if bounding box should be created for this submesh
  104247. * @returns the new submesh
  104248. */
  104249. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104250. /**
  104251. * Creates a new submesh
  104252. * @param materialIndex defines the material index to use
  104253. * @param verticesStart defines vertex index start
  104254. * @param verticesCount defines vertices count
  104255. * @param indexStart defines index start
  104256. * @param indexCount defines indices count
  104257. * @param mesh defines the parent mesh
  104258. * @param renderingMesh defines an optional rendering mesh
  104259. * @param createBoundingBox defines if bounding box should be created for this submesh
  104260. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104261. */
  104262. constructor(
  104263. /** the material index to use */
  104264. materialIndex: number,
  104265. /** vertex index start */
  104266. verticesStart: number,
  104267. /** vertices count */
  104268. verticesCount: number,
  104269. /** index start */
  104270. indexStart: number,
  104271. /** indices count */
  104272. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104273. /**
  104274. * Returns true if this submesh covers the entire parent mesh
  104275. * @ignorenaming
  104276. */
  104277. get IsGlobal(): boolean;
  104278. /**
  104279. * Returns the submesh BoudingInfo object
  104280. * @returns current bounding info (or mesh's one if the submesh is global)
  104281. */
  104282. getBoundingInfo(): BoundingInfo;
  104283. /**
  104284. * Sets the submesh BoundingInfo
  104285. * @param boundingInfo defines the new bounding info to use
  104286. * @returns the SubMesh
  104287. */
  104288. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104289. /**
  104290. * Returns the mesh of the current submesh
  104291. * @return the parent mesh
  104292. */
  104293. getMesh(): AbstractMesh;
  104294. /**
  104295. * Returns the rendering mesh of the submesh
  104296. * @returns the rendering mesh (could be different from parent mesh)
  104297. */
  104298. getRenderingMesh(): Mesh;
  104299. /**
  104300. * Returns the replacement mesh of the submesh
  104301. * @returns the replacement mesh (could be different from parent mesh)
  104302. */
  104303. getReplacementMesh(): Nullable<AbstractMesh>;
  104304. /**
  104305. * Returns the effective mesh of the submesh
  104306. * @returns the effective mesh (could be different from parent mesh)
  104307. */
  104308. getEffectiveMesh(): AbstractMesh;
  104309. /**
  104310. * Returns the submesh material
  104311. * @returns null or the current material
  104312. */
  104313. getMaterial(): Nullable<Material>;
  104314. private _IsMultiMaterial;
  104315. /**
  104316. * Sets a new updated BoundingInfo object to the submesh
  104317. * @param data defines an optional position array to use to determine the bounding info
  104318. * @returns the SubMesh
  104319. */
  104320. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104321. /** @hidden */
  104322. _checkCollision(collider: Collider): boolean;
  104323. /**
  104324. * Updates the submesh BoundingInfo
  104325. * @param world defines the world matrix to use to update the bounding info
  104326. * @returns the submesh
  104327. */
  104328. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104329. /**
  104330. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104331. * @param frustumPlanes defines the frustum planes
  104332. * @returns true if the submesh is intersecting with the frustum
  104333. */
  104334. isInFrustum(frustumPlanes: Plane[]): boolean;
  104335. /**
  104336. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104337. * @param frustumPlanes defines the frustum planes
  104338. * @returns true if the submesh is inside the frustum
  104339. */
  104340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104341. /**
  104342. * Renders the submesh
  104343. * @param enableAlphaMode defines if alpha needs to be used
  104344. * @returns the submesh
  104345. */
  104346. render(enableAlphaMode: boolean): SubMesh;
  104347. /**
  104348. * @hidden
  104349. */
  104350. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104351. /**
  104352. * Checks if the submesh intersects with a ray
  104353. * @param ray defines the ray to test
  104354. * @returns true is the passed ray intersects the submesh bounding box
  104355. */
  104356. canIntersects(ray: Ray): boolean;
  104357. /**
  104358. * Intersects current submesh with a ray
  104359. * @param ray defines the ray to test
  104360. * @param positions defines mesh's positions array
  104361. * @param indices defines mesh's indices array
  104362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104364. * @returns intersection info or null if no intersection
  104365. */
  104366. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104367. /** @hidden */
  104368. private _intersectLines;
  104369. /** @hidden */
  104370. private _intersectUnIndexedLines;
  104371. /** @hidden */
  104372. private _intersectTriangles;
  104373. /** @hidden */
  104374. private _intersectUnIndexedTriangles;
  104375. /** @hidden */
  104376. _rebuild(): void;
  104377. /**
  104378. * Creates a new submesh from the passed mesh
  104379. * @param newMesh defines the new hosting mesh
  104380. * @param newRenderingMesh defines an optional rendering mesh
  104381. * @returns the new submesh
  104382. */
  104383. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104384. /**
  104385. * Release associated resources
  104386. */
  104387. dispose(): void;
  104388. /**
  104389. * Gets the class name
  104390. * @returns the string "SubMesh".
  104391. */
  104392. getClassName(): string;
  104393. /**
  104394. * Creates a new submesh from indices data
  104395. * @param materialIndex the index of the main mesh material
  104396. * @param startIndex the index where to start the copy in the mesh indices array
  104397. * @param indexCount the number of indices to copy then from the startIndex
  104398. * @param mesh the main mesh to create the submesh from
  104399. * @param renderingMesh the optional rendering mesh
  104400. * @returns a new submesh
  104401. */
  104402. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104403. }
  104404. }
  104405. declare module BABYLON {
  104406. /**
  104407. * Class used to represent data loading progression
  104408. */
  104409. export class SceneLoaderFlags {
  104410. private static _ForceFullSceneLoadingForIncremental;
  104411. private static _ShowLoadingScreen;
  104412. private static _CleanBoneMatrixWeights;
  104413. private static _loggingLevel;
  104414. /**
  104415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104416. */
  104417. static get ForceFullSceneLoadingForIncremental(): boolean;
  104418. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104419. /**
  104420. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104421. */
  104422. static get ShowLoadingScreen(): boolean;
  104423. static set ShowLoadingScreen(value: boolean);
  104424. /**
  104425. * Defines the current logging level (while loading the scene)
  104426. * @ignorenaming
  104427. */
  104428. static get loggingLevel(): number;
  104429. static set loggingLevel(value: number);
  104430. /**
  104431. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104432. */
  104433. static get CleanBoneMatrixWeights(): boolean;
  104434. static set CleanBoneMatrixWeights(value: boolean);
  104435. }
  104436. }
  104437. declare module BABYLON {
  104438. /**
  104439. * Class used to store geometry data (vertex buffers + index buffer)
  104440. */
  104441. export class Geometry implements IGetSetVerticesData {
  104442. /**
  104443. * Gets or sets the ID of the geometry
  104444. */
  104445. id: string;
  104446. /**
  104447. * Gets or sets the unique ID of the geometry
  104448. */
  104449. uniqueId: number;
  104450. /**
  104451. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104452. */
  104453. delayLoadState: number;
  104454. /**
  104455. * Gets the file containing the data to load when running in delay load state
  104456. */
  104457. delayLoadingFile: Nullable<string>;
  104458. /**
  104459. * Callback called when the geometry is updated
  104460. */
  104461. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104462. private _scene;
  104463. private _engine;
  104464. private _meshes;
  104465. private _totalVertices;
  104466. /** @hidden */
  104467. _indices: IndicesArray;
  104468. /** @hidden */
  104469. _vertexBuffers: {
  104470. [key: string]: VertexBuffer;
  104471. };
  104472. private _isDisposed;
  104473. private _extend;
  104474. private _boundingBias;
  104475. /** @hidden */
  104476. _delayInfo: Array<string>;
  104477. private _indexBuffer;
  104478. private _indexBufferIsUpdatable;
  104479. /** @hidden */
  104480. _boundingInfo: Nullable<BoundingInfo>;
  104481. /** @hidden */
  104482. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104483. /** @hidden */
  104484. _softwareSkinningFrameId: number;
  104485. private _vertexArrayObjects;
  104486. private _updatable;
  104487. /** @hidden */
  104488. _positions: Nullable<Vector3[]>;
  104489. /**
  104490. * 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
  104491. */
  104492. get boundingBias(): Vector2;
  104493. /**
  104494. * 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
  104495. */
  104496. set boundingBias(value: Vector2);
  104497. /**
  104498. * Static function used to attach a new empty geometry to a mesh
  104499. * @param mesh defines the mesh to attach the geometry to
  104500. * @returns the new Geometry
  104501. */
  104502. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104503. /** Get the list of meshes using this geometry */
  104504. get meshes(): Mesh[];
  104505. /**
  104506. * 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
  104507. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104508. */
  104509. useBoundingInfoFromGeometry: boolean;
  104510. /**
  104511. * Creates a new geometry
  104512. * @param id defines the unique ID
  104513. * @param scene defines the hosting scene
  104514. * @param vertexData defines the VertexData used to get geometry data
  104515. * @param updatable defines if geometry must be updatable (false by default)
  104516. * @param mesh defines the mesh that will be associated with the geometry
  104517. */
  104518. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104519. /**
  104520. * Gets the current extend of the geometry
  104521. */
  104522. get extend(): {
  104523. minimum: Vector3;
  104524. maximum: Vector3;
  104525. };
  104526. /**
  104527. * Gets the hosting scene
  104528. * @returns the hosting Scene
  104529. */
  104530. getScene(): Scene;
  104531. /**
  104532. * Gets the hosting engine
  104533. * @returns the hosting Engine
  104534. */
  104535. getEngine(): Engine;
  104536. /**
  104537. * Defines if the geometry is ready to use
  104538. * @returns true if the geometry is ready to be used
  104539. */
  104540. isReady(): boolean;
  104541. /**
  104542. * Gets a value indicating that the geometry should not be serialized
  104543. */
  104544. get doNotSerialize(): boolean;
  104545. /** @hidden */
  104546. _rebuild(): void;
  104547. /**
  104548. * Affects all geometry data in one call
  104549. * @param vertexData defines the geometry data
  104550. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104551. */
  104552. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104553. /**
  104554. * Set specific vertex data
  104555. * @param kind defines the data kind (Position, normal, etc...)
  104556. * @param data defines the vertex data to use
  104557. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104558. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104559. */
  104560. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104561. /**
  104562. * Removes a specific vertex data
  104563. * @param kind defines the data kind (Position, normal, etc...)
  104564. */
  104565. removeVerticesData(kind: string): void;
  104566. /**
  104567. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104568. * @param buffer defines the vertex buffer to use
  104569. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104570. */
  104571. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104572. /**
  104573. * Update a specific vertex buffer
  104574. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104575. * It will do nothing if the buffer is not updatable
  104576. * @param kind defines the data kind (Position, normal, etc...)
  104577. * @param data defines the data to use
  104578. * @param offset defines the offset in the target buffer where to store the data
  104579. * @param useBytes set to true if the offset is in bytes
  104580. */
  104581. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104582. /**
  104583. * Update a specific vertex buffer
  104584. * This function will create a new buffer if the current one is not updatable
  104585. * @param kind defines the data kind (Position, normal, etc...)
  104586. * @param data defines the data to use
  104587. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104588. */
  104589. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104590. private _updateBoundingInfo;
  104591. /** @hidden */
  104592. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104593. /**
  104594. * Gets total number of vertices
  104595. * @returns the total number of vertices
  104596. */
  104597. getTotalVertices(): number;
  104598. /**
  104599. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104600. * @param kind defines the data kind (Position, normal, etc...)
  104601. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104602. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104603. * @returns a float array containing vertex data
  104604. */
  104605. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104606. /**
  104607. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104608. * @param kind defines the data kind (Position, normal, etc...)
  104609. * @returns true if the vertex buffer with the specified kind is updatable
  104610. */
  104611. isVertexBufferUpdatable(kind: string): boolean;
  104612. /**
  104613. * Gets a specific vertex buffer
  104614. * @param kind defines the data kind (Position, normal, etc...)
  104615. * @returns a VertexBuffer
  104616. */
  104617. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104618. /**
  104619. * Returns all vertex buffers
  104620. * @return an object holding all vertex buffers indexed by kind
  104621. */
  104622. getVertexBuffers(): Nullable<{
  104623. [key: string]: VertexBuffer;
  104624. }>;
  104625. /**
  104626. * Gets a boolean indicating if specific vertex buffer is present
  104627. * @param kind defines the data kind (Position, normal, etc...)
  104628. * @returns true if data is present
  104629. */
  104630. isVerticesDataPresent(kind: string): boolean;
  104631. /**
  104632. * Gets a list of all attached data kinds (Position, normal, etc...)
  104633. * @returns a list of string containing all kinds
  104634. */
  104635. getVerticesDataKinds(): string[];
  104636. /**
  104637. * Update index buffer
  104638. * @param indices defines the indices to store in the index buffer
  104639. * @param offset defines the offset in the target buffer where to store the data
  104640. * @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)
  104641. */
  104642. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104643. /**
  104644. * Creates a new index buffer
  104645. * @param indices defines the indices to store in the index buffer
  104646. * @param totalVertices defines the total number of vertices (could be null)
  104647. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104648. */
  104649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104650. /**
  104651. * Return the total number of indices
  104652. * @returns the total number of indices
  104653. */
  104654. getTotalIndices(): number;
  104655. /**
  104656. * Gets the index buffer array
  104657. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104659. * @returns the index buffer array
  104660. */
  104661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104662. /**
  104663. * Gets the index buffer
  104664. * @return the index buffer
  104665. */
  104666. getIndexBuffer(): Nullable<DataBuffer>;
  104667. /** @hidden */
  104668. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104669. /**
  104670. * Release the associated resources for a specific mesh
  104671. * @param mesh defines the source mesh
  104672. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104673. */
  104674. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104675. /**
  104676. * Apply current geometry to a given mesh
  104677. * @param mesh defines the mesh to apply geometry to
  104678. */
  104679. applyToMesh(mesh: Mesh): void;
  104680. private _updateExtend;
  104681. private _applyToMesh;
  104682. private notifyUpdate;
  104683. /**
  104684. * Load the geometry if it was flagged as delay loaded
  104685. * @param scene defines the hosting scene
  104686. * @param onLoaded defines a callback called when the geometry is loaded
  104687. */
  104688. load(scene: Scene, onLoaded?: () => void): void;
  104689. private _queueLoad;
  104690. /**
  104691. * Invert the geometry to move from a right handed system to a left handed one.
  104692. */
  104693. toLeftHanded(): void;
  104694. /** @hidden */
  104695. _resetPointsArrayCache(): void;
  104696. /** @hidden */
  104697. _generatePointsArray(): boolean;
  104698. /**
  104699. * Gets a value indicating if the geometry is disposed
  104700. * @returns true if the geometry was disposed
  104701. */
  104702. isDisposed(): boolean;
  104703. private _disposeVertexArrayObjects;
  104704. /**
  104705. * Free all associated resources
  104706. */
  104707. dispose(): void;
  104708. /**
  104709. * Clone the current geometry into a new geometry
  104710. * @param id defines the unique ID of the new geometry
  104711. * @returns a new geometry object
  104712. */
  104713. copy(id: string): Geometry;
  104714. /**
  104715. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104716. * @return a JSON representation of the current geometry data (without the vertices data)
  104717. */
  104718. serialize(): any;
  104719. private toNumberArray;
  104720. /**
  104721. * Serialize all vertices data into a JSON oject
  104722. * @returns a JSON representation of the current geometry data
  104723. */
  104724. serializeVerticeData(): any;
  104725. /**
  104726. * Extracts a clone of a mesh geometry
  104727. * @param mesh defines the source mesh
  104728. * @param id defines the unique ID of the new geometry object
  104729. * @returns the new geometry object
  104730. */
  104731. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104732. /**
  104733. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104734. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104735. * Be aware Math.random() could cause collisions, but:
  104736. * "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"
  104737. * @returns a string containing a new GUID
  104738. */
  104739. static RandomId(): string;
  104740. /** @hidden */
  104741. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104742. private static _CleanMatricesWeights;
  104743. /**
  104744. * Create a new geometry from persisted data (Using .babylon file format)
  104745. * @param parsedVertexData defines the persisted data
  104746. * @param scene defines the hosting scene
  104747. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104748. * @returns the new geometry object
  104749. */
  104750. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104751. }
  104752. }
  104753. declare module BABYLON {
  104754. /**
  104755. * Define an interface for all classes that will get and set the data on vertices
  104756. */
  104757. export interface IGetSetVerticesData {
  104758. /**
  104759. * Gets a boolean indicating if specific vertex data is present
  104760. * @param kind defines the vertex data kind to use
  104761. * @returns true is data kind is present
  104762. */
  104763. isVerticesDataPresent(kind: string): boolean;
  104764. /**
  104765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104766. * @param kind defines the data kind (Position, normal, etc...)
  104767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104769. * @returns a float array containing vertex data
  104770. */
  104771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104772. /**
  104773. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104774. * @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.
  104775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104776. * @returns the indices array or an empty array if the mesh has no geometry
  104777. */
  104778. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104779. /**
  104780. * Set specific vertex data
  104781. * @param kind defines the data kind (Position, normal, etc...)
  104782. * @param data defines the vertex data to use
  104783. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104784. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104785. */
  104786. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104787. /**
  104788. * Update a specific associated vertex buffer
  104789. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104790. * - VertexBuffer.PositionKind
  104791. * - VertexBuffer.UVKind
  104792. * - VertexBuffer.UV2Kind
  104793. * - VertexBuffer.UV3Kind
  104794. * - VertexBuffer.UV4Kind
  104795. * - VertexBuffer.UV5Kind
  104796. * - VertexBuffer.UV6Kind
  104797. * - VertexBuffer.ColorKind
  104798. * - VertexBuffer.MatricesIndicesKind
  104799. * - VertexBuffer.MatricesIndicesExtraKind
  104800. * - VertexBuffer.MatricesWeightsKind
  104801. * - VertexBuffer.MatricesWeightsExtraKind
  104802. * @param data defines the data source
  104803. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104804. * @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)
  104805. */
  104806. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104807. /**
  104808. * Creates a new index buffer
  104809. * @param indices defines the indices to store in the index buffer
  104810. * @param totalVertices defines the total number of vertices (could be null)
  104811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104812. */
  104813. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104814. }
  104815. /**
  104816. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104817. */
  104818. export class VertexData {
  104819. /**
  104820. * Mesh side orientation : usually the external or front surface
  104821. */
  104822. static readonly FRONTSIDE: number;
  104823. /**
  104824. * Mesh side orientation : usually the internal or back surface
  104825. */
  104826. static readonly BACKSIDE: number;
  104827. /**
  104828. * Mesh side orientation : both internal and external or front and back surfaces
  104829. */
  104830. static readonly DOUBLESIDE: number;
  104831. /**
  104832. * Mesh side orientation : by default, `FRONTSIDE`
  104833. */
  104834. static readonly DEFAULTSIDE: number;
  104835. /**
  104836. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104837. */
  104838. positions: Nullable<FloatArray>;
  104839. /**
  104840. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104841. */
  104842. normals: Nullable<FloatArray>;
  104843. /**
  104844. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104845. */
  104846. tangents: Nullable<FloatArray>;
  104847. /**
  104848. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104849. */
  104850. uvs: Nullable<FloatArray>;
  104851. /**
  104852. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104853. */
  104854. uvs2: Nullable<FloatArray>;
  104855. /**
  104856. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104857. */
  104858. uvs3: Nullable<FloatArray>;
  104859. /**
  104860. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104861. */
  104862. uvs4: Nullable<FloatArray>;
  104863. /**
  104864. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104865. */
  104866. uvs5: Nullable<FloatArray>;
  104867. /**
  104868. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104869. */
  104870. uvs6: Nullable<FloatArray>;
  104871. /**
  104872. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104873. */
  104874. colors: Nullable<FloatArray>;
  104875. /**
  104876. * 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).
  104877. */
  104878. matricesIndices: Nullable<FloatArray>;
  104879. /**
  104880. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104881. */
  104882. matricesWeights: Nullable<FloatArray>;
  104883. /**
  104884. * An array extending the number of possible indices
  104885. */
  104886. matricesIndicesExtra: Nullable<FloatArray>;
  104887. /**
  104888. * An array extending the number of possible weights when the number of indices is extended
  104889. */
  104890. matricesWeightsExtra: Nullable<FloatArray>;
  104891. /**
  104892. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104893. */
  104894. indices: Nullable<IndicesArray>;
  104895. /**
  104896. * Uses the passed data array to set the set the values for the specified kind of data
  104897. * @param data a linear array of floating numbers
  104898. * @param kind the type of data that is being set, eg positions, colors etc
  104899. */
  104900. set(data: FloatArray, kind: string): void;
  104901. /**
  104902. * Associates the vertexData to the passed Mesh.
  104903. * Sets it as updatable or not (default `false`)
  104904. * @param mesh the mesh the vertexData is applied to
  104905. * @param updatable when used and having the value true allows new data to update the vertexData
  104906. * @returns the VertexData
  104907. */
  104908. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104909. /**
  104910. * Associates the vertexData to the passed Geometry.
  104911. * Sets it as updatable or not (default `false`)
  104912. * @param geometry the geometry the vertexData is applied to
  104913. * @param updatable when used and having the value true allows new data to update the vertexData
  104914. * @returns VertexData
  104915. */
  104916. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104917. /**
  104918. * Updates the associated mesh
  104919. * @param mesh the mesh to be updated
  104920. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104921. * @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
  104922. * @returns VertexData
  104923. */
  104924. updateMesh(mesh: Mesh): VertexData;
  104925. /**
  104926. * Updates the associated geometry
  104927. * @param geometry the geometry to be updated
  104928. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104929. * @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
  104930. * @returns VertexData.
  104931. */
  104932. updateGeometry(geometry: Geometry): VertexData;
  104933. private _applyTo;
  104934. private _update;
  104935. /**
  104936. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104937. * @param matrix the transforming matrix
  104938. * @returns the VertexData
  104939. */
  104940. transform(matrix: Matrix): VertexData;
  104941. /**
  104942. * Merges the passed VertexData into the current one
  104943. * @param other the VertexData to be merged into the current one
  104944. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104945. * @returns the modified VertexData
  104946. */
  104947. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104948. private _mergeElement;
  104949. private _validate;
  104950. /**
  104951. * Serializes the VertexData
  104952. * @returns a serialized object
  104953. */
  104954. serialize(): any;
  104955. /**
  104956. * Extracts the vertexData from a mesh
  104957. * @param mesh the mesh from which to extract the VertexData
  104958. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104959. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104960. * @returns the object VertexData associated to the passed mesh
  104961. */
  104962. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104963. /**
  104964. * Extracts the vertexData from the geometry
  104965. * @param geometry the geometry from which to extract the VertexData
  104966. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104967. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104968. * @returns the object VertexData associated to the passed mesh
  104969. */
  104970. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104971. private static _ExtractFrom;
  104972. /**
  104973. * Creates the VertexData for a Ribbon
  104974. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104975. * * pathArray array of paths, each of which an array of successive Vector3
  104976. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104977. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104978. * * 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
  104979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104980. * * 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)
  104981. * * 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)
  104982. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104983. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104984. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104985. * @returns the VertexData of the ribbon
  104986. */
  104987. static CreateRibbon(options: {
  104988. pathArray: Vector3[][];
  104989. closeArray?: boolean;
  104990. closePath?: boolean;
  104991. offset?: number;
  104992. sideOrientation?: number;
  104993. frontUVs?: Vector4;
  104994. backUVs?: Vector4;
  104995. invertUV?: boolean;
  104996. uvs?: Vector2[];
  104997. colors?: Color4[];
  104998. }): VertexData;
  104999. /**
  105000. * Creates the VertexData for a box
  105001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105002. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105003. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105004. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105005. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105006. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105007. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105009. * * 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)
  105010. * * 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)
  105011. * @returns the VertexData of the box
  105012. */
  105013. static CreateBox(options: {
  105014. size?: number;
  105015. width?: number;
  105016. height?: number;
  105017. depth?: number;
  105018. faceUV?: Vector4[];
  105019. faceColors?: Color4[];
  105020. sideOrientation?: number;
  105021. frontUVs?: Vector4;
  105022. backUVs?: Vector4;
  105023. }): VertexData;
  105024. /**
  105025. * Creates the VertexData for a tiled box
  105026. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105027. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105028. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105029. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105031. * @returns the VertexData of the box
  105032. */
  105033. static CreateTiledBox(options: {
  105034. pattern?: number;
  105035. width?: number;
  105036. height?: number;
  105037. depth?: number;
  105038. tileSize?: number;
  105039. tileWidth?: number;
  105040. tileHeight?: number;
  105041. alignHorizontal?: number;
  105042. alignVertical?: number;
  105043. faceUV?: Vector4[];
  105044. faceColors?: Color4[];
  105045. sideOrientation?: number;
  105046. }): VertexData;
  105047. /**
  105048. * Creates the VertexData for a tiled plane
  105049. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105050. * * pattern a limited pattern arrangement depending on the number
  105051. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105052. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105053. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105055. * * 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)
  105056. * * 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)
  105057. * @returns the VertexData of the tiled plane
  105058. */
  105059. static CreateTiledPlane(options: {
  105060. pattern?: number;
  105061. tileSize?: number;
  105062. tileWidth?: number;
  105063. tileHeight?: number;
  105064. size?: number;
  105065. width?: number;
  105066. height?: number;
  105067. alignHorizontal?: number;
  105068. alignVertical?: number;
  105069. sideOrientation?: number;
  105070. frontUVs?: Vector4;
  105071. backUVs?: Vector4;
  105072. }): VertexData;
  105073. /**
  105074. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105076. * * segments sets the number of horizontal strips optional, default 32
  105077. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105078. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105079. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105080. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105081. * * 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
  105082. * * 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
  105083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105084. * * 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)
  105085. * * 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)
  105086. * @returns the VertexData of the ellipsoid
  105087. */
  105088. static CreateSphere(options: {
  105089. segments?: number;
  105090. diameter?: number;
  105091. diameterX?: number;
  105092. diameterY?: number;
  105093. diameterZ?: number;
  105094. arc?: number;
  105095. slice?: number;
  105096. sideOrientation?: number;
  105097. frontUVs?: Vector4;
  105098. backUVs?: Vector4;
  105099. }): VertexData;
  105100. /**
  105101. * Creates the VertexData for a cylinder, cone or prism
  105102. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105103. * * height sets the height (y direction) of the cylinder, optional, default 2
  105104. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105105. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105106. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105107. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105108. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105109. * * 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
  105110. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105111. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105112. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105113. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105115. * * 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)
  105116. * * 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)
  105117. * @returns the VertexData of the cylinder, cone or prism
  105118. */
  105119. static CreateCylinder(options: {
  105120. height?: number;
  105121. diameterTop?: number;
  105122. diameterBottom?: number;
  105123. diameter?: number;
  105124. tessellation?: number;
  105125. subdivisions?: number;
  105126. arc?: number;
  105127. faceColors?: Color4[];
  105128. faceUV?: Vector4[];
  105129. hasRings?: boolean;
  105130. enclose?: boolean;
  105131. sideOrientation?: number;
  105132. frontUVs?: Vector4;
  105133. backUVs?: Vector4;
  105134. }): VertexData;
  105135. /**
  105136. * Creates the VertexData for a torus
  105137. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105138. * * diameter the diameter of the torus, optional default 1
  105139. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105140. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105142. * * 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)
  105143. * * 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)
  105144. * @returns the VertexData of the torus
  105145. */
  105146. static CreateTorus(options: {
  105147. diameter?: number;
  105148. thickness?: number;
  105149. tessellation?: number;
  105150. sideOrientation?: number;
  105151. frontUVs?: Vector4;
  105152. backUVs?: Vector4;
  105153. }): VertexData;
  105154. /**
  105155. * Creates the VertexData of the LineSystem
  105156. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105157. * - lines an array of lines, each line being an array of successive Vector3
  105158. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105159. * @returns the VertexData of the LineSystem
  105160. */
  105161. static CreateLineSystem(options: {
  105162. lines: Vector3[][];
  105163. colors?: Nullable<Color4[][]>;
  105164. }): VertexData;
  105165. /**
  105166. * Create the VertexData for a DashedLines
  105167. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105168. * - points an array successive Vector3
  105169. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105170. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105171. * - dashNb the intended total number of dashes, optional, default 200
  105172. * @returns the VertexData for the DashedLines
  105173. */
  105174. static CreateDashedLines(options: {
  105175. points: Vector3[];
  105176. dashSize?: number;
  105177. gapSize?: number;
  105178. dashNb?: number;
  105179. }): VertexData;
  105180. /**
  105181. * Creates the VertexData for a Ground
  105182. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105183. * - width the width (x direction) of the ground, optional, default 1
  105184. * - height the height (z direction) of the ground, optional, default 1
  105185. * - subdivisions the number of subdivisions per side, optional, default 1
  105186. * @returns the VertexData of the Ground
  105187. */
  105188. static CreateGround(options: {
  105189. width?: number;
  105190. height?: number;
  105191. subdivisions?: number;
  105192. subdivisionsX?: number;
  105193. subdivisionsY?: number;
  105194. }): VertexData;
  105195. /**
  105196. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105197. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105198. * * xmin the ground minimum X coordinate, optional, default -1
  105199. * * zmin the ground minimum Z coordinate, optional, default -1
  105200. * * xmax the ground maximum X coordinate, optional, default 1
  105201. * * zmax the ground maximum Z coordinate, optional, default 1
  105202. * * 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}
  105203. * * 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}
  105204. * @returns the VertexData of the TiledGround
  105205. */
  105206. static CreateTiledGround(options: {
  105207. xmin: number;
  105208. zmin: number;
  105209. xmax: number;
  105210. zmax: number;
  105211. subdivisions?: {
  105212. w: number;
  105213. h: number;
  105214. };
  105215. precision?: {
  105216. w: number;
  105217. h: number;
  105218. };
  105219. }): VertexData;
  105220. /**
  105221. * Creates the VertexData of the Ground designed from a heightmap
  105222. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105223. * * width the width (x direction) of the ground
  105224. * * height the height (z direction) of the ground
  105225. * * subdivisions the number of subdivisions per side
  105226. * * minHeight the minimum altitude on the ground, optional, default 0
  105227. * * maxHeight the maximum altitude on the ground, optional default 1
  105228. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105229. * * buffer the array holding the image color data
  105230. * * bufferWidth the width of image
  105231. * * bufferHeight the height of image
  105232. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105233. * @returns the VertexData of the Ground designed from a heightmap
  105234. */
  105235. static CreateGroundFromHeightMap(options: {
  105236. width: number;
  105237. height: number;
  105238. subdivisions: number;
  105239. minHeight: number;
  105240. maxHeight: number;
  105241. colorFilter: Color3;
  105242. buffer: Uint8Array;
  105243. bufferWidth: number;
  105244. bufferHeight: number;
  105245. alphaFilter: number;
  105246. }): VertexData;
  105247. /**
  105248. * Creates the VertexData for a Plane
  105249. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105250. * * size sets the width and height of the plane to the value of size, optional default 1
  105251. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105252. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105254. * * 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)
  105255. * * 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)
  105256. * @returns the VertexData of the box
  105257. */
  105258. static CreatePlane(options: {
  105259. size?: number;
  105260. width?: number;
  105261. height?: number;
  105262. sideOrientation?: number;
  105263. frontUVs?: Vector4;
  105264. backUVs?: Vector4;
  105265. }): VertexData;
  105266. /**
  105267. * Creates the VertexData of the Disc or regular Polygon
  105268. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105269. * * radius the radius of the disc, optional default 0.5
  105270. * * tessellation the number of polygon sides, optional, default 64
  105271. * * 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
  105272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105273. * * 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)
  105274. * * 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)
  105275. * @returns the VertexData of the box
  105276. */
  105277. static CreateDisc(options: {
  105278. radius?: number;
  105279. tessellation?: number;
  105280. arc?: number;
  105281. sideOrientation?: number;
  105282. frontUVs?: Vector4;
  105283. backUVs?: Vector4;
  105284. }): VertexData;
  105285. /**
  105286. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105287. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105288. * @param polygon a mesh built from polygonTriangulation.build()
  105289. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105290. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105291. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105292. * @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)
  105293. * @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)
  105294. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105295. * @returns the VertexData of the Polygon
  105296. */
  105297. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105298. /**
  105299. * Creates the VertexData of the IcoSphere
  105300. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105301. * * radius the radius of the IcoSphere, optional default 1
  105302. * * radiusX allows stretching in the x direction, optional, default radius
  105303. * * radiusY allows stretching in the y direction, optional, default radius
  105304. * * radiusZ allows stretching in the z direction, optional, default radius
  105305. * * flat when true creates a flat shaded mesh, optional, default true
  105306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105308. * * 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)
  105309. * * 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)
  105310. * @returns the VertexData of the IcoSphere
  105311. */
  105312. static CreateIcoSphere(options: {
  105313. radius?: number;
  105314. radiusX?: number;
  105315. radiusY?: number;
  105316. radiusZ?: number;
  105317. flat?: boolean;
  105318. subdivisions?: number;
  105319. sideOrientation?: number;
  105320. frontUVs?: Vector4;
  105321. backUVs?: Vector4;
  105322. }): VertexData;
  105323. /**
  105324. * Creates the VertexData for a Polyhedron
  105325. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105326. * * type provided types are:
  105327. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105328. * * 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)
  105329. * * size the size of the IcoSphere, optional default 1
  105330. * * sizeX allows stretching in the x direction, optional, default size
  105331. * * sizeY allows stretching in the y direction, optional, default size
  105332. * * sizeZ allows stretching in the z direction, optional, default size
  105333. * * 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
  105334. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105335. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105336. * * flat when true creates a flat shaded mesh, optional, default true
  105337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105339. * * 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)
  105340. * * 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)
  105341. * @returns the VertexData of the Polyhedron
  105342. */
  105343. static CreatePolyhedron(options: {
  105344. type?: number;
  105345. size?: number;
  105346. sizeX?: number;
  105347. sizeY?: number;
  105348. sizeZ?: number;
  105349. custom?: any;
  105350. faceUV?: Vector4[];
  105351. faceColors?: Color4[];
  105352. flat?: boolean;
  105353. sideOrientation?: number;
  105354. frontUVs?: Vector4;
  105355. backUVs?: Vector4;
  105356. }): VertexData;
  105357. /**
  105358. * Creates the VertexData for a TorusKnot
  105359. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105360. * * radius the radius of the torus knot, optional, default 2
  105361. * * tube the thickness of the tube, optional, default 0.5
  105362. * * radialSegments the number of sides on each tube segments, optional, default 32
  105363. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105364. * * p the number of windings around the z axis, optional, default 2
  105365. * * q the number of windings around the x axis, optional, default 3
  105366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105367. * * 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)
  105368. * * 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)
  105369. * @returns the VertexData of the Torus Knot
  105370. */
  105371. static CreateTorusKnot(options: {
  105372. radius?: number;
  105373. tube?: number;
  105374. radialSegments?: number;
  105375. tubularSegments?: number;
  105376. p?: number;
  105377. q?: number;
  105378. sideOrientation?: number;
  105379. frontUVs?: Vector4;
  105380. backUVs?: Vector4;
  105381. }): VertexData;
  105382. /**
  105383. * Compute normals for given positions and indices
  105384. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105385. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105386. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105387. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105388. * * facetNormals : optional array of facet normals (vector3)
  105389. * * facetPositions : optional array of facet positions (vector3)
  105390. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105391. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105392. * * bInfo : optional bounding info, required for facetPartitioning computation
  105393. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105394. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105395. * * useRightHandedSystem: optional boolean to for right handed system computation
  105396. * * depthSort : optional boolean to enable the facet depth sort computation
  105397. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105398. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105399. */
  105400. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105401. facetNormals?: any;
  105402. facetPositions?: any;
  105403. facetPartitioning?: any;
  105404. ratio?: number;
  105405. bInfo?: any;
  105406. bbSize?: Vector3;
  105407. subDiv?: any;
  105408. useRightHandedSystem?: boolean;
  105409. depthSort?: boolean;
  105410. distanceTo?: Vector3;
  105411. depthSortedFacets?: any;
  105412. }): void;
  105413. /** @hidden */
  105414. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105415. /**
  105416. * Applies VertexData created from the imported parameters to the geometry
  105417. * @param parsedVertexData the parsed data from an imported file
  105418. * @param geometry the geometry to apply the VertexData to
  105419. */
  105420. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105421. }
  105422. }
  105423. declare module BABYLON {
  105424. /**
  105425. * Defines a target to use with MorphTargetManager
  105426. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105427. */
  105428. export class MorphTarget implements IAnimatable {
  105429. /** defines the name of the target */
  105430. name: string;
  105431. /**
  105432. * Gets or sets the list of animations
  105433. */
  105434. animations: Animation[];
  105435. private _scene;
  105436. private _positions;
  105437. private _normals;
  105438. private _tangents;
  105439. private _uvs;
  105440. private _influence;
  105441. private _uniqueId;
  105442. /**
  105443. * Observable raised when the influence changes
  105444. */
  105445. onInfluenceChanged: Observable<boolean>;
  105446. /** @hidden */
  105447. _onDataLayoutChanged: Observable<void>;
  105448. /**
  105449. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105450. */
  105451. get influence(): number;
  105452. set influence(influence: number);
  105453. /**
  105454. * Gets or sets the id of the morph Target
  105455. */
  105456. id: string;
  105457. private _animationPropertiesOverride;
  105458. /**
  105459. * Gets or sets the animation properties override
  105460. */
  105461. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105462. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105463. /**
  105464. * Creates a new MorphTarget
  105465. * @param name defines the name of the target
  105466. * @param influence defines the influence to use
  105467. * @param scene defines the scene the morphtarget belongs to
  105468. */
  105469. constructor(
  105470. /** defines the name of the target */
  105471. name: string, influence?: number, scene?: Nullable<Scene>);
  105472. /**
  105473. * Gets the unique ID of this manager
  105474. */
  105475. get uniqueId(): number;
  105476. /**
  105477. * Gets a boolean defining if the target contains position data
  105478. */
  105479. get hasPositions(): boolean;
  105480. /**
  105481. * Gets a boolean defining if the target contains normal data
  105482. */
  105483. get hasNormals(): boolean;
  105484. /**
  105485. * Gets a boolean defining if the target contains tangent data
  105486. */
  105487. get hasTangents(): boolean;
  105488. /**
  105489. * Gets a boolean defining if the target contains texture coordinates data
  105490. */
  105491. get hasUVs(): boolean;
  105492. /**
  105493. * Affects position data to this target
  105494. * @param data defines the position data to use
  105495. */
  105496. setPositions(data: Nullable<FloatArray>): void;
  105497. /**
  105498. * Gets the position data stored in this target
  105499. * @returns a FloatArray containing the position data (or null if not present)
  105500. */
  105501. getPositions(): Nullable<FloatArray>;
  105502. /**
  105503. * Affects normal data to this target
  105504. * @param data defines the normal data to use
  105505. */
  105506. setNormals(data: Nullable<FloatArray>): void;
  105507. /**
  105508. * Gets the normal data stored in this target
  105509. * @returns a FloatArray containing the normal data (or null if not present)
  105510. */
  105511. getNormals(): Nullable<FloatArray>;
  105512. /**
  105513. * Affects tangent data to this target
  105514. * @param data defines the tangent data to use
  105515. */
  105516. setTangents(data: Nullable<FloatArray>): void;
  105517. /**
  105518. * Gets the tangent data stored in this target
  105519. * @returns a FloatArray containing the tangent data (or null if not present)
  105520. */
  105521. getTangents(): Nullable<FloatArray>;
  105522. /**
  105523. * Affects texture coordinates data to this target
  105524. * @param data defines the texture coordinates data to use
  105525. */
  105526. setUVs(data: Nullable<FloatArray>): void;
  105527. /**
  105528. * Gets the texture coordinates data stored in this target
  105529. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105530. */
  105531. getUVs(): Nullable<FloatArray>;
  105532. /**
  105533. * Clone the current target
  105534. * @returns a new MorphTarget
  105535. */
  105536. clone(): MorphTarget;
  105537. /**
  105538. * Serializes the current target into a Serialization object
  105539. * @returns the serialized object
  105540. */
  105541. serialize(): any;
  105542. /**
  105543. * Returns the string "MorphTarget"
  105544. * @returns "MorphTarget"
  105545. */
  105546. getClassName(): string;
  105547. /**
  105548. * Creates a new target from serialized data
  105549. * @param serializationObject defines the serialized data to use
  105550. * @returns a new MorphTarget
  105551. */
  105552. static Parse(serializationObject: any): MorphTarget;
  105553. /**
  105554. * Creates a MorphTarget from mesh data
  105555. * @param mesh defines the source mesh
  105556. * @param name defines the name to use for the new target
  105557. * @param influence defines the influence to attach to the target
  105558. * @returns a new MorphTarget
  105559. */
  105560. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105561. }
  105562. }
  105563. declare module BABYLON {
  105564. /**
  105565. * This class is used to deform meshes using morphing between different targets
  105566. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105567. */
  105568. export class MorphTargetManager {
  105569. private _targets;
  105570. private _targetInfluenceChangedObservers;
  105571. private _targetDataLayoutChangedObservers;
  105572. private _activeTargets;
  105573. private _scene;
  105574. private _influences;
  105575. private _supportsNormals;
  105576. private _supportsTangents;
  105577. private _supportsUVs;
  105578. private _vertexCount;
  105579. private _uniqueId;
  105580. private _tempInfluences;
  105581. /**
  105582. * Gets or sets a boolean indicating if normals must be morphed
  105583. */
  105584. enableNormalMorphing: boolean;
  105585. /**
  105586. * Gets or sets a boolean indicating if tangents must be morphed
  105587. */
  105588. enableTangentMorphing: boolean;
  105589. /**
  105590. * Gets or sets a boolean indicating if UV must be morphed
  105591. */
  105592. enableUVMorphing: boolean;
  105593. /**
  105594. * Creates a new MorphTargetManager
  105595. * @param scene defines the current scene
  105596. */
  105597. constructor(scene?: Nullable<Scene>);
  105598. /**
  105599. * Gets the unique ID of this manager
  105600. */
  105601. get uniqueId(): number;
  105602. /**
  105603. * Gets the number of vertices handled by this manager
  105604. */
  105605. get vertexCount(): number;
  105606. /**
  105607. * Gets a boolean indicating if this manager supports morphing of normals
  105608. */
  105609. get supportsNormals(): boolean;
  105610. /**
  105611. * Gets a boolean indicating if this manager supports morphing of tangents
  105612. */
  105613. get supportsTangents(): boolean;
  105614. /**
  105615. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105616. */
  105617. get supportsUVs(): boolean;
  105618. /**
  105619. * Gets the number of targets stored in this manager
  105620. */
  105621. get numTargets(): number;
  105622. /**
  105623. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105624. */
  105625. get numInfluencers(): number;
  105626. /**
  105627. * Gets the list of influences (one per target)
  105628. */
  105629. get influences(): Float32Array;
  105630. /**
  105631. * Gets the active target at specified index. An active target is a target with an influence > 0
  105632. * @param index defines the index to check
  105633. * @returns the requested target
  105634. */
  105635. getActiveTarget(index: number): MorphTarget;
  105636. /**
  105637. * Gets the target at specified index
  105638. * @param index defines the index to check
  105639. * @returns the requested target
  105640. */
  105641. getTarget(index: number): MorphTarget;
  105642. /**
  105643. * Add a new target to this manager
  105644. * @param target defines the target to add
  105645. */
  105646. addTarget(target: MorphTarget): void;
  105647. /**
  105648. * Removes a target from the manager
  105649. * @param target defines the target to remove
  105650. */
  105651. removeTarget(target: MorphTarget): void;
  105652. /**
  105653. * Clone the current manager
  105654. * @returns a new MorphTargetManager
  105655. */
  105656. clone(): MorphTargetManager;
  105657. /**
  105658. * Serializes the current manager into a Serialization object
  105659. * @returns the serialized object
  105660. */
  105661. serialize(): any;
  105662. private _syncActiveTargets;
  105663. /**
  105664. * Syncrhonize the targets with all the meshes using this morph target manager
  105665. */
  105666. synchronize(): void;
  105667. /**
  105668. * Creates a new MorphTargetManager from serialized data
  105669. * @param serializationObject defines the serialized data
  105670. * @param scene defines the hosting scene
  105671. * @returns the new MorphTargetManager
  105672. */
  105673. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105674. }
  105675. }
  105676. declare module BABYLON {
  105677. /**
  105678. * Class used to represent a specific level of detail of a mesh
  105679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105680. */
  105681. export class MeshLODLevel {
  105682. /** Defines the distance where this level should start being displayed */
  105683. distance: number;
  105684. /** Defines the mesh to use to render this level */
  105685. mesh: Nullable<Mesh>;
  105686. /**
  105687. * Creates a new LOD level
  105688. * @param distance defines the distance where this level should star being displayed
  105689. * @param mesh defines the mesh to use to render this level
  105690. */
  105691. constructor(
  105692. /** Defines the distance where this level should start being displayed */
  105693. distance: number,
  105694. /** Defines the mesh to use to render this level */
  105695. mesh: Nullable<Mesh>);
  105696. }
  105697. }
  105698. declare module BABYLON {
  105699. /**
  105700. * Helper class used to generate a canvas to manipulate images
  105701. */
  105702. export class CanvasGenerator {
  105703. /**
  105704. * Create a new canvas (or offscreen canvas depending on the context)
  105705. * @param width defines the expected width
  105706. * @param height defines the expected height
  105707. * @return a new canvas or offscreen canvas
  105708. */
  105709. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105710. }
  105711. }
  105712. declare module BABYLON {
  105713. /**
  105714. * Mesh representing the gorund
  105715. */
  105716. export class GroundMesh extends Mesh {
  105717. /** If octree should be generated */
  105718. generateOctree: boolean;
  105719. private _heightQuads;
  105720. /** @hidden */
  105721. _subdivisionsX: number;
  105722. /** @hidden */
  105723. _subdivisionsY: number;
  105724. /** @hidden */
  105725. _width: number;
  105726. /** @hidden */
  105727. _height: number;
  105728. /** @hidden */
  105729. _minX: number;
  105730. /** @hidden */
  105731. _maxX: number;
  105732. /** @hidden */
  105733. _minZ: number;
  105734. /** @hidden */
  105735. _maxZ: number;
  105736. constructor(name: string, scene: Scene);
  105737. /**
  105738. * "GroundMesh"
  105739. * @returns "GroundMesh"
  105740. */
  105741. getClassName(): string;
  105742. /**
  105743. * The minimum of x and y subdivisions
  105744. */
  105745. get subdivisions(): number;
  105746. /**
  105747. * X subdivisions
  105748. */
  105749. get subdivisionsX(): number;
  105750. /**
  105751. * Y subdivisions
  105752. */
  105753. get subdivisionsY(): number;
  105754. /**
  105755. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105756. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105757. * @param chunksCount the number of subdivisions for x and y
  105758. * @param octreeBlocksSize (Default: 32)
  105759. */
  105760. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105761. /**
  105762. * Returns a height (y) value in the Worl system :
  105763. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105764. * @param x x coordinate
  105765. * @param z z coordinate
  105766. * @returns the ground y position if (x, z) are outside the ground surface.
  105767. */
  105768. getHeightAtCoordinates(x: number, z: number): number;
  105769. /**
  105770. * Returns a normalized vector (Vector3) orthogonal to the ground
  105771. * at the ground coordinates (x, z) expressed in the World system.
  105772. * @param x x coordinate
  105773. * @param z z coordinate
  105774. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105775. */
  105776. getNormalAtCoordinates(x: number, z: number): Vector3;
  105777. /**
  105778. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105779. * at the ground coordinates (x, z) expressed in the World system.
  105780. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105781. * @param x x coordinate
  105782. * @param z z coordinate
  105783. * @param ref vector to store the result
  105784. * @returns the GroundMesh.
  105785. */
  105786. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105787. /**
  105788. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105789. * if the ground has been updated.
  105790. * This can be used in the render loop.
  105791. * @returns the GroundMesh.
  105792. */
  105793. updateCoordinateHeights(): GroundMesh;
  105794. private _getFacetAt;
  105795. private _initHeightQuads;
  105796. private _computeHeightQuads;
  105797. /**
  105798. * Serializes this ground mesh
  105799. * @param serializationObject object to write serialization to
  105800. */
  105801. serialize(serializationObject: any): void;
  105802. /**
  105803. * Parses a serialized ground mesh
  105804. * @param parsedMesh the serialized mesh
  105805. * @param scene the scene to create the ground mesh in
  105806. * @returns the created ground mesh
  105807. */
  105808. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105809. }
  105810. }
  105811. declare module BABYLON {
  105812. /**
  105813. * Interface for Physics-Joint data
  105814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105815. */
  105816. export interface PhysicsJointData {
  105817. /**
  105818. * The main pivot of the joint
  105819. */
  105820. mainPivot?: Vector3;
  105821. /**
  105822. * The connected pivot of the joint
  105823. */
  105824. connectedPivot?: Vector3;
  105825. /**
  105826. * The main axis of the joint
  105827. */
  105828. mainAxis?: Vector3;
  105829. /**
  105830. * The connected axis of the joint
  105831. */
  105832. connectedAxis?: Vector3;
  105833. /**
  105834. * The collision of the joint
  105835. */
  105836. collision?: boolean;
  105837. /**
  105838. * Native Oimo/Cannon/Energy data
  105839. */
  105840. nativeParams?: any;
  105841. }
  105842. /**
  105843. * This is a holder class for the physics joint created by the physics plugin
  105844. * It holds a set of functions to control the underlying joint
  105845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105846. */
  105847. export class PhysicsJoint {
  105848. /**
  105849. * The type of the physics joint
  105850. */
  105851. type: number;
  105852. /**
  105853. * The data for the physics joint
  105854. */
  105855. jointData: PhysicsJointData;
  105856. private _physicsJoint;
  105857. protected _physicsPlugin: IPhysicsEnginePlugin;
  105858. /**
  105859. * Initializes the physics joint
  105860. * @param type The type of the physics joint
  105861. * @param jointData The data for the physics joint
  105862. */
  105863. constructor(
  105864. /**
  105865. * The type of the physics joint
  105866. */
  105867. type: number,
  105868. /**
  105869. * The data for the physics joint
  105870. */
  105871. jointData: PhysicsJointData);
  105872. /**
  105873. * Gets the physics joint
  105874. */
  105875. get physicsJoint(): any;
  105876. /**
  105877. * Sets the physics joint
  105878. */
  105879. set physicsJoint(newJoint: any);
  105880. /**
  105881. * Sets the physics plugin
  105882. */
  105883. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105884. /**
  105885. * Execute a function that is physics-plugin specific.
  105886. * @param {Function} func the function that will be executed.
  105887. * It accepts two parameters: the physics world and the physics joint
  105888. */
  105889. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105890. /**
  105891. * Distance-Joint type
  105892. */
  105893. static DistanceJoint: number;
  105894. /**
  105895. * Hinge-Joint type
  105896. */
  105897. static HingeJoint: number;
  105898. /**
  105899. * Ball-and-Socket joint type
  105900. */
  105901. static BallAndSocketJoint: number;
  105902. /**
  105903. * Wheel-Joint type
  105904. */
  105905. static WheelJoint: number;
  105906. /**
  105907. * Slider-Joint type
  105908. */
  105909. static SliderJoint: number;
  105910. /**
  105911. * Prismatic-Joint type
  105912. */
  105913. static PrismaticJoint: number;
  105914. /**
  105915. * Universal-Joint type
  105916. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105917. */
  105918. static UniversalJoint: number;
  105919. /**
  105920. * Hinge-Joint 2 type
  105921. */
  105922. static Hinge2Joint: number;
  105923. /**
  105924. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105925. */
  105926. static PointToPointJoint: number;
  105927. /**
  105928. * Spring-Joint type
  105929. */
  105930. static SpringJoint: number;
  105931. /**
  105932. * Lock-Joint type
  105933. */
  105934. static LockJoint: number;
  105935. }
  105936. /**
  105937. * A class representing a physics distance joint
  105938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105939. */
  105940. export class DistanceJoint extends PhysicsJoint {
  105941. /**
  105942. *
  105943. * @param jointData The data for the Distance-Joint
  105944. */
  105945. constructor(jointData: DistanceJointData);
  105946. /**
  105947. * Update the predefined distance.
  105948. * @param maxDistance The maximum preferred distance
  105949. * @param minDistance The minimum preferred distance
  105950. */
  105951. updateDistance(maxDistance: number, minDistance?: number): void;
  105952. }
  105953. /**
  105954. * Represents a Motor-Enabled Joint
  105955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105956. */
  105957. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105958. /**
  105959. * Initializes the Motor-Enabled Joint
  105960. * @param type The type of the joint
  105961. * @param jointData The physica joint data for the joint
  105962. */
  105963. constructor(type: number, jointData: PhysicsJointData);
  105964. /**
  105965. * Set the motor values.
  105966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105967. * @param force the force to apply
  105968. * @param maxForce max force for this motor.
  105969. */
  105970. setMotor(force?: number, maxForce?: number): void;
  105971. /**
  105972. * Set the motor's limits.
  105973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105974. * @param upperLimit The upper limit of the motor
  105975. * @param lowerLimit The lower limit of the motor
  105976. */
  105977. setLimit(upperLimit: number, lowerLimit?: number): void;
  105978. }
  105979. /**
  105980. * This class represents a single physics Hinge-Joint
  105981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105982. */
  105983. export class HingeJoint extends MotorEnabledJoint {
  105984. /**
  105985. * Initializes the Hinge-Joint
  105986. * @param jointData The joint data for the Hinge-Joint
  105987. */
  105988. constructor(jointData: PhysicsJointData);
  105989. /**
  105990. * Set the motor values.
  105991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105992. * @param {number} force the force to apply
  105993. * @param {number} maxForce max force for this motor.
  105994. */
  105995. setMotor(force?: number, maxForce?: number): void;
  105996. /**
  105997. * Set the motor's limits.
  105998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105999. * @param upperLimit The upper limit of the motor
  106000. * @param lowerLimit The lower limit of the motor
  106001. */
  106002. setLimit(upperLimit: number, lowerLimit?: number): void;
  106003. }
  106004. /**
  106005. * This class represents a dual hinge physics joint (same as wheel joint)
  106006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106007. */
  106008. export class Hinge2Joint extends MotorEnabledJoint {
  106009. /**
  106010. * Initializes the Hinge2-Joint
  106011. * @param jointData The joint data for the Hinge2-Joint
  106012. */
  106013. constructor(jointData: PhysicsJointData);
  106014. /**
  106015. * Set the motor values.
  106016. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106017. * @param {number} targetSpeed the speed the motor is to reach
  106018. * @param {number} maxForce max force for this motor.
  106019. * @param {motorIndex} the motor's index, 0 or 1.
  106020. */
  106021. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106022. /**
  106023. * Set the motor limits.
  106024. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106025. * @param {number} upperLimit the upper limit
  106026. * @param {number} lowerLimit lower limit
  106027. * @param {motorIndex} the motor's index, 0 or 1.
  106028. */
  106029. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106030. }
  106031. /**
  106032. * Interface for a motor enabled joint
  106033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106034. */
  106035. export interface IMotorEnabledJoint {
  106036. /**
  106037. * Physics joint
  106038. */
  106039. physicsJoint: any;
  106040. /**
  106041. * Sets the motor of the motor-enabled joint
  106042. * @param force The force of the motor
  106043. * @param maxForce The maximum force of the motor
  106044. * @param motorIndex The index of the motor
  106045. */
  106046. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106047. /**
  106048. * Sets the limit of the motor
  106049. * @param upperLimit The upper limit of the motor
  106050. * @param lowerLimit The lower limit of the motor
  106051. * @param motorIndex The index of the motor
  106052. */
  106053. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106054. }
  106055. /**
  106056. * Joint data for a Distance-Joint
  106057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106058. */
  106059. export interface DistanceJointData extends PhysicsJointData {
  106060. /**
  106061. * Max distance the 2 joint objects can be apart
  106062. */
  106063. maxDistance: number;
  106064. }
  106065. /**
  106066. * Joint data from a spring joint
  106067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106068. */
  106069. export interface SpringJointData extends PhysicsJointData {
  106070. /**
  106071. * Length of the spring
  106072. */
  106073. length: number;
  106074. /**
  106075. * Stiffness of the spring
  106076. */
  106077. stiffness: number;
  106078. /**
  106079. * Damping of the spring
  106080. */
  106081. damping: number;
  106082. /** this callback will be called when applying the force to the impostors. */
  106083. forceApplicationCallback: () => void;
  106084. }
  106085. }
  106086. declare module BABYLON {
  106087. /**
  106088. * Holds the data for the raycast result
  106089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106090. */
  106091. export class PhysicsRaycastResult {
  106092. private _hasHit;
  106093. private _hitDistance;
  106094. private _hitNormalWorld;
  106095. private _hitPointWorld;
  106096. private _rayFromWorld;
  106097. private _rayToWorld;
  106098. /**
  106099. * Gets if there was a hit
  106100. */
  106101. get hasHit(): boolean;
  106102. /**
  106103. * Gets the distance from the hit
  106104. */
  106105. get hitDistance(): number;
  106106. /**
  106107. * Gets the hit normal/direction in the world
  106108. */
  106109. get hitNormalWorld(): Vector3;
  106110. /**
  106111. * Gets the hit point in the world
  106112. */
  106113. get hitPointWorld(): Vector3;
  106114. /**
  106115. * Gets the ray "start point" of the ray in the world
  106116. */
  106117. get rayFromWorld(): Vector3;
  106118. /**
  106119. * Gets the ray "end point" of the ray in the world
  106120. */
  106121. get rayToWorld(): Vector3;
  106122. /**
  106123. * Sets the hit data (normal & point in world space)
  106124. * @param hitNormalWorld defines the normal in world space
  106125. * @param hitPointWorld defines the point in world space
  106126. */
  106127. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106128. /**
  106129. * Sets the distance from the start point to the hit point
  106130. * @param distance
  106131. */
  106132. setHitDistance(distance: number): void;
  106133. /**
  106134. * Calculates the distance manually
  106135. */
  106136. calculateHitDistance(): void;
  106137. /**
  106138. * Resets all the values to default
  106139. * @param from The from point on world space
  106140. * @param to The to point on world space
  106141. */
  106142. reset(from?: Vector3, to?: Vector3): void;
  106143. }
  106144. /**
  106145. * Interface for the size containing width and height
  106146. */
  106147. interface IXYZ {
  106148. /**
  106149. * X
  106150. */
  106151. x: number;
  106152. /**
  106153. * Y
  106154. */
  106155. y: number;
  106156. /**
  106157. * Z
  106158. */
  106159. z: number;
  106160. }
  106161. }
  106162. declare module BABYLON {
  106163. /**
  106164. * Interface used to describe a physics joint
  106165. */
  106166. export interface PhysicsImpostorJoint {
  106167. /** Defines the main impostor to which the joint is linked */
  106168. mainImpostor: PhysicsImpostor;
  106169. /** Defines the impostor that is connected to the main impostor using this joint */
  106170. connectedImpostor: PhysicsImpostor;
  106171. /** Defines the joint itself */
  106172. joint: PhysicsJoint;
  106173. }
  106174. /** @hidden */
  106175. export interface IPhysicsEnginePlugin {
  106176. world: any;
  106177. name: string;
  106178. setGravity(gravity: Vector3): void;
  106179. setTimeStep(timeStep: number): void;
  106180. getTimeStep(): number;
  106181. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106182. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106183. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106184. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106185. removePhysicsBody(impostor: PhysicsImpostor): void;
  106186. generateJoint(joint: PhysicsImpostorJoint): void;
  106187. removeJoint(joint: PhysicsImpostorJoint): void;
  106188. isSupported(): boolean;
  106189. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106190. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106191. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106192. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106193. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106194. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106195. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106196. getBodyMass(impostor: PhysicsImpostor): number;
  106197. getBodyFriction(impostor: PhysicsImpostor): number;
  106198. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106199. getBodyRestitution(impostor: PhysicsImpostor): number;
  106200. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106201. getBodyPressure?(impostor: PhysicsImpostor): number;
  106202. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106203. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106204. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106205. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106206. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106207. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106208. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106209. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106210. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106211. sleepBody(impostor: PhysicsImpostor): void;
  106212. wakeUpBody(impostor: PhysicsImpostor): void;
  106213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106214. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106215. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106216. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106217. getRadius(impostor: PhysicsImpostor): number;
  106218. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106219. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106220. dispose(): void;
  106221. }
  106222. /**
  106223. * Interface used to define a physics engine
  106224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106225. */
  106226. export interface IPhysicsEngine {
  106227. /**
  106228. * Gets the gravity vector used by the simulation
  106229. */
  106230. gravity: Vector3;
  106231. /**
  106232. * Sets the gravity vector used by the simulation
  106233. * @param gravity defines the gravity vector to use
  106234. */
  106235. setGravity(gravity: Vector3): void;
  106236. /**
  106237. * Set the time step of the physics engine.
  106238. * Default is 1/60.
  106239. * To slow it down, enter 1/600 for example.
  106240. * To speed it up, 1/30
  106241. * @param newTimeStep the new timestep to apply to this world.
  106242. */
  106243. setTimeStep(newTimeStep: number): void;
  106244. /**
  106245. * Get the time step of the physics engine.
  106246. * @returns the current time step
  106247. */
  106248. getTimeStep(): number;
  106249. /**
  106250. * Set the sub time step of the physics engine.
  106251. * Default is 0 meaning there is no sub steps
  106252. * To increase physics resolution precision, set a small value (like 1 ms)
  106253. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106254. */
  106255. setSubTimeStep(subTimeStep: number): void;
  106256. /**
  106257. * Get the sub time step of the physics engine.
  106258. * @returns the current sub time step
  106259. */
  106260. getSubTimeStep(): number;
  106261. /**
  106262. * Release all resources
  106263. */
  106264. dispose(): void;
  106265. /**
  106266. * Gets the name of the current physics plugin
  106267. * @returns the name of the plugin
  106268. */
  106269. getPhysicsPluginName(): string;
  106270. /**
  106271. * Adding a new impostor for the impostor tracking.
  106272. * This will be done by the impostor itself.
  106273. * @param impostor the impostor to add
  106274. */
  106275. addImpostor(impostor: PhysicsImpostor): void;
  106276. /**
  106277. * Remove an impostor from the engine.
  106278. * This impostor and its mesh will not longer be updated by the physics engine.
  106279. * @param impostor the impostor to remove
  106280. */
  106281. removeImpostor(impostor: PhysicsImpostor): void;
  106282. /**
  106283. * Add a joint to the physics engine
  106284. * @param mainImpostor defines the main impostor to which the joint is added.
  106285. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106286. * @param joint defines the joint that will connect both impostors.
  106287. */
  106288. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106289. /**
  106290. * Removes a joint from the simulation
  106291. * @param mainImpostor defines the impostor used with the joint
  106292. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106293. * @param joint defines the joint to remove
  106294. */
  106295. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106296. /**
  106297. * Gets the current plugin used to run the simulation
  106298. * @returns current plugin
  106299. */
  106300. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106301. /**
  106302. * Gets the list of physic impostors
  106303. * @returns an array of PhysicsImpostor
  106304. */
  106305. getImpostors(): Array<PhysicsImpostor>;
  106306. /**
  106307. * Gets the impostor for a physics enabled object
  106308. * @param object defines the object impersonated by the impostor
  106309. * @returns the PhysicsImpostor or null if not found
  106310. */
  106311. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106312. /**
  106313. * Gets the impostor for a physics body object
  106314. * @param body defines physics body used by the impostor
  106315. * @returns the PhysicsImpostor or null if not found
  106316. */
  106317. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106318. /**
  106319. * Does a raycast in the physics world
  106320. * @param from when should the ray start?
  106321. * @param to when should the ray end?
  106322. * @returns PhysicsRaycastResult
  106323. */
  106324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106325. /**
  106326. * Called by the scene. No need to call it.
  106327. * @param delta defines the timespam between frames
  106328. */
  106329. _step(delta: number): void;
  106330. }
  106331. }
  106332. declare module BABYLON {
  106333. /**
  106334. * The interface for the physics imposter parameters
  106335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106336. */
  106337. export interface PhysicsImpostorParameters {
  106338. /**
  106339. * The mass of the physics imposter
  106340. */
  106341. mass: number;
  106342. /**
  106343. * The friction of the physics imposter
  106344. */
  106345. friction?: number;
  106346. /**
  106347. * The coefficient of restitution of the physics imposter
  106348. */
  106349. restitution?: number;
  106350. /**
  106351. * The native options of the physics imposter
  106352. */
  106353. nativeOptions?: any;
  106354. /**
  106355. * Specifies if the parent should be ignored
  106356. */
  106357. ignoreParent?: boolean;
  106358. /**
  106359. * Specifies if bi-directional transformations should be disabled
  106360. */
  106361. disableBidirectionalTransformation?: boolean;
  106362. /**
  106363. * The pressure inside the physics imposter, soft object only
  106364. */
  106365. pressure?: number;
  106366. /**
  106367. * The stiffness the physics imposter, soft object only
  106368. */
  106369. stiffness?: number;
  106370. /**
  106371. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106372. */
  106373. velocityIterations?: number;
  106374. /**
  106375. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106376. */
  106377. positionIterations?: number;
  106378. /**
  106379. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106380. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106381. * Add to fix multiple points
  106382. */
  106383. fixedPoints?: number;
  106384. /**
  106385. * The collision margin around a soft object
  106386. */
  106387. margin?: number;
  106388. /**
  106389. * The collision margin around a soft object
  106390. */
  106391. damping?: number;
  106392. /**
  106393. * The path for a rope based on an extrusion
  106394. */
  106395. path?: any;
  106396. /**
  106397. * The shape of an extrusion used for a rope based on an extrusion
  106398. */
  106399. shape?: any;
  106400. }
  106401. /**
  106402. * Interface for a physics-enabled object
  106403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106404. */
  106405. export interface IPhysicsEnabledObject {
  106406. /**
  106407. * The position of the physics-enabled object
  106408. */
  106409. position: Vector3;
  106410. /**
  106411. * The rotation of the physics-enabled object
  106412. */
  106413. rotationQuaternion: Nullable<Quaternion>;
  106414. /**
  106415. * The scale of the physics-enabled object
  106416. */
  106417. scaling: Vector3;
  106418. /**
  106419. * The rotation of the physics-enabled object
  106420. */
  106421. rotation?: Vector3;
  106422. /**
  106423. * The parent of the physics-enabled object
  106424. */
  106425. parent?: any;
  106426. /**
  106427. * The bounding info of the physics-enabled object
  106428. * @returns The bounding info of the physics-enabled object
  106429. */
  106430. getBoundingInfo(): BoundingInfo;
  106431. /**
  106432. * Computes the world matrix
  106433. * @param force Specifies if the world matrix should be computed by force
  106434. * @returns A world matrix
  106435. */
  106436. computeWorldMatrix(force: boolean): Matrix;
  106437. /**
  106438. * Gets the world matrix
  106439. * @returns A world matrix
  106440. */
  106441. getWorldMatrix?(): Matrix;
  106442. /**
  106443. * Gets the child meshes
  106444. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106445. * @returns An array of abstract meshes
  106446. */
  106447. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106448. /**
  106449. * Gets the vertex data
  106450. * @param kind The type of vertex data
  106451. * @returns A nullable array of numbers, or a float32 array
  106452. */
  106453. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106454. /**
  106455. * Gets the indices from the mesh
  106456. * @returns A nullable array of index arrays
  106457. */
  106458. getIndices?(): Nullable<IndicesArray>;
  106459. /**
  106460. * Gets the scene from the mesh
  106461. * @returns the indices array or null
  106462. */
  106463. getScene?(): Scene;
  106464. /**
  106465. * Gets the absolute position from the mesh
  106466. * @returns the absolute position
  106467. */
  106468. getAbsolutePosition(): Vector3;
  106469. /**
  106470. * Gets the absolute pivot point from the mesh
  106471. * @returns the absolute pivot point
  106472. */
  106473. getAbsolutePivotPoint(): Vector3;
  106474. /**
  106475. * Rotates the mesh
  106476. * @param axis The axis of rotation
  106477. * @param amount The amount of rotation
  106478. * @param space The space of the rotation
  106479. * @returns The rotation transform node
  106480. */
  106481. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106482. /**
  106483. * Translates the mesh
  106484. * @param axis The axis of translation
  106485. * @param distance The distance of translation
  106486. * @param space The space of the translation
  106487. * @returns The transform node
  106488. */
  106489. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106490. /**
  106491. * Sets the absolute position of the mesh
  106492. * @param absolutePosition The absolute position of the mesh
  106493. * @returns The transform node
  106494. */
  106495. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106496. /**
  106497. * Gets the class name of the mesh
  106498. * @returns The class name
  106499. */
  106500. getClassName(): string;
  106501. }
  106502. /**
  106503. * Represents a physics imposter
  106504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106505. */
  106506. export class PhysicsImpostor {
  106507. /**
  106508. * The physics-enabled object used as the physics imposter
  106509. */
  106510. object: IPhysicsEnabledObject;
  106511. /**
  106512. * The type of the physics imposter
  106513. */
  106514. type: number;
  106515. private _options;
  106516. private _scene?;
  106517. /**
  106518. * The default object size of the imposter
  106519. */
  106520. static DEFAULT_OBJECT_SIZE: Vector3;
  106521. /**
  106522. * The identity quaternion of the imposter
  106523. */
  106524. static IDENTITY_QUATERNION: Quaternion;
  106525. /** @hidden */
  106526. _pluginData: any;
  106527. private _physicsEngine;
  106528. private _physicsBody;
  106529. private _bodyUpdateRequired;
  106530. private _onBeforePhysicsStepCallbacks;
  106531. private _onAfterPhysicsStepCallbacks;
  106532. /** @hidden */
  106533. _onPhysicsCollideCallbacks: Array<{
  106534. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106535. otherImpostors: Array<PhysicsImpostor>;
  106536. }>;
  106537. private _deltaPosition;
  106538. private _deltaRotation;
  106539. private _deltaRotationConjugated;
  106540. /** @hidden */
  106541. _isFromLine: boolean;
  106542. private _parent;
  106543. private _isDisposed;
  106544. private static _tmpVecs;
  106545. private static _tmpQuat;
  106546. /**
  106547. * Specifies if the physics imposter is disposed
  106548. */
  106549. get isDisposed(): boolean;
  106550. /**
  106551. * Gets the mass of the physics imposter
  106552. */
  106553. get mass(): number;
  106554. set mass(value: number);
  106555. /**
  106556. * Gets the coefficient of friction
  106557. */
  106558. get friction(): number;
  106559. /**
  106560. * Sets the coefficient of friction
  106561. */
  106562. set friction(value: number);
  106563. /**
  106564. * Gets the coefficient of restitution
  106565. */
  106566. get restitution(): number;
  106567. /**
  106568. * Sets the coefficient of restitution
  106569. */
  106570. set restitution(value: number);
  106571. /**
  106572. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106573. */
  106574. get pressure(): number;
  106575. /**
  106576. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106577. */
  106578. set pressure(value: number);
  106579. /**
  106580. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106581. */
  106582. get stiffness(): number;
  106583. /**
  106584. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106585. */
  106586. set stiffness(value: number);
  106587. /**
  106588. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106589. */
  106590. get velocityIterations(): number;
  106591. /**
  106592. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106593. */
  106594. set velocityIterations(value: number);
  106595. /**
  106596. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106597. */
  106598. get positionIterations(): number;
  106599. /**
  106600. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106601. */
  106602. set positionIterations(value: number);
  106603. /**
  106604. * The unique id of the physics imposter
  106605. * set by the physics engine when adding this impostor to the array
  106606. */
  106607. uniqueId: number;
  106608. /**
  106609. * @hidden
  106610. */
  106611. soft: boolean;
  106612. /**
  106613. * @hidden
  106614. */
  106615. segments: number;
  106616. private _joints;
  106617. /**
  106618. * Initializes the physics imposter
  106619. * @param object The physics-enabled object used as the physics imposter
  106620. * @param type The type of the physics imposter
  106621. * @param _options The options for the physics imposter
  106622. * @param _scene The Babylon scene
  106623. */
  106624. constructor(
  106625. /**
  106626. * The physics-enabled object used as the physics imposter
  106627. */
  106628. object: IPhysicsEnabledObject,
  106629. /**
  106630. * The type of the physics imposter
  106631. */
  106632. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106633. /**
  106634. * This function will completly initialize this impostor.
  106635. * It will create a new body - but only if this mesh has no parent.
  106636. * If it has, this impostor will not be used other than to define the impostor
  106637. * of the child mesh.
  106638. * @hidden
  106639. */
  106640. _init(): void;
  106641. private _getPhysicsParent;
  106642. /**
  106643. * Should a new body be generated.
  106644. * @returns boolean specifying if body initialization is required
  106645. */
  106646. isBodyInitRequired(): boolean;
  106647. /**
  106648. * Sets the updated scaling
  106649. * @param updated Specifies if the scaling is updated
  106650. */
  106651. setScalingUpdated(): void;
  106652. /**
  106653. * Force a regeneration of this or the parent's impostor's body.
  106654. * Use under cautious - This will remove all joints already implemented.
  106655. */
  106656. forceUpdate(): void;
  106657. /**
  106658. * Gets the body that holds this impostor. Either its own, or its parent.
  106659. */
  106660. get physicsBody(): any;
  106661. /**
  106662. * Get the parent of the physics imposter
  106663. * @returns Physics imposter or null
  106664. */
  106665. get parent(): Nullable<PhysicsImpostor>;
  106666. /**
  106667. * Sets the parent of the physics imposter
  106668. */
  106669. set parent(value: Nullable<PhysicsImpostor>);
  106670. /**
  106671. * Set the physics body. Used mainly by the physics engine/plugin
  106672. */
  106673. set physicsBody(physicsBody: any);
  106674. /**
  106675. * Resets the update flags
  106676. */
  106677. resetUpdateFlags(): void;
  106678. /**
  106679. * Gets the object extend size
  106680. * @returns the object extend size
  106681. */
  106682. getObjectExtendSize(): Vector3;
  106683. /**
  106684. * Gets the object center
  106685. * @returns The object center
  106686. */
  106687. getObjectCenter(): Vector3;
  106688. /**
  106689. * Get a specific parameter from the options parameters
  106690. * @param paramName The object parameter name
  106691. * @returns The object parameter
  106692. */
  106693. getParam(paramName: string): any;
  106694. /**
  106695. * Sets a specific parameter in the options given to the physics plugin
  106696. * @param paramName The parameter name
  106697. * @param value The value of the parameter
  106698. */
  106699. setParam(paramName: string, value: number): void;
  106700. /**
  106701. * Specifically change the body's mass option. Won't recreate the physics body object
  106702. * @param mass The mass of the physics imposter
  106703. */
  106704. setMass(mass: number): void;
  106705. /**
  106706. * Gets the linear velocity
  106707. * @returns linear velocity or null
  106708. */
  106709. getLinearVelocity(): Nullable<Vector3>;
  106710. /**
  106711. * Sets the linear velocity
  106712. * @param velocity linear velocity or null
  106713. */
  106714. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106715. /**
  106716. * Gets the angular velocity
  106717. * @returns angular velocity or null
  106718. */
  106719. getAngularVelocity(): Nullable<Vector3>;
  106720. /**
  106721. * Sets the angular velocity
  106722. * @param velocity The velocity or null
  106723. */
  106724. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106725. /**
  106726. * Execute a function with the physics plugin native code
  106727. * Provide a function the will have two variables - the world object and the physics body object
  106728. * @param func The function to execute with the physics plugin native code
  106729. */
  106730. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106731. /**
  106732. * Register a function that will be executed before the physics world is stepping forward
  106733. * @param func The function to execute before the physics world is stepped forward
  106734. */
  106735. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106736. /**
  106737. * Unregister a function that will be executed before the physics world is stepping forward
  106738. * @param func The function to execute before the physics world is stepped forward
  106739. */
  106740. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106741. /**
  106742. * Register a function that will be executed after the physics step
  106743. * @param func The function to execute after physics step
  106744. */
  106745. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106746. /**
  106747. * Unregisters a function that will be executed after the physics step
  106748. * @param func The function to execute after physics step
  106749. */
  106750. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106751. /**
  106752. * register a function that will be executed when this impostor collides against a different body
  106753. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106754. * @param func Callback that is executed on collision
  106755. */
  106756. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106757. /**
  106758. * Unregisters the physics imposter on contact
  106759. * @param collideAgainst The physics object to collide against
  106760. * @param func Callback to execute on collision
  106761. */
  106762. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106763. private _tmpQuat;
  106764. private _tmpQuat2;
  106765. /**
  106766. * Get the parent rotation
  106767. * @returns The parent rotation
  106768. */
  106769. getParentsRotation(): Quaternion;
  106770. /**
  106771. * this function is executed by the physics engine.
  106772. */
  106773. beforeStep: () => void;
  106774. /**
  106775. * this function is executed by the physics engine
  106776. */
  106777. afterStep: () => void;
  106778. /**
  106779. * Legacy collision detection event support
  106780. */
  106781. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106782. /**
  106783. * event and body object due to cannon's event-based architecture.
  106784. */
  106785. onCollide: (e: {
  106786. body: any;
  106787. }) => void;
  106788. /**
  106789. * Apply a force
  106790. * @param force The force to apply
  106791. * @param contactPoint The contact point for the force
  106792. * @returns The physics imposter
  106793. */
  106794. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106795. /**
  106796. * Apply an impulse
  106797. * @param force The impulse force
  106798. * @param contactPoint The contact point for the impulse force
  106799. * @returns The physics imposter
  106800. */
  106801. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106802. /**
  106803. * A help function to create a joint
  106804. * @param otherImpostor A physics imposter used to create a joint
  106805. * @param jointType The type of joint
  106806. * @param jointData The data for the joint
  106807. * @returns The physics imposter
  106808. */
  106809. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106810. /**
  106811. * Add a joint to this impostor with a different impostor
  106812. * @param otherImpostor A physics imposter used to add a joint
  106813. * @param joint The joint to add
  106814. * @returns The physics imposter
  106815. */
  106816. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106817. /**
  106818. * Add an anchor to a cloth impostor
  106819. * @param otherImpostor rigid impostor to anchor to
  106820. * @param width ratio across width from 0 to 1
  106821. * @param height ratio up height from 0 to 1
  106822. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106823. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106824. * @returns impostor the soft imposter
  106825. */
  106826. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106827. /**
  106828. * Add a hook to a rope impostor
  106829. * @param otherImpostor rigid impostor to anchor to
  106830. * @param length ratio across rope from 0 to 1
  106831. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106832. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106833. * @returns impostor the rope imposter
  106834. */
  106835. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106836. /**
  106837. * Will keep this body still, in a sleep mode.
  106838. * @returns the physics imposter
  106839. */
  106840. sleep(): PhysicsImpostor;
  106841. /**
  106842. * Wake the body up.
  106843. * @returns The physics imposter
  106844. */
  106845. wakeUp(): PhysicsImpostor;
  106846. /**
  106847. * Clones the physics imposter
  106848. * @param newObject The physics imposter clones to this physics-enabled object
  106849. * @returns A nullable physics imposter
  106850. */
  106851. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106852. /**
  106853. * Disposes the physics imposter
  106854. */
  106855. dispose(): void;
  106856. /**
  106857. * Sets the delta position
  106858. * @param position The delta position amount
  106859. */
  106860. setDeltaPosition(position: Vector3): void;
  106861. /**
  106862. * Sets the delta rotation
  106863. * @param rotation The delta rotation amount
  106864. */
  106865. setDeltaRotation(rotation: Quaternion): void;
  106866. /**
  106867. * Gets the box size of the physics imposter and stores the result in the input parameter
  106868. * @param result Stores the box size
  106869. * @returns The physics imposter
  106870. */
  106871. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106872. /**
  106873. * Gets the radius of the physics imposter
  106874. * @returns Radius of the physics imposter
  106875. */
  106876. getRadius(): number;
  106877. /**
  106878. * Sync a bone with this impostor
  106879. * @param bone The bone to sync to the impostor.
  106880. * @param boneMesh The mesh that the bone is influencing.
  106881. * @param jointPivot The pivot of the joint / bone in local space.
  106882. * @param distToJoint Optional distance from the impostor to the joint.
  106883. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106884. */
  106885. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106886. /**
  106887. * Sync impostor to a bone
  106888. * @param bone The bone that the impostor will be synced to.
  106889. * @param boneMesh The mesh that the bone is influencing.
  106890. * @param jointPivot The pivot of the joint / bone in local space.
  106891. * @param distToJoint Optional distance from the impostor to the joint.
  106892. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106893. * @param boneAxis Optional vector3 axis the bone is aligned with
  106894. */
  106895. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106896. /**
  106897. * No-Imposter type
  106898. */
  106899. static NoImpostor: number;
  106900. /**
  106901. * Sphere-Imposter type
  106902. */
  106903. static SphereImpostor: number;
  106904. /**
  106905. * Box-Imposter type
  106906. */
  106907. static BoxImpostor: number;
  106908. /**
  106909. * Plane-Imposter type
  106910. */
  106911. static PlaneImpostor: number;
  106912. /**
  106913. * Mesh-imposter type
  106914. */
  106915. static MeshImpostor: number;
  106916. /**
  106917. * Capsule-Impostor type (Ammo.js plugin only)
  106918. */
  106919. static CapsuleImpostor: number;
  106920. /**
  106921. * Cylinder-Imposter type
  106922. */
  106923. static CylinderImpostor: number;
  106924. /**
  106925. * Particle-Imposter type
  106926. */
  106927. static ParticleImpostor: number;
  106928. /**
  106929. * Heightmap-Imposter type
  106930. */
  106931. static HeightmapImpostor: number;
  106932. /**
  106933. * ConvexHull-Impostor type (Ammo.js plugin only)
  106934. */
  106935. static ConvexHullImpostor: number;
  106936. /**
  106937. * Custom-Imposter type (Ammo.js plugin only)
  106938. */
  106939. static CustomImpostor: number;
  106940. /**
  106941. * Rope-Imposter type
  106942. */
  106943. static RopeImpostor: number;
  106944. /**
  106945. * Cloth-Imposter type
  106946. */
  106947. static ClothImpostor: number;
  106948. /**
  106949. * Softbody-Imposter type
  106950. */
  106951. static SoftbodyImpostor: number;
  106952. }
  106953. }
  106954. declare module BABYLON {
  106955. /**
  106956. * @hidden
  106957. **/
  106958. export class _CreationDataStorage {
  106959. closePath?: boolean;
  106960. closeArray?: boolean;
  106961. idx: number[];
  106962. dashSize: number;
  106963. gapSize: number;
  106964. path3D: Path3D;
  106965. pathArray: Vector3[][];
  106966. arc: number;
  106967. radius: number;
  106968. cap: number;
  106969. tessellation: number;
  106970. }
  106971. /**
  106972. * @hidden
  106973. **/
  106974. class _InstanceDataStorage {
  106975. visibleInstances: any;
  106976. batchCache: _InstancesBatch;
  106977. instancesBufferSize: number;
  106978. instancesBuffer: Nullable<Buffer>;
  106979. instancesData: Float32Array;
  106980. overridenInstanceCount: number;
  106981. isFrozen: boolean;
  106982. previousBatch: Nullable<_InstancesBatch>;
  106983. hardwareInstancedRendering: boolean;
  106984. sideOrientation: number;
  106985. manualUpdate: boolean;
  106986. }
  106987. /**
  106988. * @hidden
  106989. **/
  106990. export class _InstancesBatch {
  106991. mustReturn: boolean;
  106992. visibleInstances: Nullable<InstancedMesh[]>[];
  106993. renderSelf: boolean[];
  106994. hardwareInstancedRendering: boolean[];
  106995. }
  106996. /**
  106997. * @hidden
  106998. **/
  106999. class _ThinInstanceDataStorage {
  107000. instancesCount: number;
  107001. matrixBuffer: Nullable<Buffer>;
  107002. matrixBufferSize: number;
  107003. matrixData: Nullable<Float32Array>;
  107004. boundingVectors: Array<Vector3>;
  107005. worldMatrices: Nullable<Matrix[]>;
  107006. }
  107007. /**
  107008. * Class used to represent renderable models
  107009. */
  107010. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107011. /**
  107012. * Mesh side orientation : usually the external or front surface
  107013. */
  107014. static readonly FRONTSIDE: number;
  107015. /**
  107016. * Mesh side orientation : usually the internal or back surface
  107017. */
  107018. static readonly BACKSIDE: number;
  107019. /**
  107020. * Mesh side orientation : both internal and external or front and back surfaces
  107021. */
  107022. static readonly DOUBLESIDE: number;
  107023. /**
  107024. * Mesh side orientation : by default, `FRONTSIDE`
  107025. */
  107026. static readonly DEFAULTSIDE: number;
  107027. /**
  107028. * Mesh cap setting : no cap
  107029. */
  107030. static readonly NO_CAP: number;
  107031. /**
  107032. * Mesh cap setting : one cap at the beginning of the mesh
  107033. */
  107034. static readonly CAP_START: number;
  107035. /**
  107036. * Mesh cap setting : one cap at the end of the mesh
  107037. */
  107038. static readonly CAP_END: number;
  107039. /**
  107040. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107041. */
  107042. static readonly CAP_ALL: number;
  107043. /**
  107044. * Mesh pattern setting : no flip or rotate
  107045. */
  107046. static readonly NO_FLIP: number;
  107047. /**
  107048. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107049. */
  107050. static readonly FLIP_TILE: number;
  107051. /**
  107052. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107053. */
  107054. static readonly ROTATE_TILE: number;
  107055. /**
  107056. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107057. */
  107058. static readonly FLIP_ROW: number;
  107059. /**
  107060. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107061. */
  107062. static readonly ROTATE_ROW: number;
  107063. /**
  107064. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107065. */
  107066. static readonly FLIP_N_ROTATE_TILE: number;
  107067. /**
  107068. * Mesh pattern setting : rotate pattern and rotate
  107069. */
  107070. static readonly FLIP_N_ROTATE_ROW: number;
  107071. /**
  107072. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107073. */
  107074. static readonly CENTER: number;
  107075. /**
  107076. * Mesh tile positioning : part tiles on left
  107077. */
  107078. static readonly LEFT: number;
  107079. /**
  107080. * Mesh tile positioning : part tiles on right
  107081. */
  107082. static readonly RIGHT: number;
  107083. /**
  107084. * Mesh tile positioning : part tiles on top
  107085. */
  107086. static readonly TOP: number;
  107087. /**
  107088. * Mesh tile positioning : part tiles on bottom
  107089. */
  107090. static readonly BOTTOM: number;
  107091. /**
  107092. * Gets the default side orientation.
  107093. * @param orientation the orientation to value to attempt to get
  107094. * @returns the default orientation
  107095. * @hidden
  107096. */
  107097. static _GetDefaultSideOrientation(orientation?: number): number;
  107098. private _internalMeshDataInfo;
  107099. get computeBonesUsingShaders(): boolean;
  107100. set computeBonesUsingShaders(value: boolean);
  107101. /**
  107102. * An event triggered before rendering the mesh
  107103. */
  107104. get onBeforeRenderObservable(): Observable<Mesh>;
  107105. /**
  107106. * An event triggered before binding the mesh
  107107. */
  107108. get onBeforeBindObservable(): Observable<Mesh>;
  107109. /**
  107110. * An event triggered after rendering the mesh
  107111. */
  107112. get onAfterRenderObservable(): Observable<Mesh>;
  107113. /**
  107114. * An event triggered before drawing the mesh
  107115. */
  107116. get onBeforeDrawObservable(): Observable<Mesh>;
  107117. private _onBeforeDrawObserver;
  107118. /**
  107119. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107120. */
  107121. set onBeforeDraw(callback: () => void);
  107122. get hasInstances(): boolean;
  107123. get hasThinInstances(): boolean;
  107124. /**
  107125. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107126. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107127. */
  107128. delayLoadState: number;
  107129. /**
  107130. * Gets the list of instances created from this mesh
  107131. * it is not supposed to be modified manually.
  107132. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107133. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107134. */
  107135. instances: InstancedMesh[];
  107136. /**
  107137. * Gets the file containing delay loading data for this mesh
  107138. */
  107139. delayLoadingFile: string;
  107140. /** @hidden */
  107141. _binaryInfo: any;
  107142. /**
  107143. * User defined function used to change how LOD level selection is done
  107144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107145. */
  107146. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107147. /**
  107148. * Gets or sets the morph target manager
  107149. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107150. */
  107151. get morphTargetManager(): Nullable<MorphTargetManager>;
  107152. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107153. /** @hidden */
  107154. _creationDataStorage: Nullable<_CreationDataStorage>;
  107155. /** @hidden */
  107156. _geometry: Nullable<Geometry>;
  107157. /** @hidden */
  107158. _delayInfo: Array<string>;
  107159. /** @hidden */
  107160. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107161. /** @hidden */
  107162. _instanceDataStorage: _InstanceDataStorage;
  107163. /** @hidden */
  107164. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107165. private _effectiveMaterial;
  107166. /** @hidden */
  107167. _shouldGenerateFlatShading: boolean;
  107168. /** @hidden */
  107169. _originalBuilderSideOrientation: number;
  107170. /**
  107171. * Use this property to change the original side orientation defined at construction time
  107172. */
  107173. overrideMaterialSideOrientation: Nullable<number>;
  107174. /**
  107175. * Gets the source mesh (the one used to clone this one from)
  107176. */
  107177. get source(): Nullable<Mesh>;
  107178. /**
  107179. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107180. */
  107181. get isUnIndexed(): boolean;
  107182. set isUnIndexed(value: boolean);
  107183. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107184. get worldMatrixInstancedBuffer(): Float32Array;
  107185. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107186. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107187. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107188. /**
  107189. * @constructor
  107190. * @param name The value used by scene.getMeshByName() to do a lookup.
  107191. * @param scene The scene to add this mesh to.
  107192. * @param parent The parent of this mesh, if it has one
  107193. * @param source An optional Mesh from which geometry is shared, cloned.
  107194. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107195. * When false, achieved by calling a clone(), also passing False.
  107196. * This will make creation of children, recursive.
  107197. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107198. */
  107199. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107200. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107201. doNotInstantiate: boolean;
  107202. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107203. /**
  107204. * Gets the class name
  107205. * @returns the string "Mesh".
  107206. */
  107207. getClassName(): string;
  107208. /** @hidden */
  107209. get _isMesh(): boolean;
  107210. /**
  107211. * Returns a description of this mesh
  107212. * @param fullDetails define if full details about this mesh must be used
  107213. * @returns a descriptive string representing this mesh
  107214. */
  107215. toString(fullDetails?: boolean): string;
  107216. /** @hidden */
  107217. _unBindEffect(): void;
  107218. /**
  107219. * Gets a boolean indicating if this mesh has LOD
  107220. */
  107221. get hasLODLevels(): boolean;
  107222. /**
  107223. * Gets the list of MeshLODLevel associated with the current mesh
  107224. * @returns an array of MeshLODLevel
  107225. */
  107226. getLODLevels(): MeshLODLevel[];
  107227. private _sortLODLevels;
  107228. /**
  107229. * Add a mesh as LOD level triggered at the given distance.
  107230. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107231. * @param distance The distance from the center of the object to show this level
  107232. * @param mesh The mesh to be added as LOD level (can be null)
  107233. * @return This mesh (for chaining)
  107234. */
  107235. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107236. /**
  107237. * Returns the LOD level mesh at the passed distance or null if not found.
  107238. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107239. * @param distance The distance from the center of the object to show this level
  107240. * @returns a Mesh or `null`
  107241. */
  107242. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107243. /**
  107244. * Remove a mesh from the LOD array
  107245. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107246. * @param mesh defines the mesh to be removed
  107247. * @return This mesh (for chaining)
  107248. */
  107249. removeLODLevel(mesh: Mesh): Mesh;
  107250. /**
  107251. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107252. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107253. * @param camera defines the camera to use to compute distance
  107254. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107255. * @return This mesh (for chaining)
  107256. */
  107257. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107258. /**
  107259. * Gets the mesh internal Geometry object
  107260. */
  107261. get geometry(): Nullable<Geometry>;
  107262. /**
  107263. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107264. * @returns the total number of vertices
  107265. */
  107266. getTotalVertices(): number;
  107267. /**
  107268. * Returns the content of an associated vertex buffer
  107269. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107270. * - VertexBuffer.PositionKind
  107271. * - VertexBuffer.UVKind
  107272. * - VertexBuffer.UV2Kind
  107273. * - VertexBuffer.UV3Kind
  107274. * - VertexBuffer.UV4Kind
  107275. * - VertexBuffer.UV5Kind
  107276. * - VertexBuffer.UV6Kind
  107277. * - VertexBuffer.ColorKind
  107278. * - VertexBuffer.MatricesIndicesKind
  107279. * - VertexBuffer.MatricesIndicesExtraKind
  107280. * - VertexBuffer.MatricesWeightsKind
  107281. * - VertexBuffer.MatricesWeightsExtraKind
  107282. * @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
  107283. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107284. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107285. */
  107286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107287. /**
  107288. * Returns the mesh VertexBuffer object from the requested `kind`
  107289. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107290. * - VertexBuffer.PositionKind
  107291. * - VertexBuffer.NormalKind
  107292. * - VertexBuffer.UVKind
  107293. * - VertexBuffer.UV2Kind
  107294. * - VertexBuffer.UV3Kind
  107295. * - VertexBuffer.UV4Kind
  107296. * - VertexBuffer.UV5Kind
  107297. * - VertexBuffer.UV6Kind
  107298. * - VertexBuffer.ColorKind
  107299. * - VertexBuffer.MatricesIndicesKind
  107300. * - VertexBuffer.MatricesIndicesExtraKind
  107301. * - VertexBuffer.MatricesWeightsKind
  107302. * - VertexBuffer.MatricesWeightsExtraKind
  107303. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107304. */
  107305. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107306. /**
  107307. * Tests if a specific vertex buffer is associated with this mesh
  107308. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107309. * - VertexBuffer.PositionKind
  107310. * - VertexBuffer.NormalKind
  107311. * - VertexBuffer.UVKind
  107312. * - VertexBuffer.UV2Kind
  107313. * - VertexBuffer.UV3Kind
  107314. * - VertexBuffer.UV4Kind
  107315. * - VertexBuffer.UV5Kind
  107316. * - VertexBuffer.UV6Kind
  107317. * - VertexBuffer.ColorKind
  107318. * - VertexBuffer.MatricesIndicesKind
  107319. * - VertexBuffer.MatricesIndicesExtraKind
  107320. * - VertexBuffer.MatricesWeightsKind
  107321. * - VertexBuffer.MatricesWeightsExtraKind
  107322. * @returns a boolean
  107323. */
  107324. isVerticesDataPresent(kind: string): boolean;
  107325. /**
  107326. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107327. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107328. * - VertexBuffer.PositionKind
  107329. * - VertexBuffer.UVKind
  107330. * - VertexBuffer.UV2Kind
  107331. * - VertexBuffer.UV3Kind
  107332. * - VertexBuffer.UV4Kind
  107333. * - VertexBuffer.UV5Kind
  107334. * - VertexBuffer.UV6Kind
  107335. * - VertexBuffer.ColorKind
  107336. * - VertexBuffer.MatricesIndicesKind
  107337. * - VertexBuffer.MatricesIndicesExtraKind
  107338. * - VertexBuffer.MatricesWeightsKind
  107339. * - VertexBuffer.MatricesWeightsExtraKind
  107340. * @returns a boolean
  107341. */
  107342. isVertexBufferUpdatable(kind: string): boolean;
  107343. /**
  107344. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107345. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107346. * - VertexBuffer.PositionKind
  107347. * - VertexBuffer.NormalKind
  107348. * - VertexBuffer.UVKind
  107349. * - VertexBuffer.UV2Kind
  107350. * - VertexBuffer.UV3Kind
  107351. * - VertexBuffer.UV4Kind
  107352. * - VertexBuffer.UV5Kind
  107353. * - VertexBuffer.UV6Kind
  107354. * - VertexBuffer.ColorKind
  107355. * - VertexBuffer.MatricesIndicesKind
  107356. * - VertexBuffer.MatricesIndicesExtraKind
  107357. * - VertexBuffer.MatricesWeightsKind
  107358. * - VertexBuffer.MatricesWeightsExtraKind
  107359. * @returns an array of strings
  107360. */
  107361. getVerticesDataKinds(): string[];
  107362. /**
  107363. * Returns a positive integer : the total number of indices in this mesh geometry.
  107364. * @returns the numner of indices or zero if the mesh has no geometry.
  107365. */
  107366. getTotalIndices(): number;
  107367. /**
  107368. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107369. * @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.
  107370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107371. * @returns the indices array or an empty array if the mesh has no geometry
  107372. */
  107373. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107374. get isBlocked(): boolean;
  107375. /**
  107376. * Determine if the current mesh is ready to be rendered
  107377. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107378. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107379. * @returns true if all associated assets are ready (material, textures, shaders)
  107380. */
  107381. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107382. /**
  107383. * 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.
  107384. */
  107385. get areNormalsFrozen(): boolean;
  107386. /**
  107387. * 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.
  107388. * @returns the current mesh
  107389. */
  107390. freezeNormals(): Mesh;
  107391. /**
  107392. * 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
  107393. * @returns the current mesh
  107394. */
  107395. unfreezeNormals(): Mesh;
  107396. /**
  107397. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107398. */
  107399. set overridenInstanceCount(count: number);
  107400. /** @hidden */
  107401. _preActivate(): Mesh;
  107402. /** @hidden */
  107403. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107404. /** @hidden */
  107405. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107406. protected _afterComputeWorldMatrix(): void;
  107407. /** @hidden */
  107408. _postActivate(): void;
  107409. /**
  107410. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107411. * This means the mesh underlying bounding box and sphere are recomputed.
  107412. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107413. * @returns the current mesh
  107414. */
  107415. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107416. /** @hidden */
  107417. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107418. /**
  107419. * This function will subdivide the mesh into multiple submeshes
  107420. * @param count defines the expected number of submeshes
  107421. */
  107422. subdivide(count: number): void;
  107423. /**
  107424. * Copy a FloatArray into a specific associated vertex buffer
  107425. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107426. * - VertexBuffer.PositionKind
  107427. * - VertexBuffer.UVKind
  107428. * - VertexBuffer.UV2Kind
  107429. * - VertexBuffer.UV3Kind
  107430. * - VertexBuffer.UV4Kind
  107431. * - VertexBuffer.UV5Kind
  107432. * - VertexBuffer.UV6Kind
  107433. * - VertexBuffer.ColorKind
  107434. * - VertexBuffer.MatricesIndicesKind
  107435. * - VertexBuffer.MatricesIndicesExtraKind
  107436. * - VertexBuffer.MatricesWeightsKind
  107437. * - VertexBuffer.MatricesWeightsExtraKind
  107438. * @param data defines the data source
  107439. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107440. * @param stride defines the data stride size (can be null)
  107441. * @returns the current mesh
  107442. */
  107443. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107444. /**
  107445. * Delete a vertex buffer associated with this mesh
  107446. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107447. * - VertexBuffer.PositionKind
  107448. * - VertexBuffer.UVKind
  107449. * - VertexBuffer.UV2Kind
  107450. * - VertexBuffer.UV3Kind
  107451. * - VertexBuffer.UV4Kind
  107452. * - VertexBuffer.UV5Kind
  107453. * - VertexBuffer.UV6Kind
  107454. * - VertexBuffer.ColorKind
  107455. * - VertexBuffer.MatricesIndicesKind
  107456. * - VertexBuffer.MatricesIndicesExtraKind
  107457. * - VertexBuffer.MatricesWeightsKind
  107458. * - VertexBuffer.MatricesWeightsExtraKind
  107459. */
  107460. removeVerticesData(kind: string): void;
  107461. /**
  107462. * Flags an associated vertex buffer as updatable
  107463. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107464. * - VertexBuffer.PositionKind
  107465. * - VertexBuffer.UVKind
  107466. * - VertexBuffer.UV2Kind
  107467. * - VertexBuffer.UV3Kind
  107468. * - VertexBuffer.UV4Kind
  107469. * - VertexBuffer.UV5Kind
  107470. * - VertexBuffer.UV6Kind
  107471. * - VertexBuffer.ColorKind
  107472. * - VertexBuffer.MatricesIndicesKind
  107473. * - VertexBuffer.MatricesIndicesExtraKind
  107474. * - VertexBuffer.MatricesWeightsKind
  107475. * - VertexBuffer.MatricesWeightsExtraKind
  107476. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107477. */
  107478. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107479. /**
  107480. * Sets the mesh global Vertex Buffer
  107481. * @param buffer defines the buffer to use
  107482. * @returns the current mesh
  107483. */
  107484. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107485. /**
  107486. * Update a specific associated vertex buffer
  107487. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107488. * - VertexBuffer.PositionKind
  107489. * - VertexBuffer.UVKind
  107490. * - VertexBuffer.UV2Kind
  107491. * - VertexBuffer.UV3Kind
  107492. * - VertexBuffer.UV4Kind
  107493. * - VertexBuffer.UV5Kind
  107494. * - VertexBuffer.UV6Kind
  107495. * - VertexBuffer.ColorKind
  107496. * - VertexBuffer.MatricesIndicesKind
  107497. * - VertexBuffer.MatricesIndicesExtraKind
  107498. * - VertexBuffer.MatricesWeightsKind
  107499. * - VertexBuffer.MatricesWeightsExtraKind
  107500. * @param data defines the data source
  107501. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107502. * @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)
  107503. * @returns the current mesh
  107504. */
  107505. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107506. /**
  107507. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107508. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107509. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107510. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107511. * @returns the current mesh
  107512. */
  107513. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107514. /**
  107515. * Creates a un-shared specific occurence of the geometry for the mesh.
  107516. * @returns the current mesh
  107517. */
  107518. makeGeometryUnique(): Mesh;
  107519. /**
  107520. * Set the index buffer of this mesh
  107521. * @param indices defines the source data
  107522. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107523. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107524. * @returns the current mesh
  107525. */
  107526. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107527. /**
  107528. * Update the current index buffer
  107529. * @param indices defines the source data
  107530. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107531. * @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)
  107532. * @returns the current mesh
  107533. */
  107534. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107535. /**
  107536. * Invert the geometry to move from a right handed system to a left handed one.
  107537. * @returns the current mesh
  107538. */
  107539. toLeftHanded(): Mesh;
  107540. /** @hidden */
  107541. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107542. /** @hidden */
  107543. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107544. /**
  107545. * Registers for this mesh a javascript function called just before the rendering process
  107546. * @param func defines the function to call before rendering this mesh
  107547. * @returns the current mesh
  107548. */
  107549. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107550. /**
  107551. * Disposes a previously registered javascript function called before the rendering
  107552. * @param func defines the function to remove
  107553. * @returns the current mesh
  107554. */
  107555. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107556. /**
  107557. * Registers for this mesh a javascript function called just after the rendering is complete
  107558. * @param func defines the function to call after rendering this mesh
  107559. * @returns the current mesh
  107560. */
  107561. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107562. /**
  107563. * Disposes a previously registered javascript function called after the rendering.
  107564. * @param func defines the function to remove
  107565. * @returns the current mesh
  107566. */
  107567. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107568. /** @hidden */
  107569. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107570. /** @hidden */
  107571. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107572. /** @hidden */
  107573. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107574. /** @hidden */
  107575. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107576. /** @hidden */
  107577. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107578. /** @hidden */
  107579. _rebuild(): void;
  107580. /** @hidden */
  107581. _freeze(): void;
  107582. /** @hidden */
  107583. _unFreeze(): void;
  107584. /**
  107585. * 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
  107586. * @param subMesh defines the subMesh to render
  107587. * @param enableAlphaMode defines if alpha mode can be changed
  107588. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107589. * @returns the current mesh
  107590. */
  107591. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107592. private _onBeforeDraw;
  107593. /**
  107594. * Renormalize the mesh and patch it up if there are no weights
  107595. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107596. * However in the case of zero weights then we set just a single influence to 1.
  107597. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107598. */
  107599. cleanMatrixWeights(): void;
  107600. private normalizeSkinFourWeights;
  107601. private normalizeSkinWeightsAndExtra;
  107602. /**
  107603. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107604. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107605. * the user know there was an issue with importing the mesh
  107606. * @returns a validation object with skinned, valid and report string
  107607. */
  107608. validateSkinning(): {
  107609. skinned: boolean;
  107610. valid: boolean;
  107611. report: string;
  107612. };
  107613. /** @hidden */
  107614. _checkDelayState(): Mesh;
  107615. private _queueLoad;
  107616. /**
  107617. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107618. * A mesh is in the frustum if its bounding box intersects the frustum
  107619. * @param frustumPlanes defines the frustum to test
  107620. * @returns true if the mesh is in the frustum planes
  107621. */
  107622. isInFrustum(frustumPlanes: Plane[]): boolean;
  107623. /**
  107624. * Sets the mesh material by the material or multiMaterial `id` property
  107625. * @param id is a string identifying the material or the multiMaterial
  107626. * @returns the current mesh
  107627. */
  107628. setMaterialByID(id: string): Mesh;
  107629. /**
  107630. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107631. * @returns an array of IAnimatable
  107632. */
  107633. getAnimatables(): IAnimatable[];
  107634. /**
  107635. * Modifies the mesh geometry according to the passed transformation matrix.
  107636. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107637. * The mesh normals are modified using the same transformation.
  107638. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107639. * @param transform defines the transform matrix to use
  107640. * @see https://doc.babylonjs.com/resources/baking_transformations
  107641. * @returns the current mesh
  107642. */
  107643. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107644. /**
  107645. * Modifies the mesh geometry according to its own current World Matrix.
  107646. * The mesh World Matrix is then reset.
  107647. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107648. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107649. * @see https://doc.babylonjs.com/resources/baking_transformations
  107650. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107651. * @returns the current mesh
  107652. */
  107653. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107654. /** @hidden */
  107655. get _positions(): Nullable<Vector3[]>;
  107656. /** @hidden */
  107657. _resetPointsArrayCache(): Mesh;
  107658. /** @hidden */
  107659. _generatePointsArray(): boolean;
  107660. /**
  107661. * Returns a new Mesh object generated from the current mesh properties.
  107662. * This method must not get confused with createInstance()
  107663. * @param name is a string, the name given to the new mesh
  107664. * @param newParent can be any Node object (default `null`)
  107665. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107666. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107667. * @returns a new mesh
  107668. */
  107669. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107670. /**
  107671. * Releases resources associated with this mesh.
  107672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107674. */
  107675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107676. /** @hidden */
  107677. _disposeInstanceSpecificData(): void;
  107678. /** @hidden */
  107679. _disposeThinInstanceSpecificData(): void;
  107680. /**
  107681. * Modifies the mesh geometry according to a displacement map.
  107682. * 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.
  107683. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107684. * @param url is a string, the URL from the image file is to be downloaded.
  107685. * @param minHeight is the lower limit of the displacement.
  107686. * @param maxHeight is the upper limit of the displacement.
  107687. * @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.
  107688. * @param uvOffset is an optional vector2 used to offset UV.
  107689. * @param uvScale is an optional vector2 used to scale UV.
  107690. * @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.
  107691. * @returns the Mesh.
  107692. */
  107693. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107694. /**
  107695. * Modifies the mesh geometry according to a displacementMap buffer.
  107696. * 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.
  107697. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107698. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107699. * @param heightMapWidth is the width of the buffer image.
  107700. * @param heightMapHeight is the height of the buffer image.
  107701. * @param minHeight is the lower limit of the displacement.
  107702. * @param maxHeight is the upper limit of the displacement.
  107703. * @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.
  107704. * @param uvOffset is an optional vector2 used to offset UV.
  107705. * @param uvScale is an optional vector2 used to scale UV.
  107706. * @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.
  107707. * @returns the Mesh.
  107708. */
  107709. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107710. /**
  107711. * Modify the mesh to get a flat shading rendering.
  107712. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107713. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107714. * @returns current mesh
  107715. */
  107716. convertToFlatShadedMesh(): Mesh;
  107717. /**
  107718. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107719. * In other words, more vertices, no more indices and a single bigger VBO.
  107720. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107721. * @returns current mesh
  107722. */
  107723. convertToUnIndexedMesh(): Mesh;
  107724. /**
  107725. * Inverses facet orientations.
  107726. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107727. * @param flipNormals will also inverts the normals
  107728. * @returns current mesh
  107729. */
  107730. flipFaces(flipNormals?: boolean): Mesh;
  107731. /**
  107732. * Increase the number of facets and hence vertices in a mesh
  107733. * Vertex normals are interpolated from existing vertex normals
  107734. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107735. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107736. */
  107737. increaseVertices(numberPerEdge: number): void;
  107738. /**
  107739. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107740. * This will undo any application of covertToFlatShadedMesh
  107741. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107742. */
  107743. forceSharedVertices(): void;
  107744. /** @hidden */
  107745. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107746. /** @hidden */
  107747. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107748. /**
  107749. * Creates a new InstancedMesh object from the mesh model.
  107750. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107751. * @param name defines the name of the new instance
  107752. * @returns a new InstancedMesh
  107753. */
  107754. createInstance(name: string): InstancedMesh;
  107755. /**
  107756. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107757. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107758. * @returns the current mesh
  107759. */
  107760. synchronizeInstances(): Mesh;
  107761. /**
  107762. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107763. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107764. * This should be used together with the simplification to avoid disappearing triangles.
  107765. * @param successCallback an optional success callback to be called after the optimization finished.
  107766. * @returns the current mesh
  107767. */
  107768. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107769. /**
  107770. * Serialize current mesh
  107771. * @param serializationObject defines the object which will receive the serialization data
  107772. */
  107773. serialize(serializationObject: any): void;
  107774. /** @hidden */
  107775. _syncGeometryWithMorphTargetManager(): void;
  107776. /** @hidden */
  107777. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107778. /**
  107779. * Returns a new Mesh object parsed from the source provided.
  107780. * @param parsedMesh is the source
  107781. * @param scene defines the hosting scene
  107782. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107783. * @returns a new Mesh
  107784. */
  107785. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107786. /**
  107787. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107789. * @param name defines the name of the mesh to create
  107790. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107791. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107792. * @param closePath creates a seam between the first and the last points of each path of the path array
  107793. * @param offset is taken in account only if the `pathArray` is containing a single path
  107794. * @param scene defines the hosting scene
  107795. * @param updatable defines if the mesh must be flagged as updatable
  107796. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107797. * @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)
  107798. * @returns a new Mesh
  107799. */
  107800. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107801. /**
  107802. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107803. * @param name defines the name of the mesh to create
  107804. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107805. * @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
  107806. * @param scene defines the hosting scene
  107807. * @param updatable defines if the mesh must be flagged as updatable
  107808. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107809. * @returns a new Mesh
  107810. */
  107811. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107812. /**
  107813. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107814. * @param name defines the name of the mesh to create
  107815. * @param size sets the size (float) of each box side (default 1)
  107816. * @param scene defines the hosting scene
  107817. * @param updatable defines if the mesh must be flagged as updatable
  107818. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107819. * @returns a new Mesh
  107820. */
  107821. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107822. /**
  107823. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107824. * @param name defines the name of the mesh to create
  107825. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107826. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107827. * @param scene defines the hosting scene
  107828. * @param updatable defines if the mesh must be flagged as updatable
  107829. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107830. * @returns a new Mesh
  107831. */
  107832. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107833. /**
  107834. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107835. * @param name defines the name of the mesh to create
  107836. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107837. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107838. * @param scene defines the hosting scene
  107839. * @returns a new Mesh
  107840. */
  107841. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107842. /**
  107843. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107844. * @param name defines the name of the mesh to create
  107845. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107846. * @param diameterTop set the top cap diameter (floats, default 1)
  107847. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107848. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107849. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107850. * @param scene defines the hosting scene
  107851. * @param updatable defines if the mesh must be flagged as updatable
  107852. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107853. * @returns a new Mesh
  107854. */
  107855. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107856. /**
  107857. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107858. * @param name defines the name of the mesh to create
  107859. * @param diameter sets the diameter size (float) of the torus (default 1)
  107860. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107861. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107862. * @param scene defines the hosting scene
  107863. * @param updatable defines if the mesh must be flagged as updatable
  107864. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107865. * @returns a new Mesh
  107866. */
  107867. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107868. /**
  107869. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107870. * @param name defines the name of the mesh to create
  107871. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107872. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107873. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107874. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107875. * @param p the number of windings on X axis (positive integers, default 2)
  107876. * @param q the number of windings on Y axis (positive integers, default 3)
  107877. * @param scene defines the hosting scene
  107878. * @param updatable defines if the mesh must be flagged as updatable
  107879. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107880. * @returns a new Mesh
  107881. */
  107882. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107883. /**
  107884. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107885. * @param name defines the name of the mesh to create
  107886. * @param points is an array successive Vector3
  107887. * @param scene defines the hosting scene
  107888. * @param updatable defines if the mesh must be flagged as updatable
  107889. * @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).
  107890. * @returns a new Mesh
  107891. */
  107892. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107893. /**
  107894. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107895. * @param name defines the name of the mesh to create
  107896. * @param points is an array successive Vector3
  107897. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107898. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107899. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107900. * @param scene defines the hosting scene
  107901. * @param updatable defines if the mesh must be flagged as updatable
  107902. * @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)
  107903. * @returns a new Mesh
  107904. */
  107905. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107906. /**
  107907. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107908. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107909. * 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.
  107910. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107911. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107912. * Remember you can only change the shape positions, not their number when updating a polygon.
  107913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107914. * @param name defines the name of the mesh to create
  107915. * @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
  107916. * @param scene defines the hosting scene
  107917. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107918. * @param updatable defines if the mesh must be flagged as updatable
  107919. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107920. * @param earcutInjection can be used to inject your own earcut reference
  107921. * @returns a new Mesh
  107922. */
  107923. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107924. /**
  107925. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107927. * @param name defines the name of the mesh to create
  107928. * @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
  107929. * @param depth defines the height of extrusion
  107930. * @param scene defines the hosting scene
  107931. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107932. * @param updatable defines if the mesh must be flagged as updatable
  107933. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107934. * @param earcutInjection can be used to inject your own earcut reference
  107935. * @returns a new Mesh
  107936. */
  107937. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107938. /**
  107939. * Creates an extruded shape mesh.
  107940. * 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
  107941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107943. * @param name defines the name of the mesh to create
  107944. * @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
  107945. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107946. * @param scale is the value to scale the shape
  107947. * @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
  107948. * @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
  107949. * @param scene defines the hosting scene
  107950. * @param updatable defines if the mesh must be flagged as updatable
  107951. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107952. * @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)
  107953. * @returns a new Mesh
  107954. */
  107955. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107956. /**
  107957. * Creates an custom extruded shape mesh.
  107958. * The custom extrusion is a parametric shape.
  107959. * It has no predefined shape. Its final shape will depend on the input parameters.
  107960. * Please consider using the same method from the MeshBuilder class instead
  107961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107962. * @param name defines the name of the mesh to create
  107963. * @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
  107964. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107965. * @param scaleFunction is a custom Javascript function called on each path point
  107966. * @param rotationFunction is a custom Javascript function called on each path point
  107967. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107968. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107969. * @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
  107970. * @param scene defines the hosting scene
  107971. * @param updatable defines if the mesh must be flagged as updatable
  107972. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107973. * @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)
  107974. * @returns a new Mesh
  107975. */
  107976. 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;
  107977. /**
  107978. * Creates lathe mesh.
  107979. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107980. * Please consider using the same method from the MeshBuilder class instead
  107981. * @param name defines the name of the mesh to create
  107982. * @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
  107983. * @param radius is the radius value of the lathe
  107984. * @param tessellation is the side number of the lathe.
  107985. * @param scene defines the hosting scene
  107986. * @param updatable defines if the mesh must be flagged as updatable
  107987. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107988. * @returns a new Mesh
  107989. */
  107990. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107991. /**
  107992. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107993. * @param name defines the name of the mesh to create
  107994. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107995. * @param scene defines the hosting scene
  107996. * @param updatable defines if the mesh must be flagged as updatable
  107997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107998. * @returns a new Mesh
  107999. */
  108000. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108001. /**
  108002. * Creates a ground mesh.
  108003. * Please consider using the same method from the MeshBuilder class instead
  108004. * @param name defines the name of the mesh to create
  108005. * @param width set the width of the ground
  108006. * @param height set the height of the ground
  108007. * @param subdivisions sets the number of subdivisions per side
  108008. * @param scene defines the hosting scene
  108009. * @param updatable defines if the mesh must be flagged as updatable
  108010. * @returns a new Mesh
  108011. */
  108012. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108013. /**
  108014. * Creates a tiled ground mesh.
  108015. * Please consider using the same method from the MeshBuilder class instead
  108016. * @param name defines the name of the mesh to create
  108017. * @param xmin set the ground minimum X coordinate
  108018. * @param zmin set the ground minimum Y coordinate
  108019. * @param xmax set the ground maximum X coordinate
  108020. * @param zmax set the ground maximum Z coordinate
  108021. * @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
  108022. * @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
  108023. * @param scene defines the hosting scene
  108024. * @param updatable defines if the mesh must be flagged as updatable
  108025. * @returns a new Mesh
  108026. */
  108027. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108028. w: number;
  108029. h: number;
  108030. }, precision: {
  108031. w: number;
  108032. h: number;
  108033. }, scene: Scene, updatable?: boolean): Mesh;
  108034. /**
  108035. * Creates a ground mesh from a height map.
  108036. * Please consider using the same method from the MeshBuilder class instead
  108037. * @see https://doc.babylonjs.com/babylon101/height_map
  108038. * @param name defines the name of the mesh to create
  108039. * @param url sets the URL of the height map image resource
  108040. * @param width set the ground width size
  108041. * @param height set the ground height size
  108042. * @param subdivisions sets the number of subdivision per side
  108043. * @param minHeight is the minimum altitude on the ground
  108044. * @param maxHeight is the maximum altitude on the ground
  108045. * @param scene defines the hosting scene
  108046. * @param updatable defines if the mesh must be flagged as updatable
  108047. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108048. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108049. * @returns a new Mesh
  108050. */
  108051. 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;
  108052. /**
  108053. * Creates a tube mesh.
  108054. * The tube is a parametric shape.
  108055. * It has no predefined shape. Its final shape will depend on the input parameters.
  108056. * Please consider using the same method from the MeshBuilder class instead
  108057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108058. * @param name defines the name of the mesh to create
  108059. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108060. * @param radius sets the tube radius size
  108061. * @param tessellation is the number of sides on the tubular surface
  108062. * @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
  108063. * @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
  108064. * @param scene defines the hosting scene
  108065. * @param updatable defines if the mesh must be flagged as updatable
  108066. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108067. * @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)
  108068. * @returns a new Mesh
  108069. */
  108070. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108071. (i: number, distance: number): number;
  108072. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108073. /**
  108074. * Creates a polyhedron mesh.
  108075. * Please consider using the same method from the MeshBuilder class instead.
  108076. * * 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
  108077. * * The parameter `size` (positive float, default 1) sets the polygon size
  108078. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108079. * * 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`
  108080. * * 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
  108081. * * 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)`)
  108082. * * 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
  108083. * * 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
  108084. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108087. * @param name defines the name of the mesh to create
  108088. * @param options defines the options used to create the mesh
  108089. * @param scene defines the hosting scene
  108090. * @returns a new Mesh
  108091. */
  108092. static CreatePolyhedron(name: string, options: {
  108093. type?: number;
  108094. size?: number;
  108095. sizeX?: number;
  108096. sizeY?: number;
  108097. sizeZ?: number;
  108098. custom?: any;
  108099. faceUV?: Vector4[];
  108100. faceColors?: Color4[];
  108101. updatable?: boolean;
  108102. sideOrientation?: number;
  108103. }, scene: Scene): Mesh;
  108104. /**
  108105. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108106. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108107. * * 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`)
  108108. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108109. * * 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
  108110. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108113. * @param name defines the name of the mesh
  108114. * @param options defines the options used to create the mesh
  108115. * @param scene defines the hosting scene
  108116. * @returns a new Mesh
  108117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108118. */
  108119. static CreateIcoSphere(name: string, options: {
  108120. radius?: number;
  108121. flat?: boolean;
  108122. subdivisions?: number;
  108123. sideOrientation?: number;
  108124. updatable?: boolean;
  108125. }, scene: Scene): Mesh;
  108126. /**
  108127. * Creates a decal mesh.
  108128. * Please consider using the same method from the MeshBuilder class instead.
  108129. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108130. * @param name defines the name of the mesh
  108131. * @param sourceMesh defines the mesh receiving the decal
  108132. * @param position sets the position of the decal in world coordinates
  108133. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108134. * @param size sets the decal scaling
  108135. * @param angle sets the angle to rotate the decal
  108136. * @returns a new Mesh
  108137. */
  108138. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108139. /**
  108140. * Prepare internal position array for software CPU skinning
  108141. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108142. */
  108143. setPositionsForCPUSkinning(): Float32Array;
  108144. /**
  108145. * Prepare internal normal array for software CPU skinning
  108146. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108147. */
  108148. setNormalsForCPUSkinning(): Float32Array;
  108149. /**
  108150. * Updates the vertex buffer by applying transformation from the bones
  108151. * @param skeleton defines the skeleton to apply to current mesh
  108152. * @returns the current mesh
  108153. */
  108154. applySkeleton(skeleton: Skeleton): Mesh;
  108155. /**
  108156. * 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
  108157. * @param meshes defines the list of meshes to scan
  108158. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108159. */
  108160. static MinMax(meshes: AbstractMesh[]): {
  108161. min: Vector3;
  108162. max: Vector3;
  108163. };
  108164. /**
  108165. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108166. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108167. * @returns a vector3
  108168. */
  108169. static Center(meshesOrMinMaxVector: {
  108170. min: Vector3;
  108171. max: Vector3;
  108172. } | AbstractMesh[]): Vector3;
  108173. /**
  108174. * Merge the array of meshes into a single mesh for performance reasons.
  108175. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108176. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108177. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108178. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108179. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108180. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108181. * @returns a new mesh
  108182. */
  108183. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108184. /** @hidden */
  108185. addInstance(instance: InstancedMesh): void;
  108186. /** @hidden */
  108187. removeInstance(instance: InstancedMesh): void;
  108188. }
  108189. }
  108190. declare module BABYLON {
  108191. /**
  108192. * This is the base class of all the camera used in the application.
  108193. * @see https://doc.babylonjs.com/features/cameras
  108194. */
  108195. export class Camera extends Node {
  108196. /** @hidden */
  108197. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108198. /**
  108199. * This is the default projection mode used by the cameras.
  108200. * It helps recreating a feeling of perspective and better appreciate depth.
  108201. * This is the best way to simulate real life cameras.
  108202. */
  108203. static readonly PERSPECTIVE_CAMERA: number;
  108204. /**
  108205. * This helps creating camera with an orthographic mode.
  108206. * 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.
  108207. */
  108208. static readonly ORTHOGRAPHIC_CAMERA: number;
  108209. /**
  108210. * This is the default FOV mode for perspective cameras.
  108211. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108212. */
  108213. static readonly FOVMODE_VERTICAL_FIXED: number;
  108214. /**
  108215. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108216. */
  108217. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108218. /**
  108219. * This specifies ther is no need for a camera rig.
  108220. * Basically only one eye is rendered corresponding to the camera.
  108221. */
  108222. static readonly RIG_MODE_NONE: number;
  108223. /**
  108224. * Simulates a camera Rig with one blue eye and one red eye.
  108225. * This can be use with 3d blue and red glasses.
  108226. */
  108227. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108228. /**
  108229. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108230. */
  108231. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108232. /**
  108233. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108234. */
  108235. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108236. /**
  108237. * Defines that both eyes of the camera will be rendered over under each other.
  108238. */
  108239. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108240. /**
  108241. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108242. */
  108243. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108244. /**
  108245. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108246. */
  108247. static readonly RIG_MODE_VR: number;
  108248. /**
  108249. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108250. */
  108251. static readonly RIG_MODE_WEBVR: number;
  108252. /**
  108253. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108254. */
  108255. static readonly RIG_MODE_CUSTOM: number;
  108256. /**
  108257. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108258. */
  108259. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108260. /**
  108261. * Define the input manager associated with the camera.
  108262. */
  108263. inputs: CameraInputsManager<Camera>;
  108264. /** @hidden */
  108265. _position: Vector3;
  108266. /**
  108267. * Define the current local position of the camera in the scene
  108268. */
  108269. get position(): Vector3;
  108270. set position(newPosition: Vector3);
  108271. /**
  108272. * The vector the camera should consider as up.
  108273. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108274. */
  108275. upVector: Vector3;
  108276. /**
  108277. * Define the current limit on the left side for an orthographic camera
  108278. * In scene unit
  108279. */
  108280. orthoLeft: Nullable<number>;
  108281. /**
  108282. * Define the current limit on the right side for an orthographic camera
  108283. * In scene unit
  108284. */
  108285. orthoRight: Nullable<number>;
  108286. /**
  108287. * Define the current limit on the bottom side for an orthographic camera
  108288. * In scene unit
  108289. */
  108290. orthoBottom: Nullable<number>;
  108291. /**
  108292. * Define the current limit on the top side for an orthographic camera
  108293. * In scene unit
  108294. */
  108295. orthoTop: Nullable<number>;
  108296. /**
  108297. * Field Of View is set in Radians. (default is 0.8)
  108298. */
  108299. fov: number;
  108300. /**
  108301. * Define the minimum distance the camera can see from.
  108302. * This is important to note that the depth buffer are not infinite and the closer it starts
  108303. * the more your scene might encounter depth fighting issue.
  108304. */
  108305. minZ: number;
  108306. /**
  108307. * Define the maximum distance the camera can see to.
  108308. * This is important to note that the depth buffer are not infinite and the further it end
  108309. * the more your scene might encounter depth fighting issue.
  108310. */
  108311. maxZ: number;
  108312. /**
  108313. * Define the default inertia of the camera.
  108314. * This helps giving a smooth feeling to the camera movement.
  108315. */
  108316. inertia: number;
  108317. /**
  108318. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108319. */
  108320. mode: number;
  108321. /**
  108322. * Define whether the camera is intermediate.
  108323. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108324. */
  108325. isIntermediate: boolean;
  108326. /**
  108327. * Define the viewport of the camera.
  108328. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108329. */
  108330. viewport: Viewport;
  108331. /**
  108332. * Restricts the camera to viewing objects with the same layerMask.
  108333. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108334. */
  108335. layerMask: number;
  108336. /**
  108337. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108338. */
  108339. fovMode: number;
  108340. /**
  108341. * Rig mode of the camera.
  108342. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108343. * This is normally controlled byt the camera themselves as internal use.
  108344. */
  108345. cameraRigMode: number;
  108346. /**
  108347. * Defines the distance between both "eyes" in case of a RIG
  108348. */
  108349. interaxialDistance: number;
  108350. /**
  108351. * Defines if stereoscopic rendering is done side by side or over under.
  108352. */
  108353. isStereoscopicSideBySide: boolean;
  108354. /**
  108355. * 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
  108356. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108357. * else in the scene. (Eg. security camera)
  108358. *
  108359. * 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)
  108360. */
  108361. customRenderTargets: RenderTargetTexture[];
  108362. /**
  108363. * When set, the camera will render to this render target instead of the default canvas
  108364. *
  108365. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108366. */
  108367. outputRenderTarget: Nullable<RenderTargetTexture>;
  108368. /**
  108369. * Observable triggered when the camera view matrix has changed.
  108370. */
  108371. onViewMatrixChangedObservable: Observable<Camera>;
  108372. /**
  108373. * Observable triggered when the camera Projection matrix has changed.
  108374. */
  108375. onProjectionMatrixChangedObservable: Observable<Camera>;
  108376. /**
  108377. * Observable triggered when the inputs have been processed.
  108378. */
  108379. onAfterCheckInputsObservable: Observable<Camera>;
  108380. /**
  108381. * Observable triggered when reset has been called and applied to the camera.
  108382. */
  108383. onRestoreStateObservable: Observable<Camera>;
  108384. /**
  108385. * Is this camera a part of a rig system?
  108386. */
  108387. isRigCamera: boolean;
  108388. /**
  108389. * If isRigCamera set to true this will be set with the parent camera.
  108390. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108391. */
  108392. rigParent?: Camera;
  108393. /** @hidden */
  108394. _cameraRigParams: any;
  108395. /** @hidden */
  108396. _rigCameras: Camera[];
  108397. /** @hidden */
  108398. _rigPostProcess: Nullable<PostProcess>;
  108399. protected _webvrViewMatrix: Matrix;
  108400. /** @hidden */
  108401. _skipRendering: boolean;
  108402. /** @hidden */
  108403. _projectionMatrix: Matrix;
  108404. /** @hidden */
  108405. _postProcesses: Nullable<PostProcess>[];
  108406. /** @hidden */
  108407. _activeMeshes: SmartArray<AbstractMesh>;
  108408. protected _globalPosition: Vector3;
  108409. /** @hidden */
  108410. _computedViewMatrix: Matrix;
  108411. private _doNotComputeProjectionMatrix;
  108412. private _transformMatrix;
  108413. private _frustumPlanes;
  108414. private _refreshFrustumPlanes;
  108415. private _storedFov;
  108416. private _stateStored;
  108417. /**
  108418. * Instantiates a new camera object.
  108419. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108420. * @see https://doc.babylonjs.com/features/cameras
  108421. * @param name Defines the name of the camera in the scene
  108422. * @param position Defines the position of the camera
  108423. * @param scene Defines the scene the camera belongs too
  108424. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108425. */
  108426. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108427. /**
  108428. * Store current camera state (fov, position, etc..)
  108429. * @returns the camera
  108430. */
  108431. storeState(): Camera;
  108432. /**
  108433. * Restores the camera state values if it has been stored. You must call storeState() first
  108434. */
  108435. protected _restoreStateValues(): boolean;
  108436. /**
  108437. * Restored camera state. You must call storeState() first.
  108438. * @returns true if restored and false otherwise
  108439. */
  108440. restoreState(): boolean;
  108441. /**
  108442. * Gets the class name of the camera.
  108443. * @returns the class name
  108444. */
  108445. getClassName(): string;
  108446. /** @hidden */
  108447. readonly _isCamera: boolean;
  108448. /**
  108449. * Gets a string representation of the camera useful for debug purpose.
  108450. * @param fullDetails Defines that a more verboe level of logging is required
  108451. * @returns the string representation
  108452. */
  108453. toString(fullDetails?: boolean): string;
  108454. /**
  108455. * Gets the current world space position of the camera.
  108456. */
  108457. get globalPosition(): Vector3;
  108458. /**
  108459. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108460. * @returns the active meshe list
  108461. */
  108462. getActiveMeshes(): SmartArray<AbstractMesh>;
  108463. /**
  108464. * Check whether a mesh is part of the current active mesh list of the camera
  108465. * @param mesh Defines the mesh to check
  108466. * @returns true if active, false otherwise
  108467. */
  108468. isActiveMesh(mesh: Mesh): boolean;
  108469. /**
  108470. * Is this camera ready to be used/rendered
  108471. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108472. * @return true if the camera is ready
  108473. */
  108474. isReady(completeCheck?: boolean): boolean;
  108475. /** @hidden */
  108476. _initCache(): void;
  108477. /** @hidden */
  108478. _updateCache(ignoreParentClass?: boolean): void;
  108479. /** @hidden */
  108480. _isSynchronized(): boolean;
  108481. /** @hidden */
  108482. _isSynchronizedViewMatrix(): boolean;
  108483. /** @hidden */
  108484. _isSynchronizedProjectionMatrix(): boolean;
  108485. /**
  108486. * Attach the input controls to a specific dom element to get the input from.
  108487. * @param element Defines the element the controls should be listened from
  108488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108489. */
  108490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108491. /**
  108492. * Detach the current controls from the specified dom element.
  108493. * @param element Defines the element to stop listening the inputs from
  108494. */
  108495. detachControl(element: HTMLElement): void;
  108496. /**
  108497. * Update the camera state according to the different inputs gathered during the frame.
  108498. */
  108499. update(): void;
  108500. /** @hidden */
  108501. _checkInputs(): void;
  108502. /** @hidden */
  108503. get rigCameras(): Camera[];
  108504. /**
  108505. * Gets the post process used by the rig cameras
  108506. */
  108507. get rigPostProcess(): Nullable<PostProcess>;
  108508. /**
  108509. * Internal, gets the first post proces.
  108510. * @returns the first post process to be run on this camera.
  108511. */
  108512. _getFirstPostProcess(): Nullable<PostProcess>;
  108513. private _cascadePostProcessesToRigCams;
  108514. /**
  108515. * Attach a post process to the camera.
  108516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108517. * @param postProcess The post process to attach to the camera
  108518. * @param insertAt The position of the post process in case several of them are in use in the scene
  108519. * @returns the position the post process has been inserted at
  108520. */
  108521. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108522. /**
  108523. * Detach a post process to the camera.
  108524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108525. * @param postProcess The post process to detach from the camera
  108526. */
  108527. detachPostProcess(postProcess: PostProcess): void;
  108528. /**
  108529. * Gets the current world matrix of the camera
  108530. */
  108531. getWorldMatrix(): Matrix;
  108532. /** @hidden */
  108533. _getViewMatrix(): Matrix;
  108534. /**
  108535. * Gets the current view matrix of the camera.
  108536. * @param force forces the camera to recompute the matrix without looking at the cached state
  108537. * @returns the view matrix
  108538. */
  108539. getViewMatrix(force?: boolean): Matrix;
  108540. /**
  108541. * Freeze the projection matrix.
  108542. * It will prevent the cache check of the camera projection compute and can speed up perf
  108543. * if no parameter of the camera are meant to change
  108544. * @param projection Defines manually a projection if necessary
  108545. */
  108546. freezeProjectionMatrix(projection?: Matrix): void;
  108547. /**
  108548. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108549. */
  108550. unfreezeProjectionMatrix(): void;
  108551. /**
  108552. * Gets the current projection matrix of the camera.
  108553. * @param force forces the camera to recompute the matrix without looking at the cached state
  108554. * @returns the projection matrix
  108555. */
  108556. getProjectionMatrix(force?: boolean): Matrix;
  108557. /**
  108558. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108559. * @returns a Matrix
  108560. */
  108561. getTransformationMatrix(): Matrix;
  108562. private _updateFrustumPlanes;
  108563. /**
  108564. * Checks if a cullable object (mesh...) is in the camera frustum
  108565. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108566. * @param target The object to check
  108567. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108568. * @returns true if the object is in frustum otherwise false
  108569. */
  108570. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108571. /**
  108572. * Checks if a cullable object (mesh...) is in the camera frustum
  108573. * Unlike isInFrustum this cheks the full bounding box
  108574. * @param target The object to check
  108575. * @returns true if the object is in frustum otherwise false
  108576. */
  108577. isCompletelyInFrustum(target: ICullable): boolean;
  108578. /**
  108579. * Gets a ray in the forward direction from the camera.
  108580. * @param length Defines the length of the ray to create
  108581. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108582. * @param origin Defines the start point of the ray which defaults to the camera position
  108583. * @returns the forward ray
  108584. */
  108585. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108586. /**
  108587. * Gets a ray in the forward direction from the camera.
  108588. * @param refRay the ray to (re)use when setting the values
  108589. * @param length Defines the length of the ray to create
  108590. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108591. * @param origin Defines the start point of the ray which defaults to the camera position
  108592. * @returns the forward ray
  108593. */
  108594. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108595. /**
  108596. * Releases resources associated with this node.
  108597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108599. */
  108600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108601. /** @hidden */
  108602. _isLeftCamera: boolean;
  108603. /**
  108604. * Gets the left camera of a rig setup in case of Rigged Camera
  108605. */
  108606. get isLeftCamera(): boolean;
  108607. /** @hidden */
  108608. _isRightCamera: boolean;
  108609. /**
  108610. * Gets the right camera of a rig setup in case of Rigged Camera
  108611. */
  108612. get isRightCamera(): boolean;
  108613. /**
  108614. * Gets the left camera of a rig setup in case of Rigged Camera
  108615. */
  108616. get leftCamera(): Nullable<FreeCamera>;
  108617. /**
  108618. * Gets the right camera of a rig setup in case of Rigged Camera
  108619. */
  108620. get rightCamera(): Nullable<FreeCamera>;
  108621. /**
  108622. * Gets the left camera target of a rig setup in case of Rigged Camera
  108623. * @returns the target position
  108624. */
  108625. getLeftTarget(): Nullable<Vector3>;
  108626. /**
  108627. * Gets the right camera target of a rig setup in case of Rigged Camera
  108628. * @returns the target position
  108629. */
  108630. getRightTarget(): Nullable<Vector3>;
  108631. /**
  108632. * @hidden
  108633. */
  108634. setCameraRigMode(mode: number, rigParams: any): void;
  108635. /** @hidden */
  108636. static _setStereoscopicRigMode(camera: Camera): void;
  108637. /** @hidden */
  108638. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108639. /** @hidden */
  108640. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108641. /** @hidden */
  108642. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108643. /** @hidden */
  108644. _getVRProjectionMatrix(): Matrix;
  108645. protected _updateCameraRotationMatrix(): void;
  108646. protected _updateWebVRCameraRotationMatrix(): void;
  108647. /**
  108648. * This function MUST be overwritten by the different WebVR cameras available.
  108649. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108650. * @hidden
  108651. */
  108652. _getWebVRProjectionMatrix(): Matrix;
  108653. /**
  108654. * This function MUST be overwritten by the different WebVR cameras available.
  108655. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108656. * @hidden
  108657. */
  108658. _getWebVRViewMatrix(): Matrix;
  108659. /** @hidden */
  108660. setCameraRigParameter(name: string, value: any): void;
  108661. /**
  108662. * needs to be overridden by children so sub has required properties to be copied
  108663. * @hidden
  108664. */
  108665. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108666. /**
  108667. * May need to be overridden by children
  108668. * @hidden
  108669. */
  108670. _updateRigCameras(): void;
  108671. /** @hidden */
  108672. _setupInputs(): void;
  108673. /**
  108674. * Serialiaze the camera setup to a json represention
  108675. * @returns the JSON representation
  108676. */
  108677. serialize(): any;
  108678. /**
  108679. * Clones the current camera.
  108680. * @param name The cloned camera name
  108681. * @returns the cloned camera
  108682. */
  108683. clone(name: string): Camera;
  108684. /**
  108685. * Gets the direction of the camera relative to a given local axis.
  108686. * @param localAxis Defines the reference axis to provide a relative direction.
  108687. * @return the direction
  108688. */
  108689. getDirection(localAxis: Vector3): Vector3;
  108690. /**
  108691. * Returns the current camera absolute rotation
  108692. */
  108693. get absoluteRotation(): Quaternion;
  108694. /**
  108695. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108696. * @param localAxis Defines the reference axis to provide a relative direction.
  108697. * @param result Defines the vector to store the result in
  108698. */
  108699. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108700. /**
  108701. * Gets a camera constructor for a given camera type
  108702. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108703. * @param name The name of the camera the result will be able to instantiate
  108704. * @param scene The scene the result will construct the camera in
  108705. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108706. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108707. * @returns a factory method to construc the camera
  108708. */
  108709. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108710. /**
  108711. * Compute the world matrix of the camera.
  108712. * @returns the camera world matrix
  108713. */
  108714. computeWorldMatrix(): Matrix;
  108715. /**
  108716. * Parse a JSON and creates the camera from the parsed information
  108717. * @param parsedCamera The JSON to parse
  108718. * @param scene The scene to instantiate the camera in
  108719. * @returns the newly constructed camera
  108720. */
  108721. static Parse(parsedCamera: any, scene: Scene): Camera;
  108722. }
  108723. }
  108724. declare module BABYLON {
  108725. /**
  108726. * Class containing static functions to help procedurally build meshes
  108727. */
  108728. export class DiscBuilder {
  108729. /**
  108730. * Creates a plane polygonal mesh. By default, this is a disc
  108731. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108732. * * 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
  108733. * * 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
  108734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108737. * @param name defines the name of the mesh
  108738. * @param options defines the options used to create the mesh
  108739. * @param scene defines the hosting scene
  108740. * @returns the plane polygonal mesh
  108741. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108742. */
  108743. static CreateDisc(name: string, options: {
  108744. radius?: number;
  108745. tessellation?: number;
  108746. arc?: number;
  108747. updatable?: boolean;
  108748. sideOrientation?: number;
  108749. frontUVs?: Vector4;
  108750. backUVs?: Vector4;
  108751. }, scene?: Nullable<Scene>): Mesh;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /**
  108756. * Options to be used when creating a FresnelParameters.
  108757. */
  108758. export type IFresnelParametersCreationOptions = {
  108759. /**
  108760. * Define the color used on edges (grazing angle)
  108761. */
  108762. leftColor?: Color3;
  108763. /**
  108764. * Define the color used on center
  108765. */
  108766. rightColor?: Color3;
  108767. /**
  108768. * Define bias applied to computed fresnel term
  108769. */
  108770. bias?: number;
  108771. /**
  108772. * Defined the power exponent applied to fresnel term
  108773. */
  108774. power?: number;
  108775. /**
  108776. * Define if the fresnel effect is enable or not.
  108777. */
  108778. isEnabled?: boolean;
  108779. };
  108780. /**
  108781. * Serialized format for FresnelParameters.
  108782. */
  108783. export type IFresnelParametersSerialized = {
  108784. /**
  108785. * Define the color used on edges (grazing angle) [as an array]
  108786. */
  108787. leftColor: number[];
  108788. /**
  108789. * Define the color used on center [as an array]
  108790. */
  108791. rightColor: number[];
  108792. /**
  108793. * Define bias applied to computed fresnel term
  108794. */
  108795. bias: number;
  108796. /**
  108797. * Defined the power exponent applied to fresnel term
  108798. */
  108799. power?: number;
  108800. /**
  108801. * Define if the fresnel effect is enable or not.
  108802. */
  108803. isEnabled: boolean;
  108804. };
  108805. /**
  108806. * This represents all the required information to add a fresnel effect on a material:
  108807. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108808. */
  108809. export class FresnelParameters {
  108810. private _isEnabled;
  108811. /**
  108812. * Define if the fresnel effect is enable or not.
  108813. */
  108814. get isEnabled(): boolean;
  108815. set isEnabled(value: boolean);
  108816. /**
  108817. * Define the color used on edges (grazing angle)
  108818. */
  108819. leftColor: Color3;
  108820. /**
  108821. * Define the color used on center
  108822. */
  108823. rightColor: Color3;
  108824. /**
  108825. * Define bias applied to computed fresnel term
  108826. */
  108827. bias: number;
  108828. /**
  108829. * Defined the power exponent applied to fresnel term
  108830. */
  108831. power: number;
  108832. /**
  108833. * Creates a new FresnelParameters object.
  108834. *
  108835. * @param options provide your own settings to optionally to override defaults
  108836. */
  108837. constructor(options?: IFresnelParametersCreationOptions);
  108838. /**
  108839. * Clones the current fresnel and its valuues
  108840. * @returns a clone fresnel configuration
  108841. */
  108842. clone(): FresnelParameters;
  108843. /**
  108844. * Determines equality between FresnelParameters objects
  108845. * @param otherFresnelParameters defines the second operand
  108846. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108847. */
  108848. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108849. /**
  108850. * Serializes the current fresnel parameters to a JSON representation.
  108851. * @return the JSON serialization
  108852. */
  108853. serialize(): IFresnelParametersSerialized;
  108854. /**
  108855. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108856. * @param parsedFresnelParameters Define the JSON representation
  108857. * @returns the parsed parameters
  108858. */
  108859. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108860. }
  108861. }
  108862. declare module BABYLON {
  108863. /**
  108864. * This groups all the flags used to control the materials channel.
  108865. */
  108866. export class MaterialFlags {
  108867. private static _DiffuseTextureEnabled;
  108868. /**
  108869. * Are diffuse textures enabled in the application.
  108870. */
  108871. static get DiffuseTextureEnabled(): boolean;
  108872. static set DiffuseTextureEnabled(value: boolean);
  108873. private static _DetailTextureEnabled;
  108874. /**
  108875. * Are detail textures enabled in the application.
  108876. */
  108877. static get DetailTextureEnabled(): boolean;
  108878. static set DetailTextureEnabled(value: boolean);
  108879. private static _AmbientTextureEnabled;
  108880. /**
  108881. * Are ambient textures enabled in the application.
  108882. */
  108883. static get AmbientTextureEnabled(): boolean;
  108884. static set AmbientTextureEnabled(value: boolean);
  108885. private static _OpacityTextureEnabled;
  108886. /**
  108887. * Are opacity textures enabled in the application.
  108888. */
  108889. static get OpacityTextureEnabled(): boolean;
  108890. static set OpacityTextureEnabled(value: boolean);
  108891. private static _ReflectionTextureEnabled;
  108892. /**
  108893. * Are reflection textures enabled in the application.
  108894. */
  108895. static get ReflectionTextureEnabled(): boolean;
  108896. static set ReflectionTextureEnabled(value: boolean);
  108897. private static _EmissiveTextureEnabled;
  108898. /**
  108899. * Are emissive textures enabled in the application.
  108900. */
  108901. static get EmissiveTextureEnabled(): boolean;
  108902. static set EmissiveTextureEnabled(value: boolean);
  108903. private static _SpecularTextureEnabled;
  108904. /**
  108905. * Are specular textures enabled in the application.
  108906. */
  108907. static get SpecularTextureEnabled(): boolean;
  108908. static set SpecularTextureEnabled(value: boolean);
  108909. private static _BumpTextureEnabled;
  108910. /**
  108911. * Are bump textures enabled in the application.
  108912. */
  108913. static get BumpTextureEnabled(): boolean;
  108914. static set BumpTextureEnabled(value: boolean);
  108915. private static _LightmapTextureEnabled;
  108916. /**
  108917. * Are lightmap textures enabled in the application.
  108918. */
  108919. static get LightmapTextureEnabled(): boolean;
  108920. static set LightmapTextureEnabled(value: boolean);
  108921. private static _RefractionTextureEnabled;
  108922. /**
  108923. * Are refraction textures enabled in the application.
  108924. */
  108925. static get RefractionTextureEnabled(): boolean;
  108926. static set RefractionTextureEnabled(value: boolean);
  108927. private static _ColorGradingTextureEnabled;
  108928. /**
  108929. * Are color grading textures enabled in the application.
  108930. */
  108931. static get ColorGradingTextureEnabled(): boolean;
  108932. static set ColorGradingTextureEnabled(value: boolean);
  108933. private static _FresnelEnabled;
  108934. /**
  108935. * Are fresnels enabled in the application.
  108936. */
  108937. static get FresnelEnabled(): boolean;
  108938. static set FresnelEnabled(value: boolean);
  108939. private static _ClearCoatTextureEnabled;
  108940. /**
  108941. * Are clear coat textures enabled in the application.
  108942. */
  108943. static get ClearCoatTextureEnabled(): boolean;
  108944. static set ClearCoatTextureEnabled(value: boolean);
  108945. private static _ClearCoatBumpTextureEnabled;
  108946. /**
  108947. * Are clear coat bump textures enabled in the application.
  108948. */
  108949. static get ClearCoatBumpTextureEnabled(): boolean;
  108950. static set ClearCoatBumpTextureEnabled(value: boolean);
  108951. private static _ClearCoatTintTextureEnabled;
  108952. /**
  108953. * Are clear coat tint textures enabled in the application.
  108954. */
  108955. static get ClearCoatTintTextureEnabled(): boolean;
  108956. static set ClearCoatTintTextureEnabled(value: boolean);
  108957. private static _SheenTextureEnabled;
  108958. /**
  108959. * Are sheen textures enabled in the application.
  108960. */
  108961. static get SheenTextureEnabled(): boolean;
  108962. static set SheenTextureEnabled(value: boolean);
  108963. private static _AnisotropicTextureEnabled;
  108964. /**
  108965. * Are anisotropic textures enabled in the application.
  108966. */
  108967. static get AnisotropicTextureEnabled(): boolean;
  108968. static set AnisotropicTextureEnabled(value: boolean);
  108969. private static _ThicknessTextureEnabled;
  108970. /**
  108971. * Are thickness textures enabled in the application.
  108972. */
  108973. static get ThicknessTextureEnabled(): boolean;
  108974. static set ThicknessTextureEnabled(value: boolean);
  108975. }
  108976. }
  108977. declare module BABYLON {
  108978. /** @hidden */
  108979. export var defaultFragmentDeclaration: {
  108980. name: string;
  108981. shader: string;
  108982. };
  108983. }
  108984. declare module BABYLON {
  108985. /** @hidden */
  108986. export var defaultUboDeclaration: {
  108987. name: string;
  108988. shader: string;
  108989. };
  108990. }
  108991. declare module BABYLON {
  108992. /** @hidden */
  108993. export var prePassDeclaration: {
  108994. name: string;
  108995. shader: string;
  108996. };
  108997. }
  108998. declare module BABYLON {
  108999. /** @hidden */
  109000. export var lightFragmentDeclaration: {
  109001. name: string;
  109002. shader: string;
  109003. };
  109004. }
  109005. declare module BABYLON {
  109006. /** @hidden */
  109007. export var lightUboDeclaration: {
  109008. name: string;
  109009. shader: string;
  109010. };
  109011. }
  109012. declare module BABYLON {
  109013. /** @hidden */
  109014. export var lightsFragmentFunctions: {
  109015. name: string;
  109016. shader: string;
  109017. };
  109018. }
  109019. declare module BABYLON {
  109020. /** @hidden */
  109021. export var shadowsFragmentFunctions: {
  109022. name: string;
  109023. shader: string;
  109024. };
  109025. }
  109026. declare module BABYLON {
  109027. /** @hidden */
  109028. export var fresnelFunction: {
  109029. name: string;
  109030. shader: string;
  109031. };
  109032. }
  109033. declare module BABYLON {
  109034. /** @hidden */
  109035. export var bumpFragmentMainFunctions: {
  109036. name: string;
  109037. shader: string;
  109038. };
  109039. }
  109040. declare module BABYLON {
  109041. /** @hidden */
  109042. export var bumpFragmentFunctions: {
  109043. name: string;
  109044. shader: string;
  109045. };
  109046. }
  109047. declare module BABYLON {
  109048. /** @hidden */
  109049. export var logDepthDeclaration: {
  109050. name: string;
  109051. shader: string;
  109052. };
  109053. }
  109054. declare module BABYLON {
  109055. /** @hidden */
  109056. export var bumpFragment: {
  109057. name: string;
  109058. shader: string;
  109059. };
  109060. }
  109061. declare module BABYLON {
  109062. /** @hidden */
  109063. export var depthPrePass: {
  109064. name: string;
  109065. shader: string;
  109066. };
  109067. }
  109068. declare module BABYLON {
  109069. /** @hidden */
  109070. export var lightFragment: {
  109071. name: string;
  109072. shader: string;
  109073. };
  109074. }
  109075. declare module BABYLON {
  109076. /** @hidden */
  109077. export var logDepthFragment: {
  109078. name: string;
  109079. shader: string;
  109080. };
  109081. }
  109082. declare module BABYLON {
  109083. /** @hidden */
  109084. export var defaultPixelShader: {
  109085. name: string;
  109086. shader: string;
  109087. };
  109088. }
  109089. declare module BABYLON {
  109090. /** @hidden */
  109091. export var defaultVertexDeclaration: {
  109092. name: string;
  109093. shader: string;
  109094. };
  109095. }
  109096. declare module BABYLON {
  109097. /** @hidden */
  109098. export var bumpVertexDeclaration: {
  109099. name: string;
  109100. shader: string;
  109101. };
  109102. }
  109103. declare module BABYLON {
  109104. /** @hidden */
  109105. export var bumpVertex: {
  109106. name: string;
  109107. shader: string;
  109108. };
  109109. }
  109110. declare module BABYLON {
  109111. /** @hidden */
  109112. export var fogVertex: {
  109113. name: string;
  109114. shader: string;
  109115. };
  109116. }
  109117. declare module BABYLON {
  109118. /** @hidden */
  109119. export var shadowsVertex: {
  109120. name: string;
  109121. shader: string;
  109122. };
  109123. }
  109124. declare module BABYLON {
  109125. /** @hidden */
  109126. export var pointCloudVertex: {
  109127. name: string;
  109128. shader: string;
  109129. };
  109130. }
  109131. declare module BABYLON {
  109132. /** @hidden */
  109133. export var logDepthVertex: {
  109134. name: string;
  109135. shader: string;
  109136. };
  109137. }
  109138. declare module BABYLON {
  109139. /** @hidden */
  109140. export var defaultVertexShader: {
  109141. name: string;
  109142. shader: string;
  109143. };
  109144. }
  109145. declare module BABYLON {
  109146. /**
  109147. * @hidden
  109148. */
  109149. export interface IMaterialDetailMapDefines {
  109150. DETAIL: boolean;
  109151. DETAILDIRECTUV: number;
  109152. DETAIL_NORMALBLENDMETHOD: number;
  109153. /** @hidden */
  109154. _areTexturesDirty: boolean;
  109155. }
  109156. /**
  109157. * Define the code related to the detail map parameters of a material
  109158. *
  109159. * Inspired from:
  109160. * 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
  109161. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109162. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109163. */
  109164. export class DetailMapConfiguration {
  109165. private _texture;
  109166. /**
  109167. * The detail texture of the material.
  109168. */
  109169. texture: Nullable<BaseTexture>;
  109170. /**
  109171. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109172. * Bigger values mean stronger blending
  109173. */
  109174. diffuseBlendLevel: number;
  109175. /**
  109176. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109177. * Bigger values mean stronger blending. Only used with PBR materials
  109178. */
  109179. roughnessBlendLevel: number;
  109180. /**
  109181. * Defines how strong the bump effect from the detail map is
  109182. * Bigger values mean stronger effect
  109183. */
  109184. bumpLevel: number;
  109185. private _normalBlendMethod;
  109186. /**
  109187. * The method used to blend the bump and detail normals together
  109188. */
  109189. normalBlendMethod: number;
  109190. private _isEnabled;
  109191. /**
  109192. * Enable or disable the detail map on this material
  109193. */
  109194. isEnabled: boolean;
  109195. /** @hidden */
  109196. private _internalMarkAllSubMeshesAsTexturesDirty;
  109197. /** @hidden */
  109198. _markAllSubMeshesAsTexturesDirty(): void;
  109199. /**
  109200. * Instantiate a new detail map
  109201. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109202. */
  109203. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109204. /**
  109205. * Gets whether the submesh is ready to be used or not.
  109206. * @param defines the list of "defines" to update.
  109207. * @param scene defines the scene the material belongs to.
  109208. * @returns - boolean indicating that the submesh is ready or not.
  109209. */
  109210. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109211. /**
  109212. * Update the defines for detail map usage
  109213. * @param defines the list of "defines" to update.
  109214. * @param scene defines the scene the material belongs to.
  109215. */
  109216. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109217. /**
  109218. * Binds the material data.
  109219. * @param uniformBuffer defines the Uniform buffer to fill in.
  109220. * @param scene defines the scene the material belongs to.
  109221. * @param isFrozen defines whether the material is frozen or not.
  109222. */
  109223. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109224. /**
  109225. * Checks to see if a texture is used in the material.
  109226. * @param texture - Base texture to use.
  109227. * @returns - Boolean specifying if a texture is used in the material.
  109228. */
  109229. hasTexture(texture: BaseTexture): boolean;
  109230. /**
  109231. * Returns an array of the actively used textures.
  109232. * @param activeTextures Array of BaseTextures
  109233. */
  109234. getActiveTextures(activeTextures: BaseTexture[]): void;
  109235. /**
  109236. * Returns the animatable textures.
  109237. * @param animatables Array of animatable textures.
  109238. */
  109239. getAnimatables(animatables: IAnimatable[]): void;
  109240. /**
  109241. * Disposes the resources of the material.
  109242. * @param forceDisposeTextures - Forces the disposal of all textures.
  109243. */
  109244. dispose(forceDisposeTextures?: boolean): void;
  109245. /**
  109246. * Get the current class name useful for serialization or dynamic coding.
  109247. * @returns "DetailMap"
  109248. */
  109249. getClassName(): string;
  109250. /**
  109251. * Add the required uniforms to the current list.
  109252. * @param uniforms defines the current uniform list.
  109253. */
  109254. static AddUniforms(uniforms: string[]): void;
  109255. /**
  109256. * Add the required samplers to the current list.
  109257. * @param samplers defines the current sampler list.
  109258. */
  109259. static AddSamplers(samplers: string[]): void;
  109260. /**
  109261. * Add the required uniforms to the current buffer.
  109262. * @param uniformBuffer defines the current uniform buffer.
  109263. */
  109264. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109265. /**
  109266. * Makes a duplicate of the current instance into another one.
  109267. * @param detailMap define the instance where to copy the info
  109268. */
  109269. copyTo(detailMap: DetailMapConfiguration): void;
  109270. /**
  109271. * Serializes this detail map instance
  109272. * @returns - An object with the serialized instance.
  109273. */
  109274. serialize(): any;
  109275. /**
  109276. * Parses a detail map setting from a serialized object.
  109277. * @param source - Serialized object.
  109278. * @param scene Defines the scene we are parsing for
  109279. * @param rootUrl Defines the rootUrl to load from
  109280. */
  109281. parse(source: any, scene: Scene, rootUrl: string): void;
  109282. }
  109283. }
  109284. declare module BABYLON {
  109285. /** @hidden */
  109286. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109287. MAINUV1: boolean;
  109288. MAINUV2: boolean;
  109289. DIFFUSE: boolean;
  109290. DIFFUSEDIRECTUV: number;
  109291. DETAIL: boolean;
  109292. DETAILDIRECTUV: number;
  109293. DETAIL_NORMALBLENDMETHOD: number;
  109294. AMBIENT: boolean;
  109295. AMBIENTDIRECTUV: number;
  109296. OPACITY: boolean;
  109297. OPACITYDIRECTUV: number;
  109298. OPACITYRGB: boolean;
  109299. REFLECTION: boolean;
  109300. EMISSIVE: boolean;
  109301. EMISSIVEDIRECTUV: number;
  109302. SPECULAR: boolean;
  109303. SPECULARDIRECTUV: number;
  109304. BUMP: boolean;
  109305. BUMPDIRECTUV: number;
  109306. PARALLAX: boolean;
  109307. PARALLAXOCCLUSION: boolean;
  109308. SPECULAROVERALPHA: boolean;
  109309. CLIPPLANE: boolean;
  109310. CLIPPLANE2: boolean;
  109311. CLIPPLANE3: boolean;
  109312. CLIPPLANE4: boolean;
  109313. CLIPPLANE5: boolean;
  109314. CLIPPLANE6: boolean;
  109315. ALPHATEST: boolean;
  109316. DEPTHPREPASS: boolean;
  109317. ALPHAFROMDIFFUSE: boolean;
  109318. POINTSIZE: boolean;
  109319. FOG: boolean;
  109320. SPECULARTERM: boolean;
  109321. DIFFUSEFRESNEL: boolean;
  109322. OPACITYFRESNEL: boolean;
  109323. REFLECTIONFRESNEL: boolean;
  109324. REFRACTIONFRESNEL: boolean;
  109325. EMISSIVEFRESNEL: boolean;
  109326. FRESNEL: boolean;
  109327. NORMAL: boolean;
  109328. UV1: boolean;
  109329. UV2: boolean;
  109330. VERTEXCOLOR: boolean;
  109331. VERTEXALPHA: boolean;
  109332. NUM_BONE_INFLUENCERS: number;
  109333. BonesPerMesh: number;
  109334. BONETEXTURE: boolean;
  109335. INSTANCES: boolean;
  109336. THIN_INSTANCES: boolean;
  109337. GLOSSINESS: boolean;
  109338. ROUGHNESS: boolean;
  109339. EMISSIVEASILLUMINATION: boolean;
  109340. LINKEMISSIVEWITHDIFFUSE: boolean;
  109341. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109342. LIGHTMAP: boolean;
  109343. LIGHTMAPDIRECTUV: number;
  109344. OBJECTSPACE_NORMALMAP: boolean;
  109345. USELIGHTMAPASSHADOWMAP: boolean;
  109346. REFLECTIONMAP_3D: boolean;
  109347. REFLECTIONMAP_SPHERICAL: boolean;
  109348. REFLECTIONMAP_PLANAR: boolean;
  109349. REFLECTIONMAP_CUBIC: boolean;
  109350. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109351. REFLECTIONMAP_PROJECTION: boolean;
  109352. REFLECTIONMAP_SKYBOX: boolean;
  109353. REFLECTIONMAP_EXPLICIT: boolean;
  109354. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109355. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109356. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109357. INVERTCUBICMAP: boolean;
  109358. LOGARITHMICDEPTH: boolean;
  109359. REFRACTION: boolean;
  109360. REFRACTIONMAP_3D: boolean;
  109361. REFLECTIONOVERALPHA: boolean;
  109362. TWOSIDEDLIGHTING: boolean;
  109363. SHADOWFLOAT: boolean;
  109364. MORPHTARGETS: boolean;
  109365. MORPHTARGETS_NORMAL: boolean;
  109366. MORPHTARGETS_TANGENT: boolean;
  109367. MORPHTARGETS_UV: boolean;
  109368. NUM_MORPH_INFLUENCERS: number;
  109369. NONUNIFORMSCALING: boolean;
  109370. PREMULTIPLYALPHA: boolean;
  109371. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109372. ALPHABLEND: boolean;
  109373. PREPASS: boolean;
  109374. SCENE_MRT_COUNT: number;
  109375. RGBDLIGHTMAP: boolean;
  109376. RGBDREFLECTION: boolean;
  109377. RGBDREFRACTION: boolean;
  109378. IMAGEPROCESSING: boolean;
  109379. VIGNETTE: boolean;
  109380. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109381. VIGNETTEBLENDMODEOPAQUE: boolean;
  109382. TONEMAPPING: boolean;
  109383. TONEMAPPING_ACES: boolean;
  109384. CONTRAST: boolean;
  109385. COLORCURVES: boolean;
  109386. COLORGRADING: boolean;
  109387. COLORGRADING3D: boolean;
  109388. SAMPLER3DGREENDEPTH: boolean;
  109389. SAMPLER3DBGRMAP: boolean;
  109390. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109391. MULTIVIEW: boolean;
  109392. /**
  109393. * If the reflection texture on this material is in linear color space
  109394. * @hidden
  109395. */
  109396. IS_REFLECTION_LINEAR: boolean;
  109397. /**
  109398. * If the refraction texture on this material is in linear color space
  109399. * @hidden
  109400. */
  109401. IS_REFRACTION_LINEAR: boolean;
  109402. EXPOSURE: boolean;
  109403. constructor();
  109404. setReflectionMode(modeToEnable: string): void;
  109405. }
  109406. /**
  109407. * This is the default material used in Babylon. It is the best trade off between quality
  109408. * and performances.
  109409. * @see https://doc.babylonjs.com/babylon101/materials
  109410. */
  109411. export class StandardMaterial extends PushMaterial {
  109412. private _diffuseTexture;
  109413. /**
  109414. * The basic texture of the material as viewed under a light.
  109415. */
  109416. diffuseTexture: Nullable<BaseTexture>;
  109417. private _ambientTexture;
  109418. /**
  109419. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109420. */
  109421. ambientTexture: Nullable<BaseTexture>;
  109422. private _opacityTexture;
  109423. /**
  109424. * Define the transparency of the material from a texture.
  109425. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109426. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109427. */
  109428. opacityTexture: Nullable<BaseTexture>;
  109429. private _reflectionTexture;
  109430. /**
  109431. * Define the texture used to display the reflection.
  109432. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109433. */
  109434. reflectionTexture: Nullable<BaseTexture>;
  109435. private _emissiveTexture;
  109436. /**
  109437. * Define texture of the material as if self lit.
  109438. * This will be mixed in the final result even in the absence of light.
  109439. */
  109440. emissiveTexture: Nullable<BaseTexture>;
  109441. private _specularTexture;
  109442. /**
  109443. * Define how the color and intensity of the highlight given by the light in the material.
  109444. */
  109445. specularTexture: Nullable<BaseTexture>;
  109446. private _bumpTexture;
  109447. /**
  109448. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109449. * 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.
  109450. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109451. */
  109452. bumpTexture: Nullable<BaseTexture>;
  109453. private _lightmapTexture;
  109454. /**
  109455. * Complex lighting can be computationally expensive to compute at runtime.
  109456. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109457. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109458. */
  109459. lightmapTexture: Nullable<BaseTexture>;
  109460. private _refractionTexture;
  109461. /**
  109462. * Define the texture used to display the refraction.
  109463. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109464. */
  109465. refractionTexture: Nullable<BaseTexture>;
  109466. /**
  109467. * The color of the material lit by the environmental background lighting.
  109468. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109469. */
  109470. ambientColor: Color3;
  109471. /**
  109472. * The basic color of the material as viewed under a light.
  109473. */
  109474. diffuseColor: Color3;
  109475. /**
  109476. * Define how the color and intensity of the highlight given by the light in the material.
  109477. */
  109478. specularColor: Color3;
  109479. /**
  109480. * Define the color of the material as if self lit.
  109481. * This will be mixed in the final result even in the absence of light.
  109482. */
  109483. emissiveColor: Color3;
  109484. /**
  109485. * Defines how sharp are the highlights in the material.
  109486. * The bigger the value the sharper giving a more glossy feeling to the result.
  109487. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109488. */
  109489. specularPower: number;
  109490. private _useAlphaFromDiffuseTexture;
  109491. /**
  109492. * Does the transparency come from the diffuse texture alpha channel.
  109493. */
  109494. useAlphaFromDiffuseTexture: boolean;
  109495. private _useEmissiveAsIllumination;
  109496. /**
  109497. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109498. */
  109499. useEmissiveAsIllumination: boolean;
  109500. private _linkEmissiveWithDiffuse;
  109501. /**
  109502. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109503. * the emissive level when the final color is close to one.
  109504. */
  109505. linkEmissiveWithDiffuse: boolean;
  109506. private _useSpecularOverAlpha;
  109507. /**
  109508. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109509. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109510. */
  109511. useSpecularOverAlpha: boolean;
  109512. private _useReflectionOverAlpha;
  109513. /**
  109514. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109515. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109516. */
  109517. useReflectionOverAlpha: boolean;
  109518. private _disableLighting;
  109519. /**
  109520. * Does lights from the scene impacts this material.
  109521. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109522. */
  109523. disableLighting: boolean;
  109524. private _useObjectSpaceNormalMap;
  109525. /**
  109526. * Allows using an object space normal map (instead of tangent space).
  109527. */
  109528. useObjectSpaceNormalMap: boolean;
  109529. private _useParallax;
  109530. /**
  109531. * Is parallax enabled or not.
  109532. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109533. */
  109534. useParallax: boolean;
  109535. private _useParallaxOcclusion;
  109536. /**
  109537. * Is parallax occlusion enabled or not.
  109538. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109539. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109540. */
  109541. useParallaxOcclusion: boolean;
  109542. /**
  109543. * 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.
  109544. */
  109545. parallaxScaleBias: number;
  109546. private _roughness;
  109547. /**
  109548. * Helps to define how blurry the reflections should appears in the material.
  109549. */
  109550. roughness: number;
  109551. /**
  109552. * In case of refraction, define the value of the index of refraction.
  109553. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109554. */
  109555. indexOfRefraction: number;
  109556. /**
  109557. * Invert the refraction texture alongside the y axis.
  109558. * It can be useful with procedural textures or probe for instance.
  109559. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109560. */
  109561. invertRefractionY: boolean;
  109562. /**
  109563. * Defines the alpha limits in alpha test mode.
  109564. */
  109565. alphaCutOff: number;
  109566. private _useLightmapAsShadowmap;
  109567. /**
  109568. * In case of light mapping, define whether the map contains light or shadow informations.
  109569. */
  109570. useLightmapAsShadowmap: boolean;
  109571. private _diffuseFresnelParameters;
  109572. /**
  109573. * Define the diffuse fresnel parameters of the material.
  109574. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109575. */
  109576. diffuseFresnelParameters: FresnelParameters;
  109577. private _opacityFresnelParameters;
  109578. /**
  109579. * Define the opacity fresnel parameters of the material.
  109580. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109581. */
  109582. opacityFresnelParameters: FresnelParameters;
  109583. private _reflectionFresnelParameters;
  109584. /**
  109585. * Define the reflection fresnel parameters of the material.
  109586. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109587. */
  109588. reflectionFresnelParameters: FresnelParameters;
  109589. private _refractionFresnelParameters;
  109590. /**
  109591. * Define the refraction fresnel parameters of the material.
  109592. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109593. */
  109594. refractionFresnelParameters: FresnelParameters;
  109595. private _emissiveFresnelParameters;
  109596. /**
  109597. * Define the emissive fresnel parameters of the material.
  109598. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109599. */
  109600. emissiveFresnelParameters: FresnelParameters;
  109601. private _useReflectionFresnelFromSpecular;
  109602. /**
  109603. * If true automatically deducts the fresnels values from the material specularity.
  109604. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109605. */
  109606. useReflectionFresnelFromSpecular: boolean;
  109607. private _useGlossinessFromSpecularMapAlpha;
  109608. /**
  109609. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109610. */
  109611. useGlossinessFromSpecularMapAlpha: boolean;
  109612. private _maxSimultaneousLights;
  109613. /**
  109614. * Defines the maximum number of lights that can be used in the material
  109615. */
  109616. maxSimultaneousLights: number;
  109617. private _invertNormalMapX;
  109618. /**
  109619. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109620. */
  109621. invertNormalMapX: boolean;
  109622. private _invertNormalMapY;
  109623. /**
  109624. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109625. */
  109626. invertNormalMapY: boolean;
  109627. private _twoSidedLighting;
  109628. /**
  109629. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109630. */
  109631. twoSidedLighting: boolean;
  109632. /**
  109633. * Default configuration related to image processing available in the standard Material.
  109634. */
  109635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109636. /**
  109637. * Gets the image processing configuration used either in this material.
  109638. */
  109639. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109640. /**
  109641. * Sets the Default image processing configuration used either in the this material.
  109642. *
  109643. * If sets to null, the scene one is in use.
  109644. */
  109645. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109646. /**
  109647. * Keep track of the image processing observer to allow dispose and replace.
  109648. */
  109649. private _imageProcessingObserver;
  109650. /**
  109651. * Attaches a new image processing configuration to the Standard Material.
  109652. * @param configuration
  109653. */
  109654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109655. /**
  109656. * Gets wether the color curves effect is enabled.
  109657. */
  109658. get cameraColorCurvesEnabled(): boolean;
  109659. /**
  109660. * Sets wether the color curves effect is enabled.
  109661. */
  109662. set cameraColorCurvesEnabled(value: boolean);
  109663. /**
  109664. * Gets wether the color grading effect is enabled.
  109665. */
  109666. get cameraColorGradingEnabled(): boolean;
  109667. /**
  109668. * Gets wether the color grading effect is enabled.
  109669. */
  109670. set cameraColorGradingEnabled(value: boolean);
  109671. /**
  109672. * Gets wether tonemapping is enabled or not.
  109673. */
  109674. get cameraToneMappingEnabled(): boolean;
  109675. /**
  109676. * Sets wether tonemapping is enabled or not
  109677. */
  109678. set cameraToneMappingEnabled(value: boolean);
  109679. /**
  109680. * The camera exposure used on this material.
  109681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109682. * This corresponds to a photographic exposure.
  109683. */
  109684. get cameraExposure(): number;
  109685. /**
  109686. * The camera exposure used on this material.
  109687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109688. * This corresponds to a photographic exposure.
  109689. */
  109690. set cameraExposure(value: number);
  109691. /**
  109692. * Gets The camera contrast used on this material.
  109693. */
  109694. get cameraContrast(): number;
  109695. /**
  109696. * Sets The camera contrast used on this material.
  109697. */
  109698. set cameraContrast(value: number);
  109699. /**
  109700. * Gets the Color Grading 2D Lookup Texture.
  109701. */
  109702. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109703. /**
  109704. * Sets the Color Grading 2D Lookup Texture.
  109705. */
  109706. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109707. /**
  109708. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109709. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109710. * 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;
  109711. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109712. */
  109713. get cameraColorCurves(): Nullable<ColorCurves>;
  109714. /**
  109715. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109716. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109717. * 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;
  109718. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109719. */
  109720. set cameraColorCurves(value: Nullable<ColorCurves>);
  109721. /**
  109722. * Can this material render to several textures at once
  109723. */
  109724. get canRenderToMRT(): boolean;
  109725. /**
  109726. * Defines the detail map parameters for the material.
  109727. */
  109728. readonly detailMap: DetailMapConfiguration;
  109729. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109730. protected _worldViewProjectionMatrix: Matrix;
  109731. protected _globalAmbientColor: Color3;
  109732. protected _useLogarithmicDepth: boolean;
  109733. protected _rebuildInParallel: boolean;
  109734. /**
  109735. * Instantiates a new standard material.
  109736. * This is the default material used in Babylon. It is the best trade off between quality
  109737. * and performances.
  109738. * @see https://doc.babylonjs.com/babylon101/materials
  109739. * @param name Define the name of the material in the scene
  109740. * @param scene Define the scene the material belong to
  109741. */
  109742. constructor(name: string, scene: Scene);
  109743. /**
  109744. * Gets a boolean indicating that current material needs to register RTT
  109745. */
  109746. get hasRenderTargetTextures(): boolean;
  109747. /**
  109748. * Gets the current class name of the material e.g. "StandardMaterial"
  109749. * Mainly use in serialization.
  109750. * @returns the class name
  109751. */
  109752. getClassName(): string;
  109753. /**
  109754. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109755. * You can try switching to logarithmic depth.
  109756. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109757. */
  109758. get useLogarithmicDepth(): boolean;
  109759. set useLogarithmicDepth(value: boolean);
  109760. /**
  109761. * Specifies if the material will require alpha blending
  109762. * @returns a boolean specifying if alpha blending is needed
  109763. */
  109764. needAlphaBlending(): boolean;
  109765. /**
  109766. * Specifies if this material should be rendered in alpha test mode
  109767. * @returns a boolean specifying if an alpha test is needed.
  109768. */
  109769. needAlphaTesting(): boolean;
  109770. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109771. /**
  109772. * Get the texture used for alpha test purpose.
  109773. * @returns the diffuse texture in case of the standard material.
  109774. */
  109775. getAlphaTestTexture(): Nullable<BaseTexture>;
  109776. /**
  109777. * Get if the submesh is ready to be used and all its information available.
  109778. * Child classes can use it to update shaders
  109779. * @param mesh defines the mesh to check
  109780. * @param subMesh defines which submesh to check
  109781. * @param useInstances specifies that instances should be used
  109782. * @returns a boolean indicating that the submesh is ready or not
  109783. */
  109784. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109785. /**
  109786. * Builds the material UBO layouts.
  109787. * Used internally during the effect preparation.
  109788. */
  109789. buildUniformLayout(): void;
  109790. /**
  109791. * Unbinds the material from the mesh
  109792. */
  109793. unbind(): void;
  109794. /**
  109795. * Binds the submesh to this material by preparing the effect and shader to draw
  109796. * @param world defines the world transformation matrix
  109797. * @param mesh defines the mesh containing the submesh
  109798. * @param subMesh defines the submesh to bind the material to
  109799. */
  109800. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109801. /**
  109802. * Get the list of animatables in the material.
  109803. * @returns the list of animatables object used in the material
  109804. */
  109805. getAnimatables(): IAnimatable[];
  109806. /**
  109807. * Gets the active textures from the material
  109808. * @returns an array of textures
  109809. */
  109810. getActiveTextures(): BaseTexture[];
  109811. /**
  109812. * Specifies if the material uses a texture
  109813. * @param texture defines the texture to check against the material
  109814. * @returns a boolean specifying if the material uses the texture
  109815. */
  109816. hasTexture(texture: BaseTexture): boolean;
  109817. /**
  109818. * Disposes the material
  109819. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109820. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109821. */
  109822. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109823. /**
  109824. * Makes a duplicate of the material, and gives it a new name
  109825. * @param name defines the new name for the duplicated material
  109826. * @returns the cloned material
  109827. */
  109828. clone(name: string): StandardMaterial;
  109829. /**
  109830. * Serializes this material in a JSON representation
  109831. * @returns the serialized material object
  109832. */
  109833. serialize(): any;
  109834. /**
  109835. * Creates a standard material from parsed material data
  109836. * @param source defines the JSON representation of the material
  109837. * @param scene defines the hosting scene
  109838. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109839. * @returns a new standard material
  109840. */
  109841. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109842. /**
  109843. * Are diffuse textures enabled in the application.
  109844. */
  109845. static get DiffuseTextureEnabled(): boolean;
  109846. static set DiffuseTextureEnabled(value: boolean);
  109847. /**
  109848. * Are detail textures enabled in the application.
  109849. */
  109850. static get DetailTextureEnabled(): boolean;
  109851. static set DetailTextureEnabled(value: boolean);
  109852. /**
  109853. * Are ambient textures enabled in the application.
  109854. */
  109855. static get AmbientTextureEnabled(): boolean;
  109856. static set AmbientTextureEnabled(value: boolean);
  109857. /**
  109858. * Are opacity textures enabled in the application.
  109859. */
  109860. static get OpacityTextureEnabled(): boolean;
  109861. static set OpacityTextureEnabled(value: boolean);
  109862. /**
  109863. * Are reflection textures enabled in the application.
  109864. */
  109865. static get ReflectionTextureEnabled(): boolean;
  109866. static set ReflectionTextureEnabled(value: boolean);
  109867. /**
  109868. * Are emissive textures enabled in the application.
  109869. */
  109870. static get EmissiveTextureEnabled(): boolean;
  109871. static set EmissiveTextureEnabled(value: boolean);
  109872. /**
  109873. * Are specular textures enabled in the application.
  109874. */
  109875. static get SpecularTextureEnabled(): boolean;
  109876. static set SpecularTextureEnabled(value: boolean);
  109877. /**
  109878. * Are bump textures enabled in the application.
  109879. */
  109880. static get BumpTextureEnabled(): boolean;
  109881. static set BumpTextureEnabled(value: boolean);
  109882. /**
  109883. * Are lightmap textures enabled in the application.
  109884. */
  109885. static get LightmapTextureEnabled(): boolean;
  109886. static set LightmapTextureEnabled(value: boolean);
  109887. /**
  109888. * Are refraction textures enabled in the application.
  109889. */
  109890. static get RefractionTextureEnabled(): boolean;
  109891. static set RefractionTextureEnabled(value: boolean);
  109892. /**
  109893. * Are color grading textures enabled in the application.
  109894. */
  109895. static get ColorGradingTextureEnabled(): boolean;
  109896. static set ColorGradingTextureEnabled(value: boolean);
  109897. /**
  109898. * Are fresnels enabled in the application.
  109899. */
  109900. static get FresnelEnabled(): boolean;
  109901. static set FresnelEnabled(value: boolean);
  109902. }
  109903. }
  109904. declare module BABYLON {
  109905. /**
  109906. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109907. *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.
  109908. * The SPS is also a particle system. It provides some methods to manage the particles.
  109909. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109910. *
  109911. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109912. */
  109913. export class SolidParticleSystem implements IDisposable {
  109914. /**
  109915. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109916. * Example : var p = SPS.particles[i];
  109917. */
  109918. particles: SolidParticle[];
  109919. /**
  109920. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109921. */
  109922. nbParticles: number;
  109923. /**
  109924. * If the particles must ever face the camera (default false). Useful for planar particles.
  109925. */
  109926. billboard: boolean;
  109927. /**
  109928. * Recompute normals when adding a shape
  109929. */
  109930. recomputeNormals: boolean;
  109931. /**
  109932. * This a counter ofr your own usage. It's not set by any SPS functions.
  109933. */
  109934. counter: number;
  109935. /**
  109936. * The SPS name. This name is also given to the underlying mesh.
  109937. */
  109938. name: string;
  109939. /**
  109940. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109941. */
  109942. mesh: Mesh;
  109943. /**
  109944. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109945. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109946. */
  109947. vars: any;
  109948. /**
  109949. * This array is populated when the SPS is set as 'pickable'.
  109950. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109951. * Each element of this array is an object `{idx: int, faceId: int}`.
  109952. * `idx` is the picked particle index in the `SPS.particles` array
  109953. * `faceId` is the picked face index counted within this particle.
  109954. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109955. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109956. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109957. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109958. */
  109959. pickedParticles: {
  109960. idx: number;
  109961. faceId: number;
  109962. }[];
  109963. /**
  109964. * This array is populated when the SPS is set as 'pickable'
  109965. * Each key of this array is a submesh index.
  109966. * Each element of this array is a second array defined like this :
  109967. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109968. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109969. * `idx` is the picked particle index in the `SPS.particles` array
  109970. * `faceId` is the picked face index counted within this particle.
  109971. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109972. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109973. */
  109974. pickedBySubMesh: {
  109975. idx: number;
  109976. faceId: number;
  109977. }[][];
  109978. /**
  109979. * This array is populated when `enableDepthSort` is set to true.
  109980. * Each element of this array is an instance of the class DepthSortedParticle.
  109981. */
  109982. depthSortedParticles: DepthSortedParticle[];
  109983. /**
  109984. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109985. * @hidden
  109986. */
  109987. _bSphereOnly: boolean;
  109988. /**
  109989. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109990. * @hidden
  109991. */
  109992. _bSphereRadiusFactor: number;
  109993. private _scene;
  109994. private _positions;
  109995. private _indices;
  109996. private _normals;
  109997. private _colors;
  109998. private _uvs;
  109999. private _indices32;
  110000. private _positions32;
  110001. private _normals32;
  110002. private _fixedNormal32;
  110003. private _colors32;
  110004. private _uvs32;
  110005. private _index;
  110006. private _updatable;
  110007. private _pickable;
  110008. private _isVisibilityBoxLocked;
  110009. private _alwaysVisible;
  110010. private _depthSort;
  110011. private _expandable;
  110012. private _shapeCounter;
  110013. private _copy;
  110014. private _color;
  110015. private _computeParticleColor;
  110016. private _computeParticleTexture;
  110017. private _computeParticleRotation;
  110018. private _computeParticleVertex;
  110019. private _computeBoundingBox;
  110020. private _depthSortParticles;
  110021. private _camera;
  110022. private _mustUnrotateFixedNormals;
  110023. private _particlesIntersect;
  110024. private _needs32Bits;
  110025. private _isNotBuilt;
  110026. private _lastParticleId;
  110027. private _idxOfId;
  110028. private _multimaterialEnabled;
  110029. private _useModelMaterial;
  110030. private _indicesByMaterial;
  110031. private _materialIndexes;
  110032. private _depthSortFunction;
  110033. private _materialSortFunction;
  110034. private _materials;
  110035. private _multimaterial;
  110036. private _materialIndexesById;
  110037. private _defaultMaterial;
  110038. private _autoUpdateSubMeshes;
  110039. private _tmpVertex;
  110040. /**
  110041. * Creates a SPS (Solid Particle System) object.
  110042. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110043. * @param scene (Scene) is the scene in which the SPS is added.
  110044. * @param options defines the options of the sps e.g.
  110045. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110046. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110047. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110048. * * 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.
  110049. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110050. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110051. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110052. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110053. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110054. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110055. */
  110056. constructor(name: string, scene: Scene, options?: {
  110057. updatable?: boolean;
  110058. isPickable?: boolean;
  110059. enableDepthSort?: boolean;
  110060. particleIntersection?: boolean;
  110061. boundingSphereOnly?: boolean;
  110062. bSphereRadiusFactor?: number;
  110063. expandable?: boolean;
  110064. useModelMaterial?: boolean;
  110065. enableMultiMaterial?: boolean;
  110066. });
  110067. /**
  110068. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110069. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110070. * @returns the created mesh
  110071. */
  110072. buildMesh(): Mesh;
  110073. /**
  110074. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110075. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110076. * Thus the particles generated from `digest()` have their property `position` set yet.
  110077. * @param mesh ( Mesh ) is the mesh to be digested
  110078. * @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
  110079. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110080. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110081. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110082. * @returns the current SPS
  110083. */
  110084. digest(mesh: Mesh, options?: {
  110085. facetNb?: number;
  110086. number?: number;
  110087. delta?: number;
  110088. storage?: [];
  110089. }): SolidParticleSystem;
  110090. /**
  110091. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110092. * @hidden
  110093. */
  110094. private _unrotateFixedNormals;
  110095. /**
  110096. * Resets the temporary working copy particle
  110097. * @hidden
  110098. */
  110099. private _resetCopy;
  110100. /**
  110101. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110102. * @param p the current index in the positions array to be updated
  110103. * @param ind the current index in the indices array
  110104. * @param shape a Vector3 array, the shape geometry
  110105. * @param positions the positions array to be updated
  110106. * @param meshInd the shape indices array
  110107. * @param indices the indices array to be updated
  110108. * @param meshUV the shape uv array
  110109. * @param uvs the uv array to be updated
  110110. * @param meshCol the shape color array
  110111. * @param colors the color array to be updated
  110112. * @param meshNor the shape normals array
  110113. * @param normals the normals array to be updated
  110114. * @param idx the particle index
  110115. * @param idxInShape the particle index in its shape
  110116. * @param options the addShape() method passed options
  110117. * @model the particle model
  110118. * @hidden
  110119. */
  110120. private _meshBuilder;
  110121. /**
  110122. * Returns a shape Vector3 array from positions float array
  110123. * @param positions float array
  110124. * @returns a vector3 array
  110125. * @hidden
  110126. */
  110127. private _posToShape;
  110128. /**
  110129. * Returns a shapeUV array from a float uvs (array deep copy)
  110130. * @param uvs as a float array
  110131. * @returns a shapeUV array
  110132. * @hidden
  110133. */
  110134. private _uvsToShapeUV;
  110135. /**
  110136. * Adds a new particle object in the particles array
  110137. * @param idx particle index in particles array
  110138. * @param id particle id
  110139. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110140. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110141. * @param model particle ModelShape object
  110142. * @param shapeId model shape identifier
  110143. * @param idxInShape index of the particle in the current model
  110144. * @param bInfo model bounding info object
  110145. * @param storage target storage array, if any
  110146. * @hidden
  110147. */
  110148. private _addParticle;
  110149. /**
  110150. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110151. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110152. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110153. * @param nb (positive integer) the number of particles to be created from this model
  110154. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110155. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110156. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110157. * @returns the number of shapes in the system
  110158. */
  110159. addShape(mesh: Mesh, nb: number, options?: {
  110160. positionFunction?: any;
  110161. vertexFunction?: any;
  110162. storage?: [];
  110163. }): number;
  110164. /**
  110165. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110166. * @hidden
  110167. */
  110168. private _rebuildParticle;
  110169. /**
  110170. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110171. * @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.
  110172. * @returns the SPS.
  110173. */
  110174. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110175. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110176. * Returns an array with the removed particles.
  110177. * 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.
  110178. * The SPS can't be empty so at least one particle needs to remain in place.
  110179. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110180. * @param start index of the first particle to remove
  110181. * @param end index of the last particle to remove (included)
  110182. * @returns an array populated with the removed particles
  110183. */
  110184. removeParticles(start: number, end: number): SolidParticle[];
  110185. /**
  110186. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110187. * @param solidParticleArray an array populated with Solid Particles objects
  110188. * @returns the SPS
  110189. */
  110190. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110191. /**
  110192. * Creates a new particle and modifies the SPS mesh geometry :
  110193. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110194. * - calls _addParticle() to populate the particle array
  110195. * factorized code from addShape() and insertParticlesFromArray()
  110196. * @param idx particle index in the particles array
  110197. * @param i particle index in its shape
  110198. * @param modelShape particle ModelShape object
  110199. * @param shape shape vertex array
  110200. * @param meshInd shape indices array
  110201. * @param meshUV shape uv array
  110202. * @param meshCol shape color array
  110203. * @param meshNor shape normals array
  110204. * @param bbInfo shape bounding info
  110205. * @param storage target particle storage
  110206. * @options addShape() passed options
  110207. * @hidden
  110208. */
  110209. private _insertNewParticle;
  110210. /**
  110211. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110212. * This method calls `updateParticle()` for each particle of the SPS.
  110213. * For an animated SPS, it is usually called within the render loop.
  110214. * 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.
  110215. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110216. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110217. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110218. * @returns the SPS.
  110219. */
  110220. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110221. /**
  110222. * Disposes the SPS.
  110223. */
  110224. dispose(): void;
  110225. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110226. * idx is the particle index in the SPS
  110227. * faceId is the picked face index counted within this particle.
  110228. * Returns null if the pickInfo can't identify a picked particle.
  110229. * @param pickingInfo (PickingInfo object)
  110230. * @returns {idx: number, faceId: number} or null
  110231. */
  110232. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110233. idx: number;
  110234. faceId: number;
  110235. }>;
  110236. /**
  110237. * Returns a SolidParticle object from its identifier : particle.id
  110238. * @param id (integer) the particle Id
  110239. * @returns the searched particle or null if not found in the SPS.
  110240. */
  110241. getParticleById(id: number): Nullable<SolidParticle>;
  110242. /**
  110243. * Returns a new array populated with the particles having the passed shapeId.
  110244. * @param shapeId (integer) the shape identifier
  110245. * @returns a new solid particle array
  110246. */
  110247. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110248. /**
  110249. * Populates the passed array "ref" with the particles having the passed shapeId.
  110250. * @param shapeId the shape identifier
  110251. * @returns the SPS
  110252. * @param ref
  110253. */
  110254. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110255. /**
  110256. * Computes the required SubMeshes according the materials assigned to the particles.
  110257. * @returns the solid particle system.
  110258. * Does nothing if called before the SPS mesh is built.
  110259. */
  110260. computeSubMeshes(): SolidParticleSystem;
  110261. /**
  110262. * Sorts the solid particles by material when MultiMaterial is enabled.
  110263. * Updates the indices32 array.
  110264. * Updates the indicesByMaterial array.
  110265. * Updates the mesh indices array.
  110266. * @returns the SPS
  110267. * @hidden
  110268. */
  110269. private _sortParticlesByMaterial;
  110270. /**
  110271. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110272. * @hidden
  110273. */
  110274. private _setMaterialIndexesById;
  110275. /**
  110276. * Returns an array with unique values of Materials from the passed array
  110277. * @param array the material array to be checked and filtered
  110278. * @hidden
  110279. */
  110280. private _filterUniqueMaterialId;
  110281. /**
  110282. * Sets a new Standard Material as _defaultMaterial if not already set.
  110283. * @hidden
  110284. */
  110285. private _setDefaultMaterial;
  110286. /**
  110287. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110288. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110289. * @returns the SPS.
  110290. */
  110291. refreshVisibleSize(): SolidParticleSystem;
  110292. /**
  110293. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110294. * @param size the size (float) of the visibility box
  110295. * note : this doesn't lock the SPS mesh bounding box.
  110296. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110297. */
  110298. setVisibilityBox(size: number): void;
  110299. /**
  110300. * Gets whether the SPS as always visible or not
  110301. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110302. */
  110303. get isAlwaysVisible(): boolean;
  110304. /**
  110305. * Sets the SPS as always visible or not
  110306. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110307. */
  110308. set isAlwaysVisible(val: boolean);
  110309. /**
  110310. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110311. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110312. */
  110313. set isVisibilityBoxLocked(val: boolean);
  110314. /**
  110315. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110316. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110317. */
  110318. get isVisibilityBoxLocked(): boolean;
  110319. /**
  110320. * Tells to `setParticles()` to compute the particle rotations or not.
  110321. * Default value : true. The SPS is faster when it's set to false.
  110322. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110323. */
  110324. set computeParticleRotation(val: boolean);
  110325. /**
  110326. * Tells to `setParticles()` to compute the particle colors or not.
  110327. * Default value : true. The SPS is faster when it's set to false.
  110328. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110329. */
  110330. set computeParticleColor(val: boolean);
  110331. set computeParticleTexture(val: boolean);
  110332. /**
  110333. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110334. * Default value : false. The SPS is faster when it's set to false.
  110335. * Note : the particle custom vertex positions aren't stored values.
  110336. */
  110337. set computeParticleVertex(val: boolean);
  110338. /**
  110339. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110340. */
  110341. set computeBoundingBox(val: boolean);
  110342. /**
  110343. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110344. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110345. * Default : `true`
  110346. */
  110347. set depthSortParticles(val: boolean);
  110348. /**
  110349. * Gets if `setParticles()` computes the particle rotations or not.
  110350. * Default value : true. The SPS is faster when it's set to false.
  110351. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110352. */
  110353. get computeParticleRotation(): boolean;
  110354. /**
  110355. * Gets if `setParticles()` computes the particle colors or not.
  110356. * Default value : true. The SPS is faster when it's set to false.
  110357. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110358. */
  110359. get computeParticleColor(): boolean;
  110360. /**
  110361. * Gets if `setParticles()` computes the particle textures or not.
  110362. * Default value : true. The SPS is faster when it's set to false.
  110363. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110364. */
  110365. get computeParticleTexture(): boolean;
  110366. /**
  110367. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110368. * Default value : false. The SPS is faster when it's set to false.
  110369. * Note : the particle custom vertex positions aren't stored values.
  110370. */
  110371. get computeParticleVertex(): boolean;
  110372. /**
  110373. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110374. */
  110375. get computeBoundingBox(): boolean;
  110376. /**
  110377. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110378. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110379. * Default : `true`
  110380. */
  110381. get depthSortParticles(): boolean;
  110382. /**
  110383. * Gets if the SPS is created as expandable at construction time.
  110384. * Default : `false`
  110385. */
  110386. get expandable(): boolean;
  110387. /**
  110388. * Gets if the SPS supports the Multi Materials
  110389. */
  110390. get multimaterialEnabled(): boolean;
  110391. /**
  110392. * Gets if the SPS uses the model materials for its own multimaterial.
  110393. */
  110394. get useModelMaterial(): boolean;
  110395. /**
  110396. * The SPS used material array.
  110397. */
  110398. get materials(): Material[];
  110399. /**
  110400. * Sets the SPS MultiMaterial from the passed materials.
  110401. * Note : the passed array is internally copied and not used then by reference.
  110402. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110403. */
  110404. setMultiMaterial(materials: Material[]): void;
  110405. /**
  110406. * The SPS computed multimaterial object
  110407. */
  110408. get multimaterial(): MultiMaterial;
  110409. set multimaterial(mm: MultiMaterial);
  110410. /**
  110411. * If the subMeshes must be updated on the next call to setParticles()
  110412. */
  110413. get autoUpdateSubMeshes(): boolean;
  110414. set autoUpdateSubMeshes(val: boolean);
  110415. /**
  110416. * This function does nothing. It may be overwritten to set all the particle first values.
  110417. * The SPS doesn't call this function, you may have to call it by your own.
  110418. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110419. */
  110420. initParticles(): void;
  110421. /**
  110422. * This function does nothing. It may be overwritten to recycle a particle.
  110423. * The SPS doesn't call this function, you may have to call it by your own.
  110424. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110425. * @param particle The particle to recycle
  110426. * @returns the recycled particle
  110427. */
  110428. recycleParticle(particle: SolidParticle): SolidParticle;
  110429. /**
  110430. * Updates a particle : this function should be overwritten by the user.
  110431. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110432. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110433. * @example : just set a particle position or velocity and recycle conditions
  110434. * @param particle The particle to update
  110435. * @returns the updated particle
  110436. */
  110437. updateParticle(particle: SolidParticle): SolidParticle;
  110438. /**
  110439. * Updates a vertex of a particle : it can be overwritten by the user.
  110440. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110441. * @param particle the current particle
  110442. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110443. * @param pt the index of the current vertex in the particle shape
  110444. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110445. * @example : just set a vertex particle position or color
  110446. * @returns the sps
  110447. */
  110448. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110449. /**
  110450. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110451. * This does nothing and may be overwritten by the user.
  110452. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110453. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110454. * @param update the boolean update value actually passed to setParticles()
  110455. */
  110456. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110457. /**
  110458. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110459. * This will be passed three parameters.
  110460. * This does nothing and may be overwritten by the user.
  110461. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110462. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110463. * @param update the boolean update value actually passed to setParticles()
  110464. */
  110465. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110466. }
  110467. }
  110468. declare module BABYLON {
  110469. /**
  110470. * Represents one particle of a solid particle system.
  110471. */
  110472. export class SolidParticle {
  110473. /**
  110474. * particle global index
  110475. */
  110476. idx: number;
  110477. /**
  110478. * particle identifier
  110479. */
  110480. id: number;
  110481. /**
  110482. * The color of the particle
  110483. */
  110484. color: Nullable<Color4>;
  110485. /**
  110486. * The world space position of the particle.
  110487. */
  110488. position: Vector3;
  110489. /**
  110490. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110491. */
  110492. rotation: Vector3;
  110493. /**
  110494. * The world space rotation quaternion of the particle.
  110495. */
  110496. rotationQuaternion: Nullable<Quaternion>;
  110497. /**
  110498. * The scaling of the particle.
  110499. */
  110500. scaling: Vector3;
  110501. /**
  110502. * The uvs of the particle.
  110503. */
  110504. uvs: Vector4;
  110505. /**
  110506. * The current speed of the particle.
  110507. */
  110508. velocity: Vector3;
  110509. /**
  110510. * The pivot point in the particle local space.
  110511. */
  110512. pivot: Vector3;
  110513. /**
  110514. * Must the particle be translated from its pivot point in its local space ?
  110515. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110516. * Default : false
  110517. */
  110518. translateFromPivot: boolean;
  110519. /**
  110520. * Is the particle active or not ?
  110521. */
  110522. alive: boolean;
  110523. /**
  110524. * Is the particle visible or not ?
  110525. */
  110526. isVisible: boolean;
  110527. /**
  110528. * Index of this particle in the global "positions" array (Internal use)
  110529. * @hidden
  110530. */
  110531. _pos: number;
  110532. /**
  110533. * @hidden Index of this particle in the global "indices" array (Internal use)
  110534. */
  110535. _ind: number;
  110536. /**
  110537. * @hidden ModelShape of this particle (Internal use)
  110538. */
  110539. _model: ModelShape;
  110540. /**
  110541. * ModelShape id of this particle
  110542. */
  110543. shapeId: number;
  110544. /**
  110545. * Index of the particle in its shape id
  110546. */
  110547. idxInShape: number;
  110548. /**
  110549. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110550. */
  110551. _modelBoundingInfo: BoundingInfo;
  110552. /**
  110553. * @hidden Particle BoundingInfo object (Internal use)
  110554. */
  110555. _boundingInfo: BoundingInfo;
  110556. /**
  110557. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110558. */
  110559. _sps: SolidParticleSystem;
  110560. /**
  110561. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110562. */
  110563. _stillInvisible: boolean;
  110564. /**
  110565. * @hidden Last computed particle rotation matrix
  110566. */
  110567. _rotationMatrix: number[];
  110568. /**
  110569. * Parent particle Id, if any.
  110570. * Default null.
  110571. */
  110572. parentId: Nullable<number>;
  110573. /**
  110574. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110575. */
  110576. materialIndex: Nullable<number>;
  110577. /**
  110578. * Custom object or properties.
  110579. */
  110580. props: Nullable<any>;
  110581. /**
  110582. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110583. * The possible values are :
  110584. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110585. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110586. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110587. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110588. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110589. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110590. * */
  110591. cullingStrategy: number;
  110592. /**
  110593. * @hidden Internal global position in the SPS.
  110594. */
  110595. _globalPosition: Vector3;
  110596. /**
  110597. * Creates a Solid Particle object.
  110598. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110599. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110600. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110601. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110602. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110603. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110604. * @param shapeId (integer) is the model shape identifier in the SPS.
  110605. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110606. * @param sps defines the sps it is associated to
  110607. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110608. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110609. */
  110610. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110611. /**
  110612. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110613. * @param target the particle target
  110614. * @returns the current particle
  110615. */
  110616. copyToRef(target: SolidParticle): SolidParticle;
  110617. /**
  110618. * Legacy support, changed scale to scaling
  110619. */
  110620. get scale(): Vector3;
  110621. /**
  110622. * Legacy support, changed scale to scaling
  110623. */
  110624. set scale(scale: Vector3);
  110625. /**
  110626. * Legacy support, changed quaternion to rotationQuaternion
  110627. */
  110628. get quaternion(): Nullable<Quaternion>;
  110629. /**
  110630. * Legacy support, changed quaternion to rotationQuaternion
  110631. */
  110632. set quaternion(q: Nullable<Quaternion>);
  110633. /**
  110634. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110635. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110636. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110637. * @returns true if it intersects
  110638. */
  110639. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110640. /**
  110641. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110642. * A particle is in the frustum if its bounding box intersects the frustum
  110643. * @param frustumPlanes defines the frustum to test
  110644. * @returns true if the particle is in the frustum planes
  110645. */
  110646. isInFrustum(frustumPlanes: Plane[]): boolean;
  110647. /**
  110648. * get the rotation matrix of the particle
  110649. * @hidden
  110650. */
  110651. getRotationMatrix(m: Matrix): void;
  110652. }
  110653. /**
  110654. * Represents the shape of the model used by one particle of a solid particle system.
  110655. * SPS internal tool, don't use it manually.
  110656. */
  110657. export class ModelShape {
  110658. /**
  110659. * The shape id
  110660. * @hidden
  110661. */
  110662. shapeID: number;
  110663. /**
  110664. * flat array of model positions (internal use)
  110665. * @hidden
  110666. */
  110667. _shape: Vector3[];
  110668. /**
  110669. * flat array of model UVs (internal use)
  110670. * @hidden
  110671. */
  110672. _shapeUV: number[];
  110673. /**
  110674. * color array of the model
  110675. * @hidden
  110676. */
  110677. _shapeColors: number[];
  110678. /**
  110679. * indices array of the model
  110680. * @hidden
  110681. */
  110682. _indices: number[];
  110683. /**
  110684. * normals array of the model
  110685. * @hidden
  110686. */
  110687. _normals: number[];
  110688. /**
  110689. * length of the shape in the model indices array (internal use)
  110690. * @hidden
  110691. */
  110692. _indicesLength: number;
  110693. /**
  110694. * Custom position function (internal use)
  110695. * @hidden
  110696. */
  110697. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110698. /**
  110699. * Custom vertex function (internal use)
  110700. * @hidden
  110701. */
  110702. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110703. /**
  110704. * Model material (internal use)
  110705. * @hidden
  110706. */
  110707. _material: Nullable<Material>;
  110708. /**
  110709. * 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.
  110710. * SPS internal tool, don't use it manually.
  110711. * @hidden
  110712. */
  110713. 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>);
  110714. }
  110715. /**
  110716. * Represents a Depth Sorted Particle in the solid particle system.
  110717. * @hidden
  110718. */
  110719. export class DepthSortedParticle {
  110720. /**
  110721. * Particle index
  110722. */
  110723. idx: number;
  110724. /**
  110725. * Index of the particle in the "indices" array
  110726. */
  110727. ind: number;
  110728. /**
  110729. * Length of the particle shape in the "indices" array
  110730. */
  110731. indicesLength: number;
  110732. /**
  110733. * Squared distance from the particle to the camera
  110734. */
  110735. sqDistance: number;
  110736. /**
  110737. * Material index when used with MultiMaterials
  110738. */
  110739. materialIndex: number;
  110740. /**
  110741. * Creates a new sorted particle
  110742. * @param materialIndex
  110743. */
  110744. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110745. }
  110746. /**
  110747. * Represents a solid particle vertex
  110748. */
  110749. export class SolidParticleVertex {
  110750. /**
  110751. * Vertex position
  110752. */
  110753. position: Vector3;
  110754. /**
  110755. * Vertex color
  110756. */
  110757. color: Color4;
  110758. /**
  110759. * Vertex UV
  110760. */
  110761. uv: Vector2;
  110762. /**
  110763. * Creates a new solid particle vertex
  110764. */
  110765. constructor();
  110766. /** Vertex x coordinate */
  110767. get x(): number;
  110768. set x(val: number);
  110769. /** Vertex y coordinate */
  110770. get y(): number;
  110771. set y(val: number);
  110772. /** Vertex z coordinate */
  110773. get z(): number;
  110774. set z(val: number);
  110775. }
  110776. }
  110777. declare module BABYLON {
  110778. /**
  110779. * @hidden
  110780. */
  110781. export class _MeshCollisionData {
  110782. _checkCollisions: boolean;
  110783. _collisionMask: number;
  110784. _collisionGroup: number;
  110785. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110786. _collider: Nullable<Collider>;
  110787. _oldPositionForCollisions: Vector3;
  110788. _diffPositionForCollisions: Vector3;
  110789. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110790. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110791. }
  110792. }
  110793. declare module BABYLON {
  110794. /** @hidden */
  110795. class _FacetDataStorage {
  110796. facetPositions: Vector3[];
  110797. facetNormals: Vector3[];
  110798. facetPartitioning: number[][];
  110799. facetNb: number;
  110800. partitioningSubdivisions: number;
  110801. partitioningBBoxRatio: number;
  110802. facetDataEnabled: boolean;
  110803. facetParameters: any;
  110804. bbSize: Vector3;
  110805. subDiv: {
  110806. max: number;
  110807. X: number;
  110808. Y: number;
  110809. Z: number;
  110810. };
  110811. facetDepthSort: boolean;
  110812. facetDepthSortEnabled: boolean;
  110813. depthSortedIndices: IndicesArray;
  110814. depthSortedFacets: {
  110815. ind: number;
  110816. sqDistance: number;
  110817. }[];
  110818. facetDepthSortFunction: (f1: {
  110819. ind: number;
  110820. sqDistance: number;
  110821. }, f2: {
  110822. ind: number;
  110823. sqDistance: number;
  110824. }) => number;
  110825. facetDepthSortFrom: Vector3;
  110826. facetDepthSortOrigin: Vector3;
  110827. invertedMatrix: Matrix;
  110828. }
  110829. /**
  110830. * @hidden
  110831. **/
  110832. class _InternalAbstractMeshDataInfo {
  110833. _hasVertexAlpha: boolean;
  110834. _useVertexColors: boolean;
  110835. _numBoneInfluencers: number;
  110836. _applyFog: boolean;
  110837. _receiveShadows: boolean;
  110838. _facetData: _FacetDataStorage;
  110839. _visibility: number;
  110840. _skeleton: Nullable<Skeleton>;
  110841. _layerMask: number;
  110842. _computeBonesUsingShaders: boolean;
  110843. _isActive: boolean;
  110844. _onlyForInstances: boolean;
  110845. _isActiveIntermediate: boolean;
  110846. _onlyForInstancesIntermediate: boolean;
  110847. _actAsRegularMesh: boolean;
  110848. }
  110849. /**
  110850. * Class used to store all common mesh properties
  110851. */
  110852. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110853. /** No occlusion */
  110854. static OCCLUSION_TYPE_NONE: number;
  110855. /** Occlusion set to optimisitic */
  110856. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110857. /** Occlusion set to strict */
  110858. static OCCLUSION_TYPE_STRICT: number;
  110859. /** Use an accurante occlusion algorithm */
  110860. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110861. /** Use a conservative occlusion algorithm */
  110862. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110863. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110864. * Test order :
  110865. * Is the bounding sphere outside the frustum ?
  110866. * If not, are the bounding box vertices outside the frustum ?
  110867. * It not, then the cullable object is in the frustum.
  110868. */
  110869. static readonly CULLINGSTRATEGY_STANDARD: number;
  110870. /** Culling strategy : Bounding Sphere Only.
  110871. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110872. * It's also less accurate than the standard because some not visible objects can still be selected.
  110873. * Test : is the bounding sphere outside the frustum ?
  110874. * If not, then the cullable object is in the frustum.
  110875. */
  110876. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110877. /** Culling strategy : Optimistic Inclusion.
  110878. * This in an inclusion test first, then the standard exclusion test.
  110879. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110880. * 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.
  110881. * Anyway, it's as accurate as the standard strategy.
  110882. * Test :
  110883. * Is the cullable object bounding sphere center in the frustum ?
  110884. * If not, apply the default culling strategy.
  110885. */
  110886. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110887. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110888. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110889. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110890. * 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.
  110891. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110892. * Test :
  110893. * Is the cullable object bounding sphere center in the frustum ?
  110894. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110895. */
  110896. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110897. /**
  110898. * No billboard
  110899. */
  110900. static get BILLBOARDMODE_NONE(): number;
  110901. /** Billboard on X axis */
  110902. static get BILLBOARDMODE_X(): number;
  110903. /** Billboard on Y axis */
  110904. static get BILLBOARDMODE_Y(): number;
  110905. /** Billboard on Z axis */
  110906. static get BILLBOARDMODE_Z(): number;
  110907. /** Billboard on all axes */
  110908. static get BILLBOARDMODE_ALL(): number;
  110909. /** Billboard on using position instead of orientation */
  110910. static get BILLBOARDMODE_USE_POSITION(): number;
  110911. /** @hidden */
  110912. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110913. /**
  110914. * The culling strategy to use to check whether the mesh must be rendered or not.
  110915. * This value can be changed at any time and will be used on the next render mesh selection.
  110916. * The possible values are :
  110917. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110918. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110919. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110920. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110921. * Please read each static variable documentation to get details about the culling process.
  110922. * */
  110923. cullingStrategy: number;
  110924. /**
  110925. * Gets the number of facets in the mesh
  110926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110927. */
  110928. get facetNb(): number;
  110929. /**
  110930. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110931. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110932. */
  110933. get partitioningSubdivisions(): number;
  110934. set partitioningSubdivisions(nb: number);
  110935. /**
  110936. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110937. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110938. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110939. */
  110940. get partitioningBBoxRatio(): number;
  110941. set partitioningBBoxRatio(ratio: number);
  110942. /**
  110943. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110944. * Works only for updatable meshes.
  110945. * Doesn't work with multi-materials
  110946. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110947. */
  110948. get mustDepthSortFacets(): boolean;
  110949. set mustDepthSortFacets(sort: boolean);
  110950. /**
  110951. * The location (Vector3) where the facet depth sort must be computed from.
  110952. * By default, the active camera position.
  110953. * Used only when facet depth sort is enabled
  110954. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110955. */
  110956. get facetDepthSortFrom(): Vector3;
  110957. set facetDepthSortFrom(location: Vector3);
  110958. /**
  110959. * gets a boolean indicating if facetData is enabled
  110960. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110961. */
  110962. get isFacetDataEnabled(): boolean;
  110963. /** @hidden */
  110964. _updateNonUniformScalingState(value: boolean): boolean;
  110965. /**
  110966. * An event triggered when this mesh collides with another one
  110967. */
  110968. onCollideObservable: Observable<AbstractMesh>;
  110969. /** Set a function to call when this mesh collides with another one */
  110970. set onCollide(callback: () => void);
  110971. /**
  110972. * An event triggered when the collision's position changes
  110973. */
  110974. onCollisionPositionChangeObservable: Observable<Vector3>;
  110975. /** Set a function to call when the collision's position changes */
  110976. set onCollisionPositionChange(callback: () => void);
  110977. /**
  110978. * An event triggered when material is changed
  110979. */
  110980. onMaterialChangedObservable: Observable<AbstractMesh>;
  110981. /**
  110982. * Gets or sets the orientation for POV movement & rotation
  110983. */
  110984. definedFacingForward: boolean;
  110985. /** @hidden */
  110986. _occlusionQuery: Nullable<WebGLQuery>;
  110987. /** @hidden */
  110988. _renderingGroup: Nullable<RenderingGroup>;
  110989. /**
  110990. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110991. */
  110992. get visibility(): number;
  110993. /**
  110994. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110995. */
  110996. set visibility(value: number);
  110997. /** Gets or sets the alpha index used to sort transparent meshes
  110998. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110999. */
  111000. alphaIndex: number;
  111001. /**
  111002. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111003. */
  111004. isVisible: boolean;
  111005. /**
  111006. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111007. */
  111008. isPickable: boolean;
  111009. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111010. showSubMeshesBoundingBox: boolean;
  111011. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111012. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111013. */
  111014. isBlocker: boolean;
  111015. /**
  111016. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111017. */
  111018. enablePointerMoveEvents: boolean;
  111019. /**
  111020. * Specifies the rendering group id for this mesh (0 by default)
  111021. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111022. */
  111023. renderingGroupId: number;
  111024. private _material;
  111025. /** Gets or sets current material */
  111026. get material(): Nullable<Material>;
  111027. set material(value: Nullable<Material>);
  111028. /**
  111029. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111030. * @see https://doc.babylonjs.com/babylon101/shadows
  111031. */
  111032. get receiveShadows(): boolean;
  111033. set receiveShadows(value: boolean);
  111034. /** Defines color to use when rendering outline */
  111035. outlineColor: Color3;
  111036. /** Define width to use when rendering outline */
  111037. outlineWidth: number;
  111038. /** Defines color to use when rendering overlay */
  111039. overlayColor: Color3;
  111040. /** Defines alpha to use when rendering overlay */
  111041. overlayAlpha: number;
  111042. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111043. get hasVertexAlpha(): boolean;
  111044. set hasVertexAlpha(value: boolean);
  111045. /** 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) */
  111046. get useVertexColors(): boolean;
  111047. set useVertexColors(value: boolean);
  111048. /**
  111049. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111050. */
  111051. get computeBonesUsingShaders(): boolean;
  111052. set computeBonesUsingShaders(value: boolean);
  111053. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111054. get numBoneInfluencers(): number;
  111055. set numBoneInfluencers(value: number);
  111056. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111057. get applyFog(): boolean;
  111058. set applyFog(value: boolean);
  111059. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111060. useOctreeForRenderingSelection: boolean;
  111061. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111062. useOctreeForPicking: boolean;
  111063. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111064. useOctreeForCollisions: boolean;
  111065. /**
  111066. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111067. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111068. */
  111069. get layerMask(): number;
  111070. set layerMask(value: number);
  111071. /**
  111072. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111073. */
  111074. alwaysSelectAsActiveMesh: boolean;
  111075. /**
  111076. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111077. */
  111078. doNotSyncBoundingInfo: boolean;
  111079. /**
  111080. * Gets or sets the current action manager
  111081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111082. */
  111083. actionManager: Nullable<AbstractActionManager>;
  111084. private _meshCollisionData;
  111085. /**
  111086. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111087. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111088. */
  111089. ellipsoid: Vector3;
  111090. /**
  111091. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111092. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111093. */
  111094. ellipsoidOffset: Vector3;
  111095. /**
  111096. * Gets or sets a collision mask used to mask collisions (default is -1).
  111097. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111098. */
  111099. get collisionMask(): number;
  111100. set collisionMask(mask: number);
  111101. /**
  111102. * Gets or sets the current collision group mask (-1 by default).
  111103. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111104. */
  111105. get collisionGroup(): number;
  111106. set collisionGroup(mask: number);
  111107. /**
  111108. * Gets or sets current surrounding meshes (null by default).
  111109. *
  111110. * By default collision detection is tested against every mesh in the scene.
  111111. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111112. * meshes will be tested for the collision.
  111113. *
  111114. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111115. */
  111116. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111117. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111118. /**
  111119. * Defines edge width used when edgesRenderer is enabled
  111120. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111121. */
  111122. edgesWidth: number;
  111123. /**
  111124. * Defines edge color used when edgesRenderer is enabled
  111125. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111126. */
  111127. edgesColor: Color4;
  111128. /** @hidden */
  111129. _edgesRenderer: Nullable<IEdgesRenderer>;
  111130. /** @hidden */
  111131. _masterMesh: Nullable<AbstractMesh>;
  111132. /** @hidden */
  111133. _boundingInfo: Nullable<BoundingInfo>;
  111134. /** @hidden */
  111135. _renderId: number;
  111136. /**
  111137. * Gets or sets the list of subMeshes
  111138. * @see https://doc.babylonjs.com/how_to/multi_materials
  111139. */
  111140. subMeshes: SubMesh[];
  111141. /** @hidden */
  111142. _intersectionsInProgress: AbstractMesh[];
  111143. /** @hidden */
  111144. _unIndexed: boolean;
  111145. /** @hidden */
  111146. _lightSources: Light[];
  111147. /** Gets the list of lights affecting that mesh */
  111148. get lightSources(): Light[];
  111149. /** @hidden */
  111150. get _positions(): Nullable<Vector3[]>;
  111151. /** @hidden */
  111152. _waitingData: {
  111153. lods: Nullable<any>;
  111154. actions: Nullable<any>;
  111155. freezeWorldMatrix: Nullable<boolean>;
  111156. };
  111157. /** @hidden */
  111158. _bonesTransformMatrices: Nullable<Float32Array>;
  111159. /** @hidden */
  111160. _transformMatrixTexture: Nullable<RawTexture>;
  111161. /**
  111162. * Gets or sets a skeleton to apply skining transformations
  111163. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111164. */
  111165. set skeleton(value: Nullable<Skeleton>);
  111166. get skeleton(): Nullable<Skeleton>;
  111167. /**
  111168. * An event triggered when the mesh is rebuilt.
  111169. */
  111170. onRebuildObservable: Observable<AbstractMesh>;
  111171. /**
  111172. * Creates a new AbstractMesh
  111173. * @param name defines the name of the mesh
  111174. * @param scene defines the hosting scene
  111175. */
  111176. constructor(name: string, scene?: Nullable<Scene>);
  111177. /**
  111178. * Returns the string "AbstractMesh"
  111179. * @returns "AbstractMesh"
  111180. */
  111181. getClassName(): string;
  111182. /**
  111183. * Gets a string representation of the current mesh
  111184. * @param fullDetails defines a boolean indicating if full details must be included
  111185. * @returns a string representation of the current mesh
  111186. */
  111187. toString(fullDetails?: boolean): string;
  111188. /**
  111189. * @hidden
  111190. */
  111191. protected _getEffectiveParent(): Nullable<Node>;
  111192. /** @hidden */
  111193. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111194. /** @hidden */
  111195. _rebuild(): void;
  111196. /** @hidden */
  111197. _resyncLightSources(): void;
  111198. /** @hidden */
  111199. _resyncLightSource(light: Light): void;
  111200. /** @hidden */
  111201. _unBindEffect(): void;
  111202. /** @hidden */
  111203. _removeLightSource(light: Light, dispose: boolean): void;
  111204. private _markSubMeshesAsDirty;
  111205. /** @hidden */
  111206. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111207. /** @hidden */
  111208. _markSubMeshesAsAttributesDirty(): void;
  111209. /** @hidden */
  111210. _markSubMeshesAsMiscDirty(): void;
  111211. /**
  111212. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111213. */
  111214. get scaling(): Vector3;
  111215. set scaling(newScaling: Vector3);
  111216. /**
  111217. * Returns true if the mesh is blocked. Implemented by child classes
  111218. */
  111219. get isBlocked(): boolean;
  111220. /**
  111221. * Returns the mesh itself by default. Implemented by child classes
  111222. * @param camera defines the camera to use to pick the right LOD level
  111223. * @returns the currentAbstractMesh
  111224. */
  111225. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111226. /**
  111227. * Returns 0 by default. Implemented by child classes
  111228. * @returns an integer
  111229. */
  111230. getTotalVertices(): number;
  111231. /**
  111232. * Returns a positive integer : the total number of indices in this mesh geometry.
  111233. * @returns the numner of indices or zero if the mesh has no geometry.
  111234. */
  111235. getTotalIndices(): number;
  111236. /**
  111237. * Returns null by default. Implemented by child classes
  111238. * @returns null
  111239. */
  111240. getIndices(): Nullable<IndicesArray>;
  111241. /**
  111242. * Returns the array of the requested vertex data kind. Implemented by child classes
  111243. * @param kind defines the vertex data kind to use
  111244. * @returns null
  111245. */
  111246. getVerticesData(kind: string): Nullable<FloatArray>;
  111247. /**
  111248. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111249. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111250. * Note that a new underlying VertexBuffer object is created each call.
  111251. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111252. * @param kind defines vertex data kind:
  111253. * * VertexBuffer.PositionKind
  111254. * * VertexBuffer.UVKind
  111255. * * VertexBuffer.UV2Kind
  111256. * * VertexBuffer.UV3Kind
  111257. * * VertexBuffer.UV4Kind
  111258. * * VertexBuffer.UV5Kind
  111259. * * VertexBuffer.UV6Kind
  111260. * * VertexBuffer.ColorKind
  111261. * * VertexBuffer.MatricesIndicesKind
  111262. * * VertexBuffer.MatricesIndicesExtraKind
  111263. * * VertexBuffer.MatricesWeightsKind
  111264. * * VertexBuffer.MatricesWeightsExtraKind
  111265. * @param data defines the data source
  111266. * @param updatable defines if the data must be flagged as updatable (or static)
  111267. * @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
  111268. * @returns the current mesh
  111269. */
  111270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111271. /**
  111272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111273. * If the mesh has no geometry, it is simply returned as it is.
  111274. * @param kind defines vertex data kind:
  111275. * * VertexBuffer.PositionKind
  111276. * * VertexBuffer.UVKind
  111277. * * VertexBuffer.UV2Kind
  111278. * * VertexBuffer.UV3Kind
  111279. * * VertexBuffer.UV4Kind
  111280. * * VertexBuffer.UV5Kind
  111281. * * VertexBuffer.UV6Kind
  111282. * * VertexBuffer.ColorKind
  111283. * * VertexBuffer.MatricesIndicesKind
  111284. * * VertexBuffer.MatricesIndicesExtraKind
  111285. * * VertexBuffer.MatricesWeightsKind
  111286. * * VertexBuffer.MatricesWeightsExtraKind
  111287. * @param data defines the data source
  111288. * @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
  111289. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111290. * @returns the current mesh
  111291. */
  111292. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111293. /**
  111294. * Sets the mesh indices,
  111295. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111296. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111297. * @param totalVertices Defines the total number of vertices
  111298. * @returns the current mesh
  111299. */
  111300. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111301. /**
  111302. * Gets a boolean indicating if specific vertex data is present
  111303. * @param kind defines the vertex data kind to use
  111304. * @returns true is data kind is present
  111305. */
  111306. isVerticesDataPresent(kind: string): boolean;
  111307. /**
  111308. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111309. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111310. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111311. * @returns a BoundingInfo
  111312. */
  111313. getBoundingInfo(): BoundingInfo;
  111314. /**
  111315. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111316. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111317. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111318. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111319. * @returns the current mesh
  111320. */
  111321. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111322. /**
  111323. * Overwrite the current bounding info
  111324. * @param boundingInfo defines the new bounding info
  111325. * @returns the current mesh
  111326. */
  111327. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111328. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111329. get useBones(): boolean;
  111330. /** @hidden */
  111331. _preActivate(): void;
  111332. /** @hidden */
  111333. _preActivateForIntermediateRendering(renderId: number): void;
  111334. /** @hidden */
  111335. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111336. /** @hidden */
  111337. _postActivate(): void;
  111338. /** @hidden */
  111339. _freeze(): void;
  111340. /** @hidden */
  111341. _unFreeze(): void;
  111342. /**
  111343. * Gets the current world matrix
  111344. * @returns a Matrix
  111345. */
  111346. getWorldMatrix(): Matrix;
  111347. /** @hidden */
  111348. _getWorldMatrixDeterminant(): number;
  111349. /**
  111350. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111351. */
  111352. get isAnInstance(): boolean;
  111353. /**
  111354. * Gets a boolean indicating if this mesh has instances
  111355. */
  111356. get hasInstances(): boolean;
  111357. /**
  111358. * Gets a boolean indicating if this mesh has thin instances
  111359. */
  111360. get hasThinInstances(): boolean;
  111361. /**
  111362. * Perform relative position change from the point of view of behind the front of the mesh.
  111363. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111364. * Supports definition of mesh facing forward or backward
  111365. * @param amountRight defines the distance on the right axis
  111366. * @param amountUp defines the distance on the up axis
  111367. * @param amountForward defines the distance on the forward axis
  111368. * @returns the current mesh
  111369. */
  111370. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111371. /**
  111372. * Calculate relative position change from the point of view of behind the front of the mesh.
  111373. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111374. * Supports definition of mesh facing forward or backward
  111375. * @param amountRight defines the distance on the right axis
  111376. * @param amountUp defines the distance on the up axis
  111377. * @param amountForward defines the distance on the forward axis
  111378. * @returns the new displacement vector
  111379. */
  111380. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111381. /**
  111382. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111383. * Supports definition of mesh facing forward or backward
  111384. * @param flipBack defines the flip
  111385. * @param twirlClockwise defines the twirl
  111386. * @param tiltRight defines the tilt
  111387. * @returns the current mesh
  111388. */
  111389. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111390. /**
  111391. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111392. * Supports definition of mesh facing forward or backward.
  111393. * @param flipBack defines the flip
  111394. * @param twirlClockwise defines the twirl
  111395. * @param tiltRight defines the tilt
  111396. * @returns the new rotation vector
  111397. */
  111398. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111399. /**
  111400. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111401. * This means the mesh underlying bounding box and sphere are recomputed.
  111402. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111403. * @returns the current mesh
  111404. */
  111405. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111406. /** @hidden */
  111407. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111408. /** @hidden */
  111409. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111410. /** @hidden */
  111411. _updateBoundingInfo(): AbstractMesh;
  111412. /** @hidden */
  111413. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111414. /** @hidden */
  111415. protected _afterComputeWorldMatrix(): void;
  111416. /** @hidden */
  111417. get _effectiveMesh(): AbstractMesh;
  111418. /**
  111419. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111420. * A mesh is in the frustum if its bounding box intersects the frustum
  111421. * @param frustumPlanes defines the frustum to test
  111422. * @returns true if the mesh is in the frustum planes
  111423. */
  111424. isInFrustum(frustumPlanes: Plane[]): boolean;
  111425. /**
  111426. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111427. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111428. * @param frustumPlanes defines the frustum to test
  111429. * @returns true if the mesh is completely in the frustum planes
  111430. */
  111431. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111432. /**
  111433. * True if the mesh intersects another mesh or a SolidParticle object
  111434. * @param mesh defines a target mesh or SolidParticle to test
  111435. * @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)
  111436. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111437. * @returns true if there is an intersection
  111438. */
  111439. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111440. /**
  111441. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111442. * @param point defines the point to test
  111443. * @returns true if there is an intersection
  111444. */
  111445. intersectsPoint(point: Vector3): boolean;
  111446. /**
  111447. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111448. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111449. */
  111450. get checkCollisions(): boolean;
  111451. set checkCollisions(collisionEnabled: boolean);
  111452. /**
  111453. * Gets Collider object used to compute collisions (not physics)
  111454. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111455. */
  111456. get collider(): Nullable<Collider>;
  111457. /**
  111458. * Move the mesh using collision engine
  111459. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111460. * @param displacement defines the requested displacement vector
  111461. * @returns the current mesh
  111462. */
  111463. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111464. private _onCollisionPositionChange;
  111465. /** @hidden */
  111466. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111467. /** @hidden */
  111468. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111469. /** @hidden */
  111470. _checkCollision(collider: Collider): AbstractMesh;
  111471. /** @hidden */
  111472. _generatePointsArray(): boolean;
  111473. /**
  111474. * Checks if the passed Ray intersects with the mesh
  111475. * @param ray defines the ray to use
  111476. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111478. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111479. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111480. * @returns the picking info
  111481. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111482. */
  111483. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111484. /**
  111485. * Clones the current mesh
  111486. * @param name defines the mesh name
  111487. * @param newParent defines the new mesh parent
  111488. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111489. * @returns the new mesh
  111490. */
  111491. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111492. /**
  111493. * Disposes all the submeshes of the current meshnp
  111494. * @returns the current mesh
  111495. */
  111496. releaseSubMeshes(): AbstractMesh;
  111497. /**
  111498. * Releases resources associated with this abstract mesh.
  111499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111501. */
  111502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111503. /**
  111504. * Adds the passed mesh as a child to the current mesh
  111505. * @param mesh defines the child mesh
  111506. * @returns the current mesh
  111507. */
  111508. addChild(mesh: AbstractMesh): AbstractMesh;
  111509. /**
  111510. * Removes the passed mesh from the current mesh children list
  111511. * @param mesh defines the child mesh
  111512. * @returns the current mesh
  111513. */
  111514. removeChild(mesh: AbstractMesh): AbstractMesh;
  111515. /** @hidden */
  111516. private _initFacetData;
  111517. /**
  111518. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111519. * This method can be called within the render loop.
  111520. * 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
  111521. * @returns the current mesh
  111522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111523. */
  111524. updateFacetData(): AbstractMesh;
  111525. /**
  111526. * Returns the facetLocalNormals array.
  111527. * The normals are expressed in the mesh local spac
  111528. * @returns an array of Vector3
  111529. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111530. */
  111531. getFacetLocalNormals(): Vector3[];
  111532. /**
  111533. * Returns the facetLocalPositions array.
  111534. * The facet positions are expressed in the mesh local space
  111535. * @returns an array of Vector3
  111536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111537. */
  111538. getFacetLocalPositions(): Vector3[];
  111539. /**
  111540. * Returns the facetLocalPartioning array
  111541. * @returns an array of array of numbers
  111542. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111543. */
  111544. getFacetLocalPartitioning(): number[][];
  111545. /**
  111546. * Returns the i-th facet position in the world system.
  111547. * This method allocates a new Vector3 per call
  111548. * @param i defines the facet index
  111549. * @returns a new Vector3
  111550. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111551. */
  111552. getFacetPosition(i: number): Vector3;
  111553. /**
  111554. * Sets the reference Vector3 with the i-th facet position in the world system
  111555. * @param i defines the facet index
  111556. * @param ref defines the target vector
  111557. * @returns the current mesh
  111558. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111559. */
  111560. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111561. /**
  111562. * Returns the i-th facet normal in the world system.
  111563. * This method allocates a new Vector3 per call
  111564. * @param i defines the facet index
  111565. * @returns a new Vector3
  111566. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111567. */
  111568. getFacetNormal(i: number): Vector3;
  111569. /**
  111570. * Sets the reference Vector3 with the i-th facet normal in the world system
  111571. * @param i defines the facet index
  111572. * @param ref defines the target vector
  111573. * @returns the current mesh
  111574. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111575. */
  111576. getFacetNormalToRef(i: number, ref: Vector3): this;
  111577. /**
  111578. * 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)
  111579. * @param x defines x coordinate
  111580. * @param y defines y coordinate
  111581. * @param z defines z coordinate
  111582. * @returns the array of facet indexes
  111583. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111584. */
  111585. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111586. /**
  111587. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111588. * @param projected sets as the (x,y,z) world projection on the facet
  111589. * @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
  111590. * @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
  111591. * @param x defines x coordinate
  111592. * @param y defines y coordinate
  111593. * @param z defines z coordinate
  111594. * @returns the face index if found (or null instead)
  111595. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111596. */
  111597. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111598. /**
  111599. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111600. * @param projected sets as the (x,y,z) local projection on the facet
  111601. * @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
  111602. * @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
  111603. * @param x defines x coordinate
  111604. * @param y defines y coordinate
  111605. * @param z defines z coordinate
  111606. * @returns the face index if found (or null instead)
  111607. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111608. */
  111609. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111610. /**
  111611. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111612. * @returns the parameters
  111613. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111614. */
  111615. getFacetDataParameters(): any;
  111616. /**
  111617. * Disables the feature FacetData and frees the related memory
  111618. * @returns the current mesh
  111619. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111620. */
  111621. disableFacetData(): AbstractMesh;
  111622. /**
  111623. * Updates the AbstractMesh indices array
  111624. * @param indices defines the data source
  111625. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111626. * @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)
  111627. * @returns the current mesh
  111628. */
  111629. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111630. /**
  111631. * Creates new normals data for the mesh
  111632. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111633. * @returns the current mesh
  111634. */
  111635. createNormals(updatable: boolean): AbstractMesh;
  111636. /**
  111637. * Align the mesh with a normal
  111638. * @param normal defines the normal to use
  111639. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111640. * @returns the current mesh
  111641. */
  111642. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111643. /** @hidden */
  111644. _checkOcclusionQuery(): boolean;
  111645. /**
  111646. * Disables the mesh edge rendering mode
  111647. * @returns the currentAbstractMesh
  111648. */
  111649. disableEdgesRendering(): AbstractMesh;
  111650. /**
  111651. * Enables the edge rendering mode on the mesh.
  111652. * This mode makes the mesh edges visible
  111653. * @param epsilon defines the maximal distance between two angles to detect a face
  111654. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111655. * @returns the currentAbstractMesh
  111656. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111657. */
  111658. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111659. /**
  111660. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111661. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111662. */
  111663. getConnectedParticleSystems(): IParticleSystem[];
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * Interface used to define ActionEvent
  111669. */
  111670. export interface IActionEvent {
  111671. /** The mesh or sprite that triggered the action */
  111672. source: any;
  111673. /** The X mouse cursor position at the time of the event */
  111674. pointerX: number;
  111675. /** The Y mouse cursor position at the time of the event */
  111676. pointerY: number;
  111677. /** The mesh that is currently pointed at (can be null) */
  111678. meshUnderPointer: Nullable<AbstractMesh>;
  111679. /** the original (browser) event that triggered the ActionEvent */
  111680. sourceEvent?: any;
  111681. /** additional data for the event */
  111682. additionalData?: any;
  111683. }
  111684. /**
  111685. * ActionEvent is the event being sent when an action is triggered.
  111686. */
  111687. export class ActionEvent implements IActionEvent {
  111688. /** The mesh or sprite that triggered the action */
  111689. source: any;
  111690. /** The X mouse cursor position at the time of the event */
  111691. pointerX: number;
  111692. /** The Y mouse cursor position at the time of the event */
  111693. pointerY: number;
  111694. /** The mesh that is currently pointed at (can be null) */
  111695. meshUnderPointer: Nullable<AbstractMesh>;
  111696. /** the original (browser) event that triggered the ActionEvent */
  111697. sourceEvent?: any;
  111698. /** additional data for the event */
  111699. additionalData?: any;
  111700. /**
  111701. * Creates a new ActionEvent
  111702. * @param source The mesh or sprite that triggered the action
  111703. * @param pointerX The X mouse cursor position at the time of the event
  111704. * @param pointerY The Y mouse cursor position at the time of the event
  111705. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111706. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111707. * @param additionalData additional data for the event
  111708. */
  111709. constructor(
  111710. /** The mesh or sprite that triggered the action */
  111711. source: any,
  111712. /** The X mouse cursor position at the time of the event */
  111713. pointerX: number,
  111714. /** The Y mouse cursor position at the time of the event */
  111715. pointerY: number,
  111716. /** The mesh that is currently pointed at (can be null) */
  111717. meshUnderPointer: Nullable<AbstractMesh>,
  111718. /** the original (browser) event that triggered the ActionEvent */
  111719. sourceEvent?: any,
  111720. /** additional data for the event */
  111721. additionalData?: any);
  111722. /**
  111723. * Helper function to auto-create an ActionEvent from a source mesh.
  111724. * @param source The source mesh that triggered the event
  111725. * @param evt The original (browser) event
  111726. * @param additionalData additional data for the event
  111727. * @returns the new ActionEvent
  111728. */
  111729. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111730. /**
  111731. * Helper function to auto-create an ActionEvent from a source sprite
  111732. * @param source The source sprite that triggered the event
  111733. * @param scene Scene associated with the sprite
  111734. * @param evt The original (browser) event
  111735. * @param additionalData additional data for the event
  111736. * @returns the new ActionEvent
  111737. */
  111738. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111739. /**
  111740. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111741. * @param scene the scene where the event occurred
  111742. * @param evt The original (browser) event
  111743. * @returns the new ActionEvent
  111744. */
  111745. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111746. /**
  111747. * Helper function to auto-create an ActionEvent from a primitive
  111748. * @param prim defines the target primitive
  111749. * @param pointerPos defines the pointer position
  111750. * @param evt The original (browser) event
  111751. * @param additionalData additional data for the event
  111752. * @returns the new ActionEvent
  111753. */
  111754. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111755. }
  111756. }
  111757. declare module BABYLON {
  111758. /**
  111759. * Abstract class used to decouple action Manager from scene and meshes.
  111760. * Do not instantiate.
  111761. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111762. */
  111763. export abstract class AbstractActionManager implements IDisposable {
  111764. /** Gets the list of active triggers */
  111765. static Triggers: {
  111766. [key: string]: number;
  111767. };
  111768. /** Gets the cursor to use when hovering items */
  111769. hoverCursor: string;
  111770. /** Gets the list of actions */
  111771. actions: IAction[];
  111772. /**
  111773. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111774. */
  111775. isRecursive: boolean;
  111776. /**
  111777. * Releases all associated resources
  111778. */
  111779. abstract dispose(): void;
  111780. /**
  111781. * Does this action manager has pointer triggers
  111782. */
  111783. abstract get hasPointerTriggers(): boolean;
  111784. /**
  111785. * Does this action manager has pick triggers
  111786. */
  111787. abstract get hasPickTriggers(): boolean;
  111788. /**
  111789. * Process a specific trigger
  111790. * @param trigger defines the trigger to process
  111791. * @param evt defines the event details to be processed
  111792. */
  111793. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111794. /**
  111795. * Does this action manager handles actions of any of the given triggers
  111796. * @param triggers defines the triggers to be tested
  111797. * @return a boolean indicating whether one (or more) of the triggers is handled
  111798. */
  111799. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111800. /**
  111801. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111802. * speed.
  111803. * @param triggerA defines the trigger to be tested
  111804. * @param triggerB defines the trigger to be tested
  111805. * @return a boolean indicating whether one (or more) of the triggers is handled
  111806. */
  111807. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111808. /**
  111809. * Does this action manager handles actions of a given trigger
  111810. * @param trigger defines the trigger to be tested
  111811. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111812. * @return whether the trigger is handled
  111813. */
  111814. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111815. /**
  111816. * Serialize this manager to a JSON object
  111817. * @param name defines the property name to store this manager
  111818. * @returns a JSON representation of this manager
  111819. */
  111820. abstract serialize(name: string): any;
  111821. /**
  111822. * Registers an action to this action manager
  111823. * @param action defines the action to be registered
  111824. * @return the action amended (prepared) after registration
  111825. */
  111826. abstract registerAction(action: IAction): Nullable<IAction>;
  111827. /**
  111828. * Unregisters an action to this action manager
  111829. * @param action defines the action to be unregistered
  111830. * @return a boolean indicating whether the action has been unregistered
  111831. */
  111832. abstract unregisterAction(action: IAction): Boolean;
  111833. /**
  111834. * Does exist one action manager with at least one trigger
  111835. **/
  111836. static get HasTriggers(): boolean;
  111837. /**
  111838. * Does exist one action manager with at least one pick trigger
  111839. **/
  111840. static get HasPickTriggers(): boolean;
  111841. /**
  111842. * Does exist one action manager that handles actions of a given trigger
  111843. * @param trigger defines the trigger to be tested
  111844. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111845. **/
  111846. static HasSpecificTrigger(trigger: number): boolean;
  111847. }
  111848. }
  111849. declare module BABYLON {
  111850. /**
  111851. * Defines how a node can be built from a string name.
  111852. */
  111853. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111854. /**
  111855. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111856. */
  111857. export class Node implements IBehaviorAware<Node> {
  111858. /** @hidden */
  111859. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111860. private static _NodeConstructors;
  111861. /**
  111862. * Add a new node constructor
  111863. * @param type defines the type name of the node to construct
  111864. * @param constructorFunc defines the constructor function
  111865. */
  111866. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111867. /**
  111868. * Returns a node constructor based on type name
  111869. * @param type defines the type name
  111870. * @param name defines the new node name
  111871. * @param scene defines the hosting scene
  111872. * @param options defines optional options to transmit to constructors
  111873. * @returns the new constructor or null
  111874. */
  111875. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111876. /**
  111877. * Gets or sets the name of the node
  111878. */
  111879. name: string;
  111880. /**
  111881. * Gets or sets the id of the node
  111882. */
  111883. id: string;
  111884. /**
  111885. * Gets or sets the unique id of the node
  111886. */
  111887. uniqueId: number;
  111888. /**
  111889. * Gets or sets a string used to store user defined state for the node
  111890. */
  111891. state: string;
  111892. /**
  111893. * Gets or sets an object used to store user defined information for the node
  111894. */
  111895. metadata: any;
  111896. /**
  111897. * For internal use only. Please do not use.
  111898. */
  111899. reservedDataStore: any;
  111900. /**
  111901. * List of inspectable custom properties (used by the Inspector)
  111902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111903. */
  111904. inspectableCustomProperties: IInspectable[];
  111905. private _doNotSerialize;
  111906. /**
  111907. * Gets or sets a boolean used to define if the node must be serialized
  111908. */
  111909. get doNotSerialize(): boolean;
  111910. set doNotSerialize(value: boolean);
  111911. /** @hidden */
  111912. _isDisposed: boolean;
  111913. /**
  111914. * Gets a list of Animations associated with the node
  111915. */
  111916. animations: Animation[];
  111917. protected _ranges: {
  111918. [name: string]: Nullable<AnimationRange>;
  111919. };
  111920. /**
  111921. * Callback raised when the node is ready to be used
  111922. */
  111923. onReady: Nullable<(node: Node) => void>;
  111924. private _isEnabled;
  111925. private _isParentEnabled;
  111926. private _isReady;
  111927. /** @hidden */
  111928. _currentRenderId: number;
  111929. private _parentUpdateId;
  111930. /** @hidden */
  111931. _childUpdateId: number;
  111932. /** @hidden */
  111933. _waitingParentId: Nullable<string>;
  111934. /** @hidden */
  111935. _scene: Scene;
  111936. /** @hidden */
  111937. _cache: any;
  111938. private _parentNode;
  111939. private _children;
  111940. /** @hidden */
  111941. _worldMatrix: Matrix;
  111942. /** @hidden */
  111943. _worldMatrixDeterminant: number;
  111944. /** @hidden */
  111945. _worldMatrixDeterminantIsDirty: boolean;
  111946. /** @hidden */
  111947. private _sceneRootNodesIndex;
  111948. /**
  111949. * Gets a boolean indicating if the node has been disposed
  111950. * @returns true if the node was disposed
  111951. */
  111952. isDisposed(): boolean;
  111953. /**
  111954. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111955. * @see https://doc.babylonjs.com/how_to/parenting
  111956. */
  111957. set parent(parent: Nullable<Node>);
  111958. get parent(): Nullable<Node>;
  111959. /** @hidden */
  111960. _addToSceneRootNodes(): void;
  111961. /** @hidden */
  111962. _removeFromSceneRootNodes(): void;
  111963. private _animationPropertiesOverride;
  111964. /**
  111965. * Gets or sets the animation properties override
  111966. */
  111967. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111968. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111969. /**
  111970. * Gets a string idenfifying the name of the class
  111971. * @returns "Node" string
  111972. */
  111973. getClassName(): string;
  111974. /** @hidden */
  111975. readonly _isNode: boolean;
  111976. /**
  111977. * An event triggered when the mesh is disposed
  111978. */
  111979. onDisposeObservable: Observable<Node>;
  111980. private _onDisposeObserver;
  111981. /**
  111982. * Sets a callback that will be raised when the node will be disposed
  111983. */
  111984. set onDispose(callback: () => void);
  111985. /**
  111986. * Creates a new Node
  111987. * @param name the name and id to be given to this node
  111988. * @param scene the scene this node will be added to
  111989. */
  111990. constructor(name: string, scene?: Nullable<Scene>);
  111991. /**
  111992. * Gets the scene of the node
  111993. * @returns a scene
  111994. */
  111995. getScene(): Scene;
  111996. /**
  111997. * Gets the engine of the node
  111998. * @returns a Engine
  111999. */
  112000. getEngine(): Engine;
  112001. private _behaviors;
  112002. /**
  112003. * Attach a behavior to the node
  112004. * @see https://doc.babylonjs.com/features/behaviour
  112005. * @param behavior defines the behavior to attach
  112006. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112007. * @returns the current Node
  112008. */
  112009. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112010. /**
  112011. * Remove an attached behavior
  112012. * @see https://doc.babylonjs.com/features/behaviour
  112013. * @param behavior defines the behavior to attach
  112014. * @returns the current Node
  112015. */
  112016. removeBehavior(behavior: Behavior<Node>): Node;
  112017. /**
  112018. * Gets the list of attached behaviors
  112019. * @see https://doc.babylonjs.com/features/behaviour
  112020. */
  112021. get behaviors(): Behavior<Node>[];
  112022. /**
  112023. * Gets an attached behavior by name
  112024. * @param name defines the name of the behavior to look for
  112025. * @see https://doc.babylonjs.com/features/behaviour
  112026. * @returns null if behavior was not found else the requested behavior
  112027. */
  112028. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112029. /**
  112030. * Returns the latest update of the World matrix
  112031. * @returns a Matrix
  112032. */
  112033. getWorldMatrix(): Matrix;
  112034. /** @hidden */
  112035. _getWorldMatrixDeterminant(): number;
  112036. /**
  112037. * Returns directly the latest state of the mesh World matrix.
  112038. * A Matrix is returned.
  112039. */
  112040. get worldMatrixFromCache(): Matrix;
  112041. /** @hidden */
  112042. _initCache(): void;
  112043. /** @hidden */
  112044. updateCache(force?: boolean): void;
  112045. /** @hidden */
  112046. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112047. /** @hidden */
  112048. _updateCache(ignoreParentClass?: boolean): void;
  112049. /** @hidden */
  112050. _isSynchronized(): boolean;
  112051. /** @hidden */
  112052. _markSyncedWithParent(): void;
  112053. /** @hidden */
  112054. isSynchronizedWithParent(): boolean;
  112055. /** @hidden */
  112056. isSynchronized(): boolean;
  112057. /**
  112058. * Is this node ready to be used/rendered
  112059. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112060. * @return true if the node is ready
  112061. */
  112062. isReady(completeCheck?: boolean): boolean;
  112063. /**
  112064. * Is this node enabled?
  112065. * 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
  112066. * @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
  112067. * @return whether this node (and its parent) is enabled
  112068. */
  112069. isEnabled(checkAncestors?: boolean): boolean;
  112070. /** @hidden */
  112071. protected _syncParentEnabledState(): void;
  112072. /**
  112073. * Set the enabled state of this node
  112074. * @param value defines the new enabled state
  112075. */
  112076. setEnabled(value: boolean): void;
  112077. /**
  112078. * Is this node a descendant of the given node?
  112079. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112080. * @param ancestor defines the parent node to inspect
  112081. * @returns a boolean indicating if this node is a descendant of the given node
  112082. */
  112083. isDescendantOf(ancestor: Node): boolean;
  112084. /** @hidden */
  112085. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112086. /**
  112087. * Will return all nodes that have this node as ascendant
  112088. * @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
  112089. * @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
  112090. * @return all children nodes of all types
  112091. */
  112092. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112093. /**
  112094. * Get all child-meshes of this node
  112095. * @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)
  112096. * @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
  112097. * @returns an array of AbstractMesh
  112098. */
  112099. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112100. /**
  112101. * Get all direct children of this node
  112102. * @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
  112103. * @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)
  112104. * @returns an array of Node
  112105. */
  112106. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112107. /** @hidden */
  112108. _setReady(state: boolean): void;
  112109. /**
  112110. * Get an animation by name
  112111. * @param name defines the name of the animation to look for
  112112. * @returns null if not found else the requested animation
  112113. */
  112114. getAnimationByName(name: string): Nullable<Animation>;
  112115. /**
  112116. * Creates an animation range for this node
  112117. * @param name defines the name of the range
  112118. * @param from defines the starting key
  112119. * @param to defines the end key
  112120. */
  112121. createAnimationRange(name: string, from: number, to: number): void;
  112122. /**
  112123. * Delete a specific animation range
  112124. * @param name defines the name of the range to delete
  112125. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112126. */
  112127. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112128. /**
  112129. * Get an animation range by name
  112130. * @param name defines the name of the animation range to look for
  112131. * @returns null if not found else the requested animation range
  112132. */
  112133. getAnimationRange(name: string): Nullable<AnimationRange>;
  112134. /**
  112135. * Gets the list of all animation ranges defined on this node
  112136. * @returns an array
  112137. */
  112138. getAnimationRanges(): Nullable<AnimationRange>[];
  112139. /**
  112140. * Will start the animation sequence
  112141. * @param name defines the range frames for animation sequence
  112142. * @param loop defines if the animation should loop (false by default)
  112143. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112144. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112145. * @returns the object created for this animation. If range does not exist, it will return null
  112146. */
  112147. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112148. /**
  112149. * Serialize animation ranges into a JSON compatible object
  112150. * @returns serialization object
  112151. */
  112152. serializeAnimationRanges(): any;
  112153. /**
  112154. * Computes the world matrix of the node
  112155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112156. * @returns the world matrix
  112157. */
  112158. computeWorldMatrix(force?: boolean): Matrix;
  112159. /**
  112160. * Releases resources associated with this node.
  112161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112163. */
  112164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112165. /**
  112166. * Parse animation range data from a serialization object and store them into a given node
  112167. * @param node defines where to store the animation ranges
  112168. * @param parsedNode defines the serialization object to read data from
  112169. * @param scene defines the hosting scene
  112170. */
  112171. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112172. /**
  112173. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112174. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112175. * @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
  112176. * @returns the new bounding vectors
  112177. */
  112178. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112179. min: Vector3;
  112180. max: Vector3;
  112181. };
  112182. }
  112183. }
  112184. declare module BABYLON {
  112185. /**
  112186. * @hidden
  112187. */
  112188. export class _IAnimationState {
  112189. key: number;
  112190. repeatCount: number;
  112191. workValue?: any;
  112192. loopMode?: number;
  112193. offsetValue?: any;
  112194. highLimitValue?: any;
  112195. }
  112196. /**
  112197. * Class used to store any kind of animation
  112198. */
  112199. export class Animation {
  112200. /**Name of the animation */
  112201. name: string;
  112202. /**Property to animate */
  112203. targetProperty: string;
  112204. /**The frames per second of the animation */
  112205. framePerSecond: number;
  112206. /**The data type of the animation */
  112207. dataType: number;
  112208. /**The loop mode of the animation */
  112209. loopMode?: number | undefined;
  112210. /**Specifies if blending should be enabled */
  112211. enableBlending?: boolean | undefined;
  112212. /**
  112213. * Use matrix interpolation instead of using direct key value when animating matrices
  112214. */
  112215. static AllowMatricesInterpolation: boolean;
  112216. /**
  112217. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112218. */
  112219. static AllowMatrixDecomposeForInterpolation: boolean;
  112220. /** Define the Url to load snippets */
  112221. static SnippetUrl: string;
  112222. /** Snippet ID if the animation was created from the snippet server */
  112223. snippetId: string;
  112224. /**
  112225. * Stores the key frames of the animation
  112226. */
  112227. private _keys;
  112228. /**
  112229. * Stores the easing function of the animation
  112230. */
  112231. private _easingFunction;
  112232. /**
  112233. * @hidden Internal use only
  112234. */
  112235. _runtimeAnimations: RuntimeAnimation[];
  112236. /**
  112237. * The set of event that will be linked to this animation
  112238. */
  112239. private _events;
  112240. /**
  112241. * Stores an array of target property paths
  112242. */
  112243. targetPropertyPath: string[];
  112244. /**
  112245. * Stores the blending speed of the animation
  112246. */
  112247. blendingSpeed: number;
  112248. /**
  112249. * Stores the animation ranges for the animation
  112250. */
  112251. private _ranges;
  112252. /**
  112253. * @hidden Internal use
  112254. */
  112255. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112256. /**
  112257. * Sets up an animation
  112258. * @param property The property to animate
  112259. * @param animationType The animation type to apply
  112260. * @param framePerSecond The frames per second of the animation
  112261. * @param easingFunction The easing function used in the animation
  112262. * @returns The created animation
  112263. */
  112264. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112265. /**
  112266. * Create and start an animation on a node
  112267. * @param name defines the name of the global animation that will be run on all nodes
  112268. * @param node defines the root node where the animation will take place
  112269. * @param targetProperty defines property to animate
  112270. * @param framePerSecond defines the number of frame per second yo use
  112271. * @param totalFrame defines the number of frames in total
  112272. * @param from defines the initial value
  112273. * @param to defines the final value
  112274. * @param loopMode defines which loop mode you want to use (off by default)
  112275. * @param easingFunction defines the easing function to use (linear by default)
  112276. * @param onAnimationEnd defines the callback to call when animation end
  112277. * @returns the animatable created for this animation
  112278. */
  112279. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112280. /**
  112281. * Create and start an animation on a node and its descendants
  112282. * @param name defines the name of the global animation that will be run on all nodes
  112283. * @param node defines the root node where the animation will take place
  112284. * @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
  112285. * @param targetProperty defines property to animate
  112286. * @param framePerSecond defines the number of frame per second to use
  112287. * @param totalFrame defines the number of frames in total
  112288. * @param from defines the initial value
  112289. * @param to defines the final value
  112290. * @param loopMode defines which loop mode you want to use (off by default)
  112291. * @param easingFunction defines the easing function to use (linear by default)
  112292. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112293. * @returns the list of animatables created for all nodes
  112294. * @example https://www.babylonjs-playground.com/#MH0VLI
  112295. */
  112296. 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[]>;
  112297. /**
  112298. * Creates a new animation, merges it with the existing animations and starts it
  112299. * @param name Name of the animation
  112300. * @param node Node which contains the scene that begins the animations
  112301. * @param targetProperty Specifies which property to animate
  112302. * @param framePerSecond The frames per second of the animation
  112303. * @param totalFrame The total number of frames
  112304. * @param from The frame at the beginning of the animation
  112305. * @param to The frame at the end of the animation
  112306. * @param loopMode Specifies the loop mode of the animation
  112307. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112308. * @param onAnimationEnd Callback to run once the animation is complete
  112309. * @returns Nullable animation
  112310. */
  112311. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112312. /**
  112313. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112314. * @param sourceAnimation defines the Animation containing keyframes to convert
  112315. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112316. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112317. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112318. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112319. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112320. */
  112321. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112322. /**
  112323. * Transition property of an host to the target Value
  112324. * @param property The property to transition
  112325. * @param targetValue The target Value of the property
  112326. * @param host The object where the property to animate belongs
  112327. * @param scene Scene used to run the animation
  112328. * @param frameRate Framerate (in frame/s) to use
  112329. * @param transition The transition type we want to use
  112330. * @param duration The duration of the animation, in milliseconds
  112331. * @param onAnimationEnd Callback trigger at the end of the animation
  112332. * @returns Nullable animation
  112333. */
  112334. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112335. /**
  112336. * Return the array of runtime animations currently using this animation
  112337. */
  112338. get runtimeAnimations(): RuntimeAnimation[];
  112339. /**
  112340. * Specifies if any of the runtime animations are currently running
  112341. */
  112342. get hasRunningRuntimeAnimations(): boolean;
  112343. /**
  112344. * Initializes the animation
  112345. * @param name Name of the animation
  112346. * @param targetProperty Property to animate
  112347. * @param framePerSecond The frames per second of the animation
  112348. * @param dataType The data type of the animation
  112349. * @param loopMode The loop mode of the animation
  112350. * @param enableBlending Specifies if blending should be enabled
  112351. */
  112352. constructor(
  112353. /**Name of the animation */
  112354. name: string,
  112355. /**Property to animate */
  112356. targetProperty: string,
  112357. /**The frames per second of the animation */
  112358. framePerSecond: number,
  112359. /**The data type of the animation */
  112360. dataType: number,
  112361. /**The loop mode of the animation */
  112362. loopMode?: number | undefined,
  112363. /**Specifies if blending should be enabled */
  112364. enableBlending?: boolean | undefined);
  112365. /**
  112366. * Converts the animation to a string
  112367. * @param fullDetails support for multiple levels of logging within scene loading
  112368. * @returns String form of the animation
  112369. */
  112370. toString(fullDetails?: boolean): string;
  112371. /**
  112372. * Add an event to this animation
  112373. * @param event Event to add
  112374. */
  112375. addEvent(event: AnimationEvent): void;
  112376. /**
  112377. * Remove all events found at the given frame
  112378. * @param frame The frame to remove events from
  112379. */
  112380. removeEvents(frame: number): void;
  112381. /**
  112382. * Retrieves all the events from the animation
  112383. * @returns Events from the animation
  112384. */
  112385. getEvents(): AnimationEvent[];
  112386. /**
  112387. * Creates an animation range
  112388. * @param name Name of the animation range
  112389. * @param from Starting frame of the animation range
  112390. * @param to Ending frame of the animation
  112391. */
  112392. createRange(name: string, from: number, to: number): void;
  112393. /**
  112394. * Deletes an animation range by name
  112395. * @param name Name of the animation range to delete
  112396. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112397. */
  112398. deleteRange(name: string, deleteFrames?: boolean): void;
  112399. /**
  112400. * Gets the animation range by name, or null if not defined
  112401. * @param name Name of the animation range
  112402. * @returns Nullable animation range
  112403. */
  112404. getRange(name: string): Nullable<AnimationRange>;
  112405. /**
  112406. * Gets the key frames from the animation
  112407. * @returns The key frames of the animation
  112408. */
  112409. getKeys(): Array<IAnimationKey>;
  112410. /**
  112411. * Gets the highest frame rate of the animation
  112412. * @returns Highest frame rate of the animation
  112413. */
  112414. getHighestFrame(): number;
  112415. /**
  112416. * Gets the easing function of the animation
  112417. * @returns Easing function of the animation
  112418. */
  112419. getEasingFunction(): IEasingFunction;
  112420. /**
  112421. * Sets the easing function of the animation
  112422. * @param easingFunction A custom mathematical formula for animation
  112423. */
  112424. setEasingFunction(easingFunction: EasingFunction): void;
  112425. /**
  112426. * Interpolates a scalar linearly
  112427. * @param startValue Start value of the animation curve
  112428. * @param endValue End value of the animation curve
  112429. * @param gradient Scalar amount to interpolate
  112430. * @returns Interpolated scalar value
  112431. */
  112432. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112433. /**
  112434. * Interpolates a scalar cubically
  112435. * @param startValue Start value of the animation curve
  112436. * @param outTangent End tangent of the animation
  112437. * @param endValue End value of the animation curve
  112438. * @param inTangent Start tangent of the animation curve
  112439. * @param gradient Scalar amount to interpolate
  112440. * @returns Interpolated scalar value
  112441. */
  112442. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112443. /**
  112444. * Interpolates a quaternion using a spherical linear interpolation
  112445. * @param startValue Start value of the animation curve
  112446. * @param endValue End value of the animation curve
  112447. * @param gradient Scalar amount to interpolate
  112448. * @returns Interpolated quaternion value
  112449. */
  112450. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112451. /**
  112452. * Interpolates a quaternion cubically
  112453. * @param startValue Start value of the animation curve
  112454. * @param outTangent End tangent of the animation curve
  112455. * @param endValue End value of the animation curve
  112456. * @param inTangent Start tangent of the animation curve
  112457. * @param gradient Scalar amount to interpolate
  112458. * @returns Interpolated quaternion value
  112459. */
  112460. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112461. /**
  112462. * Interpolates a Vector3 linearl
  112463. * @param startValue Start value of the animation curve
  112464. * @param endValue End value of the animation curve
  112465. * @param gradient Scalar amount to interpolate
  112466. * @returns Interpolated scalar value
  112467. */
  112468. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112469. /**
  112470. * Interpolates a Vector3 cubically
  112471. * @param startValue Start value of the animation curve
  112472. * @param outTangent End tangent of the animation
  112473. * @param endValue End value of the animation curve
  112474. * @param inTangent Start tangent of the animation curve
  112475. * @param gradient Scalar amount to interpolate
  112476. * @returns InterpolatedVector3 value
  112477. */
  112478. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112479. /**
  112480. * Interpolates a Vector2 linearly
  112481. * @param startValue Start value of the animation curve
  112482. * @param endValue End value of the animation curve
  112483. * @param gradient Scalar amount to interpolate
  112484. * @returns Interpolated Vector2 value
  112485. */
  112486. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112487. /**
  112488. * Interpolates a Vector2 cubically
  112489. * @param startValue Start value of the animation curve
  112490. * @param outTangent End tangent of the animation
  112491. * @param endValue End value of the animation curve
  112492. * @param inTangent Start tangent of the animation curve
  112493. * @param gradient Scalar amount to interpolate
  112494. * @returns Interpolated Vector2 value
  112495. */
  112496. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112497. /**
  112498. * Interpolates a size linearly
  112499. * @param startValue Start value of the animation curve
  112500. * @param endValue End value of the animation curve
  112501. * @param gradient Scalar amount to interpolate
  112502. * @returns Interpolated Size value
  112503. */
  112504. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112505. /**
  112506. * Interpolates a Color3 linearly
  112507. * @param startValue Start value of the animation curve
  112508. * @param endValue End value of the animation curve
  112509. * @param gradient Scalar amount to interpolate
  112510. * @returns Interpolated Color3 value
  112511. */
  112512. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112513. /**
  112514. * Interpolates a Color4 linearly
  112515. * @param startValue Start value of the animation curve
  112516. * @param endValue End value of the animation curve
  112517. * @param gradient Scalar amount to interpolate
  112518. * @returns Interpolated Color3 value
  112519. */
  112520. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112521. /**
  112522. * @hidden Internal use only
  112523. */
  112524. _getKeyValue(value: any): any;
  112525. /**
  112526. * @hidden Internal use only
  112527. */
  112528. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112529. /**
  112530. * Defines the function to use to interpolate matrices
  112531. * @param startValue defines the start matrix
  112532. * @param endValue defines the end matrix
  112533. * @param gradient defines the gradient between both matrices
  112534. * @param result defines an optional target matrix where to store the interpolation
  112535. * @returns the interpolated matrix
  112536. */
  112537. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112538. /**
  112539. * Makes a copy of the animation
  112540. * @returns Cloned animation
  112541. */
  112542. clone(): Animation;
  112543. /**
  112544. * Sets the key frames of the animation
  112545. * @param values The animation key frames to set
  112546. */
  112547. setKeys(values: Array<IAnimationKey>): void;
  112548. /**
  112549. * Serializes the animation to an object
  112550. * @returns Serialized object
  112551. */
  112552. serialize(): any;
  112553. /**
  112554. * Float animation type
  112555. */
  112556. static readonly ANIMATIONTYPE_FLOAT: number;
  112557. /**
  112558. * Vector3 animation type
  112559. */
  112560. static readonly ANIMATIONTYPE_VECTOR3: number;
  112561. /**
  112562. * Quaternion animation type
  112563. */
  112564. static readonly ANIMATIONTYPE_QUATERNION: number;
  112565. /**
  112566. * Matrix animation type
  112567. */
  112568. static readonly ANIMATIONTYPE_MATRIX: number;
  112569. /**
  112570. * Color3 animation type
  112571. */
  112572. static readonly ANIMATIONTYPE_COLOR3: number;
  112573. /**
  112574. * Color3 animation type
  112575. */
  112576. static readonly ANIMATIONTYPE_COLOR4: number;
  112577. /**
  112578. * Vector2 animation type
  112579. */
  112580. static readonly ANIMATIONTYPE_VECTOR2: number;
  112581. /**
  112582. * Size animation type
  112583. */
  112584. static readonly ANIMATIONTYPE_SIZE: number;
  112585. /**
  112586. * Relative Loop Mode
  112587. */
  112588. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112589. /**
  112590. * Cycle Loop Mode
  112591. */
  112592. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112593. /**
  112594. * Constant Loop Mode
  112595. */
  112596. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112597. /** @hidden */
  112598. static _UniversalLerp(left: any, right: any, amount: number): any;
  112599. /**
  112600. * Parses an animation object and creates an animation
  112601. * @param parsedAnimation Parsed animation object
  112602. * @returns Animation object
  112603. */
  112604. static Parse(parsedAnimation: any): Animation;
  112605. /**
  112606. * Appends the serialized animations from the source animations
  112607. * @param source Source containing the animations
  112608. * @param destination Target to store the animations
  112609. */
  112610. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112611. /**
  112612. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112613. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112614. * @param url defines the url to load from
  112615. * @returns a promise that will resolve to the new animation or an array of animations
  112616. */
  112617. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112618. /**
  112619. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112620. * @param snippetId defines the snippet to load
  112621. * @returns a promise that will resolve to the new animation or a new array of animations
  112622. */
  112623. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112624. }
  112625. }
  112626. declare module BABYLON {
  112627. /**
  112628. * Interface containing an array of animations
  112629. */
  112630. export interface IAnimatable {
  112631. /**
  112632. * Array of animations
  112633. */
  112634. animations: Nullable<Array<Animation>>;
  112635. }
  112636. }
  112637. declare module BABYLON {
  112638. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112639. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112640. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112641. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112642. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112643. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112644. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112645. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112646. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112647. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112648. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112649. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112650. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112651. /**
  112652. * Decorator used to define property that can be serialized as reference to a camera
  112653. * @param sourceName defines the name of the property to decorate
  112654. */
  112655. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112656. /**
  112657. * Class used to help serialization objects
  112658. */
  112659. export class SerializationHelper {
  112660. /** @hidden */
  112661. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112662. /** @hidden */
  112663. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112664. /** @hidden */
  112665. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112666. /** @hidden */
  112667. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112668. /**
  112669. * Appends the serialized animations from the source animations
  112670. * @param source Source containing the animations
  112671. * @param destination Target to store the animations
  112672. */
  112673. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112674. /**
  112675. * Static function used to serialized a specific entity
  112676. * @param entity defines the entity to serialize
  112677. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112678. * @returns a JSON compatible object representing the serialization of the entity
  112679. */
  112680. static Serialize<T>(entity: T, serializationObject?: any): any;
  112681. /**
  112682. * Creates a new entity from a serialization data object
  112683. * @param creationFunction defines a function used to instanciated the new entity
  112684. * @param source defines the source serialization data
  112685. * @param scene defines the hosting scene
  112686. * @param rootUrl defines the root url for resources
  112687. * @returns a new entity
  112688. */
  112689. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112690. /**
  112691. * Clones an object
  112692. * @param creationFunction defines the function used to instanciate the new object
  112693. * @param source defines the source object
  112694. * @returns the cloned object
  112695. */
  112696. static Clone<T>(creationFunction: () => T, source: T): T;
  112697. /**
  112698. * Instanciates a new object based on a source one (some data will be shared between both object)
  112699. * @param creationFunction defines the function used to instanciate the new object
  112700. * @param source defines the source object
  112701. * @returns the new object
  112702. */
  112703. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112704. }
  112705. }
  112706. declare module BABYLON {
  112707. /**
  112708. * Base class of all the textures in babylon.
  112709. * It groups all the common properties the materials, post process, lights... might need
  112710. * in order to make a correct use of the texture.
  112711. */
  112712. export class BaseTexture implements IAnimatable {
  112713. /**
  112714. * Default anisotropic filtering level for the application.
  112715. * It is set to 4 as a good tradeoff between perf and quality.
  112716. */
  112717. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112718. /**
  112719. * Gets or sets the unique id of the texture
  112720. */
  112721. uniqueId: number;
  112722. /**
  112723. * Define the name of the texture.
  112724. */
  112725. name: string;
  112726. /**
  112727. * Gets or sets an object used to store user defined information.
  112728. */
  112729. metadata: any;
  112730. /**
  112731. * For internal use only. Please do not use.
  112732. */
  112733. reservedDataStore: any;
  112734. private _hasAlpha;
  112735. /**
  112736. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112737. */
  112738. set hasAlpha(value: boolean);
  112739. get hasAlpha(): boolean;
  112740. /**
  112741. * Defines if the alpha value should be determined via the rgb values.
  112742. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112743. */
  112744. getAlphaFromRGB: boolean;
  112745. /**
  112746. * Intensity or strength of the texture.
  112747. * It is commonly used by materials to fine tune the intensity of the texture
  112748. */
  112749. level: number;
  112750. /**
  112751. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112752. * This is part of the texture as textures usually maps to one uv set.
  112753. */
  112754. coordinatesIndex: number;
  112755. private _coordinatesMode;
  112756. /**
  112757. * How a texture is mapped.
  112758. *
  112759. * | Value | Type | Description |
  112760. * | ----- | ----------------------------------- | ----------- |
  112761. * | 0 | EXPLICIT_MODE | |
  112762. * | 1 | SPHERICAL_MODE | |
  112763. * | 2 | PLANAR_MODE | |
  112764. * | 3 | CUBIC_MODE | |
  112765. * | 4 | PROJECTION_MODE | |
  112766. * | 5 | SKYBOX_MODE | |
  112767. * | 6 | INVCUBIC_MODE | |
  112768. * | 7 | EQUIRECTANGULAR_MODE | |
  112769. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112770. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112771. */
  112772. set coordinatesMode(value: number);
  112773. get coordinatesMode(): number;
  112774. /**
  112775. * | Value | Type | Description |
  112776. * | ----- | ------------------ | ----------- |
  112777. * | 0 | CLAMP_ADDRESSMODE | |
  112778. * | 1 | WRAP_ADDRESSMODE | |
  112779. * | 2 | MIRROR_ADDRESSMODE | |
  112780. */
  112781. wrapU: number;
  112782. /**
  112783. * | Value | Type | Description |
  112784. * | ----- | ------------------ | ----------- |
  112785. * | 0 | CLAMP_ADDRESSMODE | |
  112786. * | 1 | WRAP_ADDRESSMODE | |
  112787. * | 2 | MIRROR_ADDRESSMODE | |
  112788. */
  112789. wrapV: number;
  112790. /**
  112791. * | Value | Type | Description |
  112792. * | ----- | ------------------ | ----------- |
  112793. * | 0 | CLAMP_ADDRESSMODE | |
  112794. * | 1 | WRAP_ADDRESSMODE | |
  112795. * | 2 | MIRROR_ADDRESSMODE | |
  112796. */
  112797. wrapR: number;
  112798. /**
  112799. * With compliant hardware and browser (supporting anisotropic filtering)
  112800. * this defines the level of anisotropic filtering in the texture.
  112801. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112802. */
  112803. anisotropicFilteringLevel: number;
  112804. /**
  112805. * Define if the texture is a cube texture or if false a 2d texture.
  112806. */
  112807. get isCube(): boolean;
  112808. set isCube(value: boolean);
  112809. /**
  112810. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112811. */
  112812. get is3D(): boolean;
  112813. set is3D(value: boolean);
  112814. /**
  112815. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112816. */
  112817. get is2DArray(): boolean;
  112818. set is2DArray(value: boolean);
  112819. /**
  112820. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112821. * HDR texture are usually stored in linear space.
  112822. * This only impacts the PBR and Background materials
  112823. */
  112824. gammaSpace: boolean;
  112825. /**
  112826. * Gets or sets whether or not the texture contains RGBD data.
  112827. */
  112828. get isRGBD(): boolean;
  112829. set isRGBD(value: boolean);
  112830. /**
  112831. * Is Z inverted in the texture (useful in a cube texture).
  112832. */
  112833. invertZ: boolean;
  112834. /**
  112835. * Are mip maps generated for this texture or not.
  112836. */
  112837. get noMipmap(): boolean;
  112838. /**
  112839. * @hidden
  112840. */
  112841. lodLevelInAlpha: boolean;
  112842. /**
  112843. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112844. */
  112845. get lodGenerationOffset(): number;
  112846. set lodGenerationOffset(value: number);
  112847. /**
  112848. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112849. */
  112850. get lodGenerationScale(): number;
  112851. set lodGenerationScale(value: number);
  112852. /**
  112853. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112854. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112855. * average roughness values.
  112856. */
  112857. get linearSpecularLOD(): boolean;
  112858. set linearSpecularLOD(value: boolean);
  112859. /**
  112860. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112861. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112862. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112863. */
  112864. get irradianceTexture(): Nullable<BaseTexture>;
  112865. set irradianceTexture(value: Nullable<BaseTexture>);
  112866. /**
  112867. * Define if the texture is a render target.
  112868. */
  112869. isRenderTarget: boolean;
  112870. /**
  112871. * Define the unique id of the texture in the scene.
  112872. */
  112873. get uid(): string;
  112874. /** @hidden */
  112875. _prefiltered: boolean;
  112876. /**
  112877. * Return a string representation of the texture.
  112878. * @returns the texture as a string
  112879. */
  112880. toString(): string;
  112881. /**
  112882. * Get the class name of the texture.
  112883. * @returns "BaseTexture"
  112884. */
  112885. getClassName(): string;
  112886. /**
  112887. * Define the list of animation attached to the texture.
  112888. */
  112889. animations: Animation[];
  112890. /**
  112891. * An event triggered when the texture is disposed.
  112892. */
  112893. onDisposeObservable: Observable<BaseTexture>;
  112894. private _onDisposeObserver;
  112895. /**
  112896. * Callback triggered when the texture has been disposed.
  112897. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112898. */
  112899. set onDispose(callback: () => void);
  112900. /**
  112901. * Define the current state of the loading sequence when in delayed load mode.
  112902. */
  112903. delayLoadState: number;
  112904. protected _scene: Nullable<Scene>;
  112905. protected _engine: Nullable<ThinEngine>;
  112906. /** @hidden */
  112907. _texture: Nullable<InternalTexture>;
  112908. private _uid;
  112909. /**
  112910. * Define if the texture is preventinga material to render or not.
  112911. * If not and the texture is not ready, the engine will use a default black texture instead.
  112912. */
  112913. get isBlocking(): boolean;
  112914. /**
  112915. * Instantiates a new BaseTexture.
  112916. * Base class of all the textures in babylon.
  112917. * It groups all the common properties the materials, post process, lights... might need
  112918. * in order to make a correct use of the texture.
  112919. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112920. */
  112921. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112922. /**
  112923. * Get the scene the texture belongs to.
  112924. * @returns the scene or null if undefined
  112925. */
  112926. getScene(): Nullable<Scene>;
  112927. /** @hidden */
  112928. protected _getEngine(): Nullable<ThinEngine>;
  112929. /**
  112930. * Get the texture transform matrix used to offset tile the texture for istance.
  112931. * @returns the transformation matrix
  112932. */
  112933. getTextureMatrix(): Matrix;
  112934. /**
  112935. * Get the texture reflection matrix used to rotate/transform the reflection.
  112936. * @returns the reflection matrix
  112937. */
  112938. getReflectionTextureMatrix(): Matrix;
  112939. /**
  112940. * Get the underlying lower level texture from Babylon.
  112941. * @returns the insternal texture
  112942. */
  112943. getInternalTexture(): Nullable<InternalTexture>;
  112944. /**
  112945. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112946. * @returns true if ready or not blocking
  112947. */
  112948. isReadyOrNotBlocking(): boolean;
  112949. /**
  112950. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112951. * @returns true if fully ready
  112952. */
  112953. isReady(): boolean;
  112954. private _cachedSize;
  112955. /**
  112956. * Get the size of the texture.
  112957. * @returns the texture size.
  112958. */
  112959. getSize(): ISize;
  112960. /**
  112961. * Get the base size of the texture.
  112962. * It can be different from the size if the texture has been resized for POT for instance
  112963. * @returns the base size
  112964. */
  112965. getBaseSize(): ISize;
  112966. /**
  112967. * Update the sampling mode of the texture.
  112968. * Default is Trilinear mode.
  112969. *
  112970. * | Value | Type | Description |
  112971. * | ----- | ------------------ | ----------- |
  112972. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112973. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112974. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112975. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112976. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112977. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112978. * | 7 | NEAREST_LINEAR | |
  112979. * | 8 | NEAREST_NEAREST | |
  112980. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112981. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112982. * | 11 | LINEAR_LINEAR | |
  112983. * | 12 | LINEAR_NEAREST | |
  112984. *
  112985. * > _mag_: magnification filter (close to the viewer)
  112986. * > _min_: minification filter (far from the viewer)
  112987. * > _mip_: filter used between mip map levels
  112988. *@param samplingMode Define the new sampling mode of the texture
  112989. */
  112990. updateSamplingMode(samplingMode: number): void;
  112991. /**
  112992. * Scales the texture if is `canRescale()`
  112993. * @param ratio the resize factor we want to use to rescale
  112994. */
  112995. scale(ratio: number): void;
  112996. /**
  112997. * Get if the texture can rescale.
  112998. */
  112999. get canRescale(): boolean;
  113000. /** @hidden */
  113001. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113002. /** @hidden */
  113003. _rebuild(): void;
  113004. /**
  113005. * Triggers the load sequence in delayed load mode.
  113006. */
  113007. delayLoad(): void;
  113008. /**
  113009. * Clones the texture.
  113010. * @returns the cloned texture
  113011. */
  113012. clone(): Nullable<BaseTexture>;
  113013. /**
  113014. * Get the texture underlying type (INT, FLOAT...)
  113015. */
  113016. get textureType(): number;
  113017. /**
  113018. * Get the texture underlying format (RGB, RGBA...)
  113019. */
  113020. get textureFormat(): number;
  113021. /**
  113022. * Indicates that textures need to be re-calculated for all materials
  113023. */
  113024. protected _markAllSubMeshesAsTexturesDirty(): void;
  113025. /**
  113026. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113027. * This will returns an RGBA array buffer containing either in values (0-255) or
  113028. * float values (0-1) depending of the underlying buffer type.
  113029. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113030. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113031. * @param buffer defines a user defined buffer to fill with data (can be null)
  113032. * @returns The Array buffer containing the pixels data.
  113033. */
  113034. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113035. /**
  113036. * Release and destroy the underlying lower level texture aka internalTexture.
  113037. */
  113038. releaseInternalTexture(): void;
  113039. /** @hidden */
  113040. get _lodTextureHigh(): Nullable<BaseTexture>;
  113041. /** @hidden */
  113042. get _lodTextureMid(): Nullable<BaseTexture>;
  113043. /** @hidden */
  113044. get _lodTextureLow(): Nullable<BaseTexture>;
  113045. /**
  113046. * Dispose the texture and release its associated resources.
  113047. */
  113048. dispose(): void;
  113049. /**
  113050. * Serialize the texture into a JSON representation that can be parsed later on.
  113051. * @returns the JSON representation of the texture
  113052. */
  113053. serialize(): any;
  113054. /**
  113055. * Helper function to be called back once a list of texture contains only ready textures.
  113056. * @param textures Define the list of textures to wait for
  113057. * @param callback Define the callback triggered once the entire list will be ready
  113058. */
  113059. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113060. private static _isScene;
  113061. }
  113062. }
  113063. declare module BABYLON {
  113064. /**
  113065. * Options to be used when creating an effect.
  113066. */
  113067. export interface IEffectCreationOptions {
  113068. /**
  113069. * Atrributes that will be used in the shader.
  113070. */
  113071. attributes: string[];
  113072. /**
  113073. * Uniform varible names that will be set in the shader.
  113074. */
  113075. uniformsNames: string[];
  113076. /**
  113077. * Uniform buffer variable names that will be set in the shader.
  113078. */
  113079. uniformBuffersNames: string[];
  113080. /**
  113081. * Sampler texture variable names that will be set in the shader.
  113082. */
  113083. samplers: string[];
  113084. /**
  113085. * Define statements that will be set in the shader.
  113086. */
  113087. defines: any;
  113088. /**
  113089. * Possible fallbacks for this effect to improve performance when needed.
  113090. */
  113091. fallbacks: Nullable<IEffectFallbacks>;
  113092. /**
  113093. * Callback that will be called when the shader is compiled.
  113094. */
  113095. onCompiled: Nullable<(effect: Effect) => void>;
  113096. /**
  113097. * Callback that will be called if an error occurs during shader compilation.
  113098. */
  113099. onError: Nullable<(effect: Effect, errors: string) => void>;
  113100. /**
  113101. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113102. */
  113103. indexParameters?: any;
  113104. /**
  113105. * Max number of lights that can be used in the shader.
  113106. */
  113107. maxSimultaneousLights?: number;
  113108. /**
  113109. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113110. */
  113111. transformFeedbackVaryings?: Nullable<string[]>;
  113112. /**
  113113. * 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
  113114. */
  113115. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113116. /**
  113117. * Is this effect rendering to several color attachments ?
  113118. */
  113119. multiTarget?: boolean;
  113120. }
  113121. /**
  113122. * Effect containing vertex and fragment shader that can be executed on an object.
  113123. */
  113124. export class Effect implements IDisposable {
  113125. /**
  113126. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113127. */
  113128. static ShadersRepository: string;
  113129. /**
  113130. * Enable logging of the shader code when a compilation error occurs
  113131. */
  113132. static LogShaderCodeOnCompilationError: boolean;
  113133. /**
  113134. * Name of the effect.
  113135. */
  113136. name: any;
  113137. /**
  113138. * String container all the define statements that should be set on the shader.
  113139. */
  113140. defines: string;
  113141. /**
  113142. * Callback that will be called when the shader is compiled.
  113143. */
  113144. onCompiled: Nullable<(effect: Effect) => void>;
  113145. /**
  113146. * Callback that will be called if an error occurs during shader compilation.
  113147. */
  113148. onError: Nullable<(effect: Effect, errors: string) => void>;
  113149. /**
  113150. * Callback that will be called when effect is bound.
  113151. */
  113152. onBind: Nullable<(effect: Effect) => void>;
  113153. /**
  113154. * Unique ID of the effect.
  113155. */
  113156. uniqueId: number;
  113157. /**
  113158. * Observable that will be called when the shader is compiled.
  113159. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113160. */
  113161. onCompileObservable: Observable<Effect>;
  113162. /**
  113163. * Observable that will be called if an error occurs during shader compilation.
  113164. */
  113165. onErrorObservable: Observable<Effect>;
  113166. /** @hidden */
  113167. _onBindObservable: Nullable<Observable<Effect>>;
  113168. /**
  113169. * @hidden
  113170. * Specifies if the effect was previously ready
  113171. */
  113172. _wasPreviouslyReady: boolean;
  113173. /**
  113174. * Observable that will be called when effect is bound.
  113175. */
  113176. get onBindObservable(): Observable<Effect>;
  113177. /** @hidden */
  113178. _bonesComputationForcedToCPU: boolean;
  113179. /** @hidden */
  113180. _multiTarget: boolean;
  113181. private static _uniqueIdSeed;
  113182. private _engine;
  113183. private _uniformBuffersNames;
  113184. private _uniformBuffersNamesList;
  113185. private _uniformsNames;
  113186. private _samplerList;
  113187. private _samplers;
  113188. private _isReady;
  113189. private _compilationError;
  113190. private _allFallbacksProcessed;
  113191. private _attributesNames;
  113192. private _attributes;
  113193. private _attributeLocationByName;
  113194. private _uniforms;
  113195. /**
  113196. * Key for the effect.
  113197. * @hidden
  113198. */
  113199. _key: string;
  113200. private _indexParameters;
  113201. private _fallbacks;
  113202. private _vertexSourceCode;
  113203. private _fragmentSourceCode;
  113204. private _vertexSourceCodeOverride;
  113205. private _fragmentSourceCodeOverride;
  113206. private _transformFeedbackVaryings;
  113207. /**
  113208. * Compiled shader to webGL program.
  113209. * @hidden
  113210. */
  113211. _pipelineContext: Nullable<IPipelineContext>;
  113212. private _valueCache;
  113213. private static _baseCache;
  113214. /**
  113215. * Instantiates an effect.
  113216. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113217. * @param baseName Name of the effect.
  113218. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113219. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113220. * @param samplers List of sampler variables that will be passed to the shader.
  113221. * @param engine Engine to be used to render the effect
  113222. * @param defines Define statements to be added to the shader.
  113223. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113224. * @param onCompiled Callback that will be called when the shader is compiled.
  113225. * @param onError Callback that will be called if an error occurs during shader compilation.
  113226. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113227. */
  113228. 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);
  113229. private _useFinalCode;
  113230. /**
  113231. * Unique key for this effect
  113232. */
  113233. get key(): string;
  113234. /**
  113235. * If the effect has been compiled and prepared.
  113236. * @returns if the effect is compiled and prepared.
  113237. */
  113238. isReady(): boolean;
  113239. private _isReadyInternal;
  113240. /**
  113241. * The engine the effect was initialized with.
  113242. * @returns the engine.
  113243. */
  113244. getEngine(): Engine;
  113245. /**
  113246. * The pipeline context for this effect
  113247. * @returns the associated pipeline context
  113248. */
  113249. getPipelineContext(): Nullable<IPipelineContext>;
  113250. /**
  113251. * The set of names of attribute variables for the shader.
  113252. * @returns An array of attribute names.
  113253. */
  113254. getAttributesNames(): string[];
  113255. /**
  113256. * Returns the attribute at the given index.
  113257. * @param index The index of the attribute.
  113258. * @returns The location of the attribute.
  113259. */
  113260. getAttributeLocation(index: number): number;
  113261. /**
  113262. * Returns the attribute based on the name of the variable.
  113263. * @param name of the attribute to look up.
  113264. * @returns the attribute location.
  113265. */
  113266. getAttributeLocationByName(name: string): number;
  113267. /**
  113268. * The number of attributes.
  113269. * @returns the numnber of attributes.
  113270. */
  113271. getAttributesCount(): number;
  113272. /**
  113273. * Gets the index of a uniform variable.
  113274. * @param uniformName of the uniform to look up.
  113275. * @returns the index.
  113276. */
  113277. getUniformIndex(uniformName: string): number;
  113278. /**
  113279. * Returns the attribute based on the name of the variable.
  113280. * @param uniformName of the uniform to look up.
  113281. * @returns the location of the uniform.
  113282. */
  113283. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113284. /**
  113285. * Returns an array of sampler variable names
  113286. * @returns The array of sampler variable names.
  113287. */
  113288. getSamplers(): string[];
  113289. /**
  113290. * Returns an array of uniform variable names
  113291. * @returns The array of uniform variable names.
  113292. */
  113293. getUniformNames(): string[];
  113294. /**
  113295. * Returns an array of uniform buffer variable names
  113296. * @returns The array of uniform buffer variable names.
  113297. */
  113298. getUniformBuffersNames(): string[];
  113299. /**
  113300. * Returns the index parameters used to create the effect
  113301. * @returns The index parameters object
  113302. */
  113303. getIndexParameters(): any;
  113304. /**
  113305. * The error from the last compilation.
  113306. * @returns the error string.
  113307. */
  113308. getCompilationError(): string;
  113309. /**
  113310. * Gets a boolean indicating that all fallbacks were used during compilation
  113311. * @returns true if all fallbacks were used
  113312. */
  113313. allFallbacksProcessed(): boolean;
  113314. /**
  113315. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113316. * @param func The callback to be used.
  113317. */
  113318. executeWhenCompiled(func: (effect: Effect) => void): void;
  113319. private _checkIsReady;
  113320. private _loadShader;
  113321. /**
  113322. * Gets the vertex shader source code of this effect
  113323. */
  113324. get vertexSourceCode(): string;
  113325. /**
  113326. * Gets the fragment shader source code of this effect
  113327. */
  113328. get fragmentSourceCode(): string;
  113329. /**
  113330. * Recompiles the webGL program
  113331. * @param vertexSourceCode The source code for the vertex shader.
  113332. * @param fragmentSourceCode The source code for the fragment shader.
  113333. * @param onCompiled Callback called when completed.
  113334. * @param onError Callback called on error.
  113335. * @hidden
  113336. */
  113337. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113338. /**
  113339. * Prepares the effect
  113340. * @hidden
  113341. */
  113342. _prepareEffect(): void;
  113343. private _getShaderCodeAndErrorLine;
  113344. private _processCompilationErrors;
  113345. /**
  113346. * Checks if the effect is supported. (Must be called after compilation)
  113347. */
  113348. get isSupported(): boolean;
  113349. /**
  113350. * Binds a texture to the engine to be used as output of the shader.
  113351. * @param channel Name of the output variable.
  113352. * @param texture Texture to bind.
  113353. * @hidden
  113354. */
  113355. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113356. /**
  113357. * Sets a texture on the engine to be used in the shader.
  113358. * @param channel Name of the sampler variable.
  113359. * @param texture Texture to set.
  113360. */
  113361. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113362. /**
  113363. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113364. * @param channel Name of the sampler variable.
  113365. * @param texture Texture to set.
  113366. */
  113367. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113368. /**
  113369. * Sets an array of textures on the engine to be used in the shader.
  113370. * @param channel Name of the variable.
  113371. * @param textures Textures to set.
  113372. */
  113373. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113374. /**
  113375. * 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)
  113376. * @param channel Name of the sampler variable.
  113377. * @param postProcess Post process to get the input texture from.
  113378. */
  113379. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113380. /**
  113381. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113382. * 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)
  113383. * @param channel Name of the sampler variable.
  113384. * @param postProcess Post process to get the output texture from.
  113385. */
  113386. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113387. /** @hidden */
  113388. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113389. /** @hidden */
  113390. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113391. /** @hidden */
  113392. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113393. /** @hidden */
  113394. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113395. /**
  113396. * Binds a buffer to a uniform.
  113397. * @param buffer Buffer to bind.
  113398. * @param name Name of the uniform variable to bind to.
  113399. */
  113400. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113401. /**
  113402. * Binds block to a uniform.
  113403. * @param blockName Name of the block to bind.
  113404. * @param index Index to bind.
  113405. */
  113406. bindUniformBlock(blockName: string, index: number): void;
  113407. /**
  113408. * Sets an interger value on a uniform variable.
  113409. * @param uniformName Name of the variable.
  113410. * @param value Value to be set.
  113411. * @returns this effect.
  113412. */
  113413. setInt(uniformName: string, value: number): Effect;
  113414. /**
  113415. * Sets an int array on a uniform variable.
  113416. * @param uniformName Name of the variable.
  113417. * @param array array to be set.
  113418. * @returns this effect.
  113419. */
  113420. setIntArray(uniformName: string, array: Int32Array): Effect;
  113421. /**
  113422. * 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)
  113423. * @param uniformName Name of the variable.
  113424. * @param array array to be set.
  113425. * @returns this effect.
  113426. */
  113427. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113428. /**
  113429. * 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)
  113430. * @param uniformName Name of the variable.
  113431. * @param array array to be set.
  113432. * @returns this effect.
  113433. */
  113434. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113435. /**
  113436. * 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)
  113437. * @param uniformName Name of the variable.
  113438. * @param array array to be set.
  113439. * @returns this effect.
  113440. */
  113441. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113442. /**
  113443. * Sets an float array on a uniform variable.
  113444. * @param uniformName Name of the variable.
  113445. * @param array array to be set.
  113446. * @returns this effect.
  113447. */
  113448. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113449. /**
  113450. * 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)
  113451. * @param uniformName Name of the variable.
  113452. * @param array array to be set.
  113453. * @returns this effect.
  113454. */
  113455. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113456. /**
  113457. * 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)
  113458. * @param uniformName Name of the variable.
  113459. * @param array array to be set.
  113460. * @returns this effect.
  113461. */
  113462. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113463. /**
  113464. * 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)
  113465. * @param uniformName Name of the variable.
  113466. * @param array array to be set.
  113467. * @returns this effect.
  113468. */
  113469. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113470. /**
  113471. * Sets an array on a uniform variable.
  113472. * @param uniformName Name of the variable.
  113473. * @param array array to be set.
  113474. * @returns this effect.
  113475. */
  113476. setArray(uniformName: string, array: number[]): Effect;
  113477. /**
  113478. * 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)
  113479. * @param uniformName Name of the variable.
  113480. * @param array array to be set.
  113481. * @returns this effect.
  113482. */
  113483. setArray2(uniformName: string, array: number[]): Effect;
  113484. /**
  113485. * 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)
  113486. * @param uniformName Name of the variable.
  113487. * @param array array to be set.
  113488. * @returns this effect.
  113489. */
  113490. setArray3(uniformName: string, array: number[]): Effect;
  113491. /**
  113492. * 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)
  113493. * @param uniformName Name of the variable.
  113494. * @param array array to be set.
  113495. * @returns this effect.
  113496. */
  113497. setArray4(uniformName: string, array: number[]): Effect;
  113498. /**
  113499. * Sets matrices on a uniform variable.
  113500. * @param uniformName Name of the variable.
  113501. * @param matrices matrices to be set.
  113502. * @returns this effect.
  113503. */
  113504. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113505. /**
  113506. * Sets matrix on a uniform variable.
  113507. * @param uniformName Name of the variable.
  113508. * @param matrix matrix to be set.
  113509. * @returns this effect.
  113510. */
  113511. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113512. /**
  113513. * 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)
  113514. * @param uniformName Name of the variable.
  113515. * @param matrix matrix to be set.
  113516. * @returns this effect.
  113517. */
  113518. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113519. /**
  113520. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113521. * @param uniformName Name of the variable.
  113522. * @param matrix matrix to be set.
  113523. * @returns this effect.
  113524. */
  113525. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113526. /**
  113527. * Sets a float on a uniform variable.
  113528. * @param uniformName Name of the variable.
  113529. * @param value value to be set.
  113530. * @returns this effect.
  113531. */
  113532. setFloat(uniformName: string, value: number): Effect;
  113533. /**
  113534. * Sets a boolean on a uniform variable.
  113535. * @param uniformName Name of the variable.
  113536. * @param bool value to be set.
  113537. * @returns this effect.
  113538. */
  113539. setBool(uniformName: string, bool: boolean): Effect;
  113540. /**
  113541. * Sets a Vector2 on a uniform variable.
  113542. * @param uniformName Name of the variable.
  113543. * @param vector2 vector2 to be set.
  113544. * @returns this effect.
  113545. */
  113546. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113547. /**
  113548. * Sets a float2 on a uniform variable.
  113549. * @param uniformName Name of the variable.
  113550. * @param x First float in float2.
  113551. * @param y Second float in float2.
  113552. * @returns this effect.
  113553. */
  113554. setFloat2(uniformName: string, x: number, y: number): Effect;
  113555. /**
  113556. * Sets a Vector3 on a uniform variable.
  113557. * @param uniformName Name of the variable.
  113558. * @param vector3 Value to be set.
  113559. * @returns this effect.
  113560. */
  113561. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113562. /**
  113563. * Sets a float3 on a uniform variable.
  113564. * @param uniformName Name of the variable.
  113565. * @param x First float in float3.
  113566. * @param y Second float in float3.
  113567. * @param z Third float in float3.
  113568. * @returns this effect.
  113569. */
  113570. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113571. /**
  113572. * Sets a Vector4 on a uniform variable.
  113573. * @param uniformName Name of the variable.
  113574. * @param vector4 Value to be set.
  113575. * @returns this effect.
  113576. */
  113577. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113578. /**
  113579. * Sets a float4 on a uniform variable.
  113580. * @param uniformName Name of the variable.
  113581. * @param x First float in float4.
  113582. * @param y Second float in float4.
  113583. * @param z Third float in float4.
  113584. * @param w Fourth float in float4.
  113585. * @returns this effect.
  113586. */
  113587. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113588. /**
  113589. * Sets a Color3 on a uniform variable.
  113590. * @param uniformName Name of the variable.
  113591. * @param color3 Value to be set.
  113592. * @returns this effect.
  113593. */
  113594. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113595. /**
  113596. * Sets a Color4 on a uniform variable.
  113597. * @param uniformName Name of the variable.
  113598. * @param color3 Value to be set.
  113599. * @param alpha Alpha value to be set.
  113600. * @returns this effect.
  113601. */
  113602. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113603. /**
  113604. * Sets a Color4 on a uniform variable
  113605. * @param uniformName defines the name of the variable
  113606. * @param color4 defines the value to be set
  113607. * @returns this effect.
  113608. */
  113609. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113610. /** Release all associated resources */
  113611. dispose(): void;
  113612. /**
  113613. * This function will add a new shader to the shader store
  113614. * @param name the name of the shader
  113615. * @param pixelShader optional pixel shader content
  113616. * @param vertexShader optional vertex shader content
  113617. */
  113618. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113619. /**
  113620. * Store of each shader (The can be looked up using effect.key)
  113621. */
  113622. static ShadersStore: {
  113623. [key: string]: string;
  113624. };
  113625. /**
  113626. * Store of each included file for a shader (The can be looked up using effect.key)
  113627. */
  113628. static IncludesShadersStore: {
  113629. [key: string]: string;
  113630. };
  113631. /**
  113632. * Resets the cache of effects.
  113633. */
  113634. static ResetCache(): void;
  113635. }
  113636. }
  113637. declare module BABYLON {
  113638. /**
  113639. * Interface used to describe the capabilities of the engine relatively to the current browser
  113640. */
  113641. export interface EngineCapabilities {
  113642. /** Maximum textures units per fragment shader */
  113643. maxTexturesImageUnits: number;
  113644. /** Maximum texture units per vertex shader */
  113645. maxVertexTextureImageUnits: number;
  113646. /** Maximum textures units in the entire pipeline */
  113647. maxCombinedTexturesImageUnits: number;
  113648. /** Maximum texture size */
  113649. maxTextureSize: number;
  113650. /** Maximum texture samples */
  113651. maxSamples?: number;
  113652. /** Maximum cube texture size */
  113653. maxCubemapTextureSize: number;
  113654. /** Maximum render texture size */
  113655. maxRenderTextureSize: number;
  113656. /** Maximum number of vertex attributes */
  113657. maxVertexAttribs: number;
  113658. /** Maximum number of varyings */
  113659. maxVaryingVectors: number;
  113660. /** Maximum number of uniforms per vertex shader */
  113661. maxVertexUniformVectors: number;
  113662. /** Maximum number of uniforms per fragment shader */
  113663. maxFragmentUniformVectors: number;
  113664. /** Defines if standard derivates (dx/dy) are supported */
  113665. standardDerivatives: boolean;
  113666. /** Defines if s3tc texture compression is supported */
  113667. s3tc?: WEBGL_compressed_texture_s3tc;
  113668. /** Defines if pvrtc texture compression is supported */
  113669. pvrtc: any;
  113670. /** Defines if etc1 texture compression is supported */
  113671. etc1: any;
  113672. /** Defines if etc2 texture compression is supported */
  113673. etc2: any;
  113674. /** Defines if astc texture compression is supported */
  113675. astc: any;
  113676. /** Defines if float textures are supported */
  113677. textureFloat: boolean;
  113678. /** Defines if vertex array objects are supported */
  113679. vertexArrayObject: boolean;
  113680. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113681. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113682. /** Gets the maximum level of anisotropy supported */
  113683. maxAnisotropy: number;
  113684. /** Defines if instancing is supported */
  113685. instancedArrays: boolean;
  113686. /** Defines if 32 bits indices are supported */
  113687. uintIndices: boolean;
  113688. /** Defines if high precision shaders are supported */
  113689. highPrecisionShaderSupported: boolean;
  113690. /** Defines if depth reading in the fragment shader is supported */
  113691. fragmentDepthSupported: boolean;
  113692. /** Defines if float texture linear filtering is supported*/
  113693. textureFloatLinearFiltering: boolean;
  113694. /** Defines if rendering to float textures is supported */
  113695. textureFloatRender: boolean;
  113696. /** Defines if half float textures are supported*/
  113697. textureHalfFloat: boolean;
  113698. /** Defines if half float texture linear filtering is supported*/
  113699. textureHalfFloatLinearFiltering: boolean;
  113700. /** Defines if rendering to half float textures is supported */
  113701. textureHalfFloatRender: boolean;
  113702. /** Defines if textureLOD shader command is supported */
  113703. textureLOD: boolean;
  113704. /** Defines if draw buffers extension is supported */
  113705. drawBuffersExtension: boolean;
  113706. /** Defines if depth textures are supported */
  113707. depthTextureExtension: boolean;
  113708. /** Defines if float color buffer are supported */
  113709. colorBufferFloat: boolean;
  113710. /** Gets disjoint timer query extension (null if not supported) */
  113711. timerQuery?: EXT_disjoint_timer_query;
  113712. /** Defines if timestamp can be used with timer query */
  113713. canUseTimestampForTimerQuery: boolean;
  113714. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113715. multiview?: any;
  113716. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113717. oculusMultiview?: any;
  113718. /** Function used to let the system compiles shaders in background */
  113719. parallelShaderCompile?: {
  113720. COMPLETION_STATUS_KHR: number;
  113721. };
  113722. /** Max number of texture samples for MSAA */
  113723. maxMSAASamples: number;
  113724. /** Defines if the blend min max extension is supported */
  113725. blendMinMax: boolean;
  113726. }
  113727. }
  113728. declare module BABYLON {
  113729. /**
  113730. * @hidden
  113731. **/
  113732. export class DepthCullingState {
  113733. private _isDepthTestDirty;
  113734. private _isDepthMaskDirty;
  113735. private _isDepthFuncDirty;
  113736. private _isCullFaceDirty;
  113737. private _isCullDirty;
  113738. private _isZOffsetDirty;
  113739. private _isFrontFaceDirty;
  113740. private _depthTest;
  113741. private _depthMask;
  113742. private _depthFunc;
  113743. private _cull;
  113744. private _cullFace;
  113745. private _zOffset;
  113746. private _frontFace;
  113747. /**
  113748. * Initializes the state.
  113749. */
  113750. constructor();
  113751. get isDirty(): boolean;
  113752. get zOffset(): number;
  113753. set zOffset(value: number);
  113754. get cullFace(): Nullable<number>;
  113755. set cullFace(value: Nullable<number>);
  113756. get cull(): Nullable<boolean>;
  113757. set cull(value: Nullable<boolean>);
  113758. get depthFunc(): Nullable<number>;
  113759. set depthFunc(value: Nullable<number>);
  113760. get depthMask(): boolean;
  113761. set depthMask(value: boolean);
  113762. get depthTest(): boolean;
  113763. set depthTest(value: boolean);
  113764. get frontFace(): Nullable<number>;
  113765. set frontFace(value: Nullable<number>);
  113766. reset(): void;
  113767. apply(gl: WebGLRenderingContext): void;
  113768. }
  113769. }
  113770. declare module BABYLON {
  113771. /**
  113772. * @hidden
  113773. **/
  113774. export class StencilState {
  113775. /** 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 */
  113776. static readonly ALWAYS: number;
  113777. /** Passed to stencilOperation to specify that stencil value must be kept */
  113778. static readonly KEEP: number;
  113779. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113780. static readonly REPLACE: number;
  113781. private _isStencilTestDirty;
  113782. private _isStencilMaskDirty;
  113783. private _isStencilFuncDirty;
  113784. private _isStencilOpDirty;
  113785. private _stencilTest;
  113786. private _stencilMask;
  113787. private _stencilFunc;
  113788. private _stencilFuncRef;
  113789. private _stencilFuncMask;
  113790. private _stencilOpStencilFail;
  113791. private _stencilOpDepthFail;
  113792. private _stencilOpStencilDepthPass;
  113793. get isDirty(): boolean;
  113794. get stencilFunc(): number;
  113795. set stencilFunc(value: number);
  113796. get stencilFuncRef(): number;
  113797. set stencilFuncRef(value: number);
  113798. get stencilFuncMask(): number;
  113799. set stencilFuncMask(value: number);
  113800. get stencilOpStencilFail(): number;
  113801. set stencilOpStencilFail(value: number);
  113802. get stencilOpDepthFail(): number;
  113803. set stencilOpDepthFail(value: number);
  113804. get stencilOpStencilDepthPass(): number;
  113805. set stencilOpStencilDepthPass(value: number);
  113806. get stencilMask(): number;
  113807. set stencilMask(value: number);
  113808. get stencilTest(): boolean;
  113809. set stencilTest(value: boolean);
  113810. constructor();
  113811. reset(): void;
  113812. apply(gl: WebGLRenderingContext): void;
  113813. }
  113814. }
  113815. declare module BABYLON {
  113816. /**
  113817. * @hidden
  113818. **/
  113819. export class AlphaState {
  113820. private _isAlphaBlendDirty;
  113821. private _isBlendFunctionParametersDirty;
  113822. private _isBlendEquationParametersDirty;
  113823. private _isBlendConstantsDirty;
  113824. private _alphaBlend;
  113825. private _blendFunctionParameters;
  113826. private _blendEquationParameters;
  113827. private _blendConstants;
  113828. /**
  113829. * Initializes the state.
  113830. */
  113831. constructor();
  113832. get isDirty(): boolean;
  113833. get alphaBlend(): boolean;
  113834. set alphaBlend(value: boolean);
  113835. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113836. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113837. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113838. reset(): void;
  113839. apply(gl: WebGLRenderingContext): void;
  113840. }
  113841. }
  113842. declare module BABYLON {
  113843. /** @hidden */
  113844. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113845. attributeProcessor(attribute: string): string;
  113846. varyingProcessor(varying: string, isFragment: boolean): string;
  113847. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /**
  113852. * Interface for attribute information associated with buffer instanciation
  113853. */
  113854. export interface InstancingAttributeInfo {
  113855. /**
  113856. * Name of the GLSL attribute
  113857. * if attribute index is not specified, this is used to retrieve the index from the effect
  113858. */
  113859. attributeName: string;
  113860. /**
  113861. * Index/offset of the attribute in the vertex shader
  113862. * if not specified, this will be computes from the name.
  113863. */
  113864. index?: number;
  113865. /**
  113866. * size of the attribute, 1, 2, 3 or 4
  113867. */
  113868. attributeSize: number;
  113869. /**
  113870. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113871. */
  113872. offset: number;
  113873. /**
  113874. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113875. * default to 1
  113876. */
  113877. divisor?: number;
  113878. /**
  113879. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113880. * default is FLOAT
  113881. */
  113882. attributeType?: number;
  113883. /**
  113884. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113885. */
  113886. normalized?: boolean;
  113887. }
  113888. }
  113889. declare module BABYLON {
  113890. interface ThinEngine {
  113891. /**
  113892. * Update a video texture
  113893. * @param texture defines the texture to update
  113894. * @param video defines the video element to use
  113895. * @param invertY defines if data must be stored with Y axis inverted
  113896. */
  113897. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113898. }
  113899. }
  113900. declare module BABYLON {
  113901. interface ThinEngine {
  113902. /**
  113903. * Creates a dynamic texture
  113904. * @param width defines the width of the texture
  113905. * @param height defines the height of the texture
  113906. * @param generateMipMaps defines if the engine should generate the mip levels
  113907. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113908. * @returns the dynamic texture inside an InternalTexture
  113909. */
  113910. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113911. /**
  113912. * Update the content of a dynamic texture
  113913. * @param texture defines the texture to update
  113914. * @param canvas defines the canvas containing the source
  113915. * @param invertY defines if data must be stored with Y axis inverted
  113916. * @param premulAlpha defines if alpha is stored as premultiplied
  113917. * @param format defines the format of the data
  113918. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113919. */
  113920. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113921. }
  113922. }
  113923. declare module BABYLON {
  113924. /**
  113925. * Settings for finer control over video usage
  113926. */
  113927. export interface VideoTextureSettings {
  113928. /**
  113929. * Applies `autoplay` to video, if specified
  113930. */
  113931. autoPlay?: boolean;
  113932. /**
  113933. * Applies `loop` to video, if specified
  113934. */
  113935. loop?: boolean;
  113936. /**
  113937. * Automatically updates internal texture from video at every frame in the render loop
  113938. */
  113939. autoUpdateTexture: boolean;
  113940. /**
  113941. * Image src displayed during the video loading or until the user interacts with the video.
  113942. */
  113943. poster?: string;
  113944. }
  113945. /**
  113946. * If you want to display a video in your scene, this is the special texture for that.
  113947. * This special texture works similar to other textures, with the exception of a few parameters.
  113948. * @see https://doc.babylonjs.com/how_to/video_texture
  113949. */
  113950. export class VideoTexture extends Texture {
  113951. /**
  113952. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113953. */
  113954. readonly autoUpdateTexture: boolean;
  113955. /**
  113956. * The video instance used by the texture internally
  113957. */
  113958. readonly video: HTMLVideoElement;
  113959. private _onUserActionRequestedObservable;
  113960. /**
  113961. * Event triggerd when a dom action is required by the user to play the video.
  113962. * This happens due to recent changes in browser policies preventing video to auto start.
  113963. */
  113964. get onUserActionRequestedObservable(): Observable<Texture>;
  113965. private _generateMipMaps;
  113966. private _stillImageCaptured;
  113967. private _displayingPosterTexture;
  113968. private _settings;
  113969. private _createInternalTextureOnEvent;
  113970. private _frameId;
  113971. private _currentSrc;
  113972. /**
  113973. * Creates a video texture.
  113974. * If you want to display a video in your scene, this is the special texture for that.
  113975. * This special texture works similar to other textures, with the exception of a few parameters.
  113976. * @see https://doc.babylonjs.com/how_to/video_texture
  113977. * @param name optional name, will detect from video source, if not defined
  113978. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113979. * @param scene is obviously the current scene.
  113980. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113981. * @param invertY is false by default but can be used to invert video on Y axis
  113982. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113983. * @param settings allows finer control over video usage
  113984. */
  113985. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113986. private _getName;
  113987. private _getVideo;
  113988. private _createInternalTexture;
  113989. private reset;
  113990. /**
  113991. * @hidden Internal method to initiate `update`.
  113992. */
  113993. _rebuild(): void;
  113994. /**
  113995. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113996. */
  113997. update(): void;
  113998. /**
  113999. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114000. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114001. */
  114002. updateTexture(isVisible: boolean): void;
  114003. protected _updateInternalTexture: () => void;
  114004. /**
  114005. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114006. * @param url New url.
  114007. */
  114008. updateURL(url: string): void;
  114009. /**
  114010. * Clones the texture.
  114011. * @returns the cloned texture
  114012. */
  114013. clone(): VideoTexture;
  114014. /**
  114015. * Dispose the texture and release its associated resources.
  114016. */
  114017. dispose(): void;
  114018. /**
  114019. * Creates a video texture straight from a stream.
  114020. * @param scene Define the scene the texture should be created in
  114021. * @param stream Define the stream the texture should be created from
  114022. * @returns The created video texture as a promise
  114023. */
  114024. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114025. /**
  114026. * Creates a video texture straight from your WebCam video feed.
  114027. * @param scene Define the scene the texture should be created in
  114028. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114029. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114030. * @returns The created video texture as a promise
  114031. */
  114032. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114033. minWidth: number;
  114034. maxWidth: number;
  114035. minHeight: number;
  114036. maxHeight: number;
  114037. deviceId: string;
  114038. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114039. /**
  114040. * Creates a video texture straight from your WebCam video feed.
  114041. * @param scene Define the scene the texture should be created in
  114042. * @param onReady Define a callback to triggered once the texture will be ready
  114043. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114044. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114045. */
  114046. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114047. minWidth: number;
  114048. maxWidth: number;
  114049. minHeight: number;
  114050. maxHeight: number;
  114051. deviceId: string;
  114052. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114053. }
  114054. }
  114055. declare module BABYLON {
  114056. /**
  114057. * Defines the interface used by objects working like Scene
  114058. * @hidden
  114059. */
  114060. export interface ISceneLike {
  114061. _addPendingData(data: any): void;
  114062. _removePendingData(data: any): void;
  114063. offlineProvider: IOfflineProvider;
  114064. }
  114065. /** Interface defining initialization parameters for Engine class */
  114066. export interface EngineOptions extends WebGLContextAttributes {
  114067. /**
  114068. * Defines if the engine should no exceed a specified device ratio
  114069. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114070. */
  114071. limitDeviceRatio?: number;
  114072. /**
  114073. * Defines if webvr should be enabled automatically
  114074. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114075. */
  114076. autoEnableWebVR?: boolean;
  114077. /**
  114078. * Defines if webgl2 should be turned off even if supported
  114079. * @see https://doc.babylonjs.com/features/webgl2
  114080. */
  114081. disableWebGL2Support?: boolean;
  114082. /**
  114083. * Defines if webaudio should be initialized as well
  114084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114085. */
  114086. audioEngine?: boolean;
  114087. /**
  114088. * Defines if animations should run using a deterministic lock step
  114089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114090. */
  114091. deterministicLockstep?: boolean;
  114092. /** Defines the maximum steps to use with deterministic lock step mode */
  114093. lockstepMaxSteps?: number;
  114094. /** Defines the seconds between each deterministic lock step */
  114095. timeStep?: number;
  114096. /**
  114097. * Defines that engine should ignore context lost events
  114098. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114099. */
  114100. doNotHandleContextLost?: boolean;
  114101. /**
  114102. * Defines that engine should ignore modifying touch action attribute and style
  114103. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114104. */
  114105. doNotHandleTouchAction?: boolean;
  114106. /**
  114107. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114108. */
  114109. useHighPrecisionFloats?: boolean;
  114110. /**
  114111. * Make the canvas XR Compatible for XR sessions
  114112. */
  114113. xrCompatible?: boolean;
  114114. /**
  114115. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114116. */
  114117. useHighPrecisionMatrix?: boolean;
  114118. }
  114119. /**
  114120. * The base engine class (root of all engines)
  114121. */
  114122. export class ThinEngine {
  114123. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114124. static ExceptionList: ({
  114125. key: string;
  114126. capture: string;
  114127. captureConstraint: number;
  114128. targets: string[];
  114129. } | {
  114130. key: string;
  114131. capture: null;
  114132. captureConstraint: null;
  114133. targets: string[];
  114134. })[];
  114135. /** @hidden */
  114136. static _TextureLoaders: IInternalTextureLoader[];
  114137. /**
  114138. * Returns the current npm package of the sdk
  114139. */
  114140. static get NpmPackage(): string;
  114141. /**
  114142. * Returns the current version of the framework
  114143. */
  114144. static get Version(): string;
  114145. /**
  114146. * Returns a string describing the current engine
  114147. */
  114148. get description(): string;
  114149. /**
  114150. * Gets or sets the epsilon value used by collision engine
  114151. */
  114152. static CollisionsEpsilon: number;
  114153. /**
  114154. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114155. */
  114156. static get ShadersRepository(): string;
  114157. static set ShadersRepository(value: string);
  114158. /** @hidden */
  114159. _shaderProcessor: IShaderProcessor;
  114160. /**
  114161. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114162. */
  114163. forcePOTTextures: boolean;
  114164. /**
  114165. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114166. */
  114167. isFullscreen: boolean;
  114168. /**
  114169. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114170. */
  114171. cullBackFaces: boolean;
  114172. /**
  114173. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114174. */
  114175. renderEvenInBackground: boolean;
  114176. /**
  114177. * Gets or sets a boolean indicating that cache can be kept between frames
  114178. */
  114179. preventCacheWipeBetweenFrames: boolean;
  114180. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114181. validateShaderPrograms: boolean;
  114182. /**
  114183. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114184. * This can provide greater z depth for distant objects.
  114185. */
  114186. useReverseDepthBuffer: boolean;
  114187. /**
  114188. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114189. */
  114190. disableUniformBuffers: boolean;
  114191. /** @hidden */
  114192. _uniformBuffers: UniformBuffer[];
  114193. /**
  114194. * Gets a boolean indicating that the engine supports uniform buffers
  114195. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114196. */
  114197. get supportsUniformBuffers(): boolean;
  114198. /** @hidden */
  114199. _gl: WebGLRenderingContext;
  114200. /** @hidden */
  114201. _webGLVersion: number;
  114202. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114203. protected _windowIsBackground: boolean;
  114204. protected _creationOptions: EngineOptions;
  114205. protected _highPrecisionShadersAllowed: boolean;
  114206. /** @hidden */
  114207. get _shouldUseHighPrecisionShader(): boolean;
  114208. /**
  114209. * Gets a boolean indicating that only power of 2 textures are supported
  114210. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114211. */
  114212. get needPOTTextures(): boolean;
  114213. /** @hidden */
  114214. _badOS: boolean;
  114215. /** @hidden */
  114216. _badDesktopOS: boolean;
  114217. private _hardwareScalingLevel;
  114218. /** @hidden */
  114219. _caps: EngineCapabilities;
  114220. private _isStencilEnable;
  114221. private _glVersion;
  114222. private _glRenderer;
  114223. private _glVendor;
  114224. /** @hidden */
  114225. _videoTextureSupported: boolean;
  114226. protected _renderingQueueLaunched: boolean;
  114227. protected _activeRenderLoops: (() => void)[];
  114228. /**
  114229. * Observable signaled when a context lost event is raised
  114230. */
  114231. onContextLostObservable: Observable<ThinEngine>;
  114232. /**
  114233. * Observable signaled when a context restored event is raised
  114234. */
  114235. onContextRestoredObservable: Observable<ThinEngine>;
  114236. private _onContextLost;
  114237. private _onContextRestored;
  114238. protected _contextWasLost: boolean;
  114239. /** @hidden */
  114240. _doNotHandleContextLost: boolean;
  114241. /**
  114242. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114243. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114244. */
  114245. get doNotHandleContextLost(): boolean;
  114246. set doNotHandleContextLost(value: boolean);
  114247. /**
  114248. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114249. */
  114250. disableVertexArrayObjects: boolean;
  114251. /** @hidden */
  114252. protected _colorWrite: boolean;
  114253. /** @hidden */
  114254. protected _colorWriteChanged: boolean;
  114255. /** @hidden */
  114256. protected _depthCullingState: DepthCullingState;
  114257. /** @hidden */
  114258. protected _stencilState: StencilState;
  114259. /** @hidden */
  114260. _alphaState: AlphaState;
  114261. /** @hidden */
  114262. _alphaMode: number;
  114263. /** @hidden */
  114264. _alphaEquation: number;
  114265. /** @hidden */
  114266. _internalTexturesCache: InternalTexture[];
  114267. /** @hidden */
  114268. protected _activeChannel: number;
  114269. private _currentTextureChannel;
  114270. /** @hidden */
  114271. protected _boundTexturesCache: {
  114272. [key: string]: Nullable<InternalTexture>;
  114273. };
  114274. /** @hidden */
  114275. protected _currentEffect: Nullable<Effect>;
  114276. /** @hidden */
  114277. protected _currentProgram: Nullable<WebGLProgram>;
  114278. private _compiledEffects;
  114279. private _vertexAttribArraysEnabled;
  114280. /** @hidden */
  114281. protected _cachedViewport: Nullable<IViewportLike>;
  114282. private _cachedVertexArrayObject;
  114283. /** @hidden */
  114284. protected _cachedVertexBuffers: any;
  114285. /** @hidden */
  114286. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114287. /** @hidden */
  114288. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114289. /** @hidden */
  114290. _currentRenderTarget: Nullable<InternalTexture>;
  114291. private _uintIndicesCurrentlySet;
  114292. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114293. /** @hidden */
  114294. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114295. /** @hidden */
  114296. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114297. private _currentBufferPointers;
  114298. private _currentInstanceLocations;
  114299. private _currentInstanceBuffers;
  114300. private _textureUnits;
  114301. /** @hidden */
  114302. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114303. /** @hidden */
  114304. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114305. /** @hidden */
  114306. _boundRenderFunction: any;
  114307. private _vaoRecordInProgress;
  114308. private _mustWipeVertexAttributes;
  114309. private _emptyTexture;
  114310. private _emptyCubeTexture;
  114311. private _emptyTexture3D;
  114312. private _emptyTexture2DArray;
  114313. /** @hidden */
  114314. _frameHandler: number;
  114315. private _nextFreeTextureSlots;
  114316. private _maxSimultaneousTextures;
  114317. private _activeRequests;
  114318. /** @hidden */
  114319. _transformTextureUrl: Nullable<(url: string) => string>;
  114320. protected get _supportsHardwareTextureRescaling(): boolean;
  114321. private _framebufferDimensionsObject;
  114322. /**
  114323. * sets the object from which width and height will be taken from when getting render width and height
  114324. * Will fallback to the gl object
  114325. * @param dimensions the framebuffer width and height that will be used.
  114326. */
  114327. set framebufferDimensionsObject(dimensions: Nullable<{
  114328. framebufferWidth: number;
  114329. framebufferHeight: number;
  114330. }>);
  114331. /**
  114332. * Gets the current viewport
  114333. */
  114334. get currentViewport(): Nullable<IViewportLike>;
  114335. /**
  114336. * Gets the default empty texture
  114337. */
  114338. get emptyTexture(): InternalTexture;
  114339. /**
  114340. * Gets the default empty 3D texture
  114341. */
  114342. get emptyTexture3D(): InternalTexture;
  114343. /**
  114344. * Gets the default empty 2D array texture
  114345. */
  114346. get emptyTexture2DArray(): InternalTexture;
  114347. /**
  114348. * Gets the default empty cube texture
  114349. */
  114350. get emptyCubeTexture(): InternalTexture;
  114351. /**
  114352. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114353. */
  114354. readonly premultipliedAlpha: boolean;
  114355. /**
  114356. * Observable event triggered before each texture is initialized
  114357. */
  114358. onBeforeTextureInitObservable: Observable<Texture>;
  114359. /**
  114360. * Creates a new engine
  114361. * @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
  114362. * @param antialias defines enable antialiasing (default: false)
  114363. * @param options defines further options to be sent to the getContext() function
  114364. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114365. */
  114366. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114367. private _rebuildInternalTextures;
  114368. private _rebuildEffects;
  114369. /**
  114370. * Gets a boolean indicating if all created effects are ready
  114371. * @returns true if all effects are ready
  114372. */
  114373. areAllEffectsReady(): boolean;
  114374. protected _rebuildBuffers(): void;
  114375. protected _initGLContext(): void;
  114376. /**
  114377. * Gets version of the current webGL context
  114378. */
  114379. get webGLVersion(): number;
  114380. /**
  114381. * Gets a string idenfifying the name of the class
  114382. * @returns "Engine" string
  114383. */
  114384. getClassName(): string;
  114385. /**
  114386. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114387. */
  114388. get isStencilEnable(): boolean;
  114389. /** @hidden */
  114390. _prepareWorkingCanvas(): void;
  114391. /**
  114392. * Reset the texture cache to empty state
  114393. */
  114394. resetTextureCache(): void;
  114395. /**
  114396. * Gets an object containing information about the current webGL context
  114397. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114398. */
  114399. getGlInfo(): {
  114400. vendor: string;
  114401. renderer: string;
  114402. version: string;
  114403. };
  114404. /**
  114405. * Defines the hardware scaling level.
  114406. * By default the hardware scaling level is computed from the window device ratio.
  114407. * 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.
  114408. * @param level defines the level to use
  114409. */
  114410. setHardwareScalingLevel(level: number): void;
  114411. /**
  114412. * Gets the current hardware scaling level.
  114413. * By default the hardware scaling level is computed from the window device ratio.
  114414. * 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.
  114415. * @returns a number indicating the current hardware scaling level
  114416. */
  114417. getHardwareScalingLevel(): number;
  114418. /**
  114419. * Gets the list of loaded textures
  114420. * @returns an array containing all loaded textures
  114421. */
  114422. getLoadedTexturesCache(): InternalTexture[];
  114423. /**
  114424. * Gets the object containing all engine capabilities
  114425. * @returns the EngineCapabilities object
  114426. */
  114427. getCaps(): EngineCapabilities;
  114428. /**
  114429. * stop executing a render loop function and remove it from the execution array
  114430. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114431. */
  114432. stopRenderLoop(renderFunction?: () => void): void;
  114433. /** @hidden */
  114434. _renderLoop(): void;
  114435. /**
  114436. * Gets the HTML canvas attached with the current webGL context
  114437. * @returns a HTML canvas
  114438. */
  114439. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114440. /**
  114441. * Gets host window
  114442. * @returns the host window object
  114443. */
  114444. getHostWindow(): Nullable<Window>;
  114445. /**
  114446. * Gets the current render width
  114447. * @param useScreen defines if screen size must be used (or the current render target if any)
  114448. * @returns a number defining the current render width
  114449. */
  114450. getRenderWidth(useScreen?: boolean): number;
  114451. /**
  114452. * Gets the current render height
  114453. * @param useScreen defines if screen size must be used (or the current render target if any)
  114454. * @returns a number defining the current render height
  114455. */
  114456. getRenderHeight(useScreen?: boolean): number;
  114457. /**
  114458. * Can be used to override the current requestAnimationFrame requester.
  114459. * @hidden
  114460. */
  114461. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114462. /**
  114463. * Register and execute a render loop. The engine can have more than one render function
  114464. * @param renderFunction defines the function to continuously execute
  114465. */
  114466. runRenderLoop(renderFunction: () => void): void;
  114467. /**
  114468. * Clear the current render buffer or the current render target (if any is set up)
  114469. * @param color defines the color to use
  114470. * @param backBuffer defines if the back buffer must be cleared
  114471. * @param depth defines if the depth buffer must be cleared
  114472. * @param stencil defines if the stencil buffer must be cleared
  114473. */
  114474. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114475. private _viewportCached;
  114476. /** @hidden */
  114477. _viewport(x: number, y: number, width: number, height: number): void;
  114478. /**
  114479. * Set the WebGL's viewport
  114480. * @param viewport defines the viewport element to be used
  114481. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114482. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114483. */
  114484. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114485. /**
  114486. * Begin a new frame
  114487. */
  114488. beginFrame(): void;
  114489. /**
  114490. * Enf the current frame
  114491. */
  114492. endFrame(): void;
  114493. /**
  114494. * Resize the view according to the canvas' size
  114495. */
  114496. resize(): void;
  114497. /**
  114498. * Force a specific size of the canvas
  114499. * @param width defines the new canvas' width
  114500. * @param height defines the new canvas' height
  114501. * @returns true if the size was changed
  114502. */
  114503. setSize(width: number, height: number): boolean;
  114504. /**
  114505. * Binds the frame buffer to the specified texture.
  114506. * @param texture The texture to render to or null for the default canvas
  114507. * @param faceIndex The face of the texture to render to in case of cube texture
  114508. * @param requiredWidth The width of the target to render to
  114509. * @param requiredHeight The height of the target to render to
  114510. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114511. * @param lodLevel defines the lod level to bind to the frame buffer
  114512. * @param layer defines the 2d array index to bind to frame buffer to
  114513. */
  114514. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114515. /** @hidden */
  114516. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114517. /**
  114518. * Unbind the current render target texture from the webGL context
  114519. * @param texture defines the render target texture to unbind
  114520. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114521. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114522. */
  114523. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114524. /**
  114525. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114526. */
  114527. flushFramebuffer(): void;
  114528. /**
  114529. * Unbind the current render target and bind the default framebuffer
  114530. */
  114531. restoreDefaultFramebuffer(): void;
  114532. /** @hidden */
  114533. protected _resetVertexBufferBinding(): void;
  114534. /**
  114535. * Creates a vertex buffer
  114536. * @param data the data for the vertex buffer
  114537. * @returns the new WebGL static buffer
  114538. */
  114539. createVertexBuffer(data: DataArray): DataBuffer;
  114540. private _createVertexBuffer;
  114541. /**
  114542. * Creates a dynamic vertex buffer
  114543. * @param data the data for the dynamic vertex buffer
  114544. * @returns the new WebGL dynamic buffer
  114545. */
  114546. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114547. protected _resetIndexBufferBinding(): void;
  114548. /**
  114549. * Creates a new index buffer
  114550. * @param indices defines the content of the index buffer
  114551. * @param updatable defines if the index buffer must be updatable
  114552. * @returns a new webGL buffer
  114553. */
  114554. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114555. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114556. /**
  114557. * Bind a webGL buffer to the webGL context
  114558. * @param buffer defines the buffer to bind
  114559. */
  114560. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114561. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114562. private bindBuffer;
  114563. /**
  114564. * update the bound buffer with the given data
  114565. * @param data defines the data to update
  114566. */
  114567. updateArrayBuffer(data: Float32Array): void;
  114568. private _vertexAttribPointer;
  114569. /** @hidden */
  114570. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114571. private _bindVertexBuffersAttributes;
  114572. /**
  114573. * Records a vertex array object
  114574. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114575. * @param vertexBuffers defines the list of vertex buffers to store
  114576. * @param indexBuffer defines the index buffer to store
  114577. * @param effect defines the effect to store
  114578. * @returns the new vertex array object
  114579. */
  114580. recordVertexArrayObject(vertexBuffers: {
  114581. [key: string]: VertexBuffer;
  114582. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114583. /**
  114584. * Bind a specific vertex array object
  114585. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114586. * @param vertexArrayObject defines the vertex array object to bind
  114587. * @param indexBuffer defines the index buffer to bind
  114588. */
  114589. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114590. /**
  114591. * Bind webGl buffers directly to the webGL context
  114592. * @param vertexBuffer defines the vertex buffer to bind
  114593. * @param indexBuffer defines the index buffer to bind
  114594. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114595. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114596. * @param effect defines the effect associated with the vertex buffer
  114597. */
  114598. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114599. private _unbindVertexArrayObject;
  114600. /**
  114601. * Bind a list of vertex buffers to the webGL context
  114602. * @param vertexBuffers defines the list of vertex buffers to bind
  114603. * @param indexBuffer defines the index buffer to bind
  114604. * @param effect defines the effect associated with the vertex buffers
  114605. */
  114606. bindBuffers(vertexBuffers: {
  114607. [key: string]: Nullable<VertexBuffer>;
  114608. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114609. /**
  114610. * Unbind all instance attributes
  114611. */
  114612. unbindInstanceAttributes(): void;
  114613. /**
  114614. * Release and free the memory of a vertex array object
  114615. * @param vao defines the vertex array object to delete
  114616. */
  114617. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114618. /** @hidden */
  114619. _releaseBuffer(buffer: DataBuffer): boolean;
  114620. protected _deleteBuffer(buffer: DataBuffer): void;
  114621. /**
  114622. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114623. * @param instancesBuffer defines the webGL buffer to update and bind
  114624. * @param data defines the data to store in the buffer
  114625. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114626. */
  114627. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114628. /**
  114629. * Bind the content of a webGL buffer used with instantiation
  114630. * @param instancesBuffer defines the webGL buffer to bind
  114631. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114632. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114633. */
  114634. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114635. /**
  114636. * Disable the instance attribute corresponding to the name in parameter
  114637. * @param name defines the name of the attribute to disable
  114638. */
  114639. disableInstanceAttributeByName(name: string): void;
  114640. /**
  114641. * Disable the instance attribute corresponding to the location in parameter
  114642. * @param attributeLocation defines the attribute location of the attribute to disable
  114643. */
  114644. disableInstanceAttribute(attributeLocation: number): void;
  114645. /**
  114646. * Disable the attribute corresponding to the location in parameter
  114647. * @param attributeLocation defines the attribute location of the attribute to disable
  114648. */
  114649. disableAttributeByIndex(attributeLocation: number): void;
  114650. /**
  114651. * Send a draw order
  114652. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114653. * @param indexStart defines the starting index
  114654. * @param indexCount defines the number of index to draw
  114655. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114656. */
  114657. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114658. /**
  114659. * Draw a list of points
  114660. * @param verticesStart defines the index of first vertex to draw
  114661. * @param verticesCount defines the count of vertices to draw
  114662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114663. */
  114664. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114665. /**
  114666. * Draw a list of unindexed primitives
  114667. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114668. * @param verticesStart defines the index of first vertex to draw
  114669. * @param verticesCount defines the count of vertices to draw
  114670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114671. */
  114672. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114673. /**
  114674. * Draw a list of indexed primitives
  114675. * @param fillMode defines the primitive to use
  114676. * @param indexStart defines the starting index
  114677. * @param indexCount defines the number of index to draw
  114678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114679. */
  114680. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114681. /**
  114682. * Draw a list of unindexed primitives
  114683. * @param fillMode defines the primitive to use
  114684. * @param verticesStart defines the index of first vertex to draw
  114685. * @param verticesCount defines the count of vertices to draw
  114686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114687. */
  114688. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114689. private _drawMode;
  114690. /** @hidden */
  114691. protected _reportDrawCall(): void;
  114692. /** @hidden */
  114693. _releaseEffect(effect: Effect): void;
  114694. /** @hidden */
  114695. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114696. /**
  114697. * Create a new effect (used to store vertex/fragment shaders)
  114698. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114699. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114700. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114701. * @param samplers defines an array of string used to represent textures
  114702. * @param defines defines the string containing the defines to use to compile the shaders
  114703. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114704. * @param onCompiled defines a function to call when the effect creation is successful
  114705. * @param onError defines a function to call when the effect creation has failed
  114706. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114707. * @returns the new Effect
  114708. */
  114709. 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;
  114710. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114711. private _compileShader;
  114712. private _compileRawShader;
  114713. /** @hidden */
  114714. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114715. /**
  114716. * Directly creates a webGL program
  114717. * @param pipelineContext defines the pipeline context to attach to
  114718. * @param vertexCode defines the vertex shader code to use
  114719. * @param fragmentCode defines the fragment shader code to use
  114720. * @param context defines the webGL context to use (if not set, the current one will be used)
  114721. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114722. * @returns the new webGL program
  114723. */
  114724. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114725. /**
  114726. * Creates a webGL program
  114727. * @param pipelineContext defines the pipeline context to attach to
  114728. * @param vertexCode defines the vertex shader code to use
  114729. * @param fragmentCode defines the fragment shader code to use
  114730. * @param defines defines the string containing the defines to use to compile the shaders
  114731. * @param context defines the webGL context to use (if not set, the current one will be used)
  114732. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114733. * @returns the new webGL program
  114734. */
  114735. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114736. /**
  114737. * Creates a new pipeline context
  114738. * @returns the new pipeline
  114739. */
  114740. createPipelineContext(): IPipelineContext;
  114741. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114742. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114743. /** @hidden */
  114744. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114745. /** @hidden */
  114746. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114747. /** @hidden */
  114748. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114749. /**
  114750. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114751. * @param pipelineContext defines the pipeline context to use
  114752. * @param uniformsNames defines the list of uniform names
  114753. * @returns an array of webGL uniform locations
  114754. */
  114755. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114756. /**
  114757. * Gets the lsit of active attributes for a given webGL program
  114758. * @param pipelineContext defines the pipeline context to use
  114759. * @param attributesNames defines the list of attribute names to get
  114760. * @returns an array of indices indicating the offset of each attribute
  114761. */
  114762. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114763. /**
  114764. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114765. * @param effect defines the effect to activate
  114766. */
  114767. enableEffect(effect: Nullable<Effect>): void;
  114768. /**
  114769. * Set the value of an uniform to a number (int)
  114770. * @param uniform defines the webGL uniform location where to store the value
  114771. * @param value defines the int number to store
  114772. */
  114773. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114774. /**
  114775. * Set the value of an uniform to an array of int32
  114776. * @param uniform defines the webGL uniform location where to store the value
  114777. * @param array defines the array of int32 to store
  114778. */
  114779. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114780. /**
  114781. * Set the value of an uniform to an array of int32 (stored as vec2)
  114782. * @param uniform defines the webGL uniform location where to store the value
  114783. * @param array defines the array of int32 to store
  114784. */
  114785. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114786. /**
  114787. * Set the value of an uniform to an array of int32 (stored as vec3)
  114788. * @param uniform defines the webGL uniform location where to store the value
  114789. * @param array defines the array of int32 to store
  114790. */
  114791. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114792. /**
  114793. * Set the value of an uniform to an array of int32 (stored as vec4)
  114794. * @param uniform defines the webGL uniform location where to store the value
  114795. * @param array defines the array of int32 to store
  114796. */
  114797. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114798. /**
  114799. * Set the value of an uniform to an array of number
  114800. * @param uniform defines the webGL uniform location where to store the value
  114801. * @param array defines the array of number to store
  114802. */
  114803. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114804. /**
  114805. * Set the value of an uniform to an array of number (stored as vec2)
  114806. * @param uniform defines the webGL uniform location where to store the value
  114807. * @param array defines the array of number to store
  114808. */
  114809. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114810. /**
  114811. * Set the value of an uniform to an array of number (stored as vec3)
  114812. * @param uniform defines the webGL uniform location where to store the value
  114813. * @param array defines the array of number to store
  114814. */
  114815. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114816. /**
  114817. * Set the value of an uniform to an array of number (stored as vec4)
  114818. * @param uniform defines the webGL uniform location where to store the value
  114819. * @param array defines the array of number to store
  114820. */
  114821. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114822. /**
  114823. * Set the value of an uniform to an array of float32 (stored as matrices)
  114824. * @param uniform defines the webGL uniform location where to store the value
  114825. * @param matrices defines the array of float32 to store
  114826. */
  114827. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114828. /**
  114829. * Set the value of an uniform to a matrix (3x3)
  114830. * @param uniform defines the webGL uniform location where to store the value
  114831. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114832. */
  114833. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114834. /**
  114835. * Set the value of an uniform to a matrix (2x2)
  114836. * @param uniform defines the webGL uniform location where to store the value
  114837. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114838. */
  114839. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114840. /**
  114841. * Set the value of an uniform to a number (float)
  114842. * @param uniform defines the webGL uniform location where to store the value
  114843. * @param value defines the float number to store
  114844. */
  114845. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114846. /**
  114847. * Set the value of an uniform to a vec2
  114848. * @param uniform defines the webGL uniform location where to store the value
  114849. * @param x defines the 1st component of the value
  114850. * @param y defines the 2nd component of the value
  114851. */
  114852. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114853. /**
  114854. * Set the value of an uniform to a vec3
  114855. * @param uniform defines the webGL uniform location where to store the value
  114856. * @param x defines the 1st component of the value
  114857. * @param y defines the 2nd component of the value
  114858. * @param z defines the 3rd component of the value
  114859. */
  114860. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114861. /**
  114862. * Set the value of an uniform to a vec4
  114863. * @param uniform defines the webGL uniform location where to store the value
  114864. * @param x defines the 1st component of the value
  114865. * @param y defines the 2nd component of the value
  114866. * @param z defines the 3rd component of the value
  114867. * @param w defines the 4th component of the value
  114868. */
  114869. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114870. /**
  114871. * Apply all cached states (depth, culling, stencil and alpha)
  114872. */
  114873. applyStates(): void;
  114874. /**
  114875. * Enable or disable color writing
  114876. * @param enable defines the state to set
  114877. */
  114878. setColorWrite(enable: boolean): void;
  114879. /**
  114880. * Gets a boolean indicating if color writing is enabled
  114881. * @returns the current color writing state
  114882. */
  114883. getColorWrite(): boolean;
  114884. /**
  114885. * Gets the depth culling state manager
  114886. */
  114887. get depthCullingState(): DepthCullingState;
  114888. /**
  114889. * Gets the alpha state manager
  114890. */
  114891. get alphaState(): AlphaState;
  114892. /**
  114893. * Gets the stencil state manager
  114894. */
  114895. get stencilState(): StencilState;
  114896. /**
  114897. * Clears the list of texture accessible through engine.
  114898. * This can help preventing texture load conflict due to name collision.
  114899. */
  114900. clearInternalTexturesCache(): void;
  114901. /**
  114902. * Force the entire cache to be cleared
  114903. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114904. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114905. */
  114906. wipeCaches(bruteForce?: boolean): void;
  114907. /** @hidden */
  114908. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114909. min: number;
  114910. mag: number;
  114911. };
  114912. /** @hidden */
  114913. _createTexture(): WebGLTexture;
  114914. /**
  114915. * Usually called from Texture.ts.
  114916. * Passed information to create a WebGLTexture
  114917. * @param url defines a value which contains one of the following:
  114918. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114919. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114920. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114922. * @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)
  114923. * @param scene needed for loading to the correct scene
  114924. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114925. * @param onLoad optional callback to be called upon successful completion
  114926. * @param onError optional callback to be called upon failure
  114927. * @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
  114928. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114929. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114930. * @param forcedExtension defines the extension to use to pick the right loader
  114931. * @param mimeType defines an optional mime type
  114932. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114933. */
  114934. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  114935. /**
  114936. * Loads an image as an HTMLImageElement.
  114937. * @param input url string, ArrayBuffer, or Blob to load
  114938. * @param onLoad callback called when the image successfully loads
  114939. * @param onError callback called when the image fails to load
  114940. * @param offlineProvider offline provider for caching
  114941. * @param mimeType optional mime type
  114942. * @returns the HTMLImageElement of the loaded image
  114943. * @hidden
  114944. */
  114945. 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>;
  114946. /**
  114947. * @hidden
  114948. */
  114949. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114950. private _unpackFlipYCached;
  114951. /**
  114952. * In case you are sharing the context with other applications, it might
  114953. * be interested to not cache the unpack flip y state to ensure a consistent
  114954. * value would be set.
  114955. */
  114956. enableUnpackFlipYCached: boolean;
  114957. /** @hidden */
  114958. _unpackFlipY(value: boolean): void;
  114959. /** @hidden */
  114960. _getUnpackAlignement(): number;
  114961. private _getTextureTarget;
  114962. /**
  114963. * Update the sampling mode of a given texture
  114964. * @param samplingMode defines the required sampling mode
  114965. * @param texture defines the texture to update
  114966. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114967. */
  114968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114969. /**
  114970. * Update the sampling mode of a given texture
  114971. * @param texture defines the texture to update
  114972. * @param wrapU defines the texture wrap mode of the u coordinates
  114973. * @param wrapV defines the texture wrap mode of the v coordinates
  114974. * @param wrapR defines the texture wrap mode of the r coordinates
  114975. */
  114976. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114977. /** @hidden */
  114978. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114979. width: number;
  114980. height: number;
  114981. layers?: number;
  114982. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114983. /** @hidden */
  114984. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114985. /** @hidden */
  114986. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114987. /**
  114988. * Update a portion of an internal texture
  114989. * @param texture defines the texture to update
  114990. * @param imageData defines the data to store into the texture
  114991. * @param xOffset defines the x coordinates of the update rectangle
  114992. * @param yOffset defines the y coordinates of the update rectangle
  114993. * @param width defines the width of the update rectangle
  114994. * @param height defines the height of the update rectangle
  114995. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114996. * @param lod defines the lod level to update (0 by default)
  114997. */
  114998. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114999. /** @hidden */
  115000. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115001. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115002. private _prepareWebGLTexture;
  115003. /** @hidden */
  115004. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115005. private _getDepthStencilBuffer;
  115006. /** @hidden */
  115007. _releaseFramebufferObjects(texture: InternalTexture): void;
  115008. /** @hidden */
  115009. _releaseTexture(texture: InternalTexture): void;
  115010. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115011. protected _setProgram(program: WebGLProgram): void;
  115012. protected _boundUniforms: {
  115013. [key: number]: WebGLUniformLocation;
  115014. };
  115015. /**
  115016. * Binds an effect to the webGL context
  115017. * @param effect defines the effect to bind
  115018. */
  115019. bindSamplers(effect: Effect): void;
  115020. private _activateCurrentTexture;
  115021. /** @hidden */
  115022. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115023. /** @hidden */
  115024. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115025. /**
  115026. * Unbind all textures from the webGL context
  115027. */
  115028. unbindAllTextures(): void;
  115029. /**
  115030. * Sets a texture to the according uniform.
  115031. * @param channel The texture channel
  115032. * @param uniform The uniform to set
  115033. * @param texture The texture to apply
  115034. */
  115035. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115036. private _bindSamplerUniformToChannel;
  115037. private _getTextureWrapMode;
  115038. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115039. /**
  115040. * Sets an array of texture to the webGL context
  115041. * @param channel defines the channel where the texture array must be set
  115042. * @param uniform defines the associated uniform location
  115043. * @param textures defines the array of textures to bind
  115044. */
  115045. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115046. /** @hidden */
  115047. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115048. private _setTextureParameterFloat;
  115049. private _setTextureParameterInteger;
  115050. /**
  115051. * Unbind all vertex attributes from the webGL context
  115052. */
  115053. unbindAllAttributes(): void;
  115054. /**
  115055. * 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
  115056. */
  115057. releaseEffects(): void;
  115058. /**
  115059. * Dispose and release all associated resources
  115060. */
  115061. dispose(): void;
  115062. /**
  115063. * Attach a new callback raised when context lost event is fired
  115064. * @param callback defines the callback to call
  115065. */
  115066. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115067. /**
  115068. * Attach a new callback raised when context restored event is fired
  115069. * @param callback defines the callback to call
  115070. */
  115071. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115072. /**
  115073. * Get the current error code of the webGL context
  115074. * @returns the error code
  115075. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115076. */
  115077. getError(): number;
  115078. private _canRenderToFloatFramebuffer;
  115079. private _canRenderToHalfFloatFramebuffer;
  115080. private _canRenderToFramebuffer;
  115081. /** @hidden */
  115082. _getWebGLTextureType(type: number): number;
  115083. /** @hidden */
  115084. _getInternalFormat(format: number): number;
  115085. /** @hidden */
  115086. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115087. /** @hidden */
  115088. _getRGBAMultiSampleBufferFormat(type: number): number;
  115089. /** @hidden */
  115090. _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;
  115091. /**
  115092. * Loads a file from a url
  115093. * @param url url to load
  115094. * @param onSuccess callback called when the file successfully loads
  115095. * @param onProgress callback called while file is loading (if the server supports this mode)
  115096. * @param offlineProvider defines the offline provider for caching
  115097. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115098. * @param onError callback called when the file fails to load
  115099. * @returns a file request object
  115100. * @hidden
  115101. */
  115102. 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;
  115103. /**
  115104. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115105. * @param x defines the x coordinate of the rectangle where pixels must be read
  115106. * @param y defines the y coordinate of the rectangle where pixels must be read
  115107. * @param width defines the width of the rectangle where pixels must be read
  115108. * @param height defines the height of the rectangle where pixels must be read
  115109. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115110. * @returns a Uint8Array containing RGBA colors
  115111. */
  115112. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115113. private static _isSupported;
  115114. /**
  115115. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115116. * @returns true if the engine can be created
  115117. * @ignorenaming
  115118. */
  115119. static isSupported(): boolean;
  115120. /**
  115121. * Find the next highest power of two.
  115122. * @param x Number to start search from.
  115123. * @return Next highest power of two.
  115124. */
  115125. static CeilingPOT(x: number): number;
  115126. /**
  115127. * Find the next lowest power of two.
  115128. * @param x Number to start search from.
  115129. * @return Next lowest power of two.
  115130. */
  115131. static FloorPOT(x: number): number;
  115132. /**
  115133. * Find the nearest power of two.
  115134. * @param x Number to start search from.
  115135. * @return Next nearest power of two.
  115136. */
  115137. static NearestPOT(x: number): number;
  115138. /**
  115139. * Get the closest exponent of two
  115140. * @param value defines the value to approximate
  115141. * @param max defines the maximum value to return
  115142. * @param mode defines how to define the closest value
  115143. * @returns closest exponent of two of the given value
  115144. */
  115145. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115146. /**
  115147. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115148. * @param func - the function to be called
  115149. * @param requester - the object that will request the next frame. Falls back to window.
  115150. * @returns frame number
  115151. */
  115152. static QueueNewFrame(func: () => void, requester?: any): number;
  115153. /**
  115154. * Gets host document
  115155. * @returns the host document object
  115156. */
  115157. getHostDocument(): Nullable<Document>;
  115158. }
  115159. }
  115160. declare module BABYLON {
  115161. /**
  115162. * Class representing spherical harmonics coefficients to the 3rd degree
  115163. */
  115164. export class SphericalHarmonics {
  115165. /**
  115166. * Defines whether or not the harmonics have been prescaled for rendering.
  115167. */
  115168. preScaled: boolean;
  115169. /**
  115170. * The l0,0 coefficients of the spherical harmonics
  115171. */
  115172. l00: Vector3;
  115173. /**
  115174. * The l1,-1 coefficients of the spherical harmonics
  115175. */
  115176. l1_1: Vector3;
  115177. /**
  115178. * The l1,0 coefficients of the spherical harmonics
  115179. */
  115180. l10: Vector3;
  115181. /**
  115182. * The l1,1 coefficients of the spherical harmonics
  115183. */
  115184. l11: Vector3;
  115185. /**
  115186. * The l2,-2 coefficients of the spherical harmonics
  115187. */
  115188. l2_2: Vector3;
  115189. /**
  115190. * The l2,-1 coefficients of the spherical harmonics
  115191. */
  115192. l2_1: Vector3;
  115193. /**
  115194. * The l2,0 coefficients of the spherical harmonics
  115195. */
  115196. l20: Vector3;
  115197. /**
  115198. * The l2,1 coefficients of the spherical harmonics
  115199. */
  115200. l21: Vector3;
  115201. /**
  115202. * The l2,2 coefficients of the spherical harmonics
  115203. */
  115204. l22: Vector3;
  115205. /**
  115206. * Adds a light to the spherical harmonics
  115207. * @param direction the direction of the light
  115208. * @param color the color of the light
  115209. * @param deltaSolidAngle the delta solid angle of the light
  115210. */
  115211. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115212. /**
  115213. * Scales the spherical harmonics by the given amount
  115214. * @param scale the amount to scale
  115215. */
  115216. scaleInPlace(scale: number): void;
  115217. /**
  115218. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115219. *
  115220. * ```
  115221. * E_lm = A_l * L_lm
  115222. * ```
  115223. *
  115224. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115225. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115226. * the scaling factors are given in equation 9.
  115227. */
  115228. convertIncidentRadianceToIrradiance(): void;
  115229. /**
  115230. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115231. *
  115232. * ```
  115233. * L = (1/pi) * E * rho
  115234. * ```
  115235. *
  115236. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115237. */
  115238. convertIrradianceToLambertianRadiance(): void;
  115239. /**
  115240. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115241. * required operations at run time.
  115242. *
  115243. * This is simply done by scaling back the SH with Ylm constants parameter.
  115244. * The trigonometric part being applied by the shader at run time.
  115245. */
  115246. preScaleForRendering(): void;
  115247. /**
  115248. * Constructs a spherical harmonics from an array.
  115249. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115250. * @returns the spherical harmonics
  115251. */
  115252. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115253. /**
  115254. * Gets the spherical harmonics from polynomial
  115255. * @param polynomial the spherical polynomial
  115256. * @returns the spherical harmonics
  115257. */
  115258. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115259. }
  115260. /**
  115261. * Class representing spherical polynomial coefficients to the 3rd degree
  115262. */
  115263. export class SphericalPolynomial {
  115264. private _harmonics;
  115265. /**
  115266. * The spherical harmonics used to create the polynomials.
  115267. */
  115268. get preScaledHarmonics(): SphericalHarmonics;
  115269. /**
  115270. * The x coefficients of the spherical polynomial
  115271. */
  115272. x: Vector3;
  115273. /**
  115274. * The y coefficients of the spherical polynomial
  115275. */
  115276. y: Vector3;
  115277. /**
  115278. * The z coefficients of the spherical polynomial
  115279. */
  115280. z: Vector3;
  115281. /**
  115282. * The xx coefficients of the spherical polynomial
  115283. */
  115284. xx: Vector3;
  115285. /**
  115286. * The yy coefficients of the spherical polynomial
  115287. */
  115288. yy: Vector3;
  115289. /**
  115290. * The zz coefficients of the spherical polynomial
  115291. */
  115292. zz: Vector3;
  115293. /**
  115294. * The xy coefficients of the spherical polynomial
  115295. */
  115296. xy: Vector3;
  115297. /**
  115298. * The yz coefficients of the spherical polynomial
  115299. */
  115300. yz: Vector3;
  115301. /**
  115302. * The zx coefficients of the spherical polynomial
  115303. */
  115304. zx: Vector3;
  115305. /**
  115306. * Adds an ambient color to the spherical polynomial
  115307. * @param color the color to add
  115308. */
  115309. addAmbient(color: Color3): void;
  115310. /**
  115311. * Scales the spherical polynomial by the given amount
  115312. * @param scale the amount to scale
  115313. */
  115314. scaleInPlace(scale: number): void;
  115315. /**
  115316. * Gets the spherical polynomial from harmonics
  115317. * @param harmonics the spherical harmonics
  115318. * @returns the spherical polynomial
  115319. */
  115320. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115321. /**
  115322. * Constructs a spherical polynomial from an array.
  115323. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115324. * @returns the spherical polynomial
  115325. */
  115326. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115327. }
  115328. }
  115329. declare module BABYLON {
  115330. /**
  115331. * Defines the source of the internal texture
  115332. */
  115333. export enum InternalTextureSource {
  115334. /**
  115335. * The source of the texture data is unknown
  115336. */
  115337. Unknown = 0,
  115338. /**
  115339. * Texture data comes from an URL
  115340. */
  115341. Url = 1,
  115342. /**
  115343. * Texture data is only used for temporary storage
  115344. */
  115345. Temp = 2,
  115346. /**
  115347. * Texture data comes from raw data (ArrayBuffer)
  115348. */
  115349. Raw = 3,
  115350. /**
  115351. * Texture content is dynamic (video or dynamic texture)
  115352. */
  115353. Dynamic = 4,
  115354. /**
  115355. * Texture content is generated by rendering to it
  115356. */
  115357. RenderTarget = 5,
  115358. /**
  115359. * Texture content is part of a multi render target process
  115360. */
  115361. MultiRenderTarget = 6,
  115362. /**
  115363. * Texture data comes from a cube data file
  115364. */
  115365. Cube = 7,
  115366. /**
  115367. * Texture data comes from a raw cube data
  115368. */
  115369. CubeRaw = 8,
  115370. /**
  115371. * Texture data come from a prefiltered cube data file
  115372. */
  115373. CubePrefiltered = 9,
  115374. /**
  115375. * Texture content is raw 3D data
  115376. */
  115377. Raw3D = 10,
  115378. /**
  115379. * Texture content is raw 2D array data
  115380. */
  115381. Raw2DArray = 11,
  115382. /**
  115383. * Texture content is a depth texture
  115384. */
  115385. Depth = 12,
  115386. /**
  115387. * Texture data comes from a raw cube data encoded with RGBD
  115388. */
  115389. CubeRawRGBD = 13
  115390. }
  115391. /**
  115392. * Class used to store data associated with WebGL texture data for the engine
  115393. * This class should not be used directly
  115394. */
  115395. export class InternalTexture {
  115396. /** @hidden */
  115397. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115398. /**
  115399. * Defines if the texture is ready
  115400. */
  115401. isReady: boolean;
  115402. /**
  115403. * Defines if the texture is a cube texture
  115404. */
  115405. isCube: boolean;
  115406. /**
  115407. * Defines if the texture contains 3D data
  115408. */
  115409. is3D: boolean;
  115410. /**
  115411. * Defines if the texture contains 2D array data
  115412. */
  115413. is2DArray: boolean;
  115414. /**
  115415. * Defines if the texture contains multiview data
  115416. */
  115417. isMultiview: boolean;
  115418. /**
  115419. * Gets the URL used to load this texture
  115420. */
  115421. url: string;
  115422. /**
  115423. * Gets the sampling mode of the texture
  115424. */
  115425. samplingMode: number;
  115426. /**
  115427. * Gets a boolean indicating if the texture needs mipmaps generation
  115428. */
  115429. generateMipMaps: boolean;
  115430. /**
  115431. * Gets the number of samples used by the texture (WebGL2+ only)
  115432. */
  115433. samples: number;
  115434. /**
  115435. * Gets the type of the texture (int, float...)
  115436. */
  115437. type: number;
  115438. /**
  115439. * Gets the format of the texture (RGB, RGBA...)
  115440. */
  115441. format: number;
  115442. /**
  115443. * Observable called when the texture is loaded
  115444. */
  115445. onLoadedObservable: Observable<InternalTexture>;
  115446. /**
  115447. * Gets the width of the texture
  115448. */
  115449. width: number;
  115450. /**
  115451. * Gets the height of the texture
  115452. */
  115453. height: number;
  115454. /**
  115455. * Gets the depth of the texture
  115456. */
  115457. depth: number;
  115458. /**
  115459. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115460. */
  115461. baseWidth: number;
  115462. /**
  115463. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115464. */
  115465. baseHeight: number;
  115466. /**
  115467. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115468. */
  115469. baseDepth: number;
  115470. /**
  115471. * Gets a boolean indicating if the texture is inverted on Y axis
  115472. */
  115473. invertY: boolean;
  115474. /** @hidden */
  115475. _invertVScale: boolean;
  115476. /** @hidden */
  115477. _associatedChannel: number;
  115478. /** @hidden */
  115479. _source: InternalTextureSource;
  115480. /** @hidden */
  115481. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115482. /** @hidden */
  115483. _bufferView: Nullable<ArrayBufferView>;
  115484. /** @hidden */
  115485. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115486. /** @hidden */
  115487. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115488. /** @hidden */
  115489. _size: number;
  115490. /** @hidden */
  115491. _extension: string;
  115492. /** @hidden */
  115493. _files: Nullable<string[]>;
  115494. /** @hidden */
  115495. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115496. /** @hidden */
  115497. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115498. /** @hidden */
  115499. _framebuffer: Nullable<WebGLFramebuffer>;
  115500. /** @hidden */
  115501. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115502. /** @hidden */
  115503. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115504. /** @hidden */
  115505. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115506. /** @hidden */
  115507. _attachments: Nullable<number[]>;
  115508. /** @hidden */
  115509. _textureArray: Nullable<InternalTexture[]>;
  115510. /** @hidden */
  115511. _cachedCoordinatesMode: Nullable<number>;
  115512. /** @hidden */
  115513. _cachedWrapU: Nullable<number>;
  115514. /** @hidden */
  115515. _cachedWrapV: Nullable<number>;
  115516. /** @hidden */
  115517. _cachedWrapR: Nullable<number>;
  115518. /** @hidden */
  115519. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115520. /** @hidden */
  115521. _isDisabled: boolean;
  115522. /** @hidden */
  115523. _compression: Nullable<string>;
  115524. /** @hidden */
  115525. _generateStencilBuffer: boolean;
  115526. /** @hidden */
  115527. _generateDepthBuffer: boolean;
  115528. /** @hidden */
  115529. _comparisonFunction: number;
  115530. /** @hidden */
  115531. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115532. /** @hidden */
  115533. _lodGenerationScale: number;
  115534. /** @hidden */
  115535. _lodGenerationOffset: number;
  115536. /** @hidden */
  115537. _depthStencilTexture: Nullable<InternalTexture>;
  115538. /** @hidden */
  115539. _colorTextureArray: Nullable<WebGLTexture>;
  115540. /** @hidden */
  115541. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115542. /** @hidden */
  115543. _lodTextureHigh: Nullable<BaseTexture>;
  115544. /** @hidden */
  115545. _lodTextureMid: Nullable<BaseTexture>;
  115546. /** @hidden */
  115547. _lodTextureLow: Nullable<BaseTexture>;
  115548. /** @hidden */
  115549. _isRGBD: boolean;
  115550. /** @hidden */
  115551. _linearSpecularLOD: boolean;
  115552. /** @hidden */
  115553. _irradianceTexture: Nullable<BaseTexture>;
  115554. /** @hidden */
  115555. _webGLTexture: Nullable<WebGLTexture>;
  115556. /** @hidden */
  115557. _references: number;
  115558. private _engine;
  115559. /**
  115560. * Gets the Engine the texture belongs to.
  115561. * @returns The babylon engine
  115562. */
  115563. getEngine(): ThinEngine;
  115564. /**
  115565. * Gets the data source type of the texture
  115566. */
  115567. get source(): InternalTextureSource;
  115568. /**
  115569. * Creates a new InternalTexture
  115570. * @param engine defines the engine to use
  115571. * @param source defines the type of data that will be used
  115572. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115573. */
  115574. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115575. /**
  115576. * Increments the number of references (ie. the number of Texture that point to it)
  115577. */
  115578. incrementReferences(): void;
  115579. /**
  115580. * Change the size of the texture (not the size of the content)
  115581. * @param width defines the new width
  115582. * @param height defines the new height
  115583. * @param depth defines the new depth (1 by default)
  115584. */
  115585. updateSize(width: int, height: int, depth?: int): void;
  115586. /** @hidden */
  115587. _rebuild(): void;
  115588. /** @hidden */
  115589. _swapAndDie(target: InternalTexture): void;
  115590. /**
  115591. * Dispose the current allocated resources
  115592. */
  115593. dispose(): void;
  115594. }
  115595. }
  115596. declare module BABYLON {
  115597. /**
  115598. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115600. */
  115601. export class Analyser {
  115602. /**
  115603. * Gets or sets the smoothing
  115604. * @ignorenaming
  115605. */
  115606. SMOOTHING: number;
  115607. /**
  115608. * Gets or sets the FFT table size
  115609. * @ignorenaming
  115610. */
  115611. FFT_SIZE: number;
  115612. /**
  115613. * Gets or sets the bar graph amplitude
  115614. * @ignorenaming
  115615. */
  115616. BARGRAPHAMPLITUDE: number;
  115617. /**
  115618. * Gets or sets the position of the debug canvas
  115619. * @ignorenaming
  115620. */
  115621. DEBUGCANVASPOS: {
  115622. x: number;
  115623. y: number;
  115624. };
  115625. /**
  115626. * Gets or sets the debug canvas size
  115627. * @ignorenaming
  115628. */
  115629. DEBUGCANVASSIZE: {
  115630. width: number;
  115631. height: number;
  115632. };
  115633. private _byteFreqs;
  115634. private _byteTime;
  115635. private _floatFreqs;
  115636. private _webAudioAnalyser;
  115637. private _debugCanvas;
  115638. private _debugCanvasContext;
  115639. private _scene;
  115640. private _registerFunc;
  115641. private _audioEngine;
  115642. /**
  115643. * Creates a new analyser
  115644. * @param scene defines hosting scene
  115645. */
  115646. constructor(scene: Scene);
  115647. /**
  115648. * Get the number of data values you will have to play with for the visualization
  115649. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115650. * @returns a number
  115651. */
  115652. getFrequencyBinCount(): number;
  115653. /**
  115654. * Gets the current frequency data as a byte array
  115655. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115656. * @returns a Uint8Array
  115657. */
  115658. getByteFrequencyData(): Uint8Array;
  115659. /**
  115660. * Gets the current waveform as a byte array
  115661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115662. * @returns a Uint8Array
  115663. */
  115664. getByteTimeDomainData(): Uint8Array;
  115665. /**
  115666. * Gets the current frequency data as a float array
  115667. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115668. * @returns a Float32Array
  115669. */
  115670. getFloatFrequencyData(): Float32Array;
  115671. /**
  115672. * Renders the debug canvas
  115673. */
  115674. drawDebugCanvas(): void;
  115675. /**
  115676. * Stops rendering the debug canvas and removes it
  115677. */
  115678. stopDebugCanvas(): void;
  115679. /**
  115680. * Connects two audio nodes
  115681. * @param inputAudioNode defines first node to connect
  115682. * @param outputAudioNode defines second node to connect
  115683. */
  115684. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115685. /**
  115686. * Releases all associated resources
  115687. */
  115688. dispose(): void;
  115689. }
  115690. }
  115691. declare module BABYLON {
  115692. /**
  115693. * This represents an audio engine and it is responsible
  115694. * to play, synchronize and analyse sounds throughout the application.
  115695. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115696. */
  115697. export interface IAudioEngine extends IDisposable {
  115698. /**
  115699. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115700. */
  115701. readonly canUseWebAudio: boolean;
  115702. /**
  115703. * Gets the current AudioContext if available.
  115704. */
  115705. readonly audioContext: Nullable<AudioContext>;
  115706. /**
  115707. * The master gain node defines the global audio volume of your audio engine.
  115708. */
  115709. readonly masterGain: GainNode;
  115710. /**
  115711. * Gets whether or not mp3 are supported by your browser.
  115712. */
  115713. readonly isMP3supported: boolean;
  115714. /**
  115715. * Gets whether or not ogg are supported by your browser.
  115716. */
  115717. readonly isOGGsupported: boolean;
  115718. /**
  115719. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115720. * @ignoreNaming
  115721. */
  115722. WarnedWebAudioUnsupported: boolean;
  115723. /**
  115724. * Defines if the audio engine relies on a custom unlocked button.
  115725. * In this case, the embedded button will not be displayed.
  115726. */
  115727. useCustomUnlockedButton: boolean;
  115728. /**
  115729. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115730. */
  115731. readonly unlocked: boolean;
  115732. /**
  115733. * Event raised when audio has been unlocked on the browser.
  115734. */
  115735. onAudioUnlockedObservable: Observable<AudioEngine>;
  115736. /**
  115737. * Event raised when audio has been locked on the browser.
  115738. */
  115739. onAudioLockedObservable: Observable<AudioEngine>;
  115740. /**
  115741. * Flags the audio engine in Locked state.
  115742. * This happens due to new browser policies preventing audio to autoplay.
  115743. */
  115744. lock(): void;
  115745. /**
  115746. * Unlocks the audio engine once a user action has been done on the dom.
  115747. * This is helpful to resume play once browser policies have been satisfied.
  115748. */
  115749. unlock(): void;
  115750. /**
  115751. * Gets the global volume sets on the master gain.
  115752. * @returns the global volume if set or -1 otherwise
  115753. */
  115754. getGlobalVolume(): number;
  115755. /**
  115756. * Sets the global volume of your experience (sets on the master gain).
  115757. * @param newVolume Defines the new global volume of the application
  115758. */
  115759. setGlobalVolume(newVolume: number): void;
  115760. /**
  115761. * Connect the audio engine to an audio analyser allowing some amazing
  115762. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115764. * @param analyser The analyser to connect to the engine
  115765. */
  115766. connectToAnalyser(analyser: Analyser): void;
  115767. }
  115768. /**
  115769. * This represents the default audio engine used in babylon.
  115770. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115772. */
  115773. export class AudioEngine implements IAudioEngine {
  115774. private _audioContext;
  115775. private _audioContextInitialized;
  115776. private _muteButton;
  115777. private _hostElement;
  115778. /**
  115779. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115780. */
  115781. canUseWebAudio: boolean;
  115782. /**
  115783. * The master gain node defines the global audio volume of your audio engine.
  115784. */
  115785. masterGain: GainNode;
  115786. /**
  115787. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115788. * @ignoreNaming
  115789. */
  115790. WarnedWebAudioUnsupported: boolean;
  115791. /**
  115792. * Gets whether or not mp3 are supported by your browser.
  115793. */
  115794. isMP3supported: boolean;
  115795. /**
  115796. * Gets whether or not ogg are supported by your browser.
  115797. */
  115798. isOGGsupported: boolean;
  115799. /**
  115800. * Gets whether audio has been unlocked on the device.
  115801. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115802. * a user interaction has happened.
  115803. */
  115804. unlocked: boolean;
  115805. /**
  115806. * Defines if the audio engine relies on a custom unlocked button.
  115807. * In this case, the embedded button will not be displayed.
  115808. */
  115809. useCustomUnlockedButton: boolean;
  115810. /**
  115811. * Event raised when audio has been unlocked on the browser.
  115812. */
  115813. onAudioUnlockedObservable: Observable<AudioEngine>;
  115814. /**
  115815. * Event raised when audio has been locked on the browser.
  115816. */
  115817. onAudioLockedObservable: Observable<AudioEngine>;
  115818. /**
  115819. * Gets the current AudioContext if available.
  115820. */
  115821. get audioContext(): Nullable<AudioContext>;
  115822. private _connectedAnalyser;
  115823. /**
  115824. * Instantiates a new audio engine.
  115825. *
  115826. * There should be only one per page as some browsers restrict the number
  115827. * of audio contexts you can create.
  115828. * @param hostElement defines the host element where to display the mute icon if necessary
  115829. */
  115830. constructor(hostElement?: Nullable<HTMLElement>);
  115831. /**
  115832. * Flags the audio engine in Locked state.
  115833. * This happens due to new browser policies preventing audio to autoplay.
  115834. */
  115835. lock(): void;
  115836. /**
  115837. * Unlocks the audio engine once a user action has been done on the dom.
  115838. * This is helpful to resume play once browser policies have been satisfied.
  115839. */
  115840. unlock(): void;
  115841. private _resumeAudioContext;
  115842. private _initializeAudioContext;
  115843. private _tryToRun;
  115844. private _triggerRunningState;
  115845. private _triggerSuspendedState;
  115846. private _displayMuteButton;
  115847. private _moveButtonToTopLeft;
  115848. private _onResize;
  115849. private _hideMuteButton;
  115850. /**
  115851. * Destroy and release the resources associated with the audio ccontext.
  115852. */
  115853. dispose(): void;
  115854. /**
  115855. * Gets the global volume sets on the master gain.
  115856. * @returns the global volume if set or -1 otherwise
  115857. */
  115858. getGlobalVolume(): number;
  115859. /**
  115860. * Sets the global volume of your experience (sets on the master gain).
  115861. * @param newVolume Defines the new global volume of the application
  115862. */
  115863. setGlobalVolume(newVolume: number): void;
  115864. /**
  115865. * Connect the audio engine to an audio analyser allowing some amazing
  115866. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115867. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115868. * @param analyser The analyser to connect to the engine
  115869. */
  115870. connectToAnalyser(analyser: Analyser): void;
  115871. }
  115872. }
  115873. declare module BABYLON {
  115874. /**
  115875. * Interface used to present a loading screen while loading a scene
  115876. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115877. */
  115878. export interface ILoadingScreen {
  115879. /**
  115880. * Function called to display the loading screen
  115881. */
  115882. displayLoadingUI: () => void;
  115883. /**
  115884. * Function called to hide the loading screen
  115885. */
  115886. hideLoadingUI: () => void;
  115887. /**
  115888. * Gets or sets the color to use for the background
  115889. */
  115890. loadingUIBackgroundColor: string;
  115891. /**
  115892. * Gets or sets the text to display while loading
  115893. */
  115894. loadingUIText: string;
  115895. }
  115896. /**
  115897. * Class used for the default loading screen
  115898. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115899. */
  115900. export class DefaultLoadingScreen implements ILoadingScreen {
  115901. private _renderingCanvas;
  115902. private _loadingText;
  115903. private _loadingDivBackgroundColor;
  115904. private _loadingDiv;
  115905. private _loadingTextDiv;
  115906. /** Gets or sets the logo url to use for the default loading screen */
  115907. static DefaultLogoUrl: string;
  115908. /** Gets or sets the spinner url to use for the default loading screen */
  115909. static DefaultSpinnerUrl: string;
  115910. /**
  115911. * Creates a new default loading screen
  115912. * @param _renderingCanvas defines the canvas used to render the scene
  115913. * @param _loadingText defines the default text to display
  115914. * @param _loadingDivBackgroundColor defines the default background color
  115915. */
  115916. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115917. /**
  115918. * Function called to display the loading screen
  115919. */
  115920. displayLoadingUI(): void;
  115921. /**
  115922. * Function called to hide the loading screen
  115923. */
  115924. hideLoadingUI(): void;
  115925. /**
  115926. * Gets or sets the text to display while loading
  115927. */
  115928. set loadingUIText(text: string);
  115929. get loadingUIText(): string;
  115930. /**
  115931. * Gets or sets the color to use for the background
  115932. */
  115933. get loadingUIBackgroundColor(): string;
  115934. set loadingUIBackgroundColor(color: string);
  115935. private _resizeLoadingUI;
  115936. }
  115937. }
  115938. declare module BABYLON {
  115939. /**
  115940. * Interface for any object that can request an animation frame
  115941. */
  115942. export interface ICustomAnimationFrameRequester {
  115943. /**
  115944. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115945. */
  115946. renderFunction?: Function;
  115947. /**
  115948. * Called to request the next frame to render to
  115949. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115950. */
  115951. requestAnimationFrame: Function;
  115952. /**
  115953. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115954. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115955. */
  115956. requestID?: number;
  115957. }
  115958. }
  115959. declare module BABYLON {
  115960. /**
  115961. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115962. */
  115963. export class PerformanceMonitor {
  115964. private _enabled;
  115965. private _rollingFrameTime;
  115966. private _lastFrameTimeMs;
  115967. /**
  115968. * constructor
  115969. * @param frameSampleSize The number of samples required to saturate the sliding window
  115970. */
  115971. constructor(frameSampleSize?: number);
  115972. /**
  115973. * Samples current frame
  115974. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115975. */
  115976. sampleFrame(timeMs?: number): void;
  115977. /**
  115978. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115979. */
  115980. get averageFrameTime(): number;
  115981. /**
  115982. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115983. */
  115984. get averageFrameTimeVariance(): number;
  115985. /**
  115986. * Returns the frame time of the most recent frame
  115987. */
  115988. get instantaneousFrameTime(): number;
  115989. /**
  115990. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115991. */
  115992. get averageFPS(): number;
  115993. /**
  115994. * Returns the average framerate in frames per second using the most recent frame time
  115995. */
  115996. get instantaneousFPS(): number;
  115997. /**
  115998. * Returns true if enough samples have been taken to completely fill the sliding window
  115999. */
  116000. get isSaturated(): boolean;
  116001. /**
  116002. * Enables contributions to the sliding window sample set
  116003. */
  116004. enable(): void;
  116005. /**
  116006. * Disables contributions to the sliding window sample set
  116007. * Samples will not be interpolated over the disabled period
  116008. */
  116009. disable(): void;
  116010. /**
  116011. * Returns true if sampling is enabled
  116012. */
  116013. get isEnabled(): boolean;
  116014. /**
  116015. * Resets performance monitor
  116016. */
  116017. reset(): void;
  116018. }
  116019. /**
  116020. * RollingAverage
  116021. *
  116022. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116023. */
  116024. export class RollingAverage {
  116025. /**
  116026. * Current average
  116027. */
  116028. average: number;
  116029. /**
  116030. * Current variance
  116031. */
  116032. variance: number;
  116033. protected _samples: Array<number>;
  116034. protected _sampleCount: number;
  116035. protected _pos: number;
  116036. protected _m2: number;
  116037. /**
  116038. * constructor
  116039. * @param length The number of samples required to saturate the sliding window
  116040. */
  116041. constructor(length: number);
  116042. /**
  116043. * Adds a sample to the sample set
  116044. * @param v The sample value
  116045. */
  116046. add(v: number): void;
  116047. /**
  116048. * Returns previously added values or null if outside of history or outside the sliding window domain
  116049. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116050. * @return Value previously recorded with add() or null if outside of range
  116051. */
  116052. history(i: number): number;
  116053. /**
  116054. * Returns true if enough samples have been taken to completely fill the sliding window
  116055. * @return true if sample-set saturated
  116056. */
  116057. isSaturated(): boolean;
  116058. /**
  116059. * Resets the rolling average (equivalent to 0 samples taken so far)
  116060. */
  116061. reset(): void;
  116062. /**
  116063. * Wraps a value around the sample range boundaries
  116064. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116065. * @return Wrapped position in sample range
  116066. */
  116067. protected _wrapPosition(i: number): number;
  116068. }
  116069. }
  116070. declare module BABYLON {
  116071. /**
  116072. * This class is used to track a performance counter which is number based.
  116073. * The user has access to many properties which give statistics of different nature.
  116074. *
  116075. * The implementer can track two kinds of Performance Counter: time and count.
  116076. * 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.
  116077. * 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.
  116078. */
  116079. export class PerfCounter {
  116080. /**
  116081. * Gets or sets a global boolean to turn on and off all the counters
  116082. */
  116083. static Enabled: boolean;
  116084. /**
  116085. * Returns the smallest value ever
  116086. */
  116087. get min(): number;
  116088. /**
  116089. * Returns the biggest value ever
  116090. */
  116091. get max(): number;
  116092. /**
  116093. * Returns the average value since the performance counter is running
  116094. */
  116095. get average(): number;
  116096. /**
  116097. * Returns the average value of the last second the counter was monitored
  116098. */
  116099. get lastSecAverage(): number;
  116100. /**
  116101. * Returns the current value
  116102. */
  116103. get current(): number;
  116104. /**
  116105. * Gets the accumulated total
  116106. */
  116107. get total(): number;
  116108. /**
  116109. * Gets the total value count
  116110. */
  116111. get count(): number;
  116112. /**
  116113. * Creates a new counter
  116114. */
  116115. constructor();
  116116. /**
  116117. * Call this method to start monitoring a new frame.
  116118. * 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.
  116119. */
  116120. fetchNewFrame(): void;
  116121. /**
  116122. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116123. * @param newCount the count value to add to the monitored count
  116124. * @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.
  116125. */
  116126. addCount(newCount: number, fetchResult: boolean): void;
  116127. /**
  116128. * Start monitoring this performance counter
  116129. */
  116130. beginMonitoring(): void;
  116131. /**
  116132. * Compute the time lapsed since the previous beginMonitoring() call.
  116133. * @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
  116134. */
  116135. endMonitoring(newFrame?: boolean): void;
  116136. private _fetchResult;
  116137. private _startMonitoringTime;
  116138. private _min;
  116139. private _max;
  116140. private _average;
  116141. private _current;
  116142. private _totalValueCount;
  116143. private _totalAccumulated;
  116144. private _lastSecAverage;
  116145. private _lastSecAccumulated;
  116146. private _lastSecTime;
  116147. private _lastSecValueCount;
  116148. }
  116149. }
  116150. declare module BABYLON {
  116151. interface ThinEngine {
  116152. /**
  116153. * Sets alpha constants used by some alpha blending modes
  116154. * @param r defines the red component
  116155. * @param g defines the green component
  116156. * @param b defines the blue component
  116157. * @param a defines the alpha component
  116158. */
  116159. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  116160. /**
  116161. * Sets the current alpha mode
  116162. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116163. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116164. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116165. */
  116166. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116167. /**
  116168. * Gets the current alpha mode
  116169. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116170. * @returns the current alpha mode
  116171. */
  116172. getAlphaMode(): number;
  116173. /**
  116174. * Sets the current alpha equation
  116175. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  116176. */
  116177. setAlphaEquation(equation: number): void;
  116178. /**
  116179. * Gets the current alpha equation.
  116180. * @returns the current alpha equation
  116181. */
  116182. getAlphaEquation(): number;
  116183. }
  116184. }
  116185. declare module BABYLON {
  116186. interface ThinEngine {
  116187. /** @hidden */
  116188. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116189. }
  116190. }
  116191. declare module BABYLON {
  116192. /**
  116193. * Defines the interface used by display changed events
  116194. */
  116195. export interface IDisplayChangedEventArgs {
  116196. /** Gets the vrDisplay object (if any) */
  116197. vrDisplay: Nullable<any>;
  116198. /** Gets a boolean indicating if webVR is supported */
  116199. vrSupported: boolean;
  116200. }
  116201. /**
  116202. * Defines the interface used by objects containing a viewport (like a camera)
  116203. */
  116204. interface IViewportOwnerLike {
  116205. /**
  116206. * Gets or sets the viewport
  116207. */
  116208. viewport: IViewportLike;
  116209. }
  116210. /**
  116211. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116212. */
  116213. export class Engine extends ThinEngine {
  116214. /** Defines that alpha blending is disabled */
  116215. static readonly ALPHA_DISABLE: number;
  116216. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116217. static readonly ALPHA_ADD: number;
  116218. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116219. static readonly ALPHA_COMBINE: number;
  116220. /** Defines that alpha blending to DEST - SRC * DEST */
  116221. static readonly ALPHA_SUBTRACT: number;
  116222. /** Defines that alpha blending to SRC * DEST */
  116223. static readonly ALPHA_MULTIPLY: number;
  116224. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116225. static readonly ALPHA_MAXIMIZED: number;
  116226. /** Defines that alpha blending to SRC + DEST */
  116227. static readonly ALPHA_ONEONE: number;
  116228. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116229. static readonly ALPHA_PREMULTIPLIED: number;
  116230. /**
  116231. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116232. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116233. */
  116234. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116235. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116236. static readonly ALPHA_INTERPOLATE: number;
  116237. /**
  116238. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116239. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116240. */
  116241. static readonly ALPHA_SCREENMODE: number;
  116242. /** Defines that the ressource is not delayed*/
  116243. static readonly DELAYLOADSTATE_NONE: number;
  116244. /** Defines that the ressource was successfully delay loaded */
  116245. static readonly DELAYLOADSTATE_LOADED: number;
  116246. /** Defines that the ressource is currently delay loading */
  116247. static readonly DELAYLOADSTATE_LOADING: number;
  116248. /** Defines that the ressource is delayed and has not started loading */
  116249. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116251. static readonly NEVER: number;
  116252. /** 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 */
  116253. static readonly ALWAYS: number;
  116254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116255. static readonly LESS: number;
  116256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116257. static readonly EQUAL: number;
  116258. /** 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 */
  116259. static readonly LEQUAL: number;
  116260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116261. static readonly GREATER: number;
  116262. /** 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 */
  116263. static readonly GEQUAL: number;
  116264. /** 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 */
  116265. static readonly NOTEQUAL: number;
  116266. /** Passed to stencilOperation to specify that stencil value must be kept */
  116267. static readonly KEEP: number;
  116268. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116269. static readonly REPLACE: number;
  116270. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116271. static readonly INCR: number;
  116272. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116273. static readonly DECR: number;
  116274. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116275. static readonly INVERT: number;
  116276. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116277. static readonly INCR_WRAP: number;
  116278. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116279. static readonly DECR_WRAP: number;
  116280. /** Texture is not repeating outside of 0..1 UVs */
  116281. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116282. /** Texture is repeating outside of 0..1 UVs */
  116283. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116284. /** Texture is repeating and mirrored */
  116285. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116286. /** ALPHA */
  116287. static readonly TEXTUREFORMAT_ALPHA: number;
  116288. /** LUMINANCE */
  116289. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116290. /** LUMINANCE_ALPHA */
  116291. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116292. /** RGB */
  116293. static readonly TEXTUREFORMAT_RGB: number;
  116294. /** RGBA */
  116295. static readonly TEXTUREFORMAT_RGBA: number;
  116296. /** RED */
  116297. static readonly TEXTUREFORMAT_RED: number;
  116298. /** RED (2nd reference) */
  116299. static readonly TEXTUREFORMAT_R: number;
  116300. /** RG */
  116301. static readonly TEXTUREFORMAT_RG: number;
  116302. /** RED_INTEGER */
  116303. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116304. /** RED_INTEGER (2nd reference) */
  116305. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116306. /** RG_INTEGER */
  116307. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116308. /** RGB_INTEGER */
  116309. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116310. /** RGBA_INTEGER */
  116311. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116312. /** UNSIGNED_BYTE */
  116313. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116314. /** UNSIGNED_BYTE (2nd reference) */
  116315. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116316. /** FLOAT */
  116317. static readonly TEXTURETYPE_FLOAT: number;
  116318. /** HALF_FLOAT */
  116319. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116320. /** BYTE */
  116321. static readonly TEXTURETYPE_BYTE: number;
  116322. /** SHORT */
  116323. static readonly TEXTURETYPE_SHORT: number;
  116324. /** UNSIGNED_SHORT */
  116325. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116326. /** INT */
  116327. static readonly TEXTURETYPE_INT: number;
  116328. /** UNSIGNED_INT */
  116329. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116330. /** UNSIGNED_SHORT_4_4_4_4 */
  116331. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116332. /** UNSIGNED_SHORT_5_5_5_1 */
  116333. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116334. /** UNSIGNED_SHORT_5_6_5 */
  116335. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116336. /** UNSIGNED_INT_2_10_10_10_REV */
  116337. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116338. /** UNSIGNED_INT_24_8 */
  116339. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116340. /** UNSIGNED_INT_10F_11F_11F_REV */
  116341. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116342. /** UNSIGNED_INT_5_9_9_9_REV */
  116343. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116344. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116345. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116346. /** nearest is mag = nearest and min = nearest and mip = linear */
  116347. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116348. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116349. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116350. /** Trilinear is mag = linear and min = linear and mip = linear */
  116351. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116352. /** nearest is mag = nearest and min = nearest and mip = linear */
  116353. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116354. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116355. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116356. /** Trilinear is mag = linear and min = linear and mip = linear */
  116357. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116358. /** mag = nearest and min = nearest and mip = nearest */
  116359. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116360. /** mag = nearest and min = linear and mip = nearest */
  116361. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116362. /** mag = nearest and min = linear and mip = linear */
  116363. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116364. /** mag = nearest and min = linear and mip = none */
  116365. static readonly TEXTURE_NEAREST_LINEAR: number;
  116366. /** mag = nearest and min = nearest and mip = none */
  116367. static readonly TEXTURE_NEAREST_NEAREST: number;
  116368. /** mag = linear and min = nearest and mip = nearest */
  116369. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116370. /** mag = linear and min = nearest and mip = linear */
  116371. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116372. /** mag = linear and min = linear and mip = none */
  116373. static readonly TEXTURE_LINEAR_LINEAR: number;
  116374. /** mag = linear and min = nearest and mip = none */
  116375. static readonly TEXTURE_LINEAR_NEAREST: number;
  116376. /** Explicit coordinates mode */
  116377. static readonly TEXTURE_EXPLICIT_MODE: number;
  116378. /** Spherical coordinates mode */
  116379. static readonly TEXTURE_SPHERICAL_MODE: number;
  116380. /** Planar coordinates mode */
  116381. static readonly TEXTURE_PLANAR_MODE: number;
  116382. /** Cubic coordinates mode */
  116383. static readonly TEXTURE_CUBIC_MODE: number;
  116384. /** Projection coordinates mode */
  116385. static readonly TEXTURE_PROJECTION_MODE: number;
  116386. /** Skybox coordinates mode */
  116387. static readonly TEXTURE_SKYBOX_MODE: number;
  116388. /** Inverse Cubic coordinates mode */
  116389. static readonly TEXTURE_INVCUBIC_MODE: number;
  116390. /** Equirectangular coordinates mode */
  116391. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116392. /** Equirectangular Fixed coordinates mode */
  116393. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116394. /** Equirectangular Fixed Mirrored coordinates mode */
  116395. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116396. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116397. static readonly SCALEMODE_FLOOR: number;
  116398. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116399. static readonly SCALEMODE_NEAREST: number;
  116400. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116401. static readonly SCALEMODE_CEILING: number;
  116402. /**
  116403. * Returns the current npm package of the sdk
  116404. */
  116405. static get NpmPackage(): string;
  116406. /**
  116407. * Returns the current version of the framework
  116408. */
  116409. static get Version(): string;
  116410. /** Gets the list of created engines */
  116411. static get Instances(): Engine[];
  116412. /**
  116413. * Gets the latest created engine
  116414. */
  116415. static get LastCreatedEngine(): Nullable<Engine>;
  116416. /**
  116417. * Gets the latest created scene
  116418. */
  116419. static get LastCreatedScene(): Nullable<Scene>;
  116420. /**
  116421. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116422. * @param flag defines which part of the materials must be marked as dirty
  116423. * @param predicate defines a predicate used to filter which materials should be affected
  116424. */
  116425. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116426. /**
  116427. * Method called to create the default loading screen.
  116428. * This can be overriden in your own app.
  116429. * @param canvas The rendering canvas element
  116430. * @returns The loading screen
  116431. */
  116432. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116433. /**
  116434. * Method called to create the default rescale post process on each engine.
  116435. */
  116436. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116437. /**
  116438. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116439. **/
  116440. enableOfflineSupport: boolean;
  116441. /**
  116442. * 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)
  116443. **/
  116444. disableManifestCheck: boolean;
  116445. /**
  116446. * Gets the list of created scenes
  116447. */
  116448. scenes: Scene[];
  116449. /**
  116450. * Event raised when a new scene is created
  116451. */
  116452. onNewSceneAddedObservable: Observable<Scene>;
  116453. /**
  116454. * Gets the list of created postprocesses
  116455. */
  116456. postProcesses: PostProcess[];
  116457. /**
  116458. * Gets a boolean indicating if the pointer is currently locked
  116459. */
  116460. isPointerLock: boolean;
  116461. /**
  116462. * Observable event triggered each time the rendering canvas is resized
  116463. */
  116464. onResizeObservable: Observable<Engine>;
  116465. /**
  116466. * Observable event triggered each time the canvas loses focus
  116467. */
  116468. onCanvasBlurObservable: Observable<Engine>;
  116469. /**
  116470. * Observable event triggered each time the canvas gains focus
  116471. */
  116472. onCanvasFocusObservable: Observable<Engine>;
  116473. /**
  116474. * Observable event triggered each time the canvas receives pointerout event
  116475. */
  116476. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116477. /**
  116478. * Observable raised when the engine begins a new frame
  116479. */
  116480. onBeginFrameObservable: Observable<Engine>;
  116481. /**
  116482. * If set, will be used to request the next animation frame for the render loop
  116483. */
  116484. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116485. /**
  116486. * Observable raised when the engine ends the current frame
  116487. */
  116488. onEndFrameObservable: Observable<Engine>;
  116489. /**
  116490. * Observable raised when the engine is about to compile a shader
  116491. */
  116492. onBeforeShaderCompilationObservable: Observable<Engine>;
  116493. /**
  116494. * Observable raised when the engine has jsut compiled a shader
  116495. */
  116496. onAfterShaderCompilationObservable: Observable<Engine>;
  116497. /**
  116498. * Gets the audio engine
  116499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116500. * @ignorenaming
  116501. */
  116502. static audioEngine: IAudioEngine;
  116503. /**
  116504. * Default AudioEngine factory responsible of creating the Audio Engine.
  116505. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116506. */
  116507. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116508. /**
  116509. * Default offline support factory responsible of creating a tool used to store data locally.
  116510. * By default, this will create a Database object if the workload has been embedded.
  116511. */
  116512. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116513. private _loadingScreen;
  116514. private _pointerLockRequested;
  116515. private _rescalePostProcess;
  116516. private _deterministicLockstep;
  116517. private _lockstepMaxSteps;
  116518. private _timeStep;
  116519. protected get _supportsHardwareTextureRescaling(): boolean;
  116520. private _fps;
  116521. private _deltaTime;
  116522. /** @hidden */
  116523. _drawCalls: PerfCounter;
  116524. /** 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 */
  116525. canvasTabIndex: number;
  116526. /**
  116527. * Turn this value on if you want to pause FPS computation when in background
  116528. */
  116529. disablePerformanceMonitorInBackground: boolean;
  116530. private _performanceMonitor;
  116531. /**
  116532. * Gets the performance monitor attached to this engine
  116533. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116534. */
  116535. get performanceMonitor(): PerformanceMonitor;
  116536. private _onFocus;
  116537. private _onBlur;
  116538. private _onCanvasPointerOut;
  116539. private _onCanvasBlur;
  116540. private _onCanvasFocus;
  116541. private _onFullscreenChange;
  116542. private _onPointerLockChange;
  116543. /**
  116544. * Gets the HTML element used to attach event listeners
  116545. * @returns a HTML element
  116546. */
  116547. getInputElement(): Nullable<HTMLElement>;
  116548. /**
  116549. * Creates a new engine
  116550. * @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
  116551. * @param antialias defines enable antialiasing (default: false)
  116552. * @param options defines further options to be sent to the getContext() function
  116553. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116554. */
  116555. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116556. /**
  116557. * Gets current aspect ratio
  116558. * @param viewportOwner defines the camera to use to get the aspect ratio
  116559. * @param useScreen defines if screen size must be used (or the current render target if any)
  116560. * @returns a number defining the aspect ratio
  116561. */
  116562. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116563. /**
  116564. * Gets current screen aspect ratio
  116565. * @returns a number defining the aspect ratio
  116566. */
  116567. getScreenAspectRatio(): number;
  116568. /**
  116569. * Gets the client rect of the HTML canvas attached with the current webGL context
  116570. * @returns a client rectanglee
  116571. */
  116572. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116573. /**
  116574. * Gets the client rect of the HTML element used for events
  116575. * @returns a client rectanglee
  116576. */
  116577. getInputElementClientRect(): Nullable<ClientRect>;
  116578. /**
  116579. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116581. * @returns true if engine is in deterministic lock step mode
  116582. */
  116583. isDeterministicLockStep(): boolean;
  116584. /**
  116585. * Gets the max steps when engine is running in deterministic lock step
  116586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116587. * @returns the max steps
  116588. */
  116589. getLockstepMaxSteps(): number;
  116590. /**
  116591. * Returns the time in ms between steps when using deterministic lock step.
  116592. * @returns time step in (ms)
  116593. */
  116594. getTimeStep(): number;
  116595. /**
  116596. * Force the mipmap generation for the given render target texture
  116597. * @param texture defines the render target texture to use
  116598. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116599. */
  116600. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116601. /** States */
  116602. /**
  116603. * Set various states to the webGL context
  116604. * @param culling defines backface culling state
  116605. * @param zOffset defines the value to apply to zOffset (0 by default)
  116606. * @param force defines if states must be applied even if cache is up to date
  116607. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116608. */
  116609. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116610. /**
  116611. * Set the z offset to apply to current rendering
  116612. * @param value defines the offset to apply
  116613. */
  116614. setZOffset(value: number): void;
  116615. /**
  116616. * Gets the current value of the zOffset
  116617. * @returns the current zOffset state
  116618. */
  116619. getZOffset(): number;
  116620. /**
  116621. * Enable or disable depth buffering
  116622. * @param enable defines the state to set
  116623. */
  116624. setDepthBuffer(enable: boolean): void;
  116625. /**
  116626. * Gets a boolean indicating if depth writing is enabled
  116627. * @returns the current depth writing state
  116628. */
  116629. getDepthWrite(): boolean;
  116630. /**
  116631. * Enable or disable depth writing
  116632. * @param enable defines the state to set
  116633. */
  116634. setDepthWrite(enable: boolean): void;
  116635. /**
  116636. * Gets a boolean indicating if stencil buffer is enabled
  116637. * @returns the current stencil buffer state
  116638. */
  116639. getStencilBuffer(): boolean;
  116640. /**
  116641. * Enable or disable the stencil buffer
  116642. * @param enable defines if the stencil buffer must be enabled or disabled
  116643. */
  116644. setStencilBuffer(enable: boolean): void;
  116645. /**
  116646. * Gets the current stencil mask
  116647. * @returns a number defining the new stencil mask to use
  116648. */
  116649. getStencilMask(): number;
  116650. /**
  116651. * Sets the current stencil mask
  116652. * @param mask defines the new stencil mask to use
  116653. */
  116654. setStencilMask(mask: number): void;
  116655. /**
  116656. * Gets the current stencil function
  116657. * @returns a number defining the stencil function to use
  116658. */
  116659. getStencilFunction(): number;
  116660. /**
  116661. * Gets the current stencil reference value
  116662. * @returns a number defining the stencil reference value to use
  116663. */
  116664. getStencilFunctionReference(): number;
  116665. /**
  116666. * Gets the current stencil mask
  116667. * @returns a number defining the stencil mask to use
  116668. */
  116669. getStencilFunctionMask(): number;
  116670. /**
  116671. * Sets the current stencil function
  116672. * @param stencilFunc defines the new stencil function to use
  116673. */
  116674. setStencilFunction(stencilFunc: number): void;
  116675. /**
  116676. * Sets the current stencil reference
  116677. * @param reference defines the new stencil reference to use
  116678. */
  116679. setStencilFunctionReference(reference: number): void;
  116680. /**
  116681. * Sets the current stencil mask
  116682. * @param mask defines the new stencil mask to use
  116683. */
  116684. setStencilFunctionMask(mask: number): void;
  116685. /**
  116686. * Gets the current stencil operation when stencil fails
  116687. * @returns a number defining stencil operation to use when stencil fails
  116688. */
  116689. getStencilOperationFail(): number;
  116690. /**
  116691. * Gets the current stencil operation when depth fails
  116692. * @returns a number defining stencil operation to use when depth fails
  116693. */
  116694. getStencilOperationDepthFail(): number;
  116695. /**
  116696. * Gets the current stencil operation when stencil passes
  116697. * @returns a number defining stencil operation to use when stencil passes
  116698. */
  116699. getStencilOperationPass(): number;
  116700. /**
  116701. * Sets the stencil operation to use when stencil fails
  116702. * @param operation defines the stencil operation to use when stencil fails
  116703. */
  116704. setStencilOperationFail(operation: number): void;
  116705. /**
  116706. * Sets the stencil operation to use when depth fails
  116707. * @param operation defines the stencil operation to use when depth fails
  116708. */
  116709. setStencilOperationDepthFail(operation: number): void;
  116710. /**
  116711. * Sets the stencil operation to use when stencil passes
  116712. * @param operation defines the stencil operation to use when stencil passes
  116713. */
  116714. setStencilOperationPass(operation: number): void;
  116715. /**
  116716. * Sets a boolean indicating if the dithering state is enabled or disabled
  116717. * @param value defines the dithering state
  116718. */
  116719. setDitheringState(value: boolean): void;
  116720. /**
  116721. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116722. * @param value defines the rasterizer state
  116723. */
  116724. setRasterizerState(value: boolean): void;
  116725. /**
  116726. * Gets the current depth function
  116727. * @returns a number defining the depth function
  116728. */
  116729. getDepthFunction(): Nullable<number>;
  116730. /**
  116731. * Sets the current depth function
  116732. * @param depthFunc defines the function to use
  116733. */
  116734. setDepthFunction(depthFunc: number): void;
  116735. /**
  116736. * Sets the current depth function to GREATER
  116737. */
  116738. setDepthFunctionToGreater(): void;
  116739. /**
  116740. * Sets the current depth function to GEQUAL
  116741. */
  116742. setDepthFunctionToGreaterOrEqual(): void;
  116743. /**
  116744. * Sets the current depth function to LESS
  116745. */
  116746. setDepthFunctionToLess(): void;
  116747. /**
  116748. * Sets the current depth function to LEQUAL
  116749. */
  116750. setDepthFunctionToLessOrEqual(): void;
  116751. private _cachedStencilBuffer;
  116752. private _cachedStencilFunction;
  116753. private _cachedStencilMask;
  116754. private _cachedStencilOperationPass;
  116755. private _cachedStencilOperationFail;
  116756. private _cachedStencilOperationDepthFail;
  116757. private _cachedStencilReference;
  116758. /**
  116759. * Caches the the state of the stencil buffer
  116760. */
  116761. cacheStencilState(): void;
  116762. /**
  116763. * Restores the state of the stencil buffer
  116764. */
  116765. restoreStencilState(): void;
  116766. /**
  116767. * Directly set the WebGL Viewport
  116768. * @param x defines the x coordinate of the viewport (in screen space)
  116769. * @param y defines the y coordinate of the viewport (in screen space)
  116770. * @param width defines the width of the viewport (in screen space)
  116771. * @param height defines the height of the viewport (in screen space)
  116772. * @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
  116773. */
  116774. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116775. /**
  116776. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116777. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116778. * @param y defines the y-coordinate of the corner of the clear rectangle
  116779. * @param width defines the width of the clear rectangle
  116780. * @param height defines the height of the clear rectangle
  116781. * @param clearColor defines the clear color
  116782. */
  116783. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116784. /**
  116785. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116786. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116787. * @param y defines the y-coordinate of the corner of the clear rectangle
  116788. * @param width defines the width of the clear rectangle
  116789. * @param height defines the height of the clear rectangle
  116790. */
  116791. enableScissor(x: number, y: number, width: number, height: number): void;
  116792. /**
  116793. * Disable previously set scissor test rectangle
  116794. */
  116795. disableScissor(): void;
  116796. protected _reportDrawCall(): void;
  116797. /**
  116798. * Initializes a webVR display and starts listening to display change events
  116799. * The onVRDisplayChangedObservable will be notified upon these changes
  116800. * @returns The onVRDisplayChangedObservable
  116801. */
  116802. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116803. /** @hidden */
  116804. _prepareVRComponent(): void;
  116805. /** @hidden */
  116806. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116807. /** @hidden */
  116808. _submitVRFrame(): void;
  116809. /**
  116810. * Call this function to leave webVR mode
  116811. * Will do nothing if webVR is not supported or if there is no webVR device
  116812. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116813. */
  116814. disableVR(): void;
  116815. /**
  116816. * Gets a boolean indicating that the system is in VR mode and is presenting
  116817. * @returns true if VR mode is engaged
  116818. */
  116819. isVRPresenting(): boolean;
  116820. /** @hidden */
  116821. _requestVRFrame(): void;
  116822. /** @hidden */
  116823. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116824. /**
  116825. * Gets the source code of the vertex shader associated with a specific webGL program
  116826. * @param program defines the program to use
  116827. * @returns a string containing the source code of the vertex shader associated with the program
  116828. */
  116829. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116830. /**
  116831. * Gets the source code of the fragment shader associated with a specific webGL program
  116832. * @param program defines the program to use
  116833. * @returns a string containing the source code of the fragment shader associated with the program
  116834. */
  116835. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116836. /**
  116837. * Sets a depth stencil texture from a render target to the according uniform.
  116838. * @param channel The texture channel
  116839. * @param uniform The uniform to set
  116840. * @param texture The render target texture containing the depth stencil texture to apply
  116841. */
  116842. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116843. /**
  116844. * Sets a texture to the webGL context from a postprocess
  116845. * @param channel defines the channel to use
  116846. * @param postProcess defines the source postprocess
  116847. */
  116848. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116849. /**
  116850. * Binds the output of the passed in post process to the texture channel specified
  116851. * @param channel The channel the texture should be bound to
  116852. * @param postProcess The post process which's output should be bound
  116853. */
  116854. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116855. protected _rebuildBuffers(): void;
  116856. /** @hidden */
  116857. _renderFrame(): void;
  116858. _renderLoop(): void;
  116859. /** @hidden */
  116860. _renderViews(): boolean;
  116861. /**
  116862. * Toggle full screen mode
  116863. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116864. */
  116865. switchFullscreen(requestPointerLock: boolean): void;
  116866. /**
  116867. * Enters full screen mode
  116868. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116869. */
  116870. enterFullscreen(requestPointerLock: boolean): void;
  116871. /**
  116872. * Exits full screen mode
  116873. */
  116874. exitFullscreen(): void;
  116875. /**
  116876. * Enters Pointerlock mode
  116877. */
  116878. enterPointerlock(): void;
  116879. /**
  116880. * Exits Pointerlock mode
  116881. */
  116882. exitPointerlock(): void;
  116883. /**
  116884. * Begin a new frame
  116885. */
  116886. beginFrame(): void;
  116887. /**
  116888. * Enf the current frame
  116889. */
  116890. endFrame(): void;
  116891. resize(): void;
  116892. /**
  116893. * Force a specific size of the canvas
  116894. * @param width defines the new canvas' width
  116895. * @param height defines the new canvas' height
  116896. * @returns true if the size was changed
  116897. */
  116898. setSize(width: number, height: number): boolean;
  116899. /**
  116900. * Updates a dynamic vertex buffer.
  116901. * @param vertexBuffer the vertex buffer to update
  116902. * @param data the data used to update the vertex buffer
  116903. * @param byteOffset the byte offset of the data
  116904. * @param byteLength the byte length of the data
  116905. */
  116906. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116908. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116909. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116910. _releaseTexture(texture: InternalTexture): void;
  116911. /**
  116912. * @hidden
  116913. * Rescales a texture
  116914. * @param source input texutre
  116915. * @param destination destination texture
  116916. * @param scene scene to use to render the resize
  116917. * @param internalFormat format to use when resizing
  116918. * @param onComplete callback to be called when resize has completed
  116919. */
  116920. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116921. /**
  116922. * Gets the current framerate
  116923. * @returns a number representing the framerate
  116924. */
  116925. getFps(): number;
  116926. /**
  116927. * Gets the time spent between current and previous frame
  116928. * @returns a number representing the delta time in ms
  116929. */
  116930. getDeltaTime(): number;
  116931. private _measureFps;
  116932. /** @hidden */
  116933. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116934. /**
  116935. * Update a dynamic index buffer
  116936. * @param indexBuffer defines the target index buffer
  116937. * @param indices defines the data to update
  116938. * @param offset defines the offset in the target index buffer where update should start
  116939. */
  116940. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116941. /**
  116942. * Updates the sample count of a render target texture
  116943. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116944. * @param texture defines the texture to update
  116945. * @param samples defines the sample count to set
  116946. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116947. */
  116948. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116949. /**
  116950. * Updates a depth texture Comparison Mode and Function.
  116951. * If the comparison Function is equal to 0, the mode will be set to none.
  116952. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116953. * @param texture The texture to set the comparison function for
  116954. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116955. */
  116956. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116957. /**
  116958. * Creates a webGL buffer to use with instanciation
  116959. * @param capacity defines the size of the buffer
  116960. * @returns the webGL buffer
  116961. */
  116962. createInstancesBuffer(capacity: number): DataBuffer;
  116963. /**
  116964. * Delete a webGL buffer used with instanciation
  116965. * @param buffer defines the webGL buffer to delete
  116966. */
  116967. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116968. private _clientWaitAsync;
  116969. /** @hidden */
  116970. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116971. dispose(): void;
  116972. private _disableTouchAction;
  116973. /**
  116974. * Display the loading screen
  116975. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116976. */
  116977. displayLoadingUI(): void;
  116978. /**
  116979. * Hide the loading screen
  116980. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116981. */
  116982. hideLoadingUI(): void;
  116983. /**
  116984. * Gets the current loading screen object
  116985. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116986. */
  116987. get loadingScreen(): ILoadingScreen;
  116988. /**
  116989. * Sets the current loading screen object
  116990. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116991. */
  116992. set loadingScreen(loadingScreen: ILoadingScreen);
  116993. /**
  116994. * Sets the current loading screen text
  116995. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116996. */
  116997. set loadingUIText(text: string);
  116998. /**
  116999. * Sets the current loading screen background color
  117000. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117001. */
  117002. set loadingUIBackgroundColor(color: string);
  117003. /** Pointerlock and fullscreen */
  117004. /**
  117005. * Ask the browser to promote the current element to pointerlock mode
  117006. * @param element defines the DOM element to promote
  117007. */
  117008. static _RequestPointerlock(element: HTMLElement): void;
  117009. /**
  117010. * Asks the browser to exit pointerlock mode
  117011. */
  117012. static _ExitPointerlock(): void;
  117013. /**
  117014. * Ask the browser to promote the current element to fullscreen rendering mode
  117015. * @param element defines the DOM element to promote
  117016. */
  117017. static _RequestFullscreen(element: HTMLElement): void;
  117018. /**
  117019. * Asks the browser to exit fullscreen mode
  117020. */
  117021. static _ExitFullscreen(): void;
  117022. }
  117023. }
  117024. declare module BABYLON {
  117025. /**
  117026. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117027. * during the life time of the application.
  117028. */
  117029. export class EngineStore {
  117030. /** Gets the list of created engines */
  117031. static Instances: Engine[];
  117032. /** @hidden */
  117033. static _LastCreatedScene: Nullable<Scene>;
  117034. /**
  117035. * Gets the latest created engine
  117036. */
  117037. static get LastCreatedEngine(): Nullable<Engine>;
  117038. /**
  117039. * Gets the latest created scene
  117040. */
  117041. static get LastCreatedScene(): Nullable<Scene>;
  117042. /**
  117043. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117044. * @ignorenaming
  117045. */
  117046. static UseFallbackTexture: boolean;
  117047. /**
  117048. * Texture content used if a texture cannot loaded
  117049. * @ignorenaming
  117050. */
  117051. static FallbackTexture: string;
  117052. }
  117053. }
  117054. declare module BABYLON {
  117055. /**
  117056. * Helper class that provides a small promise polyfill
  117057. */
  117058. export class PromisePolyfill {
  117059. /**
  117060. * Static function used to check if the polyfill is required
  117061. * If this is the case then the function will inject the polyfill to window.Promise
  117062. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117063. */
  117064. static Apply(force?: boolean): void;
  117065. }
  117066. }
  117067. declare module BABYLON {
  117068. /**
  117069. * Interface for screenshot methods with describe argument called `size` as object with options
  117070. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117071. */
  117072. export interface IScreenshotSize {
  117073. /**
  117074. * number in pixels for canvas height
  117075. */
  117076. height?: number;
  117077. /**
  117078. * multiplier allowing render at a higher or lower resolution
  117079. * If value is defined then height and width will be ignored and taken from camera
  117080. */
  117081. precision?: number;
  117082. /**
  117083. * number in pixels for canvas width
  117084. */
  117085. width?: number;
  117086. }
  117087. }
  117088. declare module BABYLON {
  117089. interface IColor4Like {
  117090. r: float;
  117091. g: float;
  117092. b: float;
  117093. a: float;
  117094. }
  117095. /**
  117096. * Class containing a set of static utilities functions
  117097. */
  117098. export class Tools {
  117099. /**
  117100. * Gets or sets the base URL to use to load assets
  117101. */
  117102. static get BaseUrl(): string;
  117103. static set BaseUrl(value: string);
  117104. /**
  117105. * Enable/Disable Custom HTTP Request Headers globally.
  117106. * default = false
  117107. * @see CustomRequestHeaders
  117108. */
  117109. static UseCustomRequestHeaders: boolean;
  117110. /**
  117111. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117112. * i.e. when loading files, where the server/service expects an Authorization header
  117113. */
  117114. static CustomRequestHeaders: {
  117115. [key: string]: string;
  117116. };
  117117. /**
  117118. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117119. */
  117120. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117121. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117122. /**
  117123. * Default behaviour for cors in the application.
  117124. * It can be a string if the expected behavior is identical in the entire app.
  117125. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117126. */
  117127. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117128. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117129. /**
  117130. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117131. * @ignorenaming
  117132. */
  117133. static get UseFallbackTexture(): boolean;
  117134. static set UseFallbackTexture(value: boolean);
  117135. /**
  117136. * Use this object to register external classes like custom textures or material
  117137. * to allow the laoders to instantiate them
  117138. */
  117139. static get RegisteredExternalClasses(): {
  117140. [key: string]: Object;
  117141. };
  117142. static set RegisteredExternalClasses(classes: {
  117143. [key: string]: Object;
  117144. });
  117145. /**
  117146. * Texture content used if a texture cannot loaded
  117147. * @ignorenaming
  117148. */
  117149. static get fallbackTexture(): string;
  117150. static set fallbackTexture(value: string);
  117151. /**
  117152. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117153. * @param u defines the coordinate on X axis
  117154. * @param v defines the coordinate on Y axis
  117155. * @param width defines the width of the source data
  117156. * @param height defines the height of the source data
  117157. * @param pixels defines the source byte array
  117158. * @param color defines the output color
  117159. */
  117160. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117161. /**
  117162. * Interpolates between a and b via alpha
  117163. * @param a The lower value (returned when alpha = 0)
  117164. * @param b The upper value (returned when alpha = 1)
  117165. * @param alpha The interpolation-factor
  117166. * @return The mixed value
  117167. */
  117168. static Mix(a: number, b: number, alpha: number): number;
  117169. /**
  117170. * Tries to instantiate a new object from a given class name
  117171. * @param className defines the class name to instantiate
  117172. * @returns the new object or null if the system was not able to do the instantiation
  117173. */
  117174. static Instantiate(className: string): any;
  117175. /**
  117176. * Provides a slice function that will work even on IE
  117177. * @param data defines the array to slice
  117178. * @param start defines the start of the data (optional)
  117179. * @param end defines the end of the data (optional)
  117180. * @returns the new sliced array
  117181. */
  117182. static Slice<T>(data: T, start?: number, end?: number): T;
  117183. /**
  117184. * Polyfill for setImmediate
  117185. * @param action defines the action to execute after the current execution block
  117186. */
  117187. static SetImmediate(action: () => void): void;
  117188. /**
  117189. * Function indicating if a number is an exponent of 2
  117190. * @param value defines the value to test
  117191. * @returns true if the value is an exponent of 2
  117192. */
  117193. static IsExponentOfTwo(value: number): boolean;
  117194. private static _tmpFloatArray;
  117195. /**
  117196. * Returns the nearest 32-bit single precision float representation of a Number
  117197. * @param value A Number. If the parameter is of a different type, it will get converted
  117198. * to a number or to NaN if it cannot be converted
  117199. * @returns number
  117200. */
  117201. static FloatRound(value: number): number;
  117202. /**
  117203. * Extracts the filename from a path
  117204. * @param path defines the path to use
  117205. * @returns the filename
  117206. */
  117207. static GetFilename(path: string): string;
  117208. /**
  117209. * Extracts the "folder" part of a path (everything before the filename).
  117210. * @param uri The URI to extract the info from
  117211. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117212. * @returns The "folder" part of the path
  117213. */
  117214. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117215. /**
  117216. * Extracts text content from a DOM element hierarchy
  117217. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117218. */
  117219. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117220. /**
  117221. * Convert an angle in radians to degrees
  117222. * @param angle defines the angle to convert
  117223. * @returns the angle in degrees
  117224. */
  117225. static ToDegrees(angle: number): number;
  117226. /**
  117227. * Convert an angle in degrees to radians
  117228. * @param angle defines the angle to convert
  117229. * @returns the angle in radians
  117230. */
  117231. static ToRadians(angle: number): number;
  117232. /**
  117233. * Returns an array if obj is not an array
  117234. * @param obj defines the object to evaluate as an array
  117235. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117236. * @returns either obj directly if obj is an array or a new array containing obj
  117237. */
  117238. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117239. /**
  117240. * Gets the pointer prefix to use
  117241. * @param engine defines the engine we are finding the prefix for
  117242. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117243. */
  117244. static GetPointerPrefix(engine: Engine): string;
  117245. /**
  117246. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117247. * @param url define the url we are trying
  117248. * @param element define the dom element where to configure the cors policy
  117249. */
  117250. static SetCorsBehavior(url: string | string[], element: {
  117251. crossOrigin: string | null;
  117252. }): void;
  117253. /**
  117254. * Removes unwanted characters from an url
  117255. * @param url defines the url to clean
  117256. * @returns the cleaned url
  117257. */
  117258. static CleanUrl(url: string): string;
  117259. /**
  117260. * Gets or sets a function used to pre-process url before using them to load assets
  117261. */
  117262. static get PreprocessUrl(): (url: string) => string;
  117263. static set PreprocessUrl(processor: (url: string) => string);
  117264. /**
  117265. * Loads an image as an HTMLImageElement.
  117266. * @param input url string, ArrayBuffer, or Blob to load
  117267. * @param onLoad callback called when the image successfully loads
  117268. * @param onError callback called when the image fails to load
  117269. * @param offlineProvider offline provider for caching
  117270. * @param mimeType optional mime type
  117271. * @returns the HTMLImageElement of the loaded image
  117272. */
  117273. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117274. /**
  117275. * Loads a file from a url
  117276. * @param url url string, ArrayBuffer, or Blob to load
  117277. * @param onSuccess callback called when the file successfully loads
  117278. * @param onProgress callback called while file is loading (if the server supports this mode)
  117279. * @param offlineProvider defines the offline provider for caching
  117280. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117281. * @param onError callback called when the file fails to load
  117282. * @returns a file request object
  117283. */
  117284. 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;
  117285. /**
  117286. * Loads a file from a url
  117287. * @param url the file url to load
  117288. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117289. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117290. */
  117291. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117292. /**
  117293. * Load a script (identified by an url). When the url returns, the
  117294. * content of this file is added into a new script element, attached to the DOM (body element)
  117295. * @param scriptUrl defines the url of the script to laod
  117296. * @param onSuccess defines the callback called when the script is loaded
  117297. * @param onError defines the callback to call if an error occurs
  117298. * @param scriptId defines the id of the script element
  117299. */
  117300. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117301. /**
  117302. * Load an asynchronous script (identified by an url). When the url returns, the
  117303. * content of this file is added into a new script element, attached to the DOM (body element)
  117304. * @param scriptUrl defines the url of the script to laod
  117305. * @param scriptId defines the id of the script element
  117306. * @returns a promise request object
  117307. */
  117308. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117309. /**
  117310. * Loads a file from a blob
  117311. * @param fileToLoad defines the blob to use
  117312. * @param callback defines the callback to call when data is loaded
  117313. * @param progressCallback defines the callback to call during loading process
  117314. * @returns a file request object
  117315. */
  117316. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117317. /**
  117318. * Reads a file from a File object
  117319. * @param file defines the file to load
  117320. * @param onSuccess defines the callback to call when data is loaded
  117321. * @param onProgress defines the callback to call during loading process
  117322. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117323. * @param onError defines the callback to call when an error occurs
  117324. * @returns a file request object
  117325. */
  117326. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117327. /**
  117328. * Creates a data url from a given string content
  117329. * @param content defines the content to convert
  117330. * @returns the new data url link
  117331. */
  117332. static FileAsURL(content: string): string;
  117333. /**
  117334. * Format the given number to a specific decimal format
  117335. * @param value defines the number to format
  117336. * @param decimals defines the number of decimals to use
  117337. * @returns the formatted string
  117338. */
  117339. static Format(value: number, decimals?: number): string;
  117340. /**
  117341. * Tries to copy an object by duplicating every property
  117342. * @param source defines the source object
  117343. * @param destination defines the target object
  117344. * @param doNotCopyList defines a list of properties to avoid
  117345. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117346. */
  117347. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117348. /**
  117349. * Gets a boolean indicating if the given object has no own property
  117350. * @param obj defines the object to test
  117351. * @returns true if object has no own property
  117352. */
  117353. static IsEmpty(obj: any): boolean;
  117354. /**
  117355. * Function used to register events at window level
  117356. * @param windowElement defines the Window object to use
  117357. * @param events defines the events to register
  117358. */
  117359. static RegisterTopRootEvents(windowElement: Window, events: {
  117360. name: string;
  117361. handler: Nullable<(e: FocusEvent) => any>;
  117362. }[]): void;
  117363. /**
  117364. * Function used to unregister events from window level
  117365. * @param windowElement defines the Window object to use
  117366. * @param events defines the events to unregister
  117367. */
  117368. static UnregisterTopRootEvents(windowElement: Window, events: {
  117369. name: string;
  117370. handler: Nullable<(e: FocusEvent) => any>;
  117371. }[]): void;
  117372. /**
  117373. * @ignore
  117374. */
  117375. static _ScreenshotCanvas: HTMLCanvasElement;
  117376. /**
  117377. * Dumps the current bound framebuffer
  117378. * @param width defines the rendering width
  117379. * @param height defines the rendering height
  117380. * @param engine defines the hosting engine
  117381. * @param successCallback defines the callback triggered once the data are available
  117382. * @param mimeType defines the mime type of the result
  117383. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117384. */
  117385. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117386. /**
  117387. * Converts the canvas data to blob.
  117388. * This acts as a polyfill for browsers not supporting the to blob function.
  117389. * @param canvas Defines the canvas to extract the data from
  117390. * @param successCallback Defines the callback triggered once the data are available
  117391. * @param mimeType Defines the mime type of the result
  117392. */
  117393. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117394. /**
  117395. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117396. * @param successCallback defines the callback triggered once the data are available
  117397. * @param mimeType defines the mime type of the result
  117398. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117399. */
  117400. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117401. /**
  117402. * Downloads a blob in the browser
  117403. * @param blob defines the blob to download
  117404. * @param fileName defines the name of the downloaded file
  117405. */
  117406. static Download(blob: Blob, fileName: string): void;
  117407. /**
  117408. * Captures a screenshot of the current rendering
  117409. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117410. * @param engine defines the rendering engine
  117411. * @param camera defines the source camera
  117412. * @param size This parameter can be set to a single number or to an object with the
  117413. * following (optional) properties: precision, width, height. If a single number is passed,
  117414. * it will be used for both width and height. If an object is passed, the screenshot size
  117415. * will be derived from the parameters. The precision property is a multiplier allowing
  117416. * rendering at a higher or lower resolution
  117417. * @param successCallback defines the callback receives a single parameter which contains the
  117418. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117419. * src parameter of an <img> to display it
  117420. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117421. * Check your browser for supported MIME types
  117422. */
  117423. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117424. /**
  117425. * Captures a screenshot of the current rendering
  117426. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117427. * @param engine defines the rendering engine
  117428. * @param camera defines the source camera
  117429. * @param size This parameter can be set to a single number or to an object with the
  117430. * following (optional) properties: precision, width, height. If a single number is passed,
  117431. * it will be used for both width and height. If an object is passed, the screenshot size
  117432. * will be derived from the parameters. The precision property is a multiplier allowing
  117433. * rendering at a higher or lower resolution
  117434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117435. * Check your browser for supported MIME types
  117436. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117437. * to the src parameter of an <img> to display it
  117438. */
  117439. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117440. /**
  117441. * Generates an image screenshot from the specified camera.
  117442. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117443. * @param engine The engine to use for rendering
  117444. * @param camera The camera to use for rendering
  117445. * @param size This parameter can be set to a single number or to an object with the
  117446. * following (optional) properties: precision, width, height. If a single number is passed,
  117447. * it will be used for both width and height. If an object is passed, the screenshot size
  117448. * will be derived from the parameters. The precision property is a multiplier allowing
  117449. * rendering at a higher or lower resolution
  117450. * @param successCallback The callback receives a single parameter which contains the
  117451. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117452. * src parameter of an <img> to display it
  117453. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117454. * Check your browser for supported MIME types
  117455. * @param samples Texture samples (default: 1)
  117456. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117457. * @param fileName A name for for the downloaded file.
  117458. */
  117459. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117460. /**
  117461. * Generates an image screenshot from the specified camera.
  117462. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117463. * @param engine The engine to use for rendering
  117464. * @param camera The camera to use for rendering
  117465. * @param size This parameter can be set to a single number or to an object with the
  117466. * following (optional) properties: precision, width, height. If a single number is passed,
  117467. * it will be used for both width and height. If an object is passed, the screenshot size
  117468. * will be derived from the parameters. The precision property is a multiplier allowing
  117469. * rendering at a higher or lower resolution
  117470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117471. * Check your browser for supported MIME types
  117472. * @param samples Texture samples (default: 1)
  117473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117474. * @param fileName A name for for the downloaded file.
  117475. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117476. * to the src parameter of an <img> to display it
  117477. */
  117478. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117479. /**
  117480. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117481. * Be aware Math.random() could cause collisions, but:
  117482. * "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"
  117483. * @returns a pseudo random id
  117484. */
  117485. static RandomId(): string;
  117486. /**
  117487. * Test if the given uri is a base64 string
  117488. * @param uri The uri to test
  117489. * @return True if the uri is a base64 string or false otherwise
  117490. */
  117491. static IsBase64(uri: string): boolean;
  117492. /**
  117493. * Decode the given base64 uri.
  117494. * @param uri The uri to decode
  117495. * @return The decoded base64 data.
  117496. */
  117497. static DecodeBase64(uri: string): ArrayBuffer;
  117498. /**
  117499. * Gets the absolute url.
  117500. * @param url the input url
  117501. * @return the absolute url
  117502. */
  117503. static GetAbsoluteUrl(url: string): string;
  117504. /**
  117505. * No log
  117506. */
  117507. static readonly NoneLogLevel: number;
  117508. /**
  117509. * Only message logs
  117510. */
  117511. static readonly MessageLogLevel: number;
  117512. /**
  117513. * Only warning logs
  117514. */
  117515. static readonly WarningLogLevel: number;
  117516. /**
  117517. * Only error logs
  117518. */
  117519. static readonly ErrorLogLevel: number;
  117520. /**
  117521. * All logs
  117522. */
  117523. static readonly AllLogLevel: number;
  117524. /**
  117525. * Gets a value indicating the number of loading errors
  117526. * @ignorenaming
  117527. */
  117528. static get errorsCount(): number;
  117529. /**
  117530. * Callback called when a new log is added
  117531. */
  117532. static OnNewCacheEntry: (entry: string) => void;
  117533. /**
  117534. * Log a message to the console
  117535. * @param message defines the message to log
  117536. */
  117537. static Log(message: string): void;
  117538. /**
  117539. * Write a warning message to the console
  117540. * @param message defines the message to log
  117541. */
  117542. static Warn(message: string): void;
  117543. /**
  117544. * Write an error message to the console
  117545. * @param message defines the message to log
  117546. */
  117547. static Error(message: string): void;
  117548. /**
  117549. * Gets current log cache (list of logs)
  117550. */
  117551. static get LogCache(): string;
  117552. /**
  117553. * Clears the log cache
  117554. */
  117555. static ClearLogCache(): void;
  117556. /**
  117557. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117558. */
  117559. static set LogLevels(level: number);
  117560. /**
  117561. * Checks if the window object exists
  117562. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117563. */
  117564. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117565. /**
  117566. * No performance log
  117567. */
  117568. static readonly PerformanceNoneLogLevel: number;
  117569. /**
  117570. * Use user marks to log performance
  117571. */
  117572. static readonly PerformanceUserMarkLogLevel: number;
  117573. /**
  117574. * Log performance to the console
  117575. */
  117576. static readonly PerformanceConsoleLogLevel: number;
  117577. private static _performance;
  117578. /**
  117579. * Sets the current performance log level
  117580. */
  117581. static set PerformanceLogLevel(level: number);
  117582. private static _StartPerformanceCounterDisabled;
  117583. private static _EndPerformanceCounterDisabled;
  117584. private static _StartUserMark;
  117585. private static _EndUserMark;
  117586. private static _StartPerformanceConsole;
  117587. private static _EndPerformanceConsole;
  117588. /**
  117589. * Starts a performance counter
  117590. */
  117591. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117592. /**
  117593. * Ends a specific performance coutner
  117594. */
  117595. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117596. /**
  117597. * Gets either window.performance.now() if supported or Date.now() else
  117598. */
  117599. static get Now(): number;
  117600. /**
  117601. * This method will return the name of the class used to create the instance of the given object.
  117602. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117603. * @param object the object to get the class name from
  117604. * @param isType defines if the object is actually a type
  117605. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117606. */
  117607. static GetClassName(object: any, isType?: boolean): string;
  117608. /**
  117609. * Gets the first element of an array satisfying a given predicate
  117610. * @param array defines the array to browse
  117611. * @param predicate defines the predicate to use
  117612. * @returns null if not found or the element
  117613. */
  117614. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117615. /**
  117616. * This method will return the name of the full name of the class, including its owning module (if any).
  117617. * 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).
  117618. * @param object the object to get the class name from
  117619. * @param isType defines if the object is actually a type
  117620. * @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.
  117621. * @ignorenaming
  117622. */
  117623. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117624. /**
  117625. * Returns a promise that resolves after the given amount of time.
  117626. * @param delay Number of milliseconds to delay
  117627. * @returns Promise that resolves after the given amount of time
  117628. */
  117629. static DelayAsync(delay: number): Promise<void>;
  117630. /**
  117631. * Utility function to detect if the current user agent is Safari
  117632. * @returns whether or not the current user agent is safari
  117633. */
  117634. static IsSafari(): boolean;
  117635. }
  117636. /**
  117637. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117638. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117639. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117640. * @param name The name of the class, case should be preserved
  117641. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117642. */
  117643. export function className(name: string, module?: string): (target: Object) => void;
  117644. /**
  117645. * An implementation of a loop for asynchronous functions.
  117646. */
  117647. export class AsyncLoop {
  117648. /**
  117649. * Defines the number of iterations for the loop
  117650. */
  117651. iterations: number;
  117652. /**
  117653. * Defines the current index of the loop.
  117654. */
  117655. index: number;
  117656. private _done;
  117657. private _fn;
  117658. private _successCallback;
  117659. /**
  117660. * Constructor.
  117661. * @param iterations the number of iterations.
  117662. * @param func the function to run each iteration
  117663. * @param successCallback the callback that will be called upon succesful execution
  117664. * @param offset starting offset.
  117665. */
  117666. constructor(
  117667. /**
  117668. * Defines the number of iterations for the loop
  117669. */
  117670. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117671. /**
  117672. * Execute the next iteration. Must be called after the last iteration was finished.
  117673. */
  117674. executeNext(): void;
  117675. /**
  117676. * Break the loop and run the success callback.
  117677. */
  117678. breakLoop(): void;
  117679. /**
  117680. * Create and run an async loop.
  117681. * @param iterations the number of iterations.
  117682. * @param fn the function to run each iteration
  117683. * @param successCallback the callback that will be called upon succesful execution
  117684. * @param offset starting offset.
  117685. * @returns the created async loop object
  117686. */
  117687. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117688. /**
  117689. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117690. * @param iterations total number of iterations
  117691. * @param syncedIterations number of synchronous iterations in each async iteration.
  117692. * @param fn the function to call each iteration.
  117693. * @param callback a success call back that will be called when iterating stops.
  117694. * @param breakFunction a break condition (optional)
  117695. * @param timeout timeout settings for the setTimeout function. default - 0.
  117696. * @returns the created async loop object
  117697. */
  117698. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117699. }
  117700. }
  117701. declare module BABYLON {
  117702. /**
  117703. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117704. * The underlying implementation relies on an associative array to ensure the best performances.
  117705. * The value can be anything including 'null' but except 'undefined'
  117706. */
  117707. export class StringDictionary<T> {
  117708. /**
  117709. * This will clear this dictionary and copy the content from the 'source' one.
  117710. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117711. * @param source the dictionary to take the content from and copy to this dictionary
  117712. */
  117713. copyFrom(source: StringDictionary<T>): void;
  117714. /**
  117715. * Get a value based from its key
  117716. * @param key the given key to get the matching value from
  117717. * @return the value if found, otherwise undefined is returned
  117718. */
  117719. get(key: string): T | undefined;
  117720. /**
  117721. * Get a value from its key or add it if it doesn't exist.
  117722. * This method will ensure you that a given key/data will be present in the dictionary.
  117723. * @param key the given key to get the matching value from
  117724. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117725. * The factory will only be invoked if there's no data for the given key.
  117726. * @return the value corresponding to the key.
  117727. */
  117728. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117729. /**
  117730. * Get a value from its key if present in the dictionary otherwise add it
  117731. * @param key the key to get the value from
  117732. * @param val if there's no such key/value pair in the dictionary add it with this value
  117733. * @return the value corresponding to the key
  117734. */
  117735. getOrAdd(key: string, val: T): T;
  117736. /**
  117737. * Check if there's a given key in the dictionary
  117738. * @param key the key to check for
  117739. * @return true if the key is present, false otherwise
  117740. */
  117741. contains(key: string): boolean;
  117742. /**
  117743. * Add a new key and its corresponding value
  117744. * @param key the key to add
  117745. * @param value the value corresponding to the key
  117746. * @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
  117747. */
  117748. add(key: string, value: T): boolean;
  117749. /**
  117750. * Update a specific value associated to a key
  117751. * @param key defines the key to use
  117752. * @param value defines the value to store
  117753. * @returns true if the value was updated (or false if the key was not found)
  117754. */
  117755. set(key: string, value: T): boolean;
  117756. /**
  117757. * Get the element of the given key and remove it from the dictionary
  117758. * @param key defines the key to search
  117759. * @returns the value associated with the key or null if not found
  117760. */
  117761. getAndRemove(key: string): Nullable<T>;
  117762. /**
  117763. * Remove a key/value from the dictionary.
  117764. * @param key the key to remove
  117765. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117766. */
  117767. remove(key: string): boolean;
  117768. /**
  117769. * Clear the whole content of the dictionary
  117770. */
  117771. clear(): void;
  117772. /**
  117773. * Gets the current count
  117774. */
  117775. get count(): number;
  117776. /**
  117777. * Execute a callback on each key/val of the dictionary.
  117778. * Note that you can remove any element in this dictionary in the callback implementation
  117779. * @param callback the callback to execute on a given key/value pair
  117780. */
  117781. forEach(callback: (key: string, val: T) => void): void;
  117782. /**
  117783. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117784. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117785. * Note that you can remove any element in this dictionary in the callback implementation
  117786. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117787. * @returns the first item
  117788. */
  117789. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117790. private _count;
  117791. private _data;
  117792. }
  117793. }
  117794. declare module BABYLON {
  117795. /** @hidden */
  117796. export interface ICollisionCoordinator {
  117797. createCollider(): Collider;
  117798. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117799. init(scene: Scene): void;
  117800. }
  117801. /** @hidden */
  117802. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117803. private _scene;
  117804. private _scaledPosition;
  117805. private _scaledVelocity;
  117806. private _finalPosition;
  117807. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117808. createCollider(): Collider;
  117809. init(scene: Scene): void;
  117810. private _collideWithWorld;
  117811. }
  117812. }
  117813. declare module BABYLON {
  117814. /**
  117815. * Class used to manage all inputs for the scene.
  117816. */
  117817. export class InputManager {
  117818. /** The distance in pixel that you have to move to prevent some events */
  117819. static DragMovementThreshold: number;
  117820. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117821. static LongPressDelay: number;
  117822. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117823. static DoubleClickDelay: number;
  117824. /** If you need to check double click without raising a single click at first click, enable this flag */
  117825. static ExclusiveDoubleClickMode: boolean;
  117826. /** 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. */
  117827. private _alreadyAttached;
  117828. private _wheelEventName;
  117829. private _onPointerMove;
  117830. private _onPointerDown;
  117831. private _onPointerUp;
  117832. private _initClickEvent;
  117833. private _initActionManager;
  117834. private _delayedSimpleClick;
  117835. private _delayedSimpleClickTimeout;
  117836. private _previousDelayedSimpleClickTimeout;
  117837. private _meshPickProceed;
  117838. private _previousButtonPressed;
  117839. private _currentPickResult;
  117840. private _previousPickResult;
  117841. private _totalPointersPressed;
  117842. private _doubleClickOccured;
  117843. private _pointerOverMesh;
  117844. private _pickedDownMesh;
  117845. private _pickedUpMesh;
  117846. private _pointerX;
  117847. private _pointerY;
  117848. private _unTranslatedPointerX;
  117849. private _unTranslatedPointerY;
  117850. private _startingPointerPosition;
  117851. private _previousStartingPointerPosition;
  117852. private _startingPointerTime;
  117853. private _previousStartingPointerTime;
  117854. private _pointerCaptures;
  117855. private _onKeyDown;
  117856. private _onKeyUp;
  117857. private _onCanvasFocusObserver;
  117858. private _onCanvasBlurObserver;
  117859. private _scene;
  117860. /**
  117861. * Creates a new InputManager
  117862. * @param scene defines the hosting scene
  117863. */
  117864. constructor(scene: Scene);
  117865. /**
  117866. * Gets the mesh that is currently under the pointer
  117867. */
  117868. get meshUnderPointer(): Nullable<AbstractMesh>;
  117869. /**
  117870. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117871. */
  117872. get unTranslatedPointer(): Vector2;
  117873. /**
  117874. * Gets or sets the current on-screen X position of the pointer
  117875. */
  117876. get pointerX(): number;
  117877. set pointerX(value: number);
  117878. /**
  117879. * Gets or sets the current on-screen Y position of the pointer
  117880. */
  117881. get pointerY(): number;
  117882. set pointerY(value: number);
  117883. private _updatePointerPosition;
  117884. private _processPointerMove;
  117885. private _setRayOnPointerInfo;
  117886. private _checkPrePointerObservable;
  117887. /**
  117888. * Use this method to simulate a pointer move on a mesh
  117889. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117890. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117891. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117892. */
  117893. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117894. /**
  117895. * Use this method to simulate a pointer down on a mesh
  117896. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117897. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117898. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117899. */
  117900. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117901. private _processPointerDown;
  117902. /** @hidden */
  117903. _isPointerSwiping(): boolean;
  117904. /**
  117905. * Use this method to simulate a pointer up on a mesh
  117906. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117907. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117908. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117909. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117910. */
  117911. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117912. private _processPointerUp;
  117913. /**
  117914. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117915. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117916. * @returns true if the pointer was captured
  117917. */
  117918. isPointerCaptured(pointerId?: number): boolean;
  117919. /**
  117920. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117921. * @param attachUp defines if you want to attach events to pointerup
  117922. * @param attachDown defines if you want to attach events to pointerdown
  117923. * @param attachMove defines if you want to attach events to pointermove
  117924. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117925. */
  117926. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117927. /**
  117928. * Detaches all event handlers
  117929. */
  117930. detachControl(): void;
  117931. /**
  117932. * Force the value of meshUnderPointer
  117933. * @param mesh defines the mesh to use
  117934. */
  117935. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117936. /**
  117937. * Gets the mesh under the pointer
  117938. * @returns a Mesh or null if no mesh is under the pointer
  117939. */
  117940. getPointerOverMesh(): Nullable<AbstractMesh>;
  117941. }
  117942. }
  117943. declare module BABYLON {
  117944. /**
  117945. * This class defines the direct association between an animation and a target
  117946. */
  117947. export class TargetedAnimation {
  117948. /**
  117949. * Animation to perform
  117950. */
  117951. animation: Animation;
  117952. /**
  117953. * Target to animate
  117954. */
  117955. target: any;
  117956. /**
  117957. * Returns the string "TargetedAnimation"
  117958. * @returns "TargetedAnimation"
  117959. */
  117960. getClassName(): string;
  117961. /**
  117962. * Serialize the object
  117963. * @returns the JSON object representing the current entity
  117964. */
  117965. serialize(): any;
  117966. }
  117967. /**
  117968. * Use this class to create coordinated animations on multiple targets
  117969. */
  117970. export class AnimationGroup implements IDisposable {
  117971. /** The name of the animation group */
  117972. name: string;
  117973. private _scene;
  117974. private _targetedAnimations;
  117975. private _animatables;
  117976. private _from;
  117977. private _to;
  117978. private _isStarted;
  117979. private _isPaused;
  117980. private _speedRatio;
  117981. private _loopAnimation;
  117982. private _isAdditive;
  117983. /**
  117984. * Gets or sets the unique id of the node
  117985. */
  117986. uniqueId: number;
  117987. /**
  117988. * This observable will notify when one animation have ended
  117989. */
  117990. onAnimationEndObservable: Observable<TargetedAnimation>;
  117991. /**
  117992. * Observer raised when one animation loops
  117993. */
  117994. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117995. /**
  117996. * Observer raised when all animations have looped
  117997. */
  117998. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117999. /**
  118000. * This observable will notify when all animations have ended.
  118001. */
  118002. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118003. /**
  118004. * This observable will notify when all animations have paused.
  118005. */
  118006. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118007. /**
  118008. * This observable will notify when all animations are playing.
  118009. */
  118010. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118011. /**
  118012. * Gets the first frame
  118013. */
  118014. get from(): number;
  118015. /**
  118016. * Gets the last frame
  118017. */
  118018. get to(): number;
  118019. /**
  118020. * Define if the animations are started
  118021. */
  118022. get isStarted(): boolean;
  118023. /**
  118024. * Gets a value indicating that the current group is playing
  118025. */
  118026. get isPlaying(): boolean;
  118027. /**
  118028. * Gets or sets the speed ratio to use for all animations
  118029. */
  118030. get speedRatio(): number;
  118031. /**
  118032. * Gets or sets the speed ratio to use for all animations
  118033. */
  118034. set speedRatio(value: number);
  118035. /**
  118036. * Gets or sets if all animations should loop or not
  118037. */
  118038. get loopAnimation(): boolean;
  118039. set loopAnimation(value: boolean);
  118040. /**
  118041. * Gets or sets if all animations should be evaluated additively
  118042. */
  118043. get isAdditive(): boolean;
  118044. set isAdditive(value: boolean);
  118045. /**
  118046. * Gets the targeted animations for this animation group
  118047. */
  118048. get targetedAnimations(): Array<TargetedAnimation>;
  118049. /**
  118050. * returning the list of animatables controlled by this animation group.
  118051. */
  118052. get animatables(): Array<Animatable>;
  118053. /**
  118054. * Gets the list of target animations
  118055. */
  118056. get children(): TargetedAnimation[];
  118057. /**
  118058. * Instantiates a new Animation Group.
  118059. * This helps managing several animations at once.
  118060. * @see https://doc.babylonjs.com/how_to/group
  118061. * @param name Defines the name of the group
  118062. * @param scene Defines the scene the group belongs to
  118063. */
  118064. constructor(
  118065. /** The name of the animation group */
  118066. name: string, scene?: Nullable<Scene>);
  118067. /**
  118068. * Add an animation (with its target) in the group
  118069. * @param animation defines the animation we want to add
  118070. * @param target defines the target of the animation
  118071. * @returns the TargetedAnimation object
  118072. */
  118073. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118074. /**
  118075. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118076. * It can add constant keys at begin or end
  118077. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118078. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118079. * @returns the animation group
  118080. */
  118081. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118082. private _animationLoopCount;
  118083. private _animationLoopFlags;
  118084. private _processLoop;
  118085. /**
  118086. * Start all animations on given targets
  118087. * @param loop defines if animations must loop
  118088. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118089. * @param from defines the from key (optional)
  118090. * @param to defines the to key (optional)
  118091. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118092. * @returns the current animation group
  118093. */
  118094. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118095. /**
  118096. * Pause all animations
  118097. * @returns the animation group
  118098. */
  118099. pause(): AnimationGroup;
  118100. /**
  118101. * Play all animations to initial state
  118102. * This function will start() the animations if they were not started or will restart() them if they were paused
  118103. * @param loop defines if animations must loop
  118104. * @returns the animation group
  118105. */
  118106. play(loop?: boolean): AnimationGroup;
  118107. /**
  118108. * Reset all animations to initial state
  118109. * @returns the animation group
  118110. */
  118111. reset(): AnimationGroup;
  118112. /**
  118113. * Restart animations from key 0
  118114. * @returns the animation group
  118115. */
  118116. restart(): AnimationGroup;
  118117. /**
  118118. * Stop all animations
  118119. * @returns the animation group
  118120. */
  118121. stop(): AnimationGroup;
  118122. /**
  118123. * Set animation weight for all animatables
  118124. * @param weight defines the weight to use
  118125. * @return the animationGroup
  118126. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118127. */
  118128. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118129. /**
  118130. * Synchronize and normalize all animatables with a source animatable
  118131. * @param root defines the root animatable to synchronize with
  118132. * @return the animationGroup
  118133. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118134. */
  118135. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118136. /**
  118137. * Goes to a specific frame in this animation group
  118138. * @param frame the frame number to go to
  118139. * @return the animationGroup
  118140. */
  118141. goToFrame(frame: number): AnimationGroup;
  118142. /**
  118143. * Dispose all associated resources
  118144. */
  118145. dispose(): void;
  118146. private _checkAnimationGroupEnded;
  118147. /**
  118148. * Clone the current animation group and returns a copy
  118149. * @param newName defines the name of the new group
  118150. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118151. * @returns the new aniamtion group
  118152. */
  118153. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118154. /**
  118155. * Serializes the animationGroup to an object
  118156. * @returns Serialized object
  118157. */
  118158. serialize(): any;
  118159. /**
  118160. * Returns a new AnimationGroup object parsed from the source provided.
  118161. * @param parsedAnimationGroup defines the source
  118162. * @param scene defines the scene that will receive the animationGroup
  118163. * @returns a new AnimationGroup
  118164. */
  118165. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118166. /**
  118167. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118168. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118169. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118170. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118171. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118172. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118173. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118174. */
  118175. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118176. /**
  118177. * Returns the string "AnimationGroup"
  118178. * @returns "AnimationGroup"
  118179. */
  118180. getClassName(): string;
  118181. /**
  118182. * Creates a detailled string about the object
  118183. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118184. * @returns a string representing the object
  118185. */
  118186. toString(fullDetails?: boolean): string;
  118187. }
  118188. }
  118189. declare module BABYLON {
  118190. /**
  118191. * Define an interface for all classes that will hold resources
  118192. */
  118193. export interface IDisposable {
  118194. /**
  118195. * Releases all held resources
  118196. */
  118197. dispose(): void;
  118198. }
  118199. /** Interface defining initialization parameters for Scene class */
  118200. export interface SceneOptions {
  118201. /**
  118202. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118203. * It will improve performance when the number of geometries becomes important.
  118204. */
  118205. useGeometryUniqueIdsMap?: boolean;
  118206. /**
  118207. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118208. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118209. */
  118210. useMaterialMeshMap?: boolean;
  118211. /**
  118212. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118213. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118214. */
  118215. useClonedMeshMap?: boolean;
  118216. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118217. virtual?: boolean;
  118218. }
  118219. /**
  118220. * Represents a scene to be rendered by the engine.
  118221. * @see https://doc.babylonjs.com/features/scene
  118222. */
  118223. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118224. /** The fog is deactivated */
  118225. static readonly FOGMODE_NONE: number;
  118226. /** The fog density is following an exponential function */
  118227. static readonly FOGMODE_EXP: number;
  118228. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118229. static readonly FOGMODE_EXP2: number;
  118230. /** The fog density is following a linear function. */
  118231. static readonly FOGMODE_LINEAR: number;
  118232. /**
  118233. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118234. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118235. */
  118236. static MinDeltaTime: number;
  118237. /**
  118238. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118239. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118240. */
  118241. static MaxDeltaTime: number;
  118242. /**
  118243. * Factory used to create the default material.
  118244. * @param name The name of the material to create
  118245. * @param scene The scene to create the material for
  118246. * @returns The default material
  118247. */
  118248. static DefaultMaterialFactory(scene: Scene): Material;
  118249. /**
  118250. * Factory used to create the a collision coordinator.
  118251. * @returns The collision coordinator
  118252. */
  118253. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118254. /** @hidden */
  118255. _inputManager: InputManager;
  118256. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118257. cameraToUseForPointers: Nullable<Camera>;
  118258. /** @hidden */
  118259. readonly _isScene: boolean;
  118260. /** @hidden */
  118261. _blockEntityCollection: boolean;
  118262. /**
  118263. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118264. */
  118265. autoClear: boolean;
  118266. /**
  118267. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118268. */
  118269. autoClearDepthAndStencil: boolean;
  118270. /**
  118271. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118272. */
  118273. clearColor: Color4;
  118274. /**
  118275. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118276. */
  118277. ambientColor: Color3;
  118278. /**
  118279. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118280. * It should only be one of the following (if not the default embedded one):
  118281. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118282. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118283. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118284. * The material properties need to be setup according to the type of texture in use.
  118285. */
  118286. environmentBRDFTexture: BaseTexture;
  118287. /** @hidden */
  118288. protected _environmentTexture: Nullable<BaseTexture>;
  118289. /**
  118290. * Texture used in all pbr material as the reflection texture.
  118291. * As in the majority of the scene they are the same (exception for multi room and so on),
  118292. * this is easier to reference from here than from all the materials.
  118293. */
  118294. get environmentTexture(): Nullable<BaseTexture>;
  118295. /**
  118296. * Texture used in all pbr material as the reflection texture.
  118297. * As in the majority of the scene they are the same (exception for multi room and so on),
  118298. * this is easier to set here than in all the materials.
  118299. */
  118300. set environmentTexture(value: Nullable<BaseTexture>);
  118301. /** @hidden */
  118302. protected _environmentIntensity: number;
  118303. /**
  118304. * Intensity of the environment in all pbr material.
  118305. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118306. * As in the majority of the scene they are the same (exception for multi room and so on),
  118307. * this is easier to reference from here than from all the materials.
  118308. */
  118309. get environmentIntensity(): number;
  118310. /**
  118311. * Intensity of the environment in all pbr material.
  118312. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118313. * As in the majority of the scene they are the same (exception for multi room and so on),
  118314. * this is easier to set here than in all the materials.
  118315. */
  118316. set environmentIntensity(value: number);
  118317. /** @hidden */
  118318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118319. /**
  118320. * Default image processing configuration used either in the rendering
  118321. * Forward main pass or through the imageProcessingPostProcess if present.
  118322. * As in the majority of the scene they are the same (exception for multi camera),
  118323. * this is easier to reference from here than from all the materials and post process.
  118324. *
  118325. * No setter as we it is a shared configuration, you can set the values instead.
  118326. */
  118327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118328. private _forceWireframe;
  118329. /**
  118330. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118331. */
  118332. set forceWireframe(value: boolean);
  118333. get forceWireframe(): boolean;
  118334. private _skipFrustumClipping;
  118335. /**
  118336. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118337. */
  118338. set skipFrustumClipping(value: boolean);
  118339. get skipFrustumClipping(): boolean;
  118340. private _forcePointsCloud;
  118341. /**
  118342. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118343. */
  118344. set forcePointsCloud(value: boolean);
  118345. get forcePointsCloud(): boolean;
  118346. /**
  118347. * Gets or sets the active clipplane 1
  118348. */
  118349. clipPlane: Nullable<Plane>;
  118350. /**
  118351. * Gets or sets the active clipplane 2
  118352. */
  118353. clipPlane2: Nullable<Plane>;
  118354. /**
  118355. * Gets or sets the active clipplane 3
  118356. */
  118357. clipPlane3: Nullable<Plane>;
  118358. /**
  118359. * Gets or sets the active clipplane 4
  118360. */
  118361. clipPlane4: Nullable<Plane>;
  118362. /**
  118363. * Gets or sets the active clipplane 5
  118364. */
  118365. clipPlane5: Nullable<Plane>;
  118366. /**
  118367. * Gets or sets the active clipplane 6
  118368. */
  118369. clipPlane6: Nullable<Plane>;
  118370. /**
  118371. * Gets or sets a boolean indicating if animations are enabled
  118372. */
  118373. animationsEnabled: boolean;
  118374. private _animationPropertiesOverride;
  118375. /**
  118376. * Gets or sets the animation properties override
  118377. */
  118378. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118379. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118380. /**
  118381. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118382. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118383. */
  118384. useConstantAnimationDeltaTime: boolean;
  118385. /**
  118386. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118387. * Please note that it requires to run a ray cast through the scene on every frame
  118388. */
  118389. constantlyUpdateMeshUnderPointer: boolean;
  118390. /**
  118391. * Defines the HTML cursor to use when hovering over interactive elements
  118392. */
  118393. hoverCursor: string;
  118394. /**
  118395. * Defines the HTML default cursor to use (empty by default)
  118396. */
  118397. defaultCursor: string;
  118398. /**
  118399. * Defines whether cursors are handled by the scene.
  118400. */
  118401. doNotHandleCursors: boolean;
  118402. /**
  118403. * This is used to call preventDefault() on pointer down
  118404. * in order to block unwanted artifacts like system double clicks
  118405. */
  118406. preventDefaultOnPointerDown: boolean;
  118407. /**
  118408. * This is used to call preventDefault() on pointer up
  118409. * in order to block unwanted artifacts like system double clicks
  118410. */
  118411. preventDefaultOnPointerUp: boolean;
  118412. /**
  118413. * Gets or sets user defined metadata
  118414. */
  118415. metadata: any;
  118416. /**
  118417. * For internal use only. Please do not use.
  118418. */
  118419. reservedDataStore: any;
  118420. /**
  118421. * Gets the name of the plugin used to load this scene (null by default)
  118422. */
  118423. loadingPluginName: string;
  118424. /**
  118425. * Use this array to add regular expressions used to disable offline support for specific urls
  118426. */
  118427. disableOfflineSupportExceptionRules: RegExp[];
  118428. /**
  118429. * An event triggered when the scene is disposed.
  118430. */
  118431. onDisposeObservable: Observable<Scene>;
  118432. private _onDisposeObserver;
  118433. /** Sets a function to be executed when this scene is disposed. */
  118434. set onDispose(callback: () => void);
  118435. /**
  118436. * An event triggered before rendering the scene (right after animations and physics)
  118437. */
  118438. onBeforeRenderObservable: Observable<Scene>;
  118439. private _onBeforeRenderObserver;
  118440. /** Sets a function to be executed before rendering this scene */
  118441. set beforeRender(callback: Nullable<() => void>);
  118442. /**
  118443. * An event triggered after rendering the scene
  118444. */
  118445. onAfterRenderObservable: Observable<Scene>;
  118446. /**
  118447. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118448. */
  118449. onAfterRenderCameraObservable: Observable<Camera>;
  118450. private _onAfterRenderObserver;
  118451. /** Sets a function to be executed after rendering this scene */
  118452. set afterRender(callback: Nullable<() => void>);
  118453. /**
  118454. * An event triggered before animating the scene
  118455. */
  118456. onBeforeAnimationsObservable: Observable<Scene>;
  118457. /**
  118458. * An event triggered after animations processing
  118459. */
  118460. onAfterAnimationsObservable: Observable<Scene>;
  118461. /**
  118462. * An event triggered before draw calls are ready to be sent
  118463. */
  118464. onBeforeDrawPhaseObservable: Observable<Scene>;
  118465. /**
  118466. * An event triggered after draw calls have been sent
  118467. */
  118468. onAfterDrawPhaseObservable: Observable<Scene>;
  118469. /**
  118470. * An event triggered when the scene is ready
  118471. */
  118472. onReadyObservable: Observable<Scene>;
  118473. /**
  118474. * An event triggered before rendering a camera
  118475. */
  118476. onBeforeCameraRenderObservable: Observable<Camera>;
  118477. private _onBeforeCameraRenderObserver;
  118478. /** Sets a function to be executed before rendering a camera*/
  118479. set beforeCameraRender(callback: () => void);
  118480. /**
  118481. * An event triggered after rendering a camera
  118482. */
  118483. onAfterCameraRenderObservable: Observable<Camera>;
  118484. private _onAfterCameraRenderObserver;
  118485. /** Sets a function to be executed after rendering a camera*/
  118486. set afterCameraRender(callback: () => void);
  118487. /**
  118488. * An event triggered when active meshes evaluation is about to start
  118489. */
  118490. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118491. /**
  118492. * An event triggered when active meshes evaluation is done
  118493. */
  118494. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118495. /**
  118496. * An event triggered when particles rendering is about to start
  118497. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118498. */
  118499. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118500. /**
  118501. * An event triggered when particles rendering is done
  118502. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118503. */
  118504. onAfterParticlesRenderingObservable: Observable<Scene>;
  118505. /**
  118506. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118507. */
  118508. onDataLoadedObservable: Observable<Scene>;
  118509. /**
  118510. * An event triggered when a camera is created
  118511. */
  118512. onNewCameraAddedObservable: Observable<Camera>;
  118513. /**
  118514. * An event triggered when a camera is removed
  118515. */
  118516. onCameraRemovedObservable: Observable<Camera>;
  118517. /**
  118518. * An event triggered when a light is created
  118519. */
  118520. onNewLightAddedObservable: Observable<Light>;
  118521. /**
  118522. * An event triggered when a light is removed
  118523. */
  118524. onLightRemovedObservable: Observable<Light>;
  118525. /**
  118526. * An event triggered when a geometry is created
  118527. */
  118528. onNewGeometryAddedObservable: Observable<Geometry>;
  118529. /**
  118530. * An event triggered when a geometry is removed
  118531. */
  118532. onGeometryRemovedObservable: Observable<Geometry>;
  118533. /**
  118534. * An event triggered when a transform node is created
  118535. */
  118536. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118537. /**
  118538. * An event triggered when a transform node is removed
  118539. */
  118540. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118541. /**
  118542. * An event triggered when a mesh is created
  118543. */
  118544. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118545. /**
  118546. * An event triggered when a mesh is removed
  118547. */
  118548. onMeshRemovedObservable: Observable<AbstractMesh>;
  118549. /**
  118550. * An event triggered when a skeleton is created
  118551. */
  118552. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118553. /**
  118554. * An event triggered when a skeleton is removed
  118555. */
  118556. onSkeletonRemovedObservable: Observable<Skeleton>;
  118557. /**
  118558. * An event triggered when a material is created
  118559. */
  118560. onNewMaterialAddedObservable: Observable<Material>;
  118561. /**
  118562. * An event triggered when a material is removed
  118563. */
  118564. onMaterialRemovedObservable: Observable<Material>;
  118565. /**
  118566. * An event triggered when a texture is created
  118567. */
  118568. onNewTextureAddedObservable: Observable<BaseTexture>;
  118569. /**
  118570. * An event triggered when a texture is removed
  118571. */
  118572. onTextureRemovedObservable: Observable<BaseTexture>;
  118573. /**
  118574. * An event triggered when render targets are about to be rendered
  118575. * Can happen multiple times per frame.
  118576. */
  118577. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118578. /**
  118579. * An event triggered when render targets were rendered.
  118580. * Can happen multiple times per frame.
  118581. */
  118582. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118583. /**
  118584. * An event triggered before calculating deterministic simulation step
  118585. */
  118586. onBeforeStepObservable: Observable<Scene>;
  118587. /**
  118588. * An event triggered after calculating deterministic simulation step
  118589. */
  118590. onAfterStepObservable: Observable<Scene>;
  118591. /**
  118592. * An event triggered when the activeCamera property is updated
  118593. */
  118594. onActiveCameraChanged: Observable<Scene>;
  118595. /**
  118596. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118597. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118598. * 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)
  118599. */
  118600. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118601. /**
  118602. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118603. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118604. * 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)
  118605. */
  118606. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118607. /**
  118608. * This Observable will when a mesh has been imported into the scene.
  118609. */
  118610. onMeshImportedObservable: Observable<AbstractMesh>;
  118611. /**
  118612. * This Observable will when an animation file has been imported into the scene.
  118613. */
  118614. onAnimationFileImportedObservable: Observable<Scene>;
  118615. /**
  118616. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118617. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118618. */
  118619. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118620. /** @hidden */
  118621. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118622. /**
  118623. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118624. */
  118625. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118626. /**
  118627. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118628. */
  118629. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118630. /**
  118631. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118632. */
  118633. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118634. /** Callback called when a pointer move is detected */
  118635. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118636. /** Callback called when a pointer down is detected */
  118637. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118638. /** Callback called when a pointer up is detected */
  118639. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118640. /** Callback called when a pointer pick is detected */
  118641. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118642. /**
  118643. * 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).
  118644. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118645. */
  118646. onPrePointerObservable: Observable<PointerInfoPre>;
  118647. /**
  118648. * Observable event triggered each time an input event is received from the rendering canvas
  118649. */
  118650. onPointerObservable: Observable<PointerInfo>;
  118651. /**
  118652. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118653. */
  118654. get unTranslatedPointer(): Vector2;
  118655. /**
  118656. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118657. */
  118658. static get DragMovementThreshold(): number;
  118659. static set DragMovementThreshold(value: number);
  118660. /**
  118661. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118662. */
  118663. static get LongPressDelay(): number;
  118664. static set LongPressDelay(value: number);
  118665. /**
  118666. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118667. */
  118668. static get DoubleClickDelay(): number;
  118669. static set DoubleClickDelay(value: number);
  118670. /** If you need to check double click without raising a single click at first click, enable this flag */
  118671. static get ExclusiveDoubleClickMode(): boolean;
  118672. static set ExclusiveDoubleClickMode(value: boolean);
  118673. /** @hidden */
  118674. _mirroredCameraPosition: Nullable<Vector3>;
  118675. /**
  118676. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118677. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118678. */
  118679. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118680. /**
  118681. * Observable event triggered each time an keyboard event is received from the hosting window
  118682. */
  118683. onKeyboardObservable: Observable<KeyboardInfo>;
  118684. private _useRightHandedSystem;
  118685. /**
  118686. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118687. */
  118688. set useRightHandedSystem(value: boolean);
  118689. get useRightHandedSystem(): boolean;
  118690. private _timeAccumulator;
  118691. private _currentStepId;
  118692. private _currentInternalStep;
  118693. /**
  118694. * Sets the step Id used by deterministic lock step
  118695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118696. * @param newStepId defines the step Id
  118697. */
  118698. setStepId(newStepId: number): void;
  118699. /**
  118700. * Gets the step Id used by deterministic lock step
  118701. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118702. * @returns the step Id
  118703. */
  118704. getStepId(): number;
  118705. /**
  118706. * Gets the internal step used by deterministic lock step
  118707. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118708. * @returns the internal step
  118709. */
  118710. getInternalStep(): number;
  118711. private _fogEnabled;
  118712. /**
  118713. * Gets or sets a boolean indicating if fog is enabled on this scene
  118714. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118715. * (Default is true)
  118716. */
  118717. set fogEnabled(value: boolean);
  118718. get fogEnabled(): boolean;
  118719. private _fogMode;
  118720. /**
  118721. * Gets or sets the fog mode to use
  118722. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118723. * | mode | value |
  118724. * | --- | --- |
  118725. * | FOGMODE_NONE | 0 |
  118726. * | FOGMODE_EXP | 1 |
  118727. * | FOGMODE_EXP2 | 2 |
  118728. * | FOGMODE_LINEAR | 3 |
  118729. */
  118730. set fogMode(value: number);
  118731. get fogMode(): number;
  118732. /**
  118733. * Gets or sets the fog color to use
  118734. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118735. * (Default is Color3(0.2, 0.2, 0.3))
  118736. */
  118737. fogColor: Color3;
  118738. /**
  118739. * Gets or sets the fog density to use
  118740. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118741. * (Default is 0.1)
  118742. */
  118743. fogDensity: number;
  118744. /**
  118745. * Gets or sets the fog start distance to use
  118746. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118747. * (Default is 0)
  118748. */
  118749. fogStart: number;
  118750. /**
  118751. * Gets or sets the fog end distance to use
  118752. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118753. * (Default is 1000)
  118754. */
  118755. fogEnd: number;
  118756. /**
  118757. * Flag indicating that the frame buffer binding is handled by another component
  118758. */
  118759. prePass: boolean;
  118760. private _shadowsEnabled;
  118761. /**
  118762. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118763. */
  118764. set shadowsEnabled(value: boolean);
  118765. get shadowsEnabled(): boolean;
  118766. private _lightsEnabled;
  118767. /**
  118768. * Gets or sets a boolean indicating if lights are enabled on this scene
  118769. */
  118770. set lightsEnabled(value: boolean);
  118771. get lightsEnabled(): boolean;
  118772. /** All of the active cameras added to this scene. */
  118773. activeCameras: Camera[];
  118774. /** @hidden */
  118775. _activeCamera: Nullable<Camera>;
  118776. /** Gets or sets the current active camera */
  118777. get activeCamera(): Nullable<Camera>;
  118778. set activeCamera(value: Nullable<Camera>);
  118779. private _defaultMaterial;
  118780. /** The default material used on meshes when no material is affected */
  118781. get defaultMaterial(): Material;
  118782. /** The default material used on meshes when no material is affected */
  118783. set defaultMaterial(value: Material);
  118784. private _texturesEnabled;
  118785. /**
  118786. * Gets or sets a boolean indicating if textures are enabled on this scene
  118787. */
  118788. set texturesEnabled(value: boolean);
  118789. get texturesEnabled(): boolean;
  118790. /**
  118791. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118792. */
  118793. physicsEnabled: boolean;
  118794. /**
  118795. * Gets or sets a boolean indicating if particles are enabled on this scene
  118796. */
  118797. particlesEnabled: boolean;
  118798. /**
  118799. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118800. */
  118801. spritesEnabled: boolean;
  118802. private _skeletonsEnabled;
  118803. /**
  118804. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118805. */
  118806. set skeletonsEnabled(value: boolean);
  118807. get skeletonsEnabled(): boolean;
  118808. /**
  118809. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118810. */
  118811. lensFlaresEnabled: boolean;
  118812. /**
  118813. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118814. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118815. */
  118816. collisionsEnabled: boolean;
  118817. private _collisionCoordinator;
  118818. /** @hidden */
  118819. get collisionCoordinator(): ICollisionCoordinator;
  118820. /**
  118821. * Defines the gravity applied to this scene (used only for collisions)
  118822. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118823. */
  118824. gravity: Vector3;
  118825. /**
  118826. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118827. */
  118828. postProcessesEnabled: boolean;
  118829. /**
  118830. * The list of postprocesses added to the scene
  118831. */
  118832. postProcesses: PostProcess[];
  118833. /**
  118834. * Gets the current postprocess manager
  118835. */
  118836. postProcessManager: PostProcessManager;
  118837. /**
  118838. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118839. */
  118840. renderTargetsEnabled: boolean;
  118841. /**
  118842. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118843. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118844. */
  118845. dumpNextRenderTargets: boolean;
  118846. /**
  118847. * The list of user defined render targets added to the scene
  118848. */
  118849. customRenderTargets: RenderTargetTexture[];
  118850. /**
  118851. * Defines if texture loading must be delayed
  118852. * If true, textures will only be loaded when they need to be rendered
  118853. */
  118854. useDelayedTextureLoading: boolean;
  118855. /**
  118856. * Gets the list of meshes imported to the scene through SceneLoader
  118857. */
  118858. importedMeshesFiles: String[];
  118859. /**
  118860. * Gets or sets a boolean indicating if probes are enabled on this scene
  118861. */
  118862. probesEnabled: boolean;
  118863. /**
  118864. * Gets or sets the current offline provider to use to store scene data
  118865. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118866. */
  118867. offlineProvider: IOfflineProvider;
  118868. /**
  118869. * Gets or sets the action manager associated with the scene
  118870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118871. */
  118872. actionManager: AbstractActionManager;
  118873. private _meshesForIntersections;
  118874. /**
  118875. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118876. */
  118877. proceduralTexturesEnabled: boolean;
  118878. private _engine;
  118879. private _totalVertices;
  118880. /** @hidden */
  118881. _activeIndices: PerfCounter;
  118882. /** @hidden */
  118883. _activeParticles: PerfCounter;
  118884. /** @hidden */
  118885. _activeBones: PerfCounter;
  118886. private _animationRatio;
  118887. /** @hidden */
  118888. _animationTimeLast: number;
  118889. /** @hidden */
  118890. _animationTime: number;
  118891. /**
  118892. * Gets or sets a general scale for animation speed
  118893. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118894. */
  118895. animationTimeScale: number;
  118896. /** @hidden */
  118897. _cachedMaterial: Nullable<Material>;
  118898. /** @hidden */
  118899. _cachedEffect: Nullable<Effect>;
  118900. /** @hidden */
  118901. _cachedVisibility: Nullable<number>;
  118902. private _renderId;
  118903. private _frameId;
  118904. private _executeWhenReadyTimeoutId;
  118905. private _intermediateRendering;
  118906. private _viewUpdateFlag;
  118907. private _projectionUpdateFlag;
  118908. /** @hidden */
  118909. _toBeDisposed: Nullable<IDisposable>[];
  118910. private _activeRequests;
  118911. /** @hidden */
  118912. _pendingData: any[];
  118913. private _isDisposed;
  118914. /**
  118915. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118916. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118917. */
  118918. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118919. private _activeMeshes;
  118920. private _processedMaterials;
  118921. private _renderTargets;
  118922. /** @hidden */
  118923. _activeParticleSystems: SmartArray<IParticleSystem>;
  118924. private _activeSkeletons;
  118925. private _softwareSkinnedMeshes;
  118926. private _renderingManager;
  118927. /** @hidden */
  118928. _activeAnimatables: Animatable[];
  118929. private _transformMatrix;
  118930. private _sceneUbo;
  118931. /** @hidden */
  118932. _viewMatrix: Matrix;
  118933. private _projectionMatrix;
  118934. /** @hidden */
  118935. _forcedViewPosition: Nullable<Vector3>;
  118936. /** @hidden */
  118937. _frustumPlanes: Plane[];
  118938. /**
  118939. * Gets the list of frustum planes (built from the active camera)
  118940. */
  118941. get frustumPlanes(): Plane[];
  118942. /**
  118943. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118944. * This is useful if there are more lights that the maximum simulteanous authorized
  118945. */
  118946. requireLightSorting: boolean;
  118947. /** @hidden */
  118948. readonly useMaterialMeshMap: boolean;
  118949. /** @hidden */
  118950. readonly useClonedMeshMap: boolean;
  118951. private _externalData;
  118952. private _uid;
  118953. /**
  118954. * @hidden
  118955. * Backing store of defined scene components.
  118956. */
  118957. _components: ISceneComponent[];
  118958. /**
  118959. * @hidden
  118960. * Backing store of defined scene components.
  118961. */
  118962. _serializableComponents: ISceneSerializableComponent[];
  118963. /**
  118964. * List of components to register on the next registration step.
  118965. */
  118966. private _transientComponents;
  118967. /**
  118968. * Registers the transient components if needed.
  118969. */
  118970. private _registerTransientComponents;
  118971. /**
  118972. * @hidden
  118973. * Add a component to the scene.
  118974. * Note that the ccomponent could be registered on th next frame if this is called after
  118975. * the register component stage.
  118976. * @param component Defines the component to add to the scene
  118977. */
  118978. _addComponent(component: ISceneComponent): void;
  118979. /**
  118980. * @hidden
  118981. * Gets a component from the scene.
  118982. * @param name defines the name of the component to retrieve
  118983. * @returns the component or null if not present
  118984. */
  118985. _getComponent(name: string): Nullable<ISceneComponent>;
  118986. /**
  118987. * @hidden
  118988. * Defines the actions happening before camera updates.
  118989. */
  118990. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118991. /**
  118992. * @hidden
  118993. * Defines the actions happening before clear the canvas.
  118994. */
  118995. _beforeClearStage: Stage<SimpleStageAction>;
  118996. /**
  118997. * @hidden
  118998. * Defines the actions when collecting render targets for the frame.
  118999. */
  119000. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119001. /**
  119002. * @hidden
  119003. * Defines the actions happening for one camera in the frame.
  119004. */
  119005. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119006. /**
  119007. * @hidden
  119008. * Defines the actions happening during the per mesh ready checks.
  119009. */
  119010. _isReadyForMeshStage: Stage<MeshStageAction>;
  119011. /**
  119012. * @hidden
  119013. * Defines the actions happening before evaluate active mesh checks.
  119014. */
  119015. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119016. /**
  119017. * @hidden
  119018. * Defines the actions happening during the evaluate sub mesh checks.
  119019. */
  119020. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119021. /**
  119022. * @hidden
  119023. * Defines the actions happening during the active mesh stage.
  119024. */
  119025. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119026. /**
  119027. * @hidden
  119028. * Defines the actions happening during the per camera render target step.
  119029. */
  119030. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119031. /**
  119032. * @hidden
  119033. * Defines the actions happening just before the active camera is drawing.
  119034. */
  119035. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119036. /**
  119037. * @hidden
  119038. * Defines the actions happening just before a render target is drawing.
  119039. */
  119040. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119041. /**
  119042. * @hidden
  119043. * Defines the actions happening just before a rendering group is drawing.
  119044. */
  119045. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119046. /**
  119047. * @hidden
  119048. * Defines the actions happening just before a mesh is drawing.
  119049. */
  119050. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119051. /**
  119052. * @hidden
  119053. * Defines the actions happening just after a mesh has been drawn.
  119054. */
  119055. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119056. /**
  119057. * @hidden
  119058. * Defines the actions happening just after a rendering group has been drawn.
  119059. */
  119060. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119061. /**
  119062. * @hidden
  119063. * Defines the actions happening just after the active camera has been drawn.
  119064. */
  119065. _afterCameraDrawStage: Stage<CameraStageAction>;
  119066. /**
  119067. * @hidden
  119068. * Defines the actions happening just after a render target has been drawn.
  119069. */
  119070. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119071. /**
  119072. * @hidden
  119073. * Defines the actions happening just after rendering all cameras and computing intersections.
  119074. */
  119075. _afterRenderStage: Stage<SimpleStageAction>;
  119076. /**
  119077. * @hidden
  119078. * Defines the actions happening when a pointer move event happens.
  119079. */
  119080. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119081. /**
  119082. * @hidden
  119083. * Defines the actions happening when a pointer down event happens.
  119084. */
  119085. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119086. /**
  119087. * @hidden
  119088. * Defines the actions happening when a pointer up event happens.
  119089. */
  119090. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119091. /**
  119092. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119093. */
  119094. private geometriesByUniqueId;
  119095. /**
  119096. * Creates a new Scene
  119097. * @param engine defines the engine to use to render this scene
  119098. * @param options defines the scene options
  119099. */
  119100. constructor(engine: Engine, options?: SceneOptions);
  119101. /**
  119102. * Gets a string idenfifying the name of the class
  119103. * @returns "Scene" string
  119104. */
  119105. getClassName(): string;
  119106. private _defaultMeshCandidates;
  119107. /**
  119108. * @hidden
  119109. */
  119110. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119111. private _defaultSubMeshCandidates;
  119112. /**
  119113. * @hidden
  119114. */
  119115. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119116. /**
  119117. * Sets the default candidate providers for the scene.
  119118. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119119. * and getCollidingSubMeshCandidates to their default function
  119120. */
  119121. setDefaultCandidateProviders(): void;
  119122. /**
  119123. * Gets the mesh that is currently under the pointer
  119124. */
  119125. get meshUnderPointer(): Nullable<AbstractMesh>;
  119126. /**
  119127. * Gets or sets the current on-screen X position of the pointer
  119128. */
  119129. get pointerX(): number;
  119130. set pointerX(value: number);
  119131. /**
  119132. * Gets or sets the current on-screen Y position of the pointer
  119133. */
  119134. get pointerY(): number;
  119135. set pointerY(value: number);
  119136. /**
  119137. * Gets the cached material (ie. the latest rendered one)
  119138. * @returns the cached material
  119139. */
  119140. getCachedMaterial(): Nullable<Material>;
  119141. /**
  119142. * Gets the cached effect (ie. the latest rendered one)
  119143. * @returns the cached effect
  119144. */
  119145. getCachedEffect(): Nullable<Effect>;
  119146. /**
  119147. * Gets the cached visibility state (ie. the latest rendered one)
  119148. * @returns the cached visibility state
  119149. */
  119150. getCachedVisibility(): Nullable<number>;
  119151. /**
  119152. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119153. * @param material defines the current material
  119154. * @param effect defines the current effect
  119155. * @param visibility defines the current visibility state
  119156. * @returns true if one parameter is not cached
  119157. */
  119158. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119159. /**
  119160. * Gets the engine associated with the scene
  119161. * @returns an Engine
  119162. */
  119163. getEngine(): Engine;
  119164. /**
  119165. * Gets the total number of vertices rendered per frame
  119166. * @returns the total number of vertices rendered per frame
  119167. */
  119168. getTotalVertices(): number;
  119169. /**
  119170. * Gets the performance counter for total vertices
  119171. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119172. */
  119173. get totalVerticesPerfCounter(): PerfCounter;
  119174. /**
  119175. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119176. * @returns the total number of active indices rendered per frame
  119177. */
  119178. getActiveIndices(): number;
  119179. /**
  119180. * Gets the performance counter for active indices
  119181. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119182. */
  119183. get totalActiveIndicesPerfCounter(): PerfCounter;
  119184. /**
  119185. * Gets the total number of active particles rendered per frame
  119186. * @returns the total number of active particles rendered per frame
  119187. */
  119188. getActiveParticles(): number;
  119189. /**
  119190. * Gets the performance counter for active particles
  119191. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119192. */
  119193. get activeParticlesPerfCounter(): PerfCounter;
  119194. /**
  119195. * Gets the total number of active bones rendered per frame
  119196. * @returns the total number of active bones rendered per frame
  119197. */
  119198. getActiveBones(): number;
  119199. /**
  119200. * Gets the performance counter for active bones
  119201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119202. */
  119203. get activeBonesPerfCounter(): PerfCounter;
  119204. /**
  119205. * Gets the array of active meshes
  119206. * @returns an array of AbstractMesh
  119207. */
  119208. getActiveMeshes(): SmartArray<AbstractMesh>;
  119209. /**
  119210. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119211. * @returns a number
  119212. */
  119213. getAnimationRatio(): number;
  119214. /**
  119215. * Gets an unique Id for the current render phase
  119216. * @returns a number
  119217. */
  119218. getRenderId(): number;
  119219. /**
  119220. * Gets an unique Id for the current frame
  119221. * @returns a number
  119222. */
  119223. getFrameId(): number;
  119224. /** Call this function if you want to manually increment the render Id*/
  119225. incrementRenderId(): void;
  119226. private _createUbo;
  119227. /**
  119228. * Use this method to simulate a pointer move on a mesh
  119229. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119230. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119231. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119232. * @returns the current scene
  119233. */
  119234. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119235. /**
  119236. * Use this method to simulate a pointer down on a mesh
  119237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119240. * @returns the current scene
  119241. */
  119242. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119243. /**
  119244. * Use this method to simulate a pointer up on a mesh
  119245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119248. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119249. * @returns the current scene
  119250. */
  119251. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119252. /**
  119253. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119254. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119255. * @returns true if the pointer was captured
  119256. */
  119257. isPointerCaptured(pointerId?: number): boolean;
  119258. /**
  119259. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119260. * @param attachUp defines if you want to attach events to pointerup
  119261. * @param attachDown defines if you want to attach events to pointerdown
  119262. * @param attachMove defines if you want to attach events to pointermove
  119263. */
  119264. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119265. /** Detaches all event handlers*/
  119266. detachControl(): void;
  119267. /**
  119268. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119269. * Delay loaded resources are not taking in account
  119270. * @return true if all required resources are ready
  119271. */
  119272. isReady(): boolean;
  119273. /** Resets all cached information relative to material (including effect and visibility) */
  119274. resetCachedMaterial(): void;
  119275. /**
  119276. * Registers a function to be called before every frame render
  119277. * @param func defines the function to register
  119278. */
  119279. registerBeforeRender(func: () => void): void;
  119280. /**
  119281. * Unregisters a function called before every frame render
  119282. * @param func defines the function to unregister
  119283. */
  119284. unregisterBeforeRender(func: () => void): void;
  119285. /**
  119286. * Registers a function to be called after every frame render
  119287. * @param func defines the function to register
  119288. */
  119289. registerAfterRender(func: () => void): void;
  119290. /**
  119291. * Unregisters a function called after every frame render
  119292. * @param func defines the function to unregister
  119293. */
  119294. unregisterAfterRender(func: () => void): void;
  119295. private _executeOnceBeforeRender;
  119296. /**
  119297. * The provided function will run before render once and will be disposed afterwards.
  119298. * A timeout delay can be provided so that the function will be executed in N ms.
  119299. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119300. * @param func The function to be executed.
  119301. * @param timeout optional delay in ms
  119302. */
  119303. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119304. /** @hidden */
  119305. _addPendingData(data: any): void;
  119306. /** @hidden */
  119307. _removePendingData(data: any): void;
  119308. /**
  119309. * Returns the number of items waiting to be loaded
  119310. * @returns the number of items waiting to be loaded
  119311. */
  119312. getWaitingItemsCount(): number;
  119313. /**
  119314. * Returns a boolean indicating if the scene is still loading data
  119315. */
  119316. get isLoading(): boolean;
  119317. /**
  119318. * Registers a function to be executed when the scene is ready
  119319. * @param {Function} func - the function to be executed
  119320. */
  119321. executeWhenReady(func: () => void): void;
  119322. /**
  119323. * Returns a promise that resolves when the scene is ready
  119324. * @returns A promise that resolves when the scene is ready
  119325. */
  119326. whenReadyAsync(): Promise<void>;
  119327. /** @hidden */
  119328. _checkIsReady(): void;
  119329. /**
  119330. * Gets all animatable attached to the scene
  119331. */
  119332. get animatables(): Animatable[];
  119333. /**
  119334. * Resets the last animation time frame.
  119335. * Useful to override when animations start running when loading a scene for the first time.
  119336. */
  119337. resetLastAnimationTimeFrame(): void;
  119338. /**
  119339. * Gets the current view matrix
  119340. * @returns a Matrix
  119341. */
  119342. getViewMatrix(): Matrix;
  119343. /**
  119344. * Gets the current projection matrix
  119345. * @returns a Matrix
  119346. */
  119347. getProjectionMatrix(): Matrix;
  119348. /**
  119349. * Gets the current transform matrix
  119350. * @returns a Matrix made of View * Projection
  119351. */
  119352. getTransformMatrix(): Matrix;
  119353. /**
  119354. * Sets the current transform matrix
  119355. * @param viewL defines the View matrix to use
  119356. * @param projectionL defines the Projection matrix to use
  119357. * @param viewR defines the right View matrix to use (if provided)
  119358. * @param projectionR defines the right Projection matrix to use (if provided)
  119359. */
  119360. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119361. /**
  119362. * Gets the uniform buffer used to store scene data
  119363. * @returns a UniformBuffer
  119364. */
  119365. getSceneUniformBuffer(): UniformBuffer;
  119366. /**
  119367. * Gets an unique (relatively to the current scene) Id
  119368. * @returns an unique number for the scene
  119369. */
  119370. getUniqueId(): number;
  119371. /**
  119372. * Add a mesh to the list of scene's meshes
  119373. * @param newMesh defines the mesh to add
  119374. * @param recursive if all child meshes should also be added to the scene
  119375. */
  119376. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119377. /**
  119378. * Remove a mesh for the list of scene's meshes
  119379. * @param toRemove defines the mesh to remove
  119380. * @param recursive if all child meshes should also be removed from the scene
  119381. * @returns the index where the mesh was in the mesh list
  119382. */
  119383. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119384. /**
  119385. * Add a transform node to the list of scene's transform nodes
  119386. * @param newTransformNode defines the transform node to add
  119387. */
  119388. addTransformNode(newTransformNode: TransformNode): void;
  119389. /**
  119390. * Remove a transform node for the list of scene's transform nodes
  119391. * @param toRemove defines the transform node to remove
  119392. * @returns the index where the transform node was in the transform node list
  119393. */
  119394. removeTransformNode(toRemove: TransformNode): number;
  119395. /**
  119396. * Remove a skeleton for the list of scene's skeletons
  119397. * @param toRemove defines the skeleton to remove
  119398. * @returns the index where the skeleton was in the skeleton list
  119399. */
  119400. removeSkeleton(toRemove: Skeleton): number;
  119401. /**
  119402. * Remove a morph target for the list of scene's morph targets
  119403. * @param toRemove defines the morph target to remove
  119404. * @returns the index where the morph target was in the morph target list
  119405. */
  119406. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119407. /**
  119408. * Remove a light for the list of scene's lights
  119409. * @param toRemove defines the light to remove
  119410. * @returns the index where the light was in the light list
  119411. */
  119412. removeLight(toRemove: Light): number;
  119413. /**
  119414. * Remove a camera for the list of scene's cameras
  119415. * @param toRemove defines the camera to remove
  119416. * @returns the index where the camera was in the camera list
  119417. */
  119418. removeCamera(toRemove: Camera): number;
  119419. /**
  119420. * Remove a particle system for the list of scene's particle systems
  119421. * @param toRemove defines the particle system to remove
  119422. * @returns the index where the particle system was in the particle system list
  119423. */
  119424. removeParticleSystem(toRemove: IParticleSystem): number;
  119425. /**
  119426. * Remove a animation for the list of scene's animations
  119427. * @param toRemove defines the animation to remove
  119428. * @returns the index where the animation was in the animation list
  119429. */
  119430. removeAnimation(toRemove: Animation): number;
  119431. /**
  119432. * Will stop the animation of the given target
  119433. * @param target - the target
  119434. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119435. * @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)
  119436. */
  119437. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119438. /**
  119439. * Removes the given animation group from this scene.
  119440. * @param toRemove The animation group to remove
  119441. * @returns The index of the removed animation group
  119442. */
  119443. removeAnimationGroup(toRemove: AnimationGroup): number;
  119444. /**
  119445. * Removes the given multi-material from this scene.
  119446. * @param toRemove The multi-material to remove
  119447. * @returns The index of the removed multi-material
  119448. */
  119449. removeMultiMaterial(toRemove: MultiMaterial): number;
  119450. /**
  119451. * Removes the given material from this scene.
  119452. * @param toRemove The material to remove
  119453. * @returns The index of the removed material
  119454. */
  119455. removeMaterial(toRemove: Material): number;
  119456. /**
  119457. * Removes the given action manager from this scene.
  119458. * @param toRemove The action manager to remove
  119459. * @returns The index of the removed action manager
  119460. */
  119461. removeActionManager(toRemove: AbstractActionManager): number;
  119462. /**
  119463. * Removes the given texture from this scene.
  119464. * @param toRemove The texture to remove
  119465. * @returns The index of the removed texture
  119466. */
  119467. removeTexture(toRemove: BaseTexture): number;
  119468. /**
  119469. * Adds the given light to this scene
  119470. * @param newLight The light to add
  119471. */
  119472. addLight(newLight: Light): void;
  119473. /**
  119474. * Sorts the list list based on light priorities
  119475. */
  119476. sortLightsByPriority(): void;
  119477. /**
  119478. * Adds the given camera to this scene
  119479. * @param newCamera The camera to add
  119480. */
  119481. addCamera(newCamera: Camera): void;
  119482. /**
  119483. * Adds the given skeleton to this scene
  119484. * @param newSkeleton The skeleton to add
  119485. */
  119486. addSkeleton(newSkeleton: Skeleton): void;
  119487. /**
  119488. * Adds the given particle system to this scene
  119489. * @param newParticleSystem The particle system to add
  119490. */
  119491. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119492. /**
  119493. * Adds the given animation to this scene
  119494. * @param newAnimation The animation to add
  119495. */
  119496. addAnimation(newAnimation: Animation): void;
  119497. /**
  119498. * Adds the given animation group to this scene.
  119499. * @param newAnimationGroup The animation group to add
  119500. */
  119501. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119502. /**
  119503. * Adds the given multi-material to this scene
  119504. * @param newMultiMaterial The multi-material to add
  119505. */
  119506. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119507. /**
  119508. * Adds the given material to this scene
  119509. * @param newMaterial The material to add
  119510. */
  119511. addMaterial(newMaterial: Material): void;
  119512. /**
  119513. * Adds the given morph target to this scene
  119514. * @param newMorphTargetManager The morph target to add
  119515. */
  119516. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119517. /**
  119518. * Adds the given geometry to this scene
  119519. * @param newGeometry The geometry to add
  119520. */
  119521. addGeometry(newGeometry: Geometry): void;
  119522. /**
  119523. * Adds the given action manager to this scene
  119524. * @param newActionManager The action manager to add
  119525. */
  119526. addActionManager(newActionManager: AbstractActionManager): void;
  119527. /**
  119528. * Adds the given texture to this scene.
  119529. * @param newTexture The texture to add
  119530. */
  119531. addTexture(newTexture: BaseTexture): void;
  119532. /**
  119533. * Switch active camera
  119534. * @param newCamera defines the new active camera
  119535. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119536. */
  119537. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119538. /**
  119539. * sets the active camera of the scene using its ID
  119540. * @param id defines the camera's ID
  119541. * @return the new active camera or null if none found.
  119542. */
  119543. setActiveCameraByID(id: string): Nullable<Camera>;
  119544. /**
  119545. * sets the active camera of the scene using its name
  119546. * @param name defines the camera's name
  119547. * @returns the new active camera or null if none found.
  119548. */
  119549. setActiveCameraByName(name: string): Nullable<Camera>;
  119550. /**
  119551. * get an animation group using its name
  119552. * @param name defines the material's name
  119553. * @return the animation group or null if none found.
  119554. */
  119555. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119556. /**
  119557. * Get a material using its unique id
  119558. * @param uniqueId defines the material's unique id
  119559. * @return the material or null if none found.
  119560. */
  119561. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119562. /**
  119563. * get a material using its id
  119564. * @param id defines the material's ID
  119565. * @return the material or null if none found.
  119566. */
  119567. getMaterialByID(id: string): Nullable<Material>;
  119568. /**
  119569. * Gets a the last added material using a given id
  119570. * @param id defines the material's ID
  119571. * @return the last material with the given id or null if none found.
  119572. */
  119573. getLastMaterialByID(id: string): Nullable<Material>;
  119574. /**
  119575. * Gets a material using its name
  119576. * @param name defines the material's name
  119577. * @return the material or null if none found.
  119578. */
  119579. getMaterialByName(name: string): Nullable<Material>;
  119580. /**
  119581. * Get a texture using its unique id
  119582. * @param uniqueId defines the texture's unique id
  119583. * @return the texture or null if none found.
  119584. */
  119585. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119586. /**
  119587. * Gets a camera using its id
  119588. * @param id defines the id to look for
  119589. * @returns the camera or null if not found
  119590. */
  119591. getCameraByID(id: string): Nullable<Camera>;
  119592. /**
  119593. * Gets a camera using its unique id
  119594. * @param uniqueId defines the unique id to look for
  119595. * @returns the camera or null if not found
  119596. */
  119597. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119598. /**
  119599. * Gets a camera using its name
  119600. * @param name defines the camera's name
  119601. * @return the camera or null if none found.
  119602. */
  119603. getCameraByName(name: string): Nullable<Camera>;
  119604. /**
  119605. * Gets a bone using its id
  119606. * @param id defines the bone's id
  119607. * @return the bone or null if not found
  119608. */
  119609. getBoneByID(id: string): Nullable<Bone>;
  119610. /**
  119611. * Gets a bone using its id
  119612. * @param name defines the bone's name
  119613. * @return the bone or null if not found
  119614. */
  119615. getBoneByName(name: string): Nullable<Bone>;
  119616. /**
  119617. * Gets a light node using its name
  119618. * @param name defines the the light's name
  119619. * @return the light or null if none found.
  119620. */
  119621. getLightByName(name: string): Nullable<Light>;
  119622. /**
  119623. * Gets a light node using its id
  119624. * @param id defines the light's id
  119625. * @return the light or null if none found.
  119626. */
  119627. getLightByID(id: string): Nullable<Light>;
  119628. /**
  119629. * Gets a light node using its scene-generated unique ID
  119630. * @param uniqueId defines the light's unique id
  119631. * @return the light or null if none found.
  119632. */
  119633. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119634. /**
  119635. * Gets a particle system by id
  119636. * @param id defines the particle system id
  119637. * @return the corresponding system or null if none found
  119638. */
  119639. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119640. /**
  119641. * Gets a geometry using its ID
  119642. * @param id defines the geometry's id
  119643. * @return the geometry or null if none found.
  119644. */
  119645. getGeometryByID(id: string): Nullable<Geometry>;
  119646. private _getGeometryByUniqueID;
  119647. /**
  119648. * Add a new geometry to this scene
  119649. * @param geometry defines the geometry to be added to the scene.
  119650. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119651. * @return a boolean defining if the geometry was added or not
  119652. */
  119653. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119654. /**
  119655. * Removes an existing geometry
  119656. * @param geometry defines the geometry to be removed from the scene
  119657. * @return a boolean defining if the geometry was removed or not
  119658. */
  119659. removeGeometry(geometry: Geometry): boolean;
  119660. /**
  119661. * Gets the list of geometries attached to the scene
  119662. * @returns an array of Geometry
  119663. */
  119664. getGeometries(): Geometry[];
  119665. /**
  119666. * Gets the first added mesh found of a given ID
  119667. * @param id defines the id to search for
  119668. * @return the mesh found or null if not found at all
  119669. */
  119670. getMeshByID(id: string): Nullable<AbstractMesh>;
  119671. /**
  119672. * Gets a list of meshes using their id
  119673. * @param id defines the id to search for
  119674. * @returns a list of meshes
  119675. */
  119676. getMeshesByID(id: string): Array<AbstractMesh>;
  119677. /**
  119678. * Gets the first added transform node found of a given ID
  119679. * @param id defines the id to search for
  119680. * @return the found transform node or null if not found at all.
  119681. */
  119682. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119683. /**
  119684. * Gets a transform node with its auto-generated unique id
  119685. * @param uniqueId efines the unique id to search for
  119686. * @return the found transform node or null if not found at all.
  119687. */
  119688. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119689. /**
  119690. * Gets a list of transform nodes using their id
  119691. * @param id defines the id to search for
  119692. * @returns a list of transform nodes
  119693. */
  119694. getTransformNodesByID(id: string): Array<TransformNode>;
  119695. /**
  119696. * Gets a mesh with its auto-generated unique id
  119697. * @param uniqueId defines the unique id to search for
  119698. * @return the found mesh or null if not found at all.
  119699. */
  119700. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119701. /**
  119702. * Gets a the last added mesh using a given id
  119703. * @param id defines the id to search for
  119704. * @return the found mesh or null if not found at all.
  119705. */
  119706. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119707. /**
  119708. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119709. * @param id defines the id to search for
  119710. * @return the found node or null if not found at all
  119711. */
  119712. getLastEntryByID(id: string): Nullable<Node>;
  119713. /**
  119714. * Gets a node (Mesh, Camera, Light) using a given id
  119715. * @param id defines the id to search for
  119716. * @return the found node or null if not found at all
  119717. */
  119718. getNodeByID(id: string): Nullable<Node>;
  119719. /**
  119720. * Gets a node (Mesh, Camera, Light) using a given name
  119721. * @param name defines the name to search for
  119722. * @return the found node or null if not found at all.
  119723. */
  119724. getNodeByName(name: string): Nullable<Node>;
  119725. /**
  119726. * Gets a mesh using a given name
  119727. * @param name defines the name to search for
  119728. * @return the found mesh or null if not found at all.
  119729. */
  119730. getMeshByName(name: string): Nullable<AbstractMesh>;
  119731. /**
  119732. * Gets a transform node using a given name
  119733. * @param name defines the name to search for
  119734. * @return the found transform node or null if not found at all.
  119735. */
  119736. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119737. /**
  119738. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119739. * @param id defines the id to search for
  119740. * @return the found skeleton or null if not found at all.
  119741. */
  119742. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119743. /**
  119744. * Gets a skeleton using a given auto generated unique id
  119745. * @param uniqueId defines the unique id to search for
  119746. * @return the found skeleton or null if not found at all.
  119747. */
  119748. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119749. /**
  119750. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119751. * @param id defines the id to search for
  119752. * @return the found skeleton or null if not found at all.
  119753. */
  119754. getSkeletonById(id: string): Nullable<Skeleton>;
  119755. /**
  119756. * Gets a skeleton using a given name
  119757. * @param name defines the name to search for
  119758. * @return the found skeleton or null if not found at all.
  119759. */
  119760. getSkeletonByName(name: string): Nullable<Skeleton>;
  119761. /**
  119762. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119763. * @param id defines the id to search for
  119764. * @return the found morph target manager or null if not found at all.
  119765. */
  119766. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119767. /**
  119768. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119769. * @param id defines the id to search for
  119770. * @return the found morph target or null if not found at all.
  119771. */
  119772. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119773. /**
  119774. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119775. * @param name defines the name to search for
  119776. * @return the found morph target or null if not found at all.
  119777. */
  119778. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119779. /**
  119780. * Gets a boolean indicating if the given mesh is active
  119781. * @param mesh defines the mesh to look for
  119782. * @returns true if the mesh is in the active list
  119783. */
  119784. isActiveMesh(mesh: AbstractMesh): boolean;
  119785. /**
  119786. * Return a unique id as a string which can serve as an identifier for the scene
  119787. */
  119788. get uid(): string;
  119789. /**
  119790. * Add an externaly attached data from its key.
  119791. * This method call will fail and return false, if such key already exists.
  119792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119793. * @param key the unique key that identifies the data
  119794. * @param data the data object to associate to the key for this Engine instance
  119795. * @return true if no such key were already present and the data was added successfully, false otherwise
  119796. */
  119797. addExternalData<T>(key: string, data: T): boolean;
  119798. /**
  119799. * Get an externaly attached data from its key
  119800. * @param key the unique key that identifies the data
  119801. * @return the associated data, if present (can be null), or undefined if not present
  119802. */
  119803. getExternalData<T>(key: string): Nullable<T>;
  119804. /**
  119805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119806. * @param key the unique key that identifies the data
  119807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119808. * @return the associated data, can be null if the factory returned null.
  119809. */
  119810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119811. /**
  119812. * Remove an externaly attached data from the Engine instance
  119813. * @param key the unique key that identifies the data
  119814. * @return true if the data was successfully removed, false if it doesn't exist
  119815. */
  119816. removeExternalData(key: string): boolean;
  119817. private _evaluateSubMesh;
  119818. /**
  119819. * Clear the processed materials smart array preventing retention point in material dispose.
  119820. */
  119821. freeProcessedMaterials(): void;
  119822. private _preventFreeActiveMeshesAndRenderingGroups;
  119823. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119824. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119825. * when disposing several meshes in a row or a hierarchy of meshes.
  119826. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119827. */
  119828. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119829. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119830. /**
  119831. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119832. */
  119833. freeActiveMeshes(): void;
  119834. /**
  119835. * Clear the info related to rendering groups preventing retention points during dispose.
  119836. */
  119837. freeRenderingGroups(): void;
  119838. /** @hidden */
  119839. _isInIntermediateRendering(): boolean;
  119840. /**
  119841. * Lambda returning the list of potentially active meshes.
  119842. */
  119843. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119844. /**
  119845. * Lambda returning the list of potentially active sub meshes.
  119846. */
  119847. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119848. /**
  119849. * Lambda returning the list of potentially intersecting sub meshes.
  119850. */
  119851. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119852. /**
  119853. * Lambda returning the list of potentially colliding sub meshes.
  119854. */
  119855. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119856. private _activeMeshesFrozen;
  119857. private _skipEvaluateActiveMeshesCompletely;
  119858. /**
  119859. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119860. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119861. * @returns the current scene
  119862. */
  119863. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119864. /**
  119865. * Use this function to restart evaluating active meshes on every frame
  119866. * @returns the current scene
  119867. */
  119868. unfreezeActiveMeshes(): Scene;
  119869. private _evaluateActiveMeshes;
  119870. private _activeMesh;
  119871. /**
  119872. * Update the transform matrix to update from the current active camera
  119873. * @param force defines a boolean used to force the update even if cache is up to date
  119874. */
  119875. updateTransformMatrix(force?: boolean): void;
  119876. private _bindFrameBuffer;
  119877. /** @hidden */
  119878. _allowPostProcessClearColor: boolean;
  119879. /** @hidden */
  119880. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119881. private _processSubCameras;
  119882. private _checkIntersections;
  119883. /** @hidden */
  119884. _advancePhysicsEngineStep(step: number): void;
  119885. /**
  119886. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119887. */
  119888. getDeterministicFrameTime: () => number;
  119889. /** @hidden */
  119890. _animate(): void;
  119891. /** Execute all animations (for a frame) */
  119892. animate(): void;
  119893. /**
  119894. * Render the scene
  119895. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119896. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119897. */
  119898. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119899. /**
  119900. * Freeze all materials
  119901. * A frozen material will not be updatable but should be faster to render
  119902. */
  119903. freezeMaterials(): void;
  119904. /**
  119905. * Unfreeze all materials
  119906. * A frozen material will not be updatable but should be faster to render
  119907. */
  119908. unfreezeMaterials(): void;
  119909. /**
  119910. * Releases all held ressources
  119911. */
  119912. dispose(): void;
  119913. /**
  119914. * Gets if the scene is already disposed
  119915. */
  119916. get isDisposed(): boolean;
  119917. /**
  119918. * Call this function to reduce memory footprint of the scene.
  119919. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119920. */
  119921. clearCachedVertexData(): void;
  119922. /**
  119923. * This function will remove the local cached buffer data from texture.
  119924. * It will save memory but will prevent the texture from being rebuilt
  119925. */
  119926. cleanCachedTextureBuffer(): void;
  119927. /**
  119928. * Get the world extend vectors with an optional filter
  119929. *
  119930. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119931. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119932. */
  119933. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119934. min: Vector3;
  119935. max: Vector3;
  119936. };
  119937. /**
  119938. * Creates a ray that can be used to pick in the scene
  119939. * @param x defines the x coordinate of the origin (on-screen)
  119940. * @param y defines the y coordinate of the origin (on-screen)
  119941. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119942. * @param camera defines the camera to use for the picking
  119943. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119944. * @returns a Ray
  119945. */
  119946. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119947. /**
  119948. * Creates a ray that can be used to pick in the scene
  119949. * @param x defines the x coordinate of the origin (on-screen)
  119950. * @param y defines the y coordinate of the origin (on-screen)
  119951. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119952. * @param result defines the ray where to store the picking ray
  119953. * @param camera defines the camera to use for the picking
  119954. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119955. * @returns the current scene
  119956. */
  119957. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119958. /**
  119959. * Creates a ray that can be used to pick in the scene
  119960. * @param x defines the x coordinate of the origin (on-screen)
  119961. * @param y defines the y coordinate of the origin (on-screen)
  119962. * @param camera defines the camera to use for the picking
  119963. * @returns a Ray
  119964. */
  119965. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119966. /**
  119967. * Creates a ray that can be used to pick in the scene
  119968. * @param x defines the x coordinate of the origin (on-screen)
  119969. * @param y defines the y coordinate of the origin (on-screen)
  119970. * @param result defines the ray where to store the picking ray
  119971. * @param camera defines the camera to use for the picking
  119972. * @returns the current scene
  119973. */
  119974. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119975. /** Launch a ray to try to pick a mesh in the scene
  119976. * @param x position on screen
  119977. * @param y position on screen
  119978. * @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
  119979. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119980. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119982. * @returns a PickingInfo
  119983. */
  119984. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119985. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119986. * @param x position on screen
  119987. * @param y position on screen
  119988. * @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
  119989. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119990. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119991. * @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)
  119992. */
  119993. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119994. /** Use the given ray to pick a mesh in the scene
  119995. * @param ray The ray to use to pick meshes
  119996. * @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
  119997. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119999. * @returns a PickingInfo
  120000. */
  120001. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120002. /**
  120003. * Launch a ray to try to pick a mesh in the scene
  120004. * @param x X position on screen
  120005. * @param y Y position on screen
  120006. * @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
  120007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120009. * @returns an array of PickingInfo
  120010. */
  120011. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120012. /**
  120013. * Launch a ray to try to pick a mesh in the scene
  120014. * @param ray Ray to use
  120015. * @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
  120016. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120017. * @returns an array of PickingInfo
  120018. */
  120019. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120020. /**
  120021. * Force the value of meshUnderPointer
  120022. * @param mesh defines the mesh to use
  120023. */
  120024. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  120025. /**
  120026. * Gets the mesh under the pointer
  120027. * @returns a Mesh or null if no mesh is under the pointer
  120028. */
  120029. getPointerOverMesh(): Nullable<AbstractMesh>;
  120030. /** @hidden */
  120031. _rebuildGeometries(): void;
  120032. /** @hidden */
  120033. _rebuildTextures(): void;
  120034. private _getByTags;
  120035. /**
  120036. * Get a list of meshes by tags
  120037. * @param tagsQuery defines the tags query to use
  120038. * @param forEach defines a predicate used to filter results
  120039. * @returns an array of Mesh
  120040. */
  120041. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120042. /**
  120043. * Get a list of cameras by tags
  120044. * @param tagsQuery defines the tags query to use
  120045. * @param forEach defines a predicate used to filter results
  120046. * @returns an array of Camera
  120047. */
  120048. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120049. /**
  120050. * Get a list of lights by tags
  120051. * @param tagsQuery defines the tags query to use
  120052. * @param forEach defines a predicate used to filter results
  120053. * @returns an array of Light
  120054. */
  120055. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120056. /**
  120057. * Get a list of materials by tags
  120058. * @param tagsQuery defines the tags query to use
  120059. * @param forEach defines a predicate used to filter results
  120060. * @returns an array of Material
  120061. */
  120062. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120063. /**
  120064. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120065. * This allowed control for front to back rendering or reversly depending of the special needs.
  120066. *
  120067. * @param renderingGroupId The rendering group id corresponding to its index
  120068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120071. */
  120072. 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;
  120073. /**
  120074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120075. *
  120076. * @param renderingGroupId The rendering group id corresponding to its index
  120077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120078. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120079. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120080. */
  120081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120082. /**
  120083. * Gets the current auto clear configuration for one rendering group of the rendering
  120084. * manager.
  120085. * @param index the rendering group index to get the information for
  120086. * @returns The auto clear setup for the requested rendering group
  120087. */
  120088. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120089. private _blockMaterialDirtyMechanism;
  120090. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120091. get blockMaterialDirtyMechanism(): boolean;
  120092. set blockMaterialDirtyMechanism(value: boolean);
  120093. /**
  120094. * Will flag all materials as dirty to trigger new shader compilation
  120095. * @param flag defines the flag used to specify which material part must be marked as dirty
  120096. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120097. */
  120098. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120099. /** @hidden */
  120100. _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;
  120101. /** @hidden */
  120102. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120103. /** @hidden */
  120104. _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;
  120105. /** @hidden */
  120106. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120107. /** @hidden */
  120108. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120109. /** @hidden */
  120110. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120111. }
  120112. }
  120113. declare module BABYLON {
  120114. /**
  120115. * Set of assets to keep when moving a scene into an asset container.
  120116. */
  120117. export class KeepAssets extends AbstractScene {
  120118. }
  120119. /**
  120120. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120121. */
  120122. export class InstantiatedEntries {
  120123. /**
  120124. * List of new root nodes (eg. nodes with no parent)
  120125. */
  120126. rootNodes: TransformNode[];
  120127. /**
  120128. * List of new skeletons
  120129. */
  120130. skeletons: Skeleton[];
  120131. /**
  120132. * List of new animation groups
  120133. */
  120134. animationGroups: AnimationGroup[];
  120135. }
  120136. /**
  120137. * Container with a set of assets that can be added or removed from a scene.
  120138. */
  120139. export class AssetContainer extends AbstractScene {
  120140. private _wasAddedToScene;
  120141. /**
  120142. * The scene the AssetContainer belongs to.
  120143. */
  120144. scene: Scene;
  120145. /**
  120146. * Instantiates an AssetContainer.
  120147. * @param scene The scene the AssetContainer belongs to.
  120148. */
  120149. constructor(scene: Scene);
  120150. /**
  120151. * Instantiate or clone all meshes and add the new ones to the scene.
  120152. * Skeletons and animation groups will all be cloned
  120153. * @param nameFunction defines an optional function used to get new names for clones
  120154. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120155. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120156. */
  120157. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120158. /**
  120159. * Adds all the assets from the container to the scene.
  120160. */
  120161. addAllToScene(): void;
  120162. /**
  120163. * Removes all the assets in the container from the scene
  120164. */
  120165. removeAllFromScene(): void;
  120166. /**
  120167. * Disposes all the assets in the container
  120168. */
  120169. dispose(): void;
  120170. private _moveAssets;
  120171. /**
  120172. * Removes all the assets contained in the scene and adds them to the container.
  120173. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120174. */
  120175. moveAllFromScene(keepAssets?: KeepAssets): void;
  120176. /**
  120177. * 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.
  120178. * @returns the root mesh
  120179. */
  120180. createRootMesh(): Mesh;
  120181. /**
  120182. * Merge animations (direct and animation groups) from this asset container into a scene
  120183. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120184. * @param animatables set of animatables to retarget to a node from the scene
  120185. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120186. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120187. */
  120188. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120189. }
  120190. }
  120191. declare module BABYLON {
  120192. /**
  120193. * Defines how the parser contract is defined.
  120194. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120195. */
  120196. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120197. /**
  120198. * Defines how the individual parser contract is defined.
  120199. * These parser can parse an individual asset
  120200. */
  120201. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120202. /**
  120203. * Base class of the scene acting as a container for the different elements composing a scene.
  120204. * This class is dynamically extended by the different components of the scene increasing
  120205. * flexibility and reducing coupling
  120206. */
  120207. export abstract class AbstractScene {
  120208. /**
  120209. * Stores the list of available parsers in the application.
  120210. */
  120211. private static _BabylonFileParsers;
  120212. /**
  120213. * Stores the list of available individual parsers in the application.
  120214. */
  120215. private static _IndividualBabylonFileParsers;
  120216. /**
  120217. * Adds a parser in the list of available ones
  120218. * @param name Defines the name of the parser
  120219. * @param parser Defines the parser to add
  120220. */
  120221. static AddParser(name: string, parser: BabylonFileParser): void;
  120222. /**
  120223. * Gets a general parser from the list of avaialble ones
  120224. * @param name Defines the name of the parser
  120225. * @returns the requested parser or null
  120226. */
  120227. static GetParser(name: string): Nullable<BabylonFileParser>;
  120228. /**
  120229. * Adds n individual parser in the list of available ones
  120230. * @param name Defines the name of the parser
  120231. * @param parser Defines the parser to add
  120232. */
  120233. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120234. /**
  120235. * Gets an individual parser from the list of avaialble ones
  120236. * @param name Defines the name of the parser
  120237. * @returns the requested parser or null
  120238. */
  120239. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120240. /**
  120241. * Parser json data and populate both a scene and its associated container object
  120242. * @param jsonData Defines the data to parse
  120243. * @param scene Defines the scene to parse the data for
  120244. * @param container Defines the container attached to the parsing sequence
  120245. * @param rootUrl Defines the root url of the data
  120246. */
  120247. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120248. /**
  120249. * Gets the list of root nodes (ie. nodes with no parent)
  120250. */
  120251. rootNodes: Node[];
  120252. /** All of the cameras added to this scene
  120253. * @see https://doc.babylonjs.com/babylon101/cameras
  120254. */
  120255. cameras: Camera[];
  120256. /**
  120257. * All of the lights added to this scene
  120258. * @see https://doc.babylonjs.com/babylon101/lights
  120259. */
  120260. lights: Light[];
  120261. /**
  120262. * All of the (abstract) meshes added to this scene
  120263. */
  120264. meshes: AbstractMesh[];
  120265. /**
  120266. * The list of skeletons added to the scene
  120267. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120268. */
  120269. skeletons: Skeleton[];
  120270. /**
  120271. * All of the particle systems added to this scene
  120272. * @see https://doc.babylonjs.com/babylon101/particles
  120273. */
  120274. particleSystems: IParticleSystem[];
  120275. /**
  120276. * Gets a list of Animations associated with the scene
  120277. */
  120278. animations: Animation[];
  120279. /**
  120280. * All of the animation groups added to this scene
  120281. * @see https://doc.babylonjs.com/how_to/group
  120282. */
  120283. animationGroups: AnimationGroup[];
  120284. /**
  120285. * All of the multi-materials added to this scene
  120286. * @see https://doc.babylonjs.com/how_to/multi_materials
  120287. */
  120288. multiMaterials: MultiMaterial[];
  120289. /**
  120290. * All of the materials added to this scene
  120291. * In the context of a Scene, it is not supposed to be modified manually.
  120292. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120293. * Note also that the order of the Material within the array is not significant and might change.
  120294. * @see https://doc.babylonjs.com/babylon101/materials
  120295. */
  120296. materials: Material[];
  120297. /**
  120298. * The list of morph target managers added to the scene
  120299. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120300. */
  120301. morphTargetManagers: MorphTargetManager[];
  120302. /**
  120303. * The list of geometries used in the scene.
  120304. */
  120305. geometries: Geometry[];
  120306. /**
  120307. * All of the tranform nodes added to this scene
  120308. * In the context of a Scene, it is not supposed to be modified manually.
  120309. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120310. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120311. * @see https://doc.babylonjs.com/how_to/transformnode
  120312. */
  120313. transformNodes: TransformNode[];
  120314. /**
  120315. * ActionManagers available on the scene.
  120316. */
  120317. actionManagers: AbstractActionManager[];
  120318. /**
  120319. * Textures to keep.
  120320. */
  120321. textures: BaseTexture[];
  120322. /**
  120323. * Environment texture for the scene
  120324. */
  120325. environmentTexture: Nullable<BaseTexture>;
  120326. /**
  120327. * @returns all meshes, lights, cameras, transformNodes and bones
  120328. */
  120329. getNodes(): Array<Node>;
  120330. }
  120331. }
  120332. declare module BABYLON {
  120333. /**
  120334. * Interface used to define options for Sound class
  120335. */
  120336. export interface ISoundOptions {
  120337. /**
  120338. * Does the sound autoplay once loaded.
  120339. */
  120340. autoplay?: boolean;
  120341. /**
  120342. * Does the sound loop after it finishes playing once.
  120343. */
  120344. loop?: boolean;
  120345. /**
  120346. * Sound's volume
  120347. */
  120348. volume?: number;
  120349. /**
  120350. * Is it a spatial sound?
  120351. */
  120352. spatialSound?: boolean;
  120353. /**
  120354. * Maximum distance to hear that sound
  120355. */
  120356. maxDistance?: number;
  120357. /**
  120358. * Uses user defined attenuation function
  120359. */
  120360. useCustomAttenuation?: boolean;
  120361. /**
  120362. * Define the roll off factor of spatial sounds.
  120363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120364. */
  120365. rolloffFactor?: number;
  120366. /**
  120367. * Define the reference distance the sound should be heard perfectly.
  120368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120369. */
  120370. refDistance?: number;
  120371. /**
  120372. * Define the distance attenuation model the sound will follow.
  120373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120374. */
  120375. distanceModel?: string;
  120376. /**
  120377. * Defines the playback speed (1 by default)
  120378. */
  120379. playbackRate?: number;
  120380. /**
  120381. * Defines if the sound is from a streaming source
  120382. */
  120383. streaming?: boolean;
  120384. /**
  120385. * Defines an optional length (in seconds) inside the sound file
  120386. */
  120387. length?: number;
  120388. /**
  120389. * Defines an optional offset (in seconds) inside the sound file
  120390. */
  120391. offset?: number;
  120392. /**
  120393. * If true, URLs will not be required to state the audio file codec to use.
  120394. */
  120395. skipCodecCheck?: boolean;
  120396. }
  120397. /**
  120398. * Defines a sound that can be played in the application.
  120399. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120400. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120401. */
  120402. export class Sound {
  120403. /**
  120404. * The name of the sound in the scene.
  120405. */
  120406. name: string;
  120407. /**
  120408. * Does the sound autoplay once loaded.
  120409. */
  120410. autoplay: boolean;
  120411. /**
  120412. * Does the sound loop after it finishes playing once.
  120413. */
  120414. loop: boolean;
  120415. /**
  120416. * Does the sound use a custom attenuation curve to simulate the falloff
  120417. * happening when the source gets further away from the camera.
  120418. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120419. */
  120420. useCustomAttenuation: boolean;
  120421. /**
  120422. * The sound track id this sound belongs to.
  120423. */
  120424. soundTrackId: number;
  120425. /**
  120426. * Is this sound currently played.
  120427. */
  120428. isPlaying: boolean;
  120429. /**
  120430. * Is this sound currently paused.
  120431. */
  120432. isPaused: boolean;
  120433. /**
  120434. * Does this sound enables spatial sound.
  120435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120436. */
  120437. spatialSound: boolean;
  120438. /**
  120439. * Define the reference distance the sound should be heard perfectly.
  120440. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120441. */
  120442. refDistance: number;
  120443. /**
  120444. * Define the roll off factor of spatial sounds.
  120445. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120446. */
  120447. rolloffFactor: number;
  120448. /**
  120449. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120450. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120451. */
  120452. maxDistance: number;
  120453. /**
  120454. * Define the distance attenuation model the sound will follow.
  120455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120456. */
  120457. distanceModel: string;
  120458. /**
  120459. * @hidden
  120460. * Back Compat
  120461. **/
  120462. onended: () => any;
  120463. /**
  120464. * Gets or sets an object used to store user defined information for the sound.
  120465. */
  120466. metadata: any;
  120467. /**
  120468. * Observable event when the current playing sound finishes.
  120469. */
  120470. onEndedObservable: Observable<Sound>;
  120471. private _panningModel;
  120472. private _playbackRate;
  120473. private _streaming;
  120474. private _startTime;
  120475. private _startOffset;
  120476. private _position;
  120477. /** @hidden */
  120478. _positionInEmitterSpace: boolean;
  120479. private _localDirection;
  120480. private _volume;
  120481. private _isReadyToPlay;
  120482. private _isDirectional;
  120483. private _readyToPlayCallback;
  120484. private _audioBuffer;
  120485. private _soundSource;
  120486. private _streamingSource;
  120487. private _soundPanner;
  120488. private _soundGain;
  120489. private _inputAudioNode;
  120490. private _outputAudioNode;
  120491. private _coneInnerAngle;
  120492. private _coneOuterAngle;
  120493. private _coneOuterGain;
  120494. private _scene;
  120495. private _connectedTransformNode;
  120496. private _customAttenuationFunction;
  120497. private _registerFunc;
  120498. private _isOutputConnected;
  120499. private _htmlAudioElement;
  120500. private _urlType;
  120501. private _length?;
  120502. private _offset?;
  120503. /** @hidden */
  120504. static _SceneComponentInitialization: (scene: Scene) => void;
  120505. /**
  120506. * Create a sound and attach it to a scene
  120507. * @param name Name of your sound
  120508. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120509. * @param scene defines the scene the sound belongs to
  120510. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120511. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120512. */
  120513. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120514. /**
  120515. * Release the sound and its associated resources
  120516. */
  120517. dispose(): void;
  120518. /**
  120519. * Gets if the sounds is ready to be played or not.
  120520. * @returns true if ready, otherwise false
  120521. */
  120522. isReady(): boolean;
  120523. private _soundLoaded;
  120524. /**
  120525. * Sets the data of the sound from an audiobuffer
  120526. * @param audioBuffer The audioBuffer containing the data
  120527. */
  120528. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120529. /**
  120530. * Updates the current sounds options such as maxdistance, loop...
  120531. * @param options A JSON object containing values named as the object properties
  120532. */
  120533. updateOptions(options: ISoundOptions): void;
  120534. private _createSpatialParameters;
  120535. private _updateSpatialParameters;
  120536. /**
  120537. * Switch the panning model to HRTF:
  120538. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120540. */
  120541. switchPanningModelToHRTF(): void;
  120542. /**
  120543. * Switch the panning model to Equal Power:
  120544. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120546. */
  120547. switchPanningModelToEqualPower(): void;
  120548. private _switchPanningModel;
  120549. /**
  120550. * Connect this sound to a sound track audio node like gain...
  120551. * @param soundTrackAudioNode the sound track audio node to connect to
  120552. */
  120553. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120554. /**
  120555. * Transform this sound into a directional source
  120556. * @param coneInnerAngle Size of the inner cone in degree
  120557. * @param coneOuterAngle Size of the outer cone in degree
  120558. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120559. */
  120560. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120561. /**
  120562. * Gets or sets the inner angle for the directional cone.
  120563. */
  120564. get directionalConeInnerAngle(): number;
  120565. /**
  120566. * Gets or sets the inner angle for the directional cone.
  120567. */
  120568. set directionalConeInnerAngle(value: number);
  120569. /**
  120570. * Gets or sets the outer angle for the directional cone.
  120571. */
  120572. get directionalConeOuterAngle(): number;
  120573. /**
  120574. * Gets or sets the outer angle for the directional cone.
  120575. */
  120576. set directionalConeOuterAngle(value: number);
  120577. /**
  120578. * Sets the position of the emitter if spatial sound is enabled
  120579. * @param newPosition Defines the new posisiton
  120580. */
  120581. setPosition(newPosition: Vector3): void;
  120582. /**
  120583. * Sets the local direction of the emitter if spatial sound is enabled
  120584. * @param newLocalDirection Defines the new local direction
  120585. */
  120586. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120587. private _updateDirection;
  120588. /** @hidden */
  120589. updateDistanceFromListener(): void;
  120590. /**
  120591. * Sets a new custom attenuation function for the sound.
  120592. * @param callback Defines the function used for the attenuation
  120593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120594. */
  120595. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120596. /**
  120597. * Play the sound
  120598. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120599. * @param offset (optional) Start the sound at a specific time in seconds
  120600. * @param length (optional) Sound duration (in seconds)
  120601. */
  120602. play(time?: number, offset?: number, length?: number): void;
  120603. private _onended;
  120604. /**
  120605. * Stop the sound
  120606. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120607. */
  120608. stop(time?: number): void;
  120609. /**
  120610. * Put the sound in pause
  120611. */
  120612. pause(): void;
  120613. /**
  120614. * Sets a dedicated volume for this sounds
  120615. * @param newVolume Define the new volume of the sound
  120616. * @param time Define time for gradual change to new volume
  120617. */
  120618. setVolume(newVolume: number, time?: number): void;
  120619. /**
  120620. * Set the sound play back rate
  120621. * @param newPlaybackRate Define the playback rate the sound should be played at
  120622. */
  120623. setPlaybackRate(newPlaybackRate: number): void;
  120624. /**
  120625. * Gets the volume of the sound.
  120626. * @returns the volume of the sound
  120627. */
  120628. getVolume(): number;
  120629. /**
  120630. * Attach the sound to a dedicated mesh
  120631. * @param transformNode The transform node to connect the sound with
  120632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120633. */
  120634. attachToMesh(transformNode: TransformNode): void;
  120635. /**
  120636. * Detach the sound from the previously attached mesh
  120637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120638. */
  120639. detachFromMesh(): void;
  120640. private _onRegisterAfterWorldMatrixUpdate;
  120641. /**
  120642. * Clone the current sound in the scene.
  120643. * @returns the new sound clone
  120644. */
  120645. clone(): Nullable<Sound>;
  120646. /**
  120647. * Gets the current underlying audio buffer containing the data
  120648. * @returns the audio buffer
  120649. */
  120650. getAudioBuffer(): Nullable<AudioBuffer>;
  120651. /**
  120652. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120653. * @returns the source node
  120654. */
  120655. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120656. /**
  120657. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120658. * @returns the gain node
  120659. */
  120660. getSoundGain(): Nullable<GainNode>;
  120661. /**
  120662. * Serializes the Sound in a JSON representation
  120663. * @returns the JSON representation of the sound
  120664. */
  120665. serialize(): any;
  120666. /**
  120667. * Parse a JSON representation of a sound to innstantiate in a given scene
  120668. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120669. * @param scene Define the scene the new parsed sound should be created in
  120670. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120671. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120672. * @returns the newly parsed sound
  120673. */
  120674. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * This defines an action helpful to play a defined sound on a triggered action.
  120680. */
  120681. export class PlaySoundAction extends Action {
  120682. private _sound;
  120683. /**
  120684. * Instantiate the action
  120685. * @param triggerOptions defines the trigger options
  120686. * @param sound defines the sound to play
  120687. * @param condition defines the trigger related conditions
  120688. */
  120689. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120690. /** @hidden */
  120691. _prepare(): void;
  120692. /**
  120693. * Execute the action and play the sound.
  120694. */
  120695. execute(): void;
  120696. /**
  120697. * Serializes the actions and its related information.
  120698. * @param parent defines the object to serialize in
  120699. * @returns the serialized object
  120700. */
  120701. serialize(parent: any): any;
  120702. }
  120703. /**
  120704. * This defines an action helpful to stop a defined sound on a triggered action.
  120705. */
  120706. export class StopSoundAction extends Action {
  120707. private _sound;
  120708. /**
  120709. * Instantiate the action
  120710. * @param triggerOptions defines the trigger options
  120711. * @param sound defines the sound to stop
  120712. * @param condition defines the trigger related conditions
  120713. */
  120714. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120715. /** @hidden */
  120716. _prepare(): void;
  120717. /**
  120718. * Execute the action and stop the sound.
  120719. */
  120720. execute(): void;
  120721. /**
  120722. * Serializes the actions and its related information.
  120723. * @param parent defines the object to serialize in
  120724. * @returns the serialized object
  120725. */
  120726. serialize(parent: any): any;
  120727. }
  120728. }
  120729. declare module BABYLON {
  120730. /**
  120731. * This defines an action responsible to change the value of a property
  120732. * by interpolating between its current value and the newly set one once triggered.
  120733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120734. */
  120735. export class InterpolateValueAction extends Action {
  120736. /**
  120737. * Defines the path of the property where the value should be interpolated
  120738. */
  120739. propertyPath: string;
  120740. /**
  120741. * Defines the target value at the end of the interpolation.
  120742. */
  120743. value: any;
  120744. /**
  120745. * Defines the time it will take for the property to interpolate to the value.
  120746. */
  120747. duration: number;
  120748. /**
  120749. * Defines if the other scene animations should be stopped when the action has been triggered
  120750. */
  120751. stopOtherAnimations?: boolean;
  120752. /**
  120753. * Defines a callback raised once the interpolation animation has been done.
  120754. */
  120755. onInterpolationDone?: () => void;
  120756. /**
  120757. * Observable triggered once the interpolation animation has been done.
  120758. */
  120759. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120760. private _target;
  120761. private _effectiveTarget;
  120762. private _property;
  120763. /**
  120764. * Instantiate the action
  120765. * @param triggerOptions defines the trigger options
  120766. * @param target defines the object containing the value to interpolate
  120767. * @param propertyPath defines the path to the property in the target object
  120768. * @param value defines the target value at the end of the interpolation
  120769. * @param duration deines the time it will take for the property to interpolate to the value.
  120770. * @param condition defines the trigger related conditions
  120771. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120772. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120773. */
  120774. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120775. /** @hidden */
  120776. _prepare(): void;
  120777. /**
  120778. * Execute the action starts the value interpolation.
  120779. */
  120780. execute(): void;
  120781. /**
  120782. * Serializes the actions and its related information.
  120783. * @param parent defines the object to serialize in
  120784. * @returns the serialized object
  120785. */
  120786. serialize(parent: any): any;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * Options allowed during the creation of a sound track.
  120792. */
  120793. export interface ISoundTrackOptions {
  120794. /**
  120795. * The volume the sound track should take during creation
  120796. */
  120797. volume?: number;
  120798. /**
  120799. * Define if the sound track is the main sound track of the scene
  120800. */
  120801. mainTrack?: boolean;
  120802. }
  120803. /**
  120804. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120805. * It will be also used in a future release to apply effects on a specific track.
  120806. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120807. */
  120808. export class SoundTrack {
  120809. /**
  120810. * The unique identifier of the sound track in the scene.
  120811. */
  120812. id: number;
  120813. /**
  120814. * The list of sounds included in the sound track.
  120815. */
  120816. soundCollection: Array<Sound>;
  120817. private _outputAudioNode;
  120818. private _scene;
  120819. private _connectedAnalyser;
  120820. private _options;
  120821. private _isInitialized;
  120822. /**
  120823. * Creates a new sound track.
  120824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120825. * @param scene Define the scene the sound track belongs to
  120826. * @param options
  120827. */
  120828. constructor(scene: Scene, options?: ISoundTrackOptions);
  120829. private _initializeSoundTrackAudioGraph;
  120830. /**
  120831. * Release the sound track and its associated resources
  120832. */
  120833. dispose(): void;
  120834. /**
  120835. * Adds a sound to this sound track
  120836. * @param sound define the cound to add
  120837. * @ignoreNaming
  120838. */
  120839. AddSound(sound: Sound): void;
  120840. /**
  120841. * Removes a sound to this sound track
  120842. * @param sound define the cound to remove
  120843. * @ignoreNaming
  120844. */
  120845. RemoveSound(sound: Sound): void;
  120846. /**
  120847. * Set a global volume for the full sound track.
  120848. * @param newVolume Define the new volume of the sound track
  120849. */
  120850. setVolume(newVolume: number): void;
  120851. /**
  120852. * Switch the panning model to HRTF:
  120853. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120855. */
  120856. switchPanningModelToHRTF(): void;
  120857. /**
  120858. * Switch the panning model to Equal Power:
  120859. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120861. */
  120862. switchPanningModelToEqualPower(): void;
  120863. /**
  120864. * Connect the sound track to an audio analyser allowing some amazing
  120865. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120867. * @param analyser The analyser to connect to the engine
  120868. */
  120869. connectToAnalyser(analyser: Analyser): void;
  120870. }
  120871. }
  120872. declare module BABYLON {
  120873. interface AbstractScene {
  120874. /**
  120875. * The list of sounds used in the scene.
  120876. */
  120877. sounds: Nullable<Array<Sound>>;
  120878. }
  120879. interface Scene {
  120880. /**
  120881. * @hidden
  120882. * Backing field
  120883. */
  120884. _mainSoundTrack: SoundTrack;
  120885. /**
  120886. * The main sound track played by the scene.
  120887. * It cotains your primary collection of sounds.
  120888. */
  120889. mainSoundTrack: SoundTrack;
  120890. /**
  120891. * The list of sound tracks added to the scene
  120892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120893. */
  120894. soundTracks: Nullable<Array<SoundTrack>>;
  120895. /**
  120896. * Gets a sound using a given name
  120897. * @param name defines the name to search for
  120898. * @return the found sound or null if not found at all.
  120899. */
  120900. getSoundByName(name: string): Nullable<Sound>;
  120901. /**
  120902. * Gets or sets if audio support is enabled
  120903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120904. */
  120905. audioEnabled: boolean;
  120906. /**
  120907. * Gets or sets if audio will be output to headphones
  120908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120909. */
  120910. headphone: boolean;
  120911. /**
  120912. * Gets or sets custom audio listener position provider
  120913. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120914. */
  120915. audioListenerPositionProvider: Nullable<() => Vector3>;
  120916. /**
  120917. * Gets or sets a refresh rate when using 3D audio positioning
  120918. */
  120919. audioPositioningRefreshRate: number;
  120920. }
  120921. /**
  120922. * Defines the sound scene component responsible to manage any sounds
  120923. * in a given scene.
  120924. */
  120925. export class AudioSceneComponent implements ISceneSerializableComponent {
  120926. /**
  120927. * The component name helpfull to identify the component in the list of scene components.
  120928. */
  120929. readonly name: string;
  120930. /**
  120931. * The scene the component belongs to.
  120932. */
  120933. scene: Scene;
  120934. private _audioEnabled;
  120935. /**
  120936. * Gets whether audio is enabled or not.
  120937. * Please use related enable/disable method to switch state.
  120938. */
  120939. get audioEnabled(): boolean;
  120940. private _headphone;
  120941. /**
  120942. * Gets whether audio is outputing to headphone or not.
  120943. * Please use the according Switch methods to change output.
  120944. */
  120945. get headphone(): boolean;
  120946. /**
  120947. * Gets or sets a refresh rate when using 3D audio positioning
  120948. */
  120949. audioPositioningRefreshRate: number;
  120950. private _audioListenerPositionProvider;
  120951. /**
  120952. * Gets the current audio listener position provider
  120953. */
  120954. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120955. /**
  120956. * Sets a custom listener position for all sounds in the scene
  120957. * By default, this is the position of the first active camera
  120958. */
  120959. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120960. /**
  120961. * Creates a new instance of the component for the given scene
  120962. * @param scene Defines the scene to register the component in
  120963. */
  120964. constructor(scene: Scene);
  120965. /**
  120966. * Registers the component in a given scene
  120967. */
  120968. register(): void;
  120969. /**
  120970. * Rebuilds the elements related to this component in case of
  120971. * context lost for instance.
  120972. */
  120973. rebuild(): void;
  120974. /**
  120975. * Serializes the component data to the specified json object
  120976. * @param serializationObject The object to serialize to
  120977. */
  120978. serialize(serializationObject: any): void;
  120979. /**
  120980. * Adds all the elements from the container to the scene
  120981. * @param container the container holding the elements
  120982. */
  120983. addFromContainer(container: AbstractScene): void;
  120984. /**
  120985. * Removes all the elements in the container from the scene
  120986. * @param container contains the elements to remove
  120987. * @param dispose if the removed element should be disposed (default: false)
  120988. */
  120989. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120990. /**
  120991. * Disposes the component and the associated ressources.
  120992. */
  120993. dispose(): void;
  120994. /**
  120995. * Disables audio in the associated scene.
  120996. */
  120997. disableAudio(): void;
  120998. /**
  120999. * Enables audio in the associated scene.
  121000. */
  121001. enableAudio(): void;
  121002. /**
  121003. * Switch audio to headphone output.
  121004. */
  121005. switchAudioModeForHeadphones(): void;
  121006. /**
  121007. * Switch audio to normal speakers.
  121008. */
  121009. switchAudioModeForNormalSpeakers(): void;
  121010. private _cachedCameraDirection;
  121011. private _cachedCameraPosition;
  121012. private _lastCheck;
  121013. private _afterRender;
  121014. }
  121015. }
  121016. declare module BABYLON {
  121017. /**
  121018. * Wraps one or more Sound objects and selects one with random weight for playback.
  121019. */
  121020. export class WeightedSound {
  121021. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121022. loop: boolean;
  121023. private _coneInnerAngle;
  121024. private _coneOuterAngle;
  121025. private _volume;
  121026. /** A Sound is currently playing. */
  121027. isPlaying: boolean;
  121028. /** A Sound is currently paused. */
  121029. isPaused: boolean;
  121030. private _sounds;
  121031. private _weights;
  121032. private _currentIndex?;
  121033. /**
  121034. * Creates a new WeightedSound from the list of sounds given.
  121035. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121036. * @param sounds Array of Sounds that will be selected from.
  121037. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121038. */
  121039. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121040. /**
  121041. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121042. */
  121043. get directionalConeInnerAngle(): number;
  121044. /**
  121045. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121046. */
  121047. set directionalConeInnerAngle(value: number);
  121048. /**
  121049. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121050. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121051. */
  121052. get directionalConeOuterAngle(): number;
  121053. /**
  121054. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121055. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121056. */
  121057. set directionalConeOuterAngle(value: number);
  121058. /**
  121059. * Playback volume.
  121060. */
  121061. get volume(): number;
  121062. /**
  121063. * Playback volume.
  121064. */
  121065. set volume(value: number);
  121066. private _onended;
  121067. /**
  121068. * Suspend playback
  121069. */
  121070. pause(): void;
  121071. /**
  121072. * Stop playback
  121073. */
  121074. stop(): void;
  121075. /**
  121076. * Start playback.
  121077. * @param startOffset Position the clip head at a specific time in seconds.
  121078. */
  121079. play(startOffset?: number): void;
  121080. }
  121081. }
  121082. declare module BABYLON {
  121083. /**
  121084. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121085. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121086. */
  121087. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121088. /**
  121089. * Gets the name of the behavior.
  121090. */
  121091. get name(): string;
  121092. /**
  121093. * The easing function used by animations
  121094. */
  121095. static EasingFunction: BackEase;
  121096. /**
  121097. * The easing mode used by animations
  121098. */
  121099. static EasingMode: number;
  121100. /**
  121101. * The duration of the animation, in milliseconds
  121102. */
  121103. transitionDuration: number;
  121104. /**
  121105. * Length of the distance animated by the transition when lower radius is reached
  121106. */
  121107. lowerRadiusTransitionRange: number;
  121108. /**
  121109. * Length of the distance animated by the transition when upper radius is reached
  121110. */
  121111. upperRadiusTransitionRange: number;
  121112. private _autoTransitionRange;
  121113. /**
  121114. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121115. */
  121116. get autoTransitionRange(): boolean;
  121117. /**
  121118. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121119. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121120. */
  121121. set autoTransitionRange(value: boolean);
  121122. private _attachedCamera;
  121123. private _onAfterCheckInputsObserver;
  121124. private _onMeshTargetChangedObserver;
  121125. /**
  121126. * Initializes the behavior.
  121127. */
  121128. init(): void;
  121129. /**
  121130. * Attaches the behavior to its arc rotate camera.
  121131. * @param camera Defines the camera to attach the behavior to
  121132. */
  121133. attach(camera: ArcRotateCamera): void;
  121134. /**
  121135. * Detaches the behavior from its current arc rotate camera.
  121136. */
  121137. detach(): void;
  121138. private _radiusIsAnimating;
  121139. private _radiusBounceTransition;
  121140. private _animatables;
  121141. private _cachedWheelPrecision;
  121142. /**
  121143. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121144. * @param radiusLimit The limit to check against.
  121145. * @return Bool to indicate if at limit.
  121146. */
  121147. private _isRadiusAtLimit;
  121148. /**
  121149. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121150. * @param radiusDelta The delta by which to animate to. Can be negative.
  121151. */
  121152. private _applyBoundRadiusAnimation;
  121153. /**
  121154. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121155. */
  121156. protected _clearAnimationLocks(): void;
  121157. /**
  121158. * Stops and removes all animations that have been applied to the camera
  121159. */
  121160. stopAllAnimations(): void;
  121161. }
  121162. }
  121163. declare module BABYLON {
  121164. /**
  121165. * 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.
  121166. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121167. */
  121168. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121169. /**
  121170. * Gets the name of the behavior.
  121171. */
  121172. get name(): string;
  121173. private _mode;
  121174. private _radiusScale;
  121175. private _positionScale;
  121176. private _defaultElevation;
  121177. private _elevationReturnTime;
  121178. private _elevationReturnWaitTime;
  121179. private _zoomStopsAnimation;
  121180. private _framingTime;
  121181. /**
  121182. * The easing function used by animations
  121183. */
  121184. static EasingFunction: ExponentialEase;
  121185. /**
  121186. * The easing mode used by animations
  121187. */
  121188. static EasingMode: number;
  121189. /**
  121190. * Sets the current mode used by the behavior
  121191. */
  121192. set mode(mode: number);
  121193. /**
  121194. * Gets current mode used by the behavior.
  121195. */
  121196. get mode(): number;
  121197. /**
  121198. * Sets the scale applied to the radius (1 by default)
  121199. */
  121200. set radiusScale(radius: number);
  121201. /**
  121202. * Gets the scale applied to the radius
  121203. */
  121204. get radiusScale(): number;
  121205. /**
  121206. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121207. */
  121208. set positionScale(scale: number);
  121209. /**
  121210. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121211. */
  121212. get positionScale(): number;
  121213. /**
  121214. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121215. * behaviour is triggered, in radians.
  121216. */
  121217. set defaultElevation(elevation: number);
  121218. /**
  121219. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121220. * behaviour is triggered, in radians.
  121221. */
  121222. get defaultElevation(): number;
  121223. /**
  121224. * Sets the time (in milliseconds) taken to return to the default beta position.
  121225. * Negative value indicates camera should not return to default.
  121226. */
  121227. set elevationReturnTime(speed: number);
  121228. /**
  121229. * Gets the time (in milliseconds) taken to return to the default beta position.
  121230. * Negative value indicates camera should not return to default.
  121231. */
  121232. get elevationReturnTime(): number;
  121233. /**
  121234. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121235. */
  121236. set elevationReturnWaitTime(time: number);
  121237. /**
  121238. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121239. */
  121240. get elevationReturnWaitTime(): number;
  121241. /**
  121242. * Sets the flag that indicates if user zooming should stop animation.
  121243. */
  121244. set zoomStopsAnimation(flag: boolean);
  121245. /**
  121246. * Gets the flag that indicates if user zooming should stop animation.
  121247. */
  121248. get zoomStopsAnimation(): boolean;
  121249. /**
  121250. * Sets the transition time when framing the mesh, in milliseconds
  121251. */
  121252. set framingTime(time: number);
  121253. /**
  121254. * Gets the transition time when framing the mesh, in milliseconds
  121255. */
  121256. get framingTime(): number;
  121257. /**
  121258. * Define if the behavior should automatically change the configured
  121259. * camera limits and sensibilities.
  121260. */
  121261. autoCorrectCameraLimitsAndSensibility: boolean;
  121262. private _onPrePointerObservableObserver;
  121263. private _onAfterCheckInputsObserver;
  121264. private _onMeshTargetChangedObserver;
  121265. private _attachedCamera;
  121266. private _isPointerDown;
  121267. private _lastInteractionTime;
  121268. /**
  121269. * Initializes the behavior.
  121270. */
  121271. init(): void;
  121272. /**
  121273. * Attaches the behavior to its arc rotate camera.
  121274. * @param camera Defines the camera to attach the behavior to
  121275. */
  121276. attach(camera: ArcRotateCamera): void;
  121277. /**
  121278. * Detaches the behavior from its current arc rotate camera.
  121279. */
  121280. detach(): void;
  121281. private _animatables;
  121282. private _betaIsAnimating;
  121283. private _betaTransition;
  121284. private _radiusTransition;
  121285. private _vectorTransition;
  121286. /**
  121287. * Targets the given mesh and updates zoom level accordingly.
  121288. * @param mesh The mesh to target.
  121289. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121290. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121291. */
  121292. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121293. /**
  121294. * Targets the given mesh with its children and updates zoom level accordingly.
  121295. * @param mesh The mesh to target.
  121296. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121297. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121298. */
  121299. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121300. /**
  121301. * Targets the given meshes with their children and updates zoom level accordingly.
  121302. * @param meshes The mesh to target.
  121303. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121304. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121305. */
  121306. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121307. /**
  121308. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121309. * @param minimumWorld Determines the smaller position of the bounding box extend
  121310. * @param maximumWorld Determines the bigger position of the bounding box extend
  121311. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121312. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121313. */
  121314. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121315. /**
  121316. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121317. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121318. * frustum width.
  121319. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121320. * to fully enclose the mesh in the viewing frustum.
  121321. */
  121322. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121323. /**
  121324. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121325. * is automatically returned to its default position (expected to be above ground plane).
  121326. */
  121327. private _maintainCameraAboveGround;
  121328. /**
  121329. * Returns the frustum slope based on the canvas ratio and camera FOV
  121330. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121331. */
  121332. private _getFrustumSlope;
  121333. /**
  121334. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121335. */
  121336. private _clearAnimationLocks;
  121337. /**
  121338. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121339. */
  121340. private _applyUserInteraction;
  121341. /**
  121342. * Stops and removes all animations that have been applied to the camera
  121343. */
  121344. stopAllAnimations(): void;
  121345. /**
  121346. * Gets a value indicating if the user is moving the camera
  121347. */
  121348. get isUserIsMoving(): boolean;
  121349. /**
  121350. * The camera can move all the way towards the mesh.
  121351. */
  121352. static IgnoreBoundsSizeMode: number;
  121353. /**
  121354. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121355. */
  121356. static FitFrustumSidesMode: number;
  121357. }
  121358. }
  121359. declare module BABYLON {
  121360. /**
  121361. * Base class for Camera Pointer Inputs.
  121362. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121363. * for example usage.
  121364. */
  121365. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121366. /**
  121367. * Defines the camera the input is attached to.
  121368. */
  121369. abstract camera: Camera;
  121370. /**
  121371. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121372. */
  121373. protected _altKey: boolean;
  121374. protected _ctrlKey: boolean;
  121375. protected _metaKey: boolean;
  121376. protected _shiftKey: boolean;
  121377. /**
  121378. * Which mouse buttons were pressed at time of last mouse event.
  121379. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121380. */
  121381. protected _buttonsPressed: number;
  121382. /**
  121383. * Defines the buttons associated with the input to handle camera move.
  121384. */
  121385. buttons: number[];
  121386. /**
  121387. * Attach the input controls to a specific dom element to get the input from.
  121388. * @param element Defines the element the controls should be listened from
  121389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121390. */
  121391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121392. /**
  121393. * Detach the current controls from the specified dom element.
  121394. * @param element Defines the element to stop listening the inputs from
  121395. */
  121396. detachControl(element: Nullable<HTMLElement>): void;
  121397. /**
  121398. * Gets the class name of the current input.
  121399. * @returns the class name
  121400. */
  121401. getClassName(): string;
  121402. /**
  121403. * Get the friendly name associated with the input class.
  121404. * @returns the input friendly name
  121405. */
  121406. getSimpleName(): string;
  121407. /**
  121408. * Called on pointer POINTERDOUBLETAP event.
  121409. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121410. */
  121411. protected onDoubleTap(type: string): void;
  121412. /**
  121413. * Called on pointer POINTERMOVE event if only a single touch is active.
  121414. * Override this method to provide functionality.
  121415. */
  121416. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121417. /**
  121418. * Called on pointer POINTERMOVE event if multiple touches are active.
  121419. * Override this method to provide functionality.
  121420. */
  121421. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121422. /**
  121423. * Called on JS contextmenu event.
  121424. * Override this method to provide functionality.
  121425. */
  121426. protected onContextMenu(evt: PointerEvent): void;
  121427. /**
  121428. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121429. * press.
  121430. * Override this method to provide functionality.
  121431. */
  121432. protected onButtonDown(evt: PointerEvent): void;
  121433. /**
  121434. * Called each time a new POINTERUP event occurs. Ie, for each button
  121435. * release.
  121436. * Override this method to provide functionality.
  121437. */
  121438. protected onButtonUp(evt: PointerEvent): void;
  121439. /**
  121440. * Called when window becomes inactive.
  121441. * Override this method to provide functionality.
  121442. */
  121443. protected onLostFocus(): void;
  121444. private _pointerInput;
  121445. private _observer;
  121446. private _onLostFocus;
  121447. private pointA;
  121448. private pointB;
  121449. }
  121450. }
  121451. declare module BABYLON {
  121452. /**
  121453. * Manage the pointers inputs to control an arc rotate camera.
  121454. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121455. */
  121456. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121457. /**
  121458. * Defines the camera the input is attached to.
  121459. */
  121460. camera: ArcRotateCamera;
  121461. /**
  121462. * Gets the class name of the current input.
  121463. * @returns the class name
  121464. */
  121465. getClassName(): string;
  121466. /**
  121467. * Defines the buttons associated with the input to handle camera move.
  121468. */
  121469. buttons: number[];
  121470. /**
  121471. * Defines the pointer angular sensibility along the X axis or how fast is
  121472. * the camera rotating.
  121473. */
  121474. angularSensibilityX: number;
  121475. /**
  121476. * Defines the pointer angular sensibility along the Y axis or how fast is
  121477. * the camera rotating.
  121478. */
  121479. angularSensibilityY: number;
  121480. /**
  121481. * Defines the pointer pinch precision or how fast is the camera zooming.
  121482. */
  121483. pinchPrecision: number;
  121484. /**
  121485. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121486. * from 0.
  121487. * It defines the percentage of current camera.radius to use as delta when
  121488. * pinch zoom is used.
  121489. */
  121490. pinchDeltaPercentage: number;
  121491. /**
  121492. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121493. * that any object in the plane at the camera's target point will scale
  121494. * perfectly with finger motion.
  121495. * Overrides pinchDeltaPercentage and pinchPrecision.
  121496. */
  121497. useNaturalPinchZoom: boolean;
  121498. /**
  121499. * Defines the pointer panning sensibility or how fast is the camera moving.
  121500. */
  121501. panningSensibility: number;
  121502. /**
  121503. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121504. */
  121505. multiTouchPanning: boolean;
  121506. /**
  121507. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121508. * zoom (pinch) through multitouch.
  121509. */
  121510. multiTouchPanAndZoom: boolean;
  121511. /**
  121512. * Revers pinch action direction.
  121513. */
  121514. pinchInwards: boolean;
  121515. private _isPanClick;
  121516. private _twoFingerActivityCount;
  121517. private _isPinching;
  121518. /**
  121519. * Called on pointer POINTERMOVE event if only a single touch is active.
  121520. */
  121521. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121522. /**
  121523. * Called on pointer POINTERDOUBLETAP event.
  121524. */
  121525. protected onDoubleTap(type: string): void;
  121526. /**
  121527. * Called on pointer POINTERMOVE event if multiple touches are active.
  121528. */
  121529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121530. /**
  121531. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121532. * press.
  121533. */
  121534. protected onButtonDown(evt: PointerEvent): void;
  121535. /**
  121536. * Called each time a new POINTERUP event occurs. Ie, for each button
  121537. * release.
  121538. */
  121539. protected onButtonUp(evt: PointerEvent): void;
  121540. /**
  121541. * Called when window becomes inactive.
  121542. */
  121543. protected onLostFocus(): void;
  121544. }
  121545. }
  121546. declare module BABYLON {
  121547. /**
  121548. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121549. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121550. */
  121551. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121552. /**
  121553. * Defines the camera the input is attached to.
  121554. */
  121555. camera: ArcRotateCamera;
  121556. /**
  121557. * Defines the list of key codes associated with the up action (increase alpha)
  121558. */
  121559. keysUp: number[];
  121560. /**
  121561. * Defines the list of key codes associated with the down action (decrease alpha)
  121562. */
  121563. keysDown: number[];
  121564. /**
  121565. * Defines the list of key codes associated with the left action (increase beta)
  121566. */
  121567. keysLeft: number[];
  121568. /**
  121569. * Defines the list of key codes associated with the right action (decrease beta)
  121570. */
  121571. keysRight: number[];
  121572. /**
  121573. * Defines the list of key codes associated with the reset action.
  121574. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121575. */
  121576. keysReset: number[];
  121577. /**
  121578. * Defines the panning sensibility of the inputs.
  121579. * (How fast is the camera panning)
  121580. */
  121581. panningSensibility: number;
  121582. /**
  121583. * Defines the zooming sensibility of the inputs.
  121584. * (How fast is the camera zooming)
  121585. */
  121586. zoomingSensibility: number;
  121587. /**
  121588. * Defines whether maintaining the alt key down switch the movement mode from
  121589. * orientation to zoom.
  121590. */
  121591. useAltToZoom: boolean;
  121592. /**
  121593. * Rotation speed of the camera
  121594. */
  121595. angularSpeed: number;
  121596. private _keys;
  121597. private _ctrlPressed;
  121598. private _altPressed;
  121599. private _onCanvasBlurObserver;
  121600. private _onKeyboardObserver;
  121601. private _engine;
  121602. private _scene;
  121603. /**
  121604. * Attach the input controls to a specific dom element to get the input from.
  121605. * @param element Defines the element the controls should be listened from
  121606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121607. */
  121608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121609. /**
  121610. * Detach the current controls from the specified dom element.
  121611. * @param element Defines the element to stop listening the inputs from
  121612. */
  121613. detachControl(element: Nullable<HTMLElement>): void;
  121614. /**
  121615. * Update the current camera state depending on the inputs that have been used this frame.
  121616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121617. */
  121618. checkInputs(): void;
  121619. /**
  121620. * Gets the class name of the current intput.
  121621. * @returns the class name
  121622. */
  121623. getClassName(): string;
  121624. /**
  121625. * Get the friendly name associated with the input class.
  121626. * @returns the input friendly name
  121627. */
  121628. getSimpleName(): string;
  121629. }
  121630. }
  121631. declare module BABYLON {
  121632. /**
  121633. * Manage the mouse wheel inputs to control an arc rotate camera.
  121634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121635. */
  121636. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121637. /**
  121638. * Defines the camera the input is attached to.
  121639. */
  121640. camera: ArcRotateCamera;
  121641. /**
  121642. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121643. */
  121644. wheelPrecision: number;
  121645. /**
  121646. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121647. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121648. */
  121649. wheelDeltaPercentage: number;
  121650. private _wheel;
  121651. private _observer;
  121652. private computeDeltaFromMouseWheelLegacyEvent;
  121653. /**
  121654. * Attach the input controls to a specific dom element to get the input from.
  121655. * @param element Defines the element the controls should be listened from
  121656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121657. */
  121658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121659. /**
  121660. * Detach the current controls from the specified dom element.
  121661. * @param element Defines the element to stop listening the inputs from
  121662. */
  121663. detachControl(element: Nullable<HTMLElement>): void;
  121664. /**
  121665. * Gets the class name of the current intput.
  121666. * @returns the class name
  121667. */
  121668. getClassName(): string;
  121669. /**
  121670. * Get the friendly name associated with the input class.
  121671. * @returns the input friendly name
  121672. */
  121673. getSimpleName(): string;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. /**
  121678. * Default Inputs manager for the ArcRotateCamera.
  121679. * It groups all the default supported inputs for ease of use.
  121680. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121681. */
  121682. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121683. /**
  121684. * Instantiates a new ArcRotateCameraInputsManager.
  121685. * @param camera Defines the camera the inputs belong to
  121686. */
  121687. constructor(camera: ArcRotateCamera);
  121688. /**
  121689. * Add mouse wheel input support to the input manager.
  121690. * @returns the current input manager
  121691. */
  121692. addMouseWheel(): ArcRotateCameraInputsManager;
  121693. /**
  121694. * Add pointers input support to the input manager.
  121695. * @returns the current input manager
  121696. */
  121697. addPointers(): ArcRotateCameraInputsManager;
  121698. /**
  121699. * Add keyboard input support to the input manager.
  121700. * @returns the current input manager
  121701. */
  121702. addKeyboard(): ArcRotateCameraInputsManager;
  121703. }
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * This represents an orbital type of camera.
  121708. *
  121709. * 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.
  121710. * 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.
  121711. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121712. */
  121713. export class ArcRotateCamera extends TargetCamera {
  121714. /**
  121715. * Defines the rotation angle of the camera along the longitudinal axis.
  121716. */
  121717. alpha: number;
  121718. /**
  121719. * Defines the rotation angle of the camera along the latitudinal axis.
  121720. */
  121721. beta: number;
  121722. /**
  121723. * Defines the radius of the camera from it s target point.
  121724. */
  121725. radius: number;
  121726. protected _target: Vector3;
  121727. protected _targetHost: Nullable<AbstractMesh>;
  121728. /**
  121729. * Defines the target point of the camera.
  121730. * The camera looks towards it form the radius distance.
  121731. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  121732. */
  121733. get target(): Vector3;
  121734. set target(value: Vector3);
  121735. /**
  121736. * Define the current local position of the camera in the scene
  121737. */
  121738. get position(): Vector3;
  121739. set position(newPosition: Vector3);
  121740. protected _upVector: Vector3;
  121741. protected _upToYMatrix: Matrix;
  121742. protected _YToUpMatrix: Matrix;
  121743. /**
  121744. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121745. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121746. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121747. */
  121748. set upVector(vec: Vector3);
  121749. get upVector(): Vector3;
  121750. /**
  121751. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121752. */
  121753. setMatUp(): void;
  121754. /**
  121755. * Current inertia value on the longitudinal axis.
  121756. * The bigger this number the longer it will take for the camera to stop.
  121757. */
  121758. inertialAlphaOffset: number;
  121759. /**
  121760. * Current inertia value on the latitudinal axis.
  121761. * The bigger this number the longer it will take for the camera to stop.
  121762. */
  121763. inertialBetaOffset: number;
  121764. /**
  121765. * Current inertia value on the radius axis.
  121766. * The bigger this number the longer it will take for the camera to stop.
  121767. */
  121768. inertialRadiusOffset: number;
  121769. /**
  121770. * Minimum allowed angle on the longitudinal axis.
  121771. * This can help limiting how the Camera is able to move in the scene.
  121772. */
  121773. lowerAlphaLimit: Nullable<number>;
  121774. /**
  121775. * Maximum allowed angle on the longitudinal axis.
  121776. * This can help limiting how the Camera is able to move in the scene.
  121777. */
  121778. upperAlphaLimit: Nullable<number>;
  121779. /**
  121780. * Minimum allowed angle on the latitudinal axis.
  121781. * This can help limiting how the Camera is able to move in the scene.
  121782. */
  121783. lowerBetaLimit: number;
  121784. /**
  121785. * Maximum allowed angle on the latitudinal axis.
  121786. * This can help limiting how the Camera is able to move in the scene.
  121787. */
  121788. upperBetaLimit: number;
  121789. /**
  121790. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121791. * This can help limiting how the Camera is able to move in the scene.
  121792. */
  121793. lowerRadiusLimit: Nullable<number>;
  121794. /**
  121795. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121796. * This can help limiting how the Camera is able to move in the scene.
  121797. */
  121798. upperRadiusLimit: Nullable<number>;
  121799. /**
  121800. * Defines the current inertia value used during panning of the camera along the X axis.
  121801. */
  121802. inertialPanningX: number;
  121803. /**
  121804. * Defines the current inertia value used during panning of the camera along the Y axis.
  121805. */
  121806. inertialPanningY: number;
  121807. /**
  121808. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121809. * Basically if your fingers moves away from more than this distance you will be considered
  121810. * in pinch mode.
  121811. */
  121812. pinchToPanMaxDistance: number;
  121813. /**
  121814. * Defines the maximum distance the camera can pan.
  121815. * This could help keeping the cammera always in your scene.
  121816. */
  121817. panningDistanceLimit: Nullable<number>;
  121818. /**
  121819. * Defines the target of the camera before paning.
  121820. */
  121821. panningOriginTarget: Vector3;
  121822. /**
  121823. * Defines the value of the inertia used during panning.
  121824. * 0 would mean stop inertia and one would mean no decelleration at all.
  121825. */
  121826. panningInertia: number;
  121827. /**
  121828. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121829. */
  121830. get angularSensibilityX(): number;
  121831. set angularSensibilityX(value: number);
  121832. /**
  121833. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121834. */
  121835. get angularSensibilityY(): number;
  121836. set angularSensibilityY(value: number);
  121837. /**
  121838. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121839. */
  121840. get pinchPrecision(): number;
  121841. set pinchPrecision(value: number);
  121842. /**
  121843. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121844. * It will be used instead of pinchDeltaPrecision if different from 0.
  121845. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121846. */
  121847. get pinchDeltaPercentage(): number;
  121848. set pinchDeltaPercentage(value: number);
  121849. /**
  121850. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121851. * and pinch delta percentage.
  121852. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121853. * that any object in the plane at the camera's target point will scale
  121854. * perfectly with finger motion.
  121855. */
  121856. get useNaturalPinchZoom(): boolean;
  121857. set useNaturalPinchZoom(value: boolean);
  121858. /**
  121859. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121860. */
  121861. get panningSensibility(): number;
  121862. set panningSensibility(value: number);
  121863. /**
  121864. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121865. */
  121866. get keysUp(): number[];
  121867. set keysUp(value: number[]);
  121868. /**
  121869. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121870. */
  121871. get keysDown(): number[];
  121872. set keysDown(value: number[]);
  121873. /**
  121874. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121875. */
  121876. get keysLeft(): number[];
  121877. set keysLeft(value: number[]);
  121878. /**
  121879. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121880. */
  121881. get keysRight(): number[];
  121882. set keysRight(value: number[]);
  121883. /**
  121884. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121885. */
  121886. get wheelPrecision(): number;
  121887. set wheelPrecision(value: number);
  121888. /**
  121889. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121890. * It will be used instead of pinchDeltaPrecision if different from 0.
  121891. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121892. */
  121893. get wheelDeltaPercentage(): number;
  121894. set wheelDeltaPercentage(value: number);
  121895. /**
  121896. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121897. */
  121898. zoomOnFactor: number;
  121899. /**
  121900. * Defines a screen offset for the camera position.
  121901. */
  121902. targetScreenOffset: Vector2;
  121903. /**
  121904. * Allows the camera to be completely reversed.
  121905. * If false the camera can not arrive upside down.
  121906. */
  121907. allowUpsideDown: boolean;
  121908. /**
  121909. * Define if double tap/click is used to restore the previously saved state of the camera.
  121910. */
  121911. useInputToRestoreState: boolean;
  121912. /** @hidden */
  121913. _viewMatrix: Matrix;
  121914. /** @hidden */
  121915. _useCtrlForPanning: boolean;
  121916. /** @hidden */
  121917. _panningMouseButton: number;
  121918. /**
  121919. * Defines the input associated to the camera.
  121920. */
  121921. inputs: ArcRotateCameraInputsManager;
  121922. /** @hidden */
  121923. _reset: () => void;
  121924. /**
  121925. * Defines the allowed panning axis.
  121926. */
  121927. panningAxis: Vector3;
  121928. protected _localDirection: Vector3;
  121929. protected _transformedDirection: Vector3;
  121930. private _bouncingBehavior;
  121931. /**
  121932. * Gets the bouncing behavior of the camera if it has been enabled.
  121933. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121934. */
  121935. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121936. /**
  121937. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121938. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121939. */
  121940. get useBouncingBehavior(): boolean;
  121941. set useBouncingBehavior(value: boolean);
  121942. private _framingBehavior;
  121943. /**
  121944. * Gets the framing behavior of the camera if it has been enabled.
  121945. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121946. */
  121947. get framingBehavior(): Nullable<FramingBehavior>;
  121948. /**
  121949. * Defines if the framing behavior of the camera is enabled on the camera.
  121950. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121951. */
  121952. get useFramingBehavior(): boolean;
  121953. set useFramingBehavior(value: boolean);
  121954. private _autoRotationBehavior;
  121955. /**
  121956. * Gets the auto rotation behavior of the camera if it has been enabled.
  121957. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121958. */
  121959. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121960. /**
  121961. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121962. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121963. */
  121964. get useAutoRotationBehavior(): boolean;
  121965. set useAutoRotationBehavior(value: boolean);
  121966. /**
  121967. * Observable triggered when the mesh target has been changed on the camera.
  121968. */
  121969. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121970. /**
  121971. * Event raised when the camera is colliding with a mesh.
  121972. */
  121973. onCollide: (collidedMesh: AbstractMesh) => void;
  121974. /**
  121975. * Defines whether the camera should check collision with the objects oh the scene.
  121976. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121977. */
  121978. checkCollisions: boolean;
  121979. /**
  121980. * Defines the collision radius of the camera.
  121981. * This simulates a sphere around the camera.
  121982. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121983. */
  121984. collisionRadius: Vector3;
  121985. protected _collider: Collider;
  121986. protected _previousPosition: Vector3;
  121987. protected _collisionVelocity: Vector3;
  121988. protected _newPosition: Vector3;
  121989. protected _previousAlpha: number;
  121990. protected _previousBeta: number;
  121991. protected _previousRadius: number;
  121992. protected _collisionTriggered: boolean;
  121993. protected _targetBoundingCenter: Nullable<Vector3>;
  121994. private _computationVector;
  121995. /**
  121996. * Instantiates a new ArcRotateCamera in a given scene
  121997. * @param name Defines the name of the camera
  121998. * @param alpha Defines the camera rotation along the logitudinal axis
  121999. * @param beta Defines the camera rotation along the latitudinal axis
  122000. * @param radius Defines the camera distance from its target
  122001. * @param target Defines the camera target
  122002. * @param scene Defines the scene the camera belongs to
  122003. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122004. */
  122005. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122006. /** @hidden */
  122007. _initCache(): void;
  122008. /** @hidden */
  122009. _updateCache(ignoreParentClass?: boolean): void;
  122010. protected _getTargetPosition(): Vector3;
  122011. private _storedAlpha;
  122012. private _storedBeta;
  122013. private _storedRadius;
  122014. private _storedTarget;
  122015. private _storedTargetScreenOffset;
  122016. /**
  122017. * Stores the current state of the camera (alpha, beta, radius and target)
  122018. * @returns the camera itself
  122019. */
  122020. storeState(): Camera;
  122021. /**
  122022. * @hidden
  122023. * Restored camera state. You must call storeState() first
  122024. */
  122025. _restoreStateValues(): boolean;
  122026. /** @hidden */
  122027. _isSynchronizedViewMatrix(): boolean;
  122028. /**
  122029. * Attached controls to the current camera.
  122030. * @param element Defines the element the controls should be listened from
  122031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122032. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122033. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122034. */
  122035. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122036. /**
  122037. * Detach the current controls from the camera.
  122038. * The camera will stop reacting to inputs.
  122039. * @param element Defines the element to stop listening the inputs from
  122040. */
  122041. detachControl(element: HTMLElement): void;
  122042. /** @hidden */
  122043. _checkInputs(): void;
  122044. protected _checkLimits(): void;
  122045. /**
  122046. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122047. */
  122048. rebuildAnglesAndRadius(): void;
  122049. /**
  122050. * Use a position to define the current camera related information like alpha, beta and radius
  122051. * @param position Defines the position to set the camera at
  122052. */
  122053. setPosition(position: Vector3): void;
  122054. /**
  122055. * Defines the target the camera should look at.
  122056. * This will automatically adapt alpha beta and radius to fit within the new target.
  122057. * @param target Defines the new target as a Vector or a mesh
  122058. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122059. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122060. */
  122061. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122062. /** @hidden */
  122063. _getViewMatrix(): Matrix;
  122064. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122065. /**
  122066. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122067. * @param meshes Defines the mesh to zoom on
  122068. * @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)
  122069. */
  122070. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122071. /**
  122072. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122073. * The target will be changed but the radius
  122074. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122075. * @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)
  122076. */
  122077. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122078. min: Vector3;
  122079. max: Vector3;
  122080. distance: number;
  122081. }, doNotUpdateMaxZ?: boolean): void;
  122082. /**
  122083. * @override
  122084. * Override Camera.createRigCamera
  122085. */
  122086. createRigCamera(name: string, cameraIndex: number): Camera;
  122087. /**
  122088. * @hidden
  122089. * @override
  122090. * Override Camera._updateRigCameras
  122091. */
  122092. _updateRigCameras(): void;
  122093. /**
  122094. * Destroy the camera and release the current resources hold by it.
  122095. */
  122096. dispose(): void;
  122097. /**
  122098. * Gets the current object class name.
  122099. * @return the class name
  122100. */
  122101. getClassName(): string;
  122102. }
  122103. }
  122104. declare module BABYLON {
  122105. /**
  122106. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122107. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122108. */
  122109. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122110. /**
  122111. * Gets the name of the behavior.
  122112. */
  122113. get name(): string;
  122114. private _zoomStopsAnimation;
  122115. private _idleRotationSpeed;
  122116. private _idleRotationWaitTime;
  122117. private _idleRotationSpinupTime;
  122118. /**
  122119. * Sets the flag that indicates if user zooming should stop animation.
  122120. */
  122121. set zoomStopsAnimation(flag: boolean);
  122122. /**
  122123. * Gets the flag that indicates if user zooming should stop animation.
  122124. */
  122125. get zoomStopsAnimation(): boolean;
  122126. /**
  122127. * Sets the default speed at which the camera rotates around the model.
  122128. */
  122129. set idleRotationSpeed(speed: number);
  122130. /**
  122131. * Gets the default speed at which the camera rotates around the model.
  122132. */
  122133. get idleRotationSpeed(): number;
  122134. /**
  122135. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122136. */
  122137. set idleRotationWaitTime(time: number);
  122138. /**
  122139. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122140. */
  122141. get idleRotationWaitTime(): number;
  122142. /**
  122143. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122144. */
  122145. set idleRotationSpinupTime(time: number);
  122146. /**
  122147. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122148. */
  122149. get idleRotationSpinupTime(): number;
  122150. /**
  122151. * Gets a value indicating if the camera is currently rotating because of this behavior
  122152. */
  122153. get rotationInProgress(): boolean;
  122154. private _onPrePointerObservableObserver;
  122155. private _onAfterCheckInputsObserver;
  122156. private _attachedCamera;
  122157. private _isPointerDown;
  122158. private _lastFrameTime;
  122159. private _lastInteractionTime;
  122160. private _cameraRotationSpeed;
  122161. /**
  122162. * Initializes the behavior.
  122163. */
  122164. init(): void;
  122165. /**
  122166. * Attaches the behavior to its arc rotate camera.
  122167. * @param camera Defines the camera to attach the behavior to
  122168. */
  122169. attach(camera: ArcRotateCamera): void;
  122170. /**
  122171. * Detaches the behavior from its current arc rotate camera.
  122172. */
  122173. detach(): void;
  122174. /**
  122175. * Returns true if user is scrolling.
  122176. * @return true if user is scrolling.
  122177. */
  122178. private _userIsZooming;
  122179. private _lastFrameRadius;
  122180. private _shouldAnimationStopForInteraction;
  122181. /**
  122182. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122183. */
  122184. private _applyUserInteraction;
  122185. private _userIsMoving;
  122186. }
  122187. }
  122188. declare module BABYLON {
  122189. /**
  122190. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122191. */
  122192. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122193. private ui;
  122194. /**
  122195. * The name of the behavior
  122196. */
  122197. name: string;
  122198. /**
  122199. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122200. */
  122201. distanceAwayFromFace: number;
  122202. /**
  122203. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122204. */
  122205. distanceAwayFromBottomOfFace: number;
  122206. private _faceVectors;
  122207. private _target;
  122208. private _scene;
  122209. private _onRenderObserver;
  122210. private _tmpMatrix;
  122211. private _tmpVector;
  122212. /**
  122213. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122214. * @param ui The transform node that should be attched to the mesh
  122215. */
  122216. constructor(ui: TransformNode);
  122217. /**
  122218. * Initializes the behavior
  122219. */
  122220. init(): void;
  122221. private _closestFace;
  122222. private _zeroVector;
  122223. private _lookAtTmpMatrix;
  122224. private _lookAtToRef;
  122225. /**
  122226. * Attaches the AttachToBoxBehavior to the passed in mesh
  122227. * @param target The mesh that the specified node will be attached to
  122228. */
  122229. attach(target: Mesh): void;
  122230. /**
  122231. * Detaches the behavior from the mesh
  122232. */
  122233. detach(): void;
  122234. }
  122235. }
  122236. declare module BABYLON {
  122237. /**
  122238. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122239. */
  122240. export class FadeInOutBehavior implements Behavior<Mesh> {
  122241. /**
  122242. * Time in milliseconds to delay before fading in (Default: 0)
  122243. */
  122244. delay: number;
  122245. /**
  122246. * Time in milliseconds for the mesh to fade in (Default: 300)
  122247. */
  122248. fadeInTime: number;
  122249. private _millisecondsPerFrame;
  122250. private _hovered;
  122251. private _hoverValue;
  122252. private _ownerNode;
  122253. /**
  122254. * Instatiates the FadeInOutBehavior
  122255. */
  122256. constructor();
  122257. /**
  122258. * The name of the behavior
  122259. */
  122260. get name(): string;
  122261. /**
  122262. * Initializes the behavior
  122263. */
  122264. init(): void;
  122265. /**
  122266. * Attaches the fade behavior on the passed in mesh
  122267. * @param ownerNode The mesh that will be faded in/out once attached
  122268. */
  122269. attach(ownerNode: Mesh): void;
  122270. /**
  122271. * Detaches the behavior from the mesh
  122272. */
  122273. detach(): void;
  122274. /**
  122275. * Triggers the mesh to begin fading in or out
  122276. * @param value if the object should fade in or out (true to fade in)
  122277. */
  122278. fadeIn(value: boolean): void;
  122279. private _update;
  122280. private _setAllVisibility;
  122281. }
  122282. }
  122283. declare module BABYLON {
  122284. /**
  122285. * Class containing a set of static utilities functions for managing Pivots
  122286. * @hidden
  122287. */
  122288. export class PivotTools {
  122289. private static _PivotCached;
  122290. private static _OldPivotPoint;
  122291. private static _PivotTranslation;
  122292. private static _PivotTmpVector;
  122293. /** @hidden */
  122294. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122295. /** @hidden */
  122296. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122297. }
  122298. }
  122299. declare module BABYLON {
  122300. /**
  122301. * Class containing static functions to help procedurally build meshes
  122302. */
  122303. export class PlaneBuilder {
  122304. /**
  122305. * Creates a plane mesh
  122306. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122307. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122308. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122312. * @param name defines the name of the mesh
  122313. * @param options defines the options used to create the mesh
  122314. * @param scene defines the hosting scene
  122315. * @returns the plane mesh
  122316. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122317. */
  122318. static CreatePlane(name: string, options: {
  122319. size?: number;
  122320. width?: number;
  122321. height?: number;
  122322. sideOrientation?: number;
  122323. frontUVs?: Vector4;
  122324. backUVs?: Vector4;
  122325. updatable?: boolean;
  122326. sourcePlane?: Plane;
  122327. }, scene?: Nullable<Scene>): Mesh;
  122328. }
  122329. }
  122330. declare module BABYLON {
  122331. /**
  122332. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122333. */
  122334. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122335. private static _AnyMouseID;
  122336. /**
  122337. * Abstract mesh the behavior is set on
  122338. */
  122339. attachedNode: AbstractMesh;
  122340. private _dragPlane;
  122341. private _scene;
  122342. private _pointerObserver;
  122343. private _beforeRenderObserver;
  122344. private static _planeScene;
  122345. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122346. /**
  122347. * 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)
  122348. */
  122349. maxDragAngle: number;
  122350. /**
  122351. * @hidden
  122352. */
  122353. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122354. /**
  122355. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122356. */
  122357. currentDraggingPointerID: number;
  122358. /**
  122359. * The last position where the pointer hit the drag plane in world space
  122360. */
  122361. lastDragPosition: Vector3;
  122362. /**
  122363. * If the behavior is currently in a dragging state
  122364. */
  122365. dragging: boolean;
  122366. /**
  122367. * 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)
  122368. */
  122369. dragDeltaRatio: number;
  122370. /**
  122371. * If the drag plane orientation should be updated during the dragging (Default: true)
  122372. */
  122373. updateDragPlane: boolean;
  122374. private _debugMode;
  122375. private _moving;
  122376. /**
  122377. * Fires each time the attached mesh is dragged with the pointer
  122378. * * delta between last drag position and current drag position in world space
  122379. * * dragDistance along the drag axis
  122380. * * dragPlaneNormal normal of the current drag plane used during the drag
  122381. * * dragPlanePoint in world space where the drag intersects the drag plane
  122382. */
  122383. onDragObservable: Observable<{
  122384. delta: Vector3;
  122385. dragPlanePoint: Vector3;
  122386. dragPlaneNormal: Vector3;
  122387. dragDistance: number;
  122388. pointerId: number;
  122389. }>;
  122390. /**
  122391. * Fires each time a drag begins (eg. mouse down on mesh)
  122392. */
  122393. onDragStartObservable: Observable<{
  122394. dragPlanePoint: Vector3;
  122395. pointerId: number;
  122396. }>;
  122397. /**
  122398. * Fires each time a drag ends (eg. mouse release after drag)
  122399. */
  122400. onDragEndObservable: Observable<{
  122401. dragPlanePoint: Vector3;
  122402. pointerId: number;
  122403. }>;
  122404. /**
  122405. * If the attached mesh should be moved when dragged
  122406. */
  122407. moveAttached: boolean;
  122408. /**
  122409. * If the drag behavior will react to drag events (Default: true)
  122410. */
  122411. enabled: boolean;
  122412. /**
  122413. * If pointer events should start and release the drag (Default: true)
  122414. */
  122415. startAndReleaseDragOnPointerEvents: boolean;
  122416. /**
  122417. * If camera controls should be detached during the drag
  122418. */
  122419. detachCameraControls: boolean;
  122420. /**
  122421. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122422. */
  122423. useObjectOrientationForDragging: boolean;
  122424. private _options;
  122425. /**
  122426. * Gets the options used by the behavior
  122427. */
  122428. get options(): {
  122429. dragAxis?: Vector3;
  122430. dragPlaneNormal?: Vector3;
  122431. };
  122432. /**
  122433. * Sets the options used by the behavior
  122434. */
  122435. set options(options: {
  122436. dragAxis?: Vector3;
  122437. dragPlaneNormal?: Vector3;
  122438. });
  122439. /**
  122440. * Creates a pointer drag behavior that can be attached to a mesh
  122441. * @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)
  122442. */
  122443. constructor(options?: {
  122444. dragAxis?: Vector3;
  122445. dragPlaneNormal?: Vector3;
  122446. });
  122447. /**
  122448. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122449. */
  122450. validateDrag: (targetPosition: Vector3) => boolean;
  122451. /**
  122452. * The name of the behavior
  122453. */
  122454. get name(): string;
  122455. /**
  122456. * Initializes the behavior
  122457. */
  122458. init(): void;
  122459. private _tmpVector;
  122460. private _alternatePickedPoint;
  122461. private _worldDragAxis;
  122462. private _targetPosition;
  122463. private _attachedElement;
  122464. /**
  122465. * Attaches the drag behavior the passed in mesh
  122466. * @param ownerNode The mesh that will be dragged around once attached
  122467. * @param predicate Predicate to use for pick filtering
  122468. */
  122469. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122470. /**
  122471. * Force relase the drag action by code.
  122472. */
  122473. releaseDrag(): void;
  122474. private _startDragRay;
  122475. private _lastPointerRay;
  122476. /**
  122477. * Simulates the start of a pointer drag event on the behavior
  122478. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122479. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122480. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122481. */
  122482. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122483. private _startDrag;
  122484. private _dragDelta;
  122485. private _moveDrag;
  122486. private _pickWithRayOnDragPlane;
  122487. private _pointA;
  122488. private _pointC;
  122489. private _localAxis;
  122490. private _lookAt;
  122491. private _updateDragPlanePosition;
  122492. /**
  122493. * Detaches the behavior from the mesh
  122494. */
  122495. detach(): void;
  122496. }
  122497. }
  122498. declare module BABYLON {
  122499. /**
  122500. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122501. */
  122502. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122503. private _dragBehaviorA;
  122504. private _dragBehaviorB;
  122505. private _startDistance;
  122506. private _initialScale;
  122507. private _targetScale;
  122508. private _ownerNode;
  122509. private _sceneRenderObserver;
  122510. /**
  122511. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122512. */
  122513. constructor();
  122514. /**
  122515. * The name of the behavior
  122516. */
  122517. get name(): string;
  122518. /**
  122519. * Initializes the behavior
  122520. */
  122521. init(): void;
  122522. private _getCurrentDistance;
  122523. /**
  122524. * Attaches the scale behavior the passed in mesh
  122525. * @param ownerNode The mesh that will be scaled around once attached
  122526. */
  122527. attach(ownerNode: Mesh): void;
  122528. /**
  122529. * Detaches the behavior from the mesh
  122530. */
  122531. detach(): void;
  122532. }
  122533. }
  122534. declare module BABYLON {
  122535. /**
  122536. * 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
  122537. */
  122538. export class SixDofDragBehavior implements Behavior<Mesh> {
  122539. private static _virtualScene;
  122540. private _ownerNode;
  122541. private _sceneRenderObserver;
  122542. private _scene;
  122543. private _targetPosition;
  122544. private _virtualOriginMesh;
  122545. private _virtualDragMesh;
  122546. private _pointerObserver;
  122547. private _moving;
  122548. private _startingOrientation;
  122549. private _attachedElement;
  122550. /**
  122551. * 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)
  122552. */
  122553. private zDragFactor;
  122554. /**
  122555. * If the object should rotate to face the drag origin
  122556. */
  122557. rotateDraggedObject: boolean;
  122558. /**
  122559. * If the behavior is currently in a dragging state
  122560. */
  122561. dragging: boolean;
  122562. /**
  122563. * 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)
  122564. */
  122565. dragDeltaRatio: number;
  122566. /**
  122567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122568. */
  122569. currentDraggingPointerID: number;
  122570. /**
  122571. * If camera controls should be detached during the drag
  122572. */
  122573. detachCameraControls: boolean;
  122574. /**
  122575. * Fires each time a drag starts
  122576. */
  122577. onDragStartObservable: Observable<{}>;
  122578. /**
  122579. * Fires each time a drag ends (eg. mouse release after drag)
  122580. */
  122581. onDragEndObservable: Observable<{}>;
  122582. /**
  122583. * 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
  122584. */
  122585. constructor();
  122586. /**
  122587. * The name of the behavior
  122588. */
  122589. get name(): string;
  122590. /**
  122591. * Initializes the behavior
  122592. */
  122593. init(): void;
  122594. /**
  122595. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122596. */
  122597. private get _pointerCamera();
  122598. /**
  122599. * Attaches the scale behavior the passed in mesh
  122600. * @param ownerNode The mesh that will be scaled around once attached
  122601. */
  122602. attach(ownerNode: Mesh): void;
  122603. /**
  122604. * Detaches the behavior from the mesh
  122605. */
  122606. detach(): void;
  122607. }
  122608. }
  122609. declare module BABYLON {
  122610. /**
  122611. * Class used to apply inverse kinematics to bones
  122612. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122613. */
  122614. export class BoneIKController {
  122615. private static _tmpVecs;
  122616. private static _tmpQuat;
  122617. private static _tmpMats;
  122618. /**
  122619. * Gets or sets the target mesh
  122620. */
  122621. targetMesh: AbstractMesh;
  122622. /** Gets or sets the mesh used as pole */
  122623. poleTargetMesh: AbstractMesh;
  122624. /**
  122625. * Gets or sets the bone used as pole
  122626. */
  122627. poleTargetBone: Nullable<Bone>;
  122628. /**
  122629. * Gets or sets the target position
  122630. */
  122631. targetPosition: Vector3;
  122632. /**
  122633. * Gets or sets the pole target position
  122634. */
  122635. poleTargetPosition: Vector3;
  122636. /**
  122637. * Gets or sets the pole target local offset
  122638. */
  122639. poleTargetLocalOffset: Vector3;
  122640. /**
  122641. * Gets or sets the pole angle
  122642. */
  122643. poleAngle: number;
  122644. /**
  122645. * Gets or sets the mesh associated with the controller
  122646. */
  122647. mesh: AbstractMesh;
  122648. /**
  122649. * 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)
  122650. */
  122651. slerpAmount: number;
  122652. private _bone1Quat;
  122653. private _bone1Mat;
  122654. private _bone2Ang;
  122655. private _bone1;
  122656. private _bone2;
  122657. private _bone1Length;
  122658. private _bone2Length;
  122659. private _maxAngle;
  122660. private _maxReach;
  122661. private _rightHandedSystem;
  122662. private _bendAxis;
  122663. private _slerping;
  122664. private _adjustRoll;
  122665. /**
  122666. * Gets or sets maximum allowed angle
  122667. */
  122668. get maxAngle(): number;
  122669. set maxAngle(value: number);
  122670. /**
  122671. * Creates a new BoneIKController
  122672. * @param mesh defines the mesh to control
  122673. * @param bone defines the bone to control
  122674. * @param options defines options to set up the controller
  122675. */
  122676. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122677. targetMesh?: AbstractMesh;
  122678. poleTargetMesh?: AbstractMesh;
  122679. poleTargetBone?: Bone;
  122680. poleTargetLocalOffset?: Vector3;
  122681. poleAngle?: number;
  122682. bendAxis?: Vector3;
  122683. maxAngle?: number;
  122684. slerpAmount?: number;
  122685. });
  122686. private _setMaxAngle;
  122687. /**
  122688. * Force the controller to update the bones
  122689. */
  122690. update(): void;
  122691. }
  122692. }
  122693. declare module BABYLON {
  122694. /**
  122695. * Class used to make a bone look toward a point in space
  122696. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122697. */
  122698. export class BoneLookController {
  122699. private static _tmpVecs;
  122700. private static _tmpQuat;
  122701. private static _tmpMats;
  122702. /**
  122703. * The target Vector3 that the bone will look at
  122704. */
  122705. target: Vector3;
  122706. /**
  122707. * The mesh that the bone is attached to
  122708. */
  122709. mesh: AbstractMesh;
  122710. /**
  122711. * The bone that will be looking to the target
  122712. */
  122713. bone: Bone;
  122714. /**
  122715. * The up axis of the coordinate system that is used when the bone is rotated
  122716. */
  122717. upAxis: Vector3;
  122718. /**
  122719. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122720. */
  122721. upAxisSpace: Space;
  122722. /**
  122723. * Used to make an adjustment to the yaw of the bone
  122724. */
  122725. adjustYaw: number;
  122726. /**
  122727. * Used to make an adjustment to the pitch of the bone
  122728. */
  122729. adjustPitch: number;
  122730. /**
  122731. * Used to make an adjustment to the roll of the bone
  122732. */
  122733. adjustRoll: number;
  122734. /**
  122735. * 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)
  122736. */
  122737. slerpAmount: number;
  122738. private _minYaw;
  122739. private _maxYaw;
  122740. private _minPitch;
  122741. private _maxPitch;
  122742. private _minYawSin;
  122743. private _minYawCos;
  122744. private _maxYawSin;
  122745. private _maxYawCos;
  122746. private _midYawConstraint;
  122747. private _minPitchTan;
  122748. private _maxPitchTan;
  122749. private _boneQuat;
  122750. private _slerping;
  122751. private _transformYawPitch;
  122752. private _transformYawPitchInv;
  122753. private _firstFrameSkipped;
  122754. private _yawRange;
  122755. private _fowardAxis;
  122756. /**
  122757. * Gets or sets the minimum yaw angle that the bone can look to
  122758. */
  122759. get minYaw(): number;
  122760. set minYaw(value: number);
  122761. /**
  122762. * Gets or sets the maximum yaw angle that the bone can look to
  122763. */
  122764. get maxYaw(): number;
  122765. set maxYaw(value: number);
  122766. /**
  122767. * Gets or sets the minimum pitch angle that the bone can look to
  122768. */
  122769. get minPitch(): number;
  122770. set minPitch(value: number);
  122771. /**
  122772. * Gets or sets the maximum pitch angle that the bone can look to
  122773. */
  122774. get maxPitch(): number;
  122775. set maxPitch(value: number);
  122776. /**
  122777. * Create a BoneLookController
  122778. * @param mesh the mesh that the bone belongs to
  122779. * @param bone the bone that will be looking to the target
  122780. * @param target the target Vector3 to look at
  122781. * @param options optional settings:
  122782. * * maxYaw: the maximum angle the bone will yaw to
  122783. * * minYaw: the minimum angle the bone will yaw to
  122784. * * maxPitch: the maximum angle the bone will pitch to
  122785. * * minPitch: the minimum angle the bone will yaw to
  122786. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122787. * * upAxis: the up axis of the coordinate system
  122788. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122789. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122790. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122791. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122792. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122793. * * adjustRoll: used to make an adjustment to the roll of the bone
  122794. **/
  122795. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122796. maxYaw?: number;
  122797. minYaw?: number;
  122798. maxPitch?: number;
  122799. minPitch?: number;
  122800. slerpAmount?: number;
  122801. upAxis?: Vector3;
  122802. upAxisSpace?: Space;
  122803. yawAxis?: Vector3;
  122804. pitchAxis?: Vector3;
  122805. adjustYaw?: number;
  122806. adjustPitch?: number;
  122807. adjustRoll?: number;
  122808. });
  122809. /**
  122810. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122811. */
  122812. update(): void;
  122813. private _getAngleDiff;
  122814. private _getAngleBetween;
  122815. private _isAngleBetween;
  122816. }
  122817. }
  122818. declare module BABYLON {
  122819. /**
  122820. * Manage the gamepad inputs to control an arc rotate camera.
  122821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122822. */
  122823. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122824. /**
  122825. * Defines the camera the input is attached to.
  122826. */
  122827. camera: ArcRotateCamera;
  122828. /**
  122829. * Defines the gamepad the input is gathering event from.
  122830. */
  122831. gamepad: Nullable<Gamepad>;
  122832. /**
  122833. * Defines the gamepad rotation sensiblity.
  122834. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122835. */
  122836. gamepadRotationSensibility: number;
  122837. /**
  122838. * Defines the gamepad move sensiblity.
  122839. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122840. */
  122841. gamepadMoveSensibility: number;
  122842. private _yAxisScale;
  122843. /**
  122844. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122845. */
  122846. get invertYAxis(): boolean;
  122847. set invertYAxis(value: boolean);
  122848. private _onGamepadConnectedObserver;
  122849. private _onGamepadDisconnectedObserver;
  122850. /**
  122851. * Attach the input controls to a specific dom element to get the input from.
  122852. * @param element Defines the element the controls should be listened from
  122853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122854. */
  122855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122856. /**
  122857. * Detach the current controls from the specified dom element.
  122858. * @param element Defines the element to stop listening the inputs from
  122859. */
  122860. detachControl(element: Nullable<HTMLElement>): void;
  122861. /**
  122862. * Update the current camera state depending on the inputs that have been used this frame.
  122863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122864. */
  122865. checkInputs(): void;
  122866. /**
  122867. * Gets the class name of the current intput.
  122868. * @returns the class name
  122869. */
  122870. getClassName(): string;
  122871. /**
  122872. * Get the friendly name associated with the input class.
  122873. * @returns the input friendly name
  122874. */
  122875. getSimpleName(): string;
  122876. }
  122877. }
  122878. declare module BABYLON {
  122879. interface ArcRotateCameraInputsManager {
  122880. /**
  122881. * Add orientation input support to the input manager.
  122882. * @returns the current input manager
  122883. */
  122884. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122885. }
  122886. /**
  122887. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122889. */
  122890. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122891. /**
  122892. * Defines the camera the input is attached to.
  122893. */
  122894. camera: ArcRotateCamera;
  122895. /**
  122896. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122897. */
  122898. alphaCorrection: number;
  122899. /**
  122900. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122901. */
  122902. gammaCorrection: number;
  122903. private _alpha;
  122904. private _gamma;
  122905. private _dirty;
  122906. private _deviceOrientationHandler;
  122907. /**
  122908. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122909. */
  122910. constructor();
  122911. /**
  122912. * Attach the input controls to a specific dom element to get the input from.
  122913. * @param element Defines the element the controls should be listened from
  122914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122915. */
  122916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122917. /** @hidden */
  122918. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122919. /**
  122920. * Update the current camera state depending on the inputs that have been used this frame.
  122921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122922. */
  122923. checkInputs(): void;
  122924. /**
  122925. * Detach the current controls from the specified dom element.
  122926. * @param element Defines the element to stop listening the inputs from
  122927. */
  122928. detachControl(element: Nullable<HTMLElement>): void;
  122929. /**
  122930. * Gets the class name of the current intput.
  122931. * @returns the class name
  122932. */
  122933. getClassName(): string;
  122934. /**
  122935. * Get the friendly name associated with the input class.
  122936. * @returns the input friendly name
  122937. */
  122938. getSimpleName(): string;
  122939. }
  122940. }
  122941. declare module BABYLON {
  122942. /**
  122943. * Listen to mouse events to control the camera.
  122944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122945. */
  122946. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122947. /**
  122948. * Defines the camera the input is attached to.
  122949. */
  122950. camera: FlyCamera;
  122951. /**
  122952. * Defines if touch is enabled. (Default is true.)
  122953. */
  122954. touchEnabled: boolean;
  122955. /**
  122956. * Defines the buttons associated with the input to handle camera rotation.
  122957. */
  122958. buttons: number[];
  122959. /**
  122960. * Assign buttons for Yaw control.
  122961. */
  122962. buttonsYaw: number[];
  122963. /**
  122964. * Assign buttons for Pitch control.
  122965. */
  122966. buttonsPitch: number[];
  122967. /**
  122968. * Assign buttons for Roll control.
  122969. */
  122970. buttonsRoll: number[];
  122971. /**
  122972. * Detect if any button is being pressed while mouse is moved.
  122973. * -1 = Mouse locked.
  122974. * 0 = Left button.
  122975. * 1 = Middle Button.
  122976. * 2 = Right Button.
  122977. */
  122978. activeButton: number;
  122979. /**
  122980. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122981. * Higher values reduce its sensitivity.
  122982. */
  122983. angularSensibility: number;
  122984. private _mousemoveCallback;
  122985. private _observer;
  122986. private _rollObserver;
  122987. private previousPosition;
  122988. private noPreventDefault;
  122989. private element;
  122990. /**
  122991. * Listen to mouse events to control the camera.
  122992. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122993. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122994. */
  122995. constructor(touchEnabled?: boolean);
  122996. /**
  122997. * Attach the mouse control to the HTML DOM element.
  122998. * @param element Defines the element that listens to the input events.
  122999. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123000. */
  123001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123002. /**
  123003. * Detach the current controls from the specified dom element.
  123004. * @param element Defines the element to stop listening the inputs from
  123005. */
  123006. detachControl(element: Nullable<HTMLElement>): void;
  123007. /**
  123008. * Gets the class name of the current input.
  123009. * @returns the class name.
  123010. */
  123011. getClassName(): string;
  123012. /**
  123013. * Get the friendly name associated with the input class.
  123014. * @returns the input's friendly name.
  123015. */
  123016. getSimpleName(): string;
  123017. private _pointerInput;
  123018. private _onMouseMove;
  123019. /**
  123020. * Rotate camera by mouse offset.
  123021. */
  123022. private rotateCamera;
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Default Inputs manager for the FlyCamera.
  123028. * It groups all the default supported inputs for ease of use.
  123029. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123030. */
  123031. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123032. /**
  123033. * Instantiates a new FlyCameraInputsManager.
  123034. * @param camera Defines the camera the inputs belong to.
  123035. */
  123036. constructor(camera: FlyCamera);
  123037. /**
  123038. * Add keyboard input support to the input manager.
  123039. * @returns the new FlyCameraKeyboardMoveInput().
  123040. */
  123041. addKeyboard(): FlyCameraInputsManager;
  123042. /**
  123043. * Add mouse input support to the input manager.
  123044. * @param touchEnabled Enable touch screen support.
  123045. * @returns the new FlyCameraMouseInput().
  123046. */
  123047. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123048. }
  123049. }
  123050. declare module BABYLON {
  123051. /**
  123052. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123053. * such as in a 3D Space Shooter or a Flight Simulator.
  123054. */
  123055. export class FlyCamera extends TargetCamera {
  123056. /**
  123057. * Define the collision ellipsoid of the camera.
  123058. * This is helpful for simulating a camera body, like a player's body.
  123059. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123060. */
  123061. ellipsoid: Vector3;
  123062. /**
  123063. * Define an offset for the position of the ellipsoid around the camera.
  123064. * This can be helpful if the camera is attached away from the player's body center,
  123065. * such as at its head.
  123066. */
  123067. ellipsoidOffset: Vector3;
  123068. /**
  123069. * Enable or disable collisions of the camera with the rest of the scene objects.
  123070. */
  123071. checkCollisions: boolean;
  123072. /**
  123073. * Enable or disable gravity on the camera.
  123074. */
  123075. applyGravity: boolean;
  123076. /**
  123077. * Define the current direction the camera is moving to.
  123078. */
  123079. cameraDirection: Vector3;
  123080. /**
  123081. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123082. * This overrides and empties cameraRotation.
  123083. */
  123084. rotationQuaternion: Quaternion;
  123085. /**
  123086. * Track Roll to maintain the wanted Rolling when looking around.
  123087. */
  123088. _trackRoll: number;
  123089. /**
  123090. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123091. */
  123092. rollCorrect: number;
  123093. /**
  123094. * Mimic a banked turn, Rolling the camera when Yawing.
  123095. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123096. */
  123097. bankedTurn: boolean;
  123098. /**
  123099. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123100. */
  123101. bankedTurnLimit: number;
  123102. /**
  123103. * Value of 0 disables the banked Roll.
  123104. * Value of 1 is equal to the Yaw angle in radians.
  123105. */
  123106. bankedTurnMultiplier: number;
  123107. /**
  123108. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123109. */
  123110. inputs: FlyCameraInputsManager;
  123111. /**
  123112. * Gets the input sensibility for mouse input.
  123113. * Higher values reduce sensitivity.
  123114. */
  123115. get angularSensibility(): number;
  123116. /**
  123117. * Sets the input sensibility for a mouse input.
  123118. * Higher values reduce sensitivity.
  123119. */
  123120. set angularSensibility(value: number);
  123121. /**
  123122. * Get the keys for camera movement forward.
  123123. */
  123124. get keysForward(): number[];
  123125. /**
  123126. * Set the keys for camera movement forward.
  123127. */
  123128. set keysForward(value: number[]);
  123129. /**
  123130. * Get the keys for camera movement backward.
  123131. */
  123132. get keysBackward(): number[];
  123133. set keysBackward(value: number[]);
  123134. /**
  123135. * Get the keys for camera movement up.
  123136. */
  123137. get keysUp(): number[];
  123138. /**
  123139. * Set the keys for camera movement up.
  123140. */
  123141. set keysUp(value: number[]);
  123142. /**
  123143. * Get the keys for camera movement down.
  123144. */
  123145. get keysDown(): number[];
  123146. /**
  123147. * Set the keys for camera movement down.
  123148. */
  123149. set keysDown(value: number[]);
  123150. /**
  123151. * Get the keys for camera movement left.
  123152. */
  123153. get keysLeft(): number[];
  123154. /**
  123155. * Set the keys for camera movement left.
  123156. */
  123157. set keysLeft(value: number[]);
  123158. /**
  123159. * Set the keys for camera movement right.
  123160. */
  123161. get keysRight(): number[];
  123162. /**
  123163. * Set the keys for camera movement right.
  123164. */
  123165. set keysRight(value: number[]);
  123166. /**
  123167. * Event raised when the camera collides with a mesh in the scene.
  123168. */
  123169. onCollide: (collidedMesh: AbstractMesh) => void;
  123170. private _collider;
  123171. private _needMoveForGravity;
  123172. private _oldPosition;
  123173. private _diffPosition;
  123174. private _newPosition;
  123175. /** @hidden */
  123176. _localDirection: Vector3;
  123177. /** @hidden */
  123178. _transformedDirection: Vector3;
  123179. /**
  123180. * Instantiates a FlyCamera.
  123181. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123182. * such as in a 3D Space Shooter or a Flight Simulator.
  123183. * @param name Define the name of the camera in the scene.
  123184. * @param position Define the starting position of the camera in the scene.
  123185. * @param scene Define the scene the camera belongs to.
  123186. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123187. */
  123188. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123189. /**
  123190. * Attach a control to the HTML DOM element.
  123191. * @param element Defines the element that listens to the input events.
  123192. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123193. */
  123194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123195. /**
  123196. * Detach a control from the HTML DOM element.
  123197. * The camera will stop reacting to that input.
  123198. * @param element Defines the element that listens to the input events.
  123199. */
  123200. detachControl(element: HTMLElement): void;
  123201. private _collisionMask;
  123202. /**
  123203. * Get the mask that the camera ignores in collision events.
  123204. */
  123205. get collisionMask(): number;
  123206. /**
  123207. * Set the mask that the camera ignores in collision events.
  123208. */
  123209. set collisionMask(mask: number);
  123210. /** @hidden */
  123211. _collideWithWorld(displacement: Vector3): void;
  123212. /** @hidden */
  123213. private _onCollisionPositionChange;
  123214. /** @hidden */
  123215. _checkInputs(): void;
  123216. /** @hidden */
  123217. _decideIfNeedsToMove(): boolean;
  123218. /** @hidden */
  123219. _updatePosition(): void;
  123220. /**
  123221. * Restore the Roll to its target value at the rate specified.
  123222. * @param rate - Higher means slower restoring.
  123223. * @hidden
  123224. */
  123225. restoreRoll(rate: number): void;
  123226. /**
  123227. * Destroy the camera and release the current resources held by it.
  123228. */
  123229. dispose(): void;
  123230. /**
  123231. * Get the current object class name.
  123232. * @returns the class name.
  123233. */
  123234. getClassName(): string;
  123235. }
  123236. }
  123237. declare module BABYLON {
  123238. /**
  123239. * Listen to keyboard events to control the camera.
  123240. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123241. */
  123242. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123243. /**
  123244. * Defines the camera the input is attached to.
  123245. */
  123246. camera: FlyCamera;
  123247. /**
  123248. * The list of keyboard keys used to control the forward move of the camera.
  123249. */
  123250. keysForward: number[];
  123251. /**
  123252. * The list of keyboard keys used to control the backward move of the camera.
  123253. */
  123254. keysBackward: number[];
  123255. /**
  123256. * The list of keyboard keys used to control the forward move of the camera.
  123257. */
  123258. keysUp: number[];
  123259. /**
  123260. * The list of keyboard keys used to control the backward move of the camera.
  123261. */
  123262. keysDown: number[];
  123263. /**
  123264. * The list of keyboard keys used to control the right strafe move of the camera.
  123265. */
  123266. keysRight: number[];
  123267. /**
  123268. * The list of keyboard keys used to control the left strafe move of the camera.
  123269. */
  123270. keysLeft: number[];
  123271. private _keys;
  123272. private _onCanvasBlurObserver;
  123273. private _onKeyboardObserver;
  123274. private _engine;
  123275. private _scene;
  123276. /**
  123277. * Attach the input controls to a specific dom element to get the input from.
  123278. * @param element Defines the element the controls should be listened from
  123279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123280. */
  123281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123282. /**
  123283. * Detach the current controls from the specified dom element.
  123284. * @param element Defines the element to stop listening the inputs from
  123285. */
  123286. detachControl(element: Nullable<HTMLElement>): void;
  123287. /**
  123288. * Gets the class name of the current intput.
  123289. * @returns the class name
  123290. */
  123291. getClassName(): string;
  123292. /** @hidden */
  123293. _onLostFocus(e: FocusEvent): void;
  123294. /**
  123295. * Get the friendly name associated with the input class.
  123296. * @returns the input friendly name
  123297. */
  123298. getSimpleName(): string;
  123299. /**
  123300. * Update the current camera state depending on the inputs that have been used this frame.
  123301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123302. */
  123303. checkInputs(): void;
  123304. }
  123305. }
  123306. declare module BABYLON {
  123307. /**
  123308. * Manage the mouse wheel inputs to control a follow camera.
  123309. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123310. */
  123311. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123312. /**
  123313. * Defines the camera the input is attached to.
  123314. */
  123315. camera: FollowCamera;
  123316. /**
  123317. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123318. */
  123319. axisControlRadius: boolean;
  123320. /**
  123321. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123322. */
  123323. axisControlHeight: boolean;
  123324. /**
  123325. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123326. */
  123327. axisControlRotation: boolean;
  123328. /**
  123329. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123330. * relation to mouseWheel events.
  123331. */
  123332. wheelPrecision: number;
  123333. /**
  123334. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123335. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123336. */
  123337. wheelDeltaPercentage: number;
  123338. private _wheel;
  123339. private _observer;
  123340. /**
  123341. * Attach the input controls to a specific dom element to get the input from.
  123342. * @param element Defines the element the controls should be listened from
  123343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123344. */
  123345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123346. /**
  123347. * Detach the current controls from the specified dom element.
  123348. * @param element Defines the element to stop listening the inputs from
  123349. */
  123350. detachControl(element: Nullable<HTMLElement>): void;
  123351. /**
  123352. * Gets the class name of the current intput.
  123353. * @returns the class name
  123354. */
  123355. getClassName(): string;
  123356. /**
  123357. * Get the friendly name associated with the input class.
  123358. * @returns the input friendly name
  123359. */
  123360. getSimpleName(): string;
  123361. }
  123362. }
  123363. declare module BABYLON {
  123364. /**
  123365. * Manage the pointers inputs to control an follow camera.
  123366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123367. */
  123368. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123369. /**
  123370. * Defines the camera the input is attached to.
  123371. */
  123372. camera: FollowCamera;
  123373. /**
  123374. * Gets the class name of the current input.
  123375. * @returns the class name
  123376. */
  123377. getClassName(): string;
  123378. /**
  123379. * Defines the pointer angular sensibility along the X axis or how fast is
  123380. * the camera rotating.
  123381. * A negative number will reverse the axis direction.
  123382. */
  123383. angularSensibilityX: number;
  123384. /**
  123385. * Defines the pointer angular sensibility along the Y axis or how fast is
  123386. * the camera rotating.
  123387. * A negative number will reverse the axis direction.
  123388. */
  123389. angularSensibilityY: number;
  123390. /**
  123391. * Defines the pointer pinch precision or how fast is the camera zooming.
  123392. * A negative number will reverse the axis direction.
  123393. */
  123394. pinchPrecision: number;
  123395. /**
  123396. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123397. * from 0.
  123398. * It defines the percentage of current camera.radius to use as delta when
  123399. * pinch zoom is used.
  123400. */
  123401. pinchDeltaPercentage: number;
  123402. /**
  123403. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123404. */
  123405. axisXControlRadius: boolean;
  123406. /**
  123407. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123408. */
  123409. axisXControlHeight: boolean;
  123410. /**
  123411. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123412. */
  123413. axisXControlRotation: boolean;
  123414. /**
  123415. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123416. */
  123417. axisYControlRadius: boolean;
  123418. /**
  123419. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123420. */
  123421. axisYControlHeight: boolean;
  123422. /**
  123423. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123424. */
  123425. axisYControlRotation: boolean;
  123426. /**
  123427. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123428. */
  123429. axisPinchControlRadius: boolean;
  123430. /**
  123431. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123432. */
  123433. axisPinchControlHeight: boolean;
  123434. /**
  123435. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123436. */
  123437. axisPinchControlRotation: boolean;
  123438. /**
  123439. * Log error messages if basic misconfiguration has occurred.
  123440. */
  123441. warningEnable: boolean;
  123442. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123443. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123444. private _warningCounter;
  123445. private _warning;
  123446. }
  123447. }
  123448. declare module BABYLON {
  123449. /**
  123450. * Default Inputs manager for the FollowCamera.
  123451. * It groups all the default supported inputs for ease of use.
  123452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123453. */
  123454. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123455. /**
  123456. * Instantiates a new FollowCameraInputsManager.
  123457. * @param camera Defines the camera the inputs belong to
  123458. */
  123459. constructor(camera: FollowCamera);
  123460. /**
  123461. * Add keyboard input support to the input manager.
  123462. * @returns the current input manager
  123463. */
  123464. addKeyboard(): FollowCameraInputsManager;
  123465. /**
  123466. * Add mouse wheel input support to the input manager.
  123467. * @returns the current input manager
  123468. */
  123469. addMouseWheel(): FollowCameraInputsManager;
  123470. /**
  123471. * Add pointers input support to the input manager.
  123472. * @returns the current input manager
  123473. */
  123474. addPointers(): FollowCameraInputsManager;
  123475. /**
  123476. * Add orientation input support to the input manager.
  123477. * @returns the current input manager
  123478. */
  123479. addVRDeviceOrientation(): FollowCameraInputsManager;
  123480. }
  123481. }
  123482. declare module BABYLON {
  123483. /**
  123484. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123485. * an arc rotate version arcFollowCamera are available.
  123486. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123487. */
  123488. export class FollowCamera extends TargetCamera {
  123489. /**
  123490. * Distance the follow camera should follow an object at
  123491. */
  123492. radius: number;
  123493. /**
  123494. * Minimum allowed distance of the camera to the axis of rotation
  123495. * (The camera can not get closer).
  123496. * This can help limiting how the Camera is able to move in the scene.
  123497. */
  123498. lowerRadiusLimit: Nullable<number>;
  123499. /**
  123500. * Maximum allowed distance of the camera to the axis of rotation
  123501. * (The camera can not get further).
  123502. * This can help limiting how the Camera is able to move in the scene.
  123503. */
  123504. upperRadiusLimit: Nullable<number>;
  123505. /**
  123506. * Define a rotation offset between the camera and the object it follows
  123507. */
  123508. rotationOffset: number;
  123509. /**
  123510. * Minimum allowed angle to camera position relative to target object.
  123511. * This can help limiting how the Camera is able to move in the scene.
  123512. */
  123513. lowerRotationOffsetLimit: Nullable<number>;
  123514. /**
  123515. * Maximum allowed angle to camera position relative to target object.
  123516. * This can help limiting how the Camera is able to move in the scene.
  123517. */
  123518. upperRotationOffsetLimit: Nullable<number>;
  123519. /**
  123520. * Define a height offset between the camera and the object it follows.
  123521. * It can help following an object from the top (like a car chaing a plane)
  123522. */
  123523. heightOffset: number;
  123524. /**
  123525. * Minimum allowed height of camera position relative to target object.
  123526. * This can help limiting how the Camera is able to move in the scene.
  123527. */
  123528. lowerHeightOffsetLimit: Nullable<number>;
  123529. /**
  123530. * Maximum allowed height of camera position relative to target object.
  123531. * This can help limiting how the Camera is able to move in the scene.
  123532. */
  123533. upperHeightOffsetLimit: Nullable<number>;
  123534. /**
  123535. * Define how fast the camera can accelerate to follow it s target.
  123536. */
  123537. cameraAcceleration: number;
  123538. /**
  123539. * Define the speed limit of the camera following an object.
  123540. */
  123541. maxCameraSpeed: number;
  123542. /**
  123543. * Define the target of the camera.
  123544. */
  123545. lockedTarget: Nullable<AbstractMesh>;
  123546. /**
  123547. * Defines the input associated with the camera.
  123548. */
  123549. inputs: FollowCameraInputsManager;
  123550. /**
  123551. * Instantiates the follow camera.
  123552. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123553. * @param name Define the name of the camera in the scene
  123554. * @param position Define the position of the camera
  123555. * @param scene Define the scene the camera belong to
  123556. * @param lockedTarget Define the target of the camera
  123557. */
  123558. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123559. private _follow;
  123560. /**
  123561. * Attached controls to the current camera.
  123562. * @param element Defines the element the controls should be listened from
  123563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123564. */
  123565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123566. /**
  123567. * Detach the current controls from the camera.
  123568. * The camera will stop reacting to inputs.
  123569. * @param element Defines the element to stop listening the inputs from
  123570. */
  123571. detachControl(element: HTMLElement): void;
  123572. /** @hidden */
  123573. _checkInputs(): void;
  123574. private _checkLimits;
  123575. /**
  123576. * Gets the camera class name.
  123577. * @returns the class name
  123578. */
  123579. getClassName(): string;
  123580. }
  123581. /**
  123582. * Arc Rotate version of the follow camera.
  123583. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123584. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123585. */
  123586. export class ArcFollowCamera extends TargetCamera {
  123587. /** The longitudinal angle of the camera */
  123588. alpha: number;
  123589. /** The latitudinal angle of the camera */
  123590. beta: number;
  123591. /** The radius of the camera from its target */
  123592. radius: number;
  123593. private _cartesianCoordinates;
  123594. /** Define the camera target (the mesh it should follow) */
  123595. private _meshTarget;
  123596. /**
  123597. * Instantiates a new ArcFollowCamera
  123598. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123599. * @param name Define the name of the camera
  123600. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123601. * @param beta Define the rotation angle of the camera around the elevation axis
  123602. * @param radius Define the radius of the camera from its target point
  123603. * @param target Define the target of the camera
  123604. * @param scene Define the scene the camera belongs to
  123605. */
  123606. constructor(name: string,
  123607. /** The longitudinal angle of the camera */
  123608. alpha: number,
  123609. /** The latitudinal angle of the camera */
  123610. beta: number,
  123611. /** The radius of the camera from its target */
  123612. radius: number,
  123613. /** Define the camera target (the mesh it should follow) */
  123614. target: Nullable<AbstractMesh>, scene: Scene);
  123615. private _follow;
  123616. /** @hidden */
  123617. _checkInputs(): void;
  123618. /**
  123619. * Returns the class name of the object.
  123620. * It is mostly used internally for serialization purposes.
  123621. */
  123622. getClassName(): string;
  123623. }
  123624. }
  123625. declare module BABYLON {
  123626. /**
  123627. * Manage the keyboard inputs to control the movement of a follow camera.
  123628. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123629. */
  123630. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123631. /**
  123632. * Defines the camera the input is attached to.
  123633. */
  123634. camera: FollowCamera;
  123635. /**
  123636. * Defines the list of key codes associated with the up action (increase heightOffset)
  123637. */
  123638. keysHeightOffsetIncr: number[];
  123639. /**
  123640. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123641. */
  123642. keysHeightOffsetDecr: number[];
  123643. /**
  123644. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123645. */
  123646. keysHeightOffsetModifierAlt: boolean;
  123647. /**
  123648. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123649. */
  123650. keysHeightOffsetModifierCtrl: boolean;
  123651. /**
  123652. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123653. */
  123654. keysHeightOffsetModifierShift: boolean;
  123655. /**
  123656. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123657. */
  123658. keysRotationOffsetIncr: number[];
  123659. /**
  123660. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123661. */
  123662. keysRotationOffsetDecr: number[];
  123663. /**
  123664. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123665. */
  123666. keysRotationOffsetModifierAlt: boolean;
  123667. /**
  123668. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123669. */
  123670. keysRotationOffsetModifierCtrl: boolean;
  123671. /**
  123672. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123673. */
  123674. keysRotationOffsetModifierShift: boolean;
  123675. /**
  123676. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123677. */
  123678. keysRadiusIncr: number[];
  123679. /**
  123680. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123681. */
  123682. keysRadiusDecr: number[];
  123683. /**
  123684. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123685. */
  123686. keysRadiusModifierAlt: boolean;
  123687. /**
  123688. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123689. */
  123690. keysRadiusModifierCtrl: boolean;
  123691. /**
  123692. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123693. */
  123694. keysRadiusModifierShift: boolean;
  123695. /**
  123696. * Defines the rate of change of heightOffset.
  123697. */
  123698. heightSensibility: number;
  123699. /**
  123700. * Defines the rate of change of rotationOffset.
  123701. */
  123702. rotationSensibility: number;
  123703. /**
  123704. * Defines the rate of change of radius.
  123705. */
  123706. radiusSensibility: number;
  123707. private _keys;
  123708. private _ctrlPressed;
  123709. private _altPressed;
  123710. private _shiftPressed;
  123711. private _onCanvasBlurObserver;
  123712. private _onKeyboardObserver;
  123713. private _engine;
  123714. private _scene;
  123715. /**
  123716. * Attach the input controls to a specific dom element to get the input from.
  123717. * @param element Defines the element the controls should be listened from
  123718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123719. */
  123720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123721. /**
  123722. * Detach the current controls from the specified dom element.
  123723. * @param element Defines the element to stop listening the inputs from
  123724. */
  123725. detachControl(element: Nullable<HTMLElement>): void;
  123726. /**
  123727. * Update the current camera state depending on the inputs that have been used this frame.
  123728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123729. */
  123730. checkInputs(): void;
  123731. /**
  123732. * Gets the class name of the current input.
  123733. * @returns the class name
  123734. */
  123735. getClassName(): string;
  123736. /**
  123737. * Get the friendly name associated with the input class.
  123738. * @returns the input friendly name
  123739. */
  123740. getSimpleName(): string;
  123741. /**
  123742. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123743. * allow modification of the heightOffset value.
  123744. */
  123745. private _modifierHeightOffset;
  123746. /**
  123747. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123748. * allow modification of the rotationOffset value.
  123749. */
  123750. private _modifierRotationOffset;
  123751. /**
  123752. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123753. * allow modification of the radius value.
  123754. */
  123755. private _modifierRadius;
  123756. }
  123757. }
  123758. declare module BABYLON {
  123759. interface FreeCameraInputsManager {
  123760. /**
  123761. * @hidden
  123762. */
  123763. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123764. /**
  123765. * Add orientation input support to the input manager.
  123766. * @returns the current input manager
  123767. */
  123768. addDeviceOrientation(): FreeCameraInputsManager;
  123769. }
  123770. /**
  123771. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123772. * Screen rotation is taken into account.
  123773. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123774. */
  123775. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123776. private _camera;
  123777. private _screenOrientationAngle;
  123778. private _constantTranform;
  123779. private _screenQuaternion;
  123780. private _alpha;
  123781. private _beta;
  123782. private _gamma;
  123783. /**
  123784. * Can be used to detect if a device orientation sensor is available on a device
  123785. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123786. * @returns a promise that will resolve on orientation change
  123787. */
  123788. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123789. /**
  123790. * @hidden
  123791. */
  123792. _onDeviceOrientationChangedObservable: Observable<void>;
  123793. /**
  123794. * Instantiates a new input
  123795. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123796. */
  123797. constructor();
  123798. /**
  123799. * Define the camera controlled by the input.
  123800. */
  123801. get camera(): FreeCamera;
  123802. set camera(camera: FreeCamera);
  123803. /**
  123804. * Attach the input controls to a specific dom element to get the input from.
  123805. * @param element Defines the element the controls should be listened from
  123806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123807. */
  123808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123809. private _orientationChanged;
  123810. private _deviceOrientation;
  123811. /**
  123812. * Detach the current controls from the specified dom element.
  123813. * @param element Defines the element to stop listening the inputs from
  123814. */
  123815. detachControl(element: Nullable<HTMLElement>): void;
  123816. /**
  123817. * Update the current camera state depending on the inputs that have been used this frame.
  123818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123819. */
  123820. checkInputs(): void;
  123821. /**
  123822. * Gets the class name of the current intput.
  123823. * @returns the class name
  123824. */
  123825. getClassName(): string;
  123826. /**
  123827. * Get the friendly name associated with the input class.
  123828. * @returns the input friendly name
  123829. */
  123830. getSimpleName(): string;
  123831. }
  123832. }
  123833. declare module BABYLON {
  123834. /**
  123835. * Manage the gamepad inputs to control a free camera.
  123836. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123837. */
  123838. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123839. /**
  123840. * Define the camera the input is attached to.
  123841. */
  123842. camera: FreeCamera;
  123843. /**
  123844. * Define the Gamepad controlling the input
  123845. */
  123846. gamepad: Nullable<Gamepad>;
  123847. /**
  123848. * Defines the gamepad rotation sensiblity.
  123849. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123850. */
  123851. gamepadAngularSensibility: number;
  123852. /**
  123853. * Defines the gamepad move sensiblity.
  123854. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123855. */
  123856. gamepadMoveSensibility: number;
  123857. private _yAxisScale;
  123858. /**
  123859. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123860. */
  123861. get invertYAxis(): boolean;
  123862. set invertYAxis(value: boolean);
  123863. private _onGamepadConnectedObserver;
  123864. private _onGamepadDisconnectedObserver;
  123865. private _cameraTransform;
  123866. private _deltaTransform;
  123867. private _vector3;
  123868. private _vector2;
  123869. /**
  123870. * Attach the input controls to a specific dom element to get the input from.
  123871. * @param element Defines the element the controls should be listened from
  123872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123873. */
  123874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123875. /**
  123876. * Detach the current controls from the specified dom element.
  123877. * @param element Defines the element to stop listening the inputs from
  123878. */
  123879. detachControl(element: Nullable<HTMLElement>): void;
  123880. /**
  123881. * Update the current camera state depending on the inputs that have been used this frame.
  123882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123883. */
  123884. checkInputs(): void;
  123885. /**
  123886. * Gets the class name of the current intput.
  123887. * @returns the class name
  123888. */
  123889. getClassName(): string;
  123890. /**
  123891. * Get the friendly name associated with the input class.
  123892. * @returns the input friendly name
  123893. */
  123894. getSimpleName(): string;
  123895. }
  123896. }
  123897. declare module BABYLON {
  123898. /**
  123899. * Defines the potential axis of a Joystick
  123900. */
  123901. export enum JoystickAxis {
  123902. /** X axis */
  123903. X = 0,
  123904. /** Y axis */
  123905. Y = 1,
  123906. /** Z axis */
  123907. Z = 2
  123908. }
  123909. /**
  123910. * Represents the different customization options available
  123911. * for VirtualJoystick
  123912. */
  123913. interface VirtualJoystickCustomizations {
  123914. /**
  123915. * Size of the joystick's puck
  123916. */
  123917. puckSize: number;
  123918. /**
  123919. * Size of the joystick's container
  123920. */
  123921. containerSize: number;
  123922. /**
  123923. * Color of the joystick && puck
  123924. */
  123925. color: string;
  123926. /**
  123927. * Image URL for the joystick's puck
  123928. */
  123929. puckImage?: string;
  123930. /**
  123931. * Image URL for the joystick's container
  123932. */
  123933. containerImage?: string;
  123934. /**
  123935. * Defines the unmoving position of the joystick container
  123936. */
  123937. position?: {
  123938. x: number;
  123939. y: number;
  123940. };
  123941. /**
  123942. * Defines whether or not the joystick container is always visible
  123943. */
  123944. alwaysVisible: boolean;
  123945. /**
  123946. * Defines whether or not to limit the movement of the puck to the joystick's container
  123947. */
  123948. limitToContainer: boolean;
  123949. }
  123950. /**
  123951. * Class used to define virtual joystick (used in touch mode)
  123952. */
  123953. export class VirtualJoystick {
  123954. /**
  123955. * Gets or sets a boolean indicating that left and right values must be inverted
  123956. */
  123957. reverseLeftRight: boolean;
  123958. /**
  123959. * Gets or sets a boolean indicating that up and down values must be inverted
  123960. */
  123961. reverseUpDown: boolean;
  123962. /**
  123963. * Gets the offset value for the position (ie. the change of the position value)
  123964. */
  123965. deltaPosition: Vector3;
  123966. /**
  123967. * Gets a boolean indicating if the virtual joystick was pressed
  123968. */
  123969. pressed: boolean;
  123970. /**
  123971. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123972. */
  123973. static Canvas: Nullable<HTMLCanvasElement>;
  123974. /**
  123975. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123976. */
  123977. limitToContainer: boolean;
  123978. private static _globalJoystickIndex;
  123979. private static _alwaysVisibleSticks;
  123980. private static vjCanvasContext;
  123981. private static vjCanvasWidth;
  123982. private static vjCanvasHeight;
  123983. private static halfWidth;
  123984. private static _GetDefaultOptions;
  123985. private _action;
  123986. private _axisTargetedByLeftAndRight;
  123987. private _axisTargetedByUpAndDown;
  123988. private _joystickSensibility;
  123989. private _inversedSensibility;
  123990. private _joystickPointerID;
  123991. private _joystickColor;
  123992. private _joystickPointerPos;
  123993. private _joystickPreviousPointerPos;
  123994. private _joystickPointerStartPos;
  123995. private _deltaJoystickVector;
  123996. private _leftJoystick;
  123997. private _touches;
  123998. private _joystickPosition;
  123999. private _alwaysVisible;
  124000. private _puckImage;
  124001. private _containerImage;
  124002. private _joystickPuckSize;
  124003. private _joystickContainerSize;
  124004. private _clearPuckSize;
  124005. private _clearContainerSize;
  124006. private _clearPuckSizeOffset;
  124007. private _clearContainerSizeOffset;
  124008. private _onPointerDownHandlerRef;
  124009. private _onPointerMoveHandlerRef;
  124010. private _onPointerUpHandlerRef;
  124011. private _onResize;
  124012. /**
  124013. * Creates a new virtual joystick
  124014. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124015. * @param customizations Defines the options we want to customize the VirtualJoystick
  124016. */
  124017. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124018. /**
  124019. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124020. * @param newJoystickSensibility defines the new sensibility
  124021. */
  124022. setJoystickSensibility(newJoystickSensibility: number): void;
  124023. private _onPointerDown;
  124024. private _onPointerMove;
  124025. private _onPointerUp;
  124026. /**
  124027. * Change the color of the virtual joystick
  124028. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124029. */
  124030. setJoystickColor(newColor: string): void;
  124031. /**
  124032. * Size of the joystick's container
  124033. */
  124034. set containerSize(newSize: number);
  124035. get containerSize(): number;
  124036. /**
  124037. * Size of the joystick's puck
  124038. */
  124039. set puckSize(newSize: number);
  124040. get puckSize(): number;
  124041. /**
  124042. * Clears the set position of the joystick
  124043. */
  124044. clearPosition(): void;
  124045. /**
  124046. * Defines whether or not the joystick container is always visible
  124047. */
  124048. set alwaysVisible(value: boolean);
  124049. get alwaysVisible(): boolean;
  124050. /**
  124051. * Sets the constant position of the Joystick container
  124052. * @param x X axis coordinate
  124053. * @param y Y axis coordinate
  124054. */
  124055. setPosition(x: number, y: number): void;
  124056. /**
  124057. * Defines a callback to call when the joystick is touched
  124058. * @param action defines the callback
  124059. */
  124060. setActionOnTouch(action: () => any): void;
  124061. /**
  124062. * Defines which axis you'd like to control for left & right
  124063. * @param axis defines the axis to use
  124064. */
  124065. setAxisForLeftRight(axis: JoystickAxis): void;
  124066. /**
  124067. * Defines which axis you'd like to control for up & down
  124068. * @param axis defines the axis to use
  124069. */
  124070. setAxisForUpDown(axis: JoystickAxis): void;
  124071. /**
  124072. * Clears the canvas from the previous puck / container draw
  124073. */
  124074. private _clearPreviousDraw;
  124075. /**
  124076. * Loads `urlPath` to be used for the container's image
  124077. * @param urlPath defines the urlPath of an image to use
  124078. */
  124079. setContainerImage(urlPath: string): void;
  124080. /**
  124081. * Loads `urlPath` to be used for the puck's image
  124082. * @param urlPath defines the urlPath of an image to use
  124083. */
  124084. setPuckImage(urlPath: string): void;
  124085. /**
  124086. * Draws the Virtual Joystick's container
  124087. */
  124088. private _drawContainer;
  124089. /**
  124090. * Draws the Virtual Joystick's puck
  124091. */
  124092. private _drawPuck;
  124093. private _drawVirtualJoystick;
  124094. /**
  124095. * Release internal HTML canvas
  124096. */
  124097. releaseCanvas(): void;
  124098. }
  124099. }
  124100. declare module BABYLON {
  124101. interface FreeCameraInputsManager {
  124102. /**
  124103. * Add virtual joystick input support to the input manager.
  124104. * @returns the current input manager
  124105. */
  124106. addVirtualJoystick(): FreeCameraInputsManager;
  124107. }
  124108. /**
  124109. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124111. */
  124112. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124113. /**
  124114. * Defines the camera the input is attached to.
  124115. */
  124116. camera: FreeCamera;
  124117. private _leftjoystick;
  124118. private _rightjoystick;
  124119. /**
  124120. * Gets the left stick of the virtual joystick.
  124121. * @returns The virtual Joystick
  124122. */
  124123. getLeftJoystick(): VirtualJoystick;
  124124. /**
  124125. * Gets the right stick of the virtual joystick.
  124126. * @returns The virtual Joystick
  124127. */
  124128. getRightJoystick(): VirtualJoystick;
  124129. /**
  124130. * Update the current camera state depending on the inputs that have been used this frame.
  124131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124132. */
  124133. checkInputs(): void;
  124134. /**
  124135. * Attach the input controls to a specific dom element to get the input from.
  124136. * @param element Defines the element the controls should be listened from
  124137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124138. */
  124139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124140. /**
  124141. * Detach the current controls from the specified dom element.
  124142. * @param element Defines the element to stop listening the inputs from
  124143. */
  124144. detachControl(element: Nullable<HTMLElement>): void;
  124145. /**
  124146. * Gets the class name of the current intput.
  124147. * @returns the class name
  124148. */
  124149. getClassName(): string;
  124150. /**
  124151. * Get the friendly name associated with the input class.
  124152. * @returns the input friendly name
  124153. */
  124154. getSimpleName(): string;
  124155. }
  124156. }
  124157. declare module BABYLON {
  124158. /**
  124159. * This represents a FPS type of camera controlled by touch.
  124160. * This is like a universal camera minus the Gamepad controls.
  124161. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124162. */
  124163. export class TouchCamera extends FreeCamera {
  124164. /**
  124165. * Defines the touch sensibility for rotation.
  124166. * The higher the faster.
  124167. */
  124168. get touchAngularSensibility(): number;
  124169. set touchAngularSensibility(value: number);
  124170. /**
  124171. * Defines the touch sensibility for move.
  124172. * The higher the faster.
  124173. */
  124174. get touchMoveSensibility(): number;
  124175. set touchMoveSensibility(value: number);
  124176. /**
  124177. * Instantiates a new touch camera.
  124178. * This represents a FPS type of camera controlled by touch.
  124179. * This is like a universal camera minus the Gamepad controls.
  124180. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124181. * @param name Define the name of the camera in the scene
  124182. * @param position Define the start position of the camera in the scene
  124183. * @param scene Define the scene the camera belongs to
  124184. */
  124185. constructor(name: string, position: Vector3, scene: Scene);
  124186. /**
  124187. * Gets the current object class name.
  124188. * @return the class name
  124189. */
  124190. getClassName(): string;
  124191. /** @hidden */
  124192. _setupInputs(): void;
  124193. }
  124194. }
  124195. declare module BABYLON {
  124196. /**
  124197. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124198. * being tilted forward or back and left or right.
  124199. */
  124200. export class DeviceOrientationCamera extends FreeCamera {
  124201. private _initialQuaternion;
  124202. private _quaternionCache;
  124203. private _tmpDragQuaternion;
  124204. private _disablePointerInputWhenUsingDeviceOrientation;
  124205. /**
  124206. * Creates a new device orientation camera
  124207. * @param name The name of the camera
  124208. * @param position The start position camera
  124209. * @param scene The scene the camera belongs to
  124210. */
  124211. constructor(name: string, position: Vector3, scene: Scene);
  124212. /**
  124213. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124214. */
  124215. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124216. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124217. private _dragFactor;
  124218. /**
  124219. * Enabled turning on the y axis when the orientation sensor is active
  124220. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124221. */
  124222. enableHorizontalDragging(dragFactor?: number): void;
  124223. /**
  124224. * Gets the current instance class name ("DeviceOrientationCamera").
  124225. * This helps avoiding instanceof at run time.
  124226. * @returns the class name
  124227. */
  124228. getClassName(): string;
  124229. /**
  124230. * @hidden
  124231. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124232. */
  124233. _checkInputs(): void;
  124234. /**
  124235. * Reset the camera to its default orientation on the specified axis only.
  124236. * @param axis The axis to reset
  124237. */
  124238. resetToCurrentRotation(axis?: Axis): void;
  124239. }
  124240. }
  124241. declare module BABYLON {
  124242. /**
  124243. * Defines supported buttons for XBox360 compatible gamepads
  124244. */
  124245. export enum Xbox360Button {
  124246. /** A */
  124247. A = 0,
  124248. /** B */
  124249. B = 1,
  124250. /** X */
  124251. X = 2,
  124252. /** Y */
  124253. Y = 3,
  124254. /** Left button */
  124255. LB = 4,
  124256. /** Right button */
  124257. RB = 5,
  124258. /** Back */
  124259. Back = 8,
  124260. /** Start */
  124261. Start = 9,
  124262. /** Left stick */
  124263. LeftStick = 10,
  124264. /** Right stick */
  124265. RightStick = 11
  124266. }
  124267. /** Defines values for XBox360 DPad */
  124268. export enum Xbox360Dpad {
  124269. /** Up */
  124270. Up = 12,
  124271. /** Down */
  124272. Down = 13,
  124273. /** Left */
  124274. Left = 14,
  124275. /** Right */
  124276. Right = 15
  124277. }
  124278. /**
  124279. * Defines a XBox360 gamepad
  124280. */
  124281. export class Xbox360Pad extends Gamepad {
  124282. private _leftTrigger;
  124283. private _rightTrigger;
  124284. private _onlefttriggerchanged;
  124285. private _onrighttriggerchanged;
  124286. private _onbuttondown;
  124287. private _onbuttonup;
  124288. private _ondpaddown;
  124289. private _ondpadup;
  124290. /** Observable raised when a button is pressed */
  124291. onButtonDownObservable: Observable<Xbox360Button>;
  124292. /** Observable raised when a button is released */
  124293. onButtonUpObservable: Observable<Xbox360Button>;
  124294. /** Observable raised when a pad is pressed */
  124295. onPadDownObservable: Observable<Xbox360Dpad>;
  124296. /** Observable raised when a pad is released */
  124297. onPadUpObservable: Observable<Xbox360Dpad>;
  124298. private _buttonA;
  124299. private _buttonB;
  124300. private _buttonX;
  124301. private _buttonY;
  124302. private _buttonBack;
  124303. private _buttonStart;
  124304. private _buttonLB;
  124305. private _buttonRB;
  124306. private _buttonLeftStick;
  124307. private _buttonRightStick;
  124308. private _dPadUp;
  124309. private _dPadDown;
  124310. private _dPadLeft;
  124311. private _dPadRight;
  124312. private _isXboxOnePad;
  124313. /**
  124314. * Creates a new XBox360 gamepad object
  124315. * @param id defines the id of this gamepad
  124316. * @param index defines its index
  124317. * @param gamepad defines the internal HTML gamepad object
  124318. * @param xboxOne defines if it is a XBox One gamepad
  124319. */
  124320. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124321. /**
  124322. * Defines the callback to call when left trigger is pressed
  124323. * @param callback defines the callback to use
  124324. */
  124325. onlefttriggerchanged(callback: (value: number) => void): void;
  124326. /**
  124327. * Defines the callback to call when right trigger is pressed
  124328. * @param callback defines the callback to use
  124329. */
  124330. onrighttriggerchanged(callback: (value: number) => void): void;
  124331. /**
  124332. * Gets the left trigger value
  124333. */
  124334. get leftTrigger(): number;
  124335. /**
  124336. * Sets the left trigger value
  124337. */
  124338. set leftTrigger(newValue: number);
  124339. /**
  124340. * Gets the right trigger value
  124341. */
  124342. get rightTrigger(): number;
  124343. /**
  124344. * Sets the right trigger value
  124345. */
  124346. set rightTrigger(newValue: number);
  124347. /**
  124348. * Defines the callback to call when a button is pressed
  124349. * @param callback defines the callback to use
  124350. */
  124351. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124352. /**
  124353. * Defines the callback to call when a button is released
  124354. * @param callback defines the callback to use
  124355. */
  124356. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124357. /**
  124358. * Defines the callback to call when a pad is pressed
  124359. * @param callback defines the callback to use
  124360. */
  124361. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124362. /**
  124363. * Defines the callback to call when a pad is released
  124364. * @param callback defines the callback to use
  124365. */
  124366. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124367. private _setButtonValue;
  124368. private _setDPadValue;
  124369. /**
  124370. * Gets the value of the `A` button
  124371. */
  124372. get buttonA(): number;
  124373. /**
  124374. * Sets the value of the `A` button
  124375. */
  124376. set buttonA(value: number);
  124377. /**
  124378. * Gets the value of the `B` button
  124379. */
  124380. get buttonB(): number;
  124381. /**
  124382. * Sets the value of the `B` button
  124383. */
  124384. set buttonB(value: number);
  124385. /**
  124386. * Gets the value of the `X` button
  124387. */
  124388. get buttonX(): number;
  124389. /**
  124390. * Sets the value of the `X` button
  124391. */
  124392. set buttonX(value: number);
  124393. /**
  124394. * Gets the value of the `Y` button
  124395. */
  124396. get buttonY(): number;
  124397. /**
  124398. * Sets the value of the `Y` button
  124399. */
  124400. set buttonY(value: number);
  124401. /**
  124402. * Gets the value of the `Start` button
  124403. */
  124404. get buttonStart(): number;
  124405. /**
  124406. * Sets the value of the `Start` button
  124407. */
  124408. set buttonStart(value: number);
  124409. /**
  124410. * Gets the value of the `Back` button
  124411. */
  124412. get buttonBack(): number;
  124413. /**
  124414. * Sets the value of the `Back` button
  124415. */
  124416. set buttonBack(value: number);
  124417. /**
  124418. * Gets the value of the `Left` button
  124419. */
  124420. get buttonLB(): number;
  124421. /**
  124422. * Sets the value of the `Left` button
  124423. */
  124424. set buttonLB(value: number);
  124425. /**
  124426. * Gets the value of the `Right` button
  124427. */
  124428. get buttonRB(): number;
  124429. /**
  124430. * Sets the value of the `Right` button
  124431. */
  124432. set buttonRB(value: number);
  124433. /**
  124434. * Gets the value of the Left joystick
  124435. */
  124436. get buttonLeftStick(): number;
  124437. /**
  124438. * Sets the value of the Left joystick
  124439. */
  124440. set buttonLeftStick(value: number);
  124441. /**
  124442. * Gets the value of the Right joystick
  124443. */
  124444. get buttonRightStick(): number;
  124445. /**
  124446. * Sets the value of the Right joystick
  124447. */
  124448. set buttonRightStick(value: number);
  124449. /**
  124450. * Gets the value of D-pad up
  124451. */
  124452. get dPadUp(): number;
  124453. /**
  124454. * Sets the value of D-pad up
  124455. */
  124456. set dPadUp(value: number);
  124457. /**
  124458. * Gets the value of D-pad down
  124459. */
  124460. get dPadDown(): number;
  124461. /**
  124462. * Sets the value of D-pad down
  124463. */
  124464. set dPadDown(value: number);
  124465. /**
  124466. * Gets the value of D-pad left
  124467. */
  124468. get dPadLeft(): number;
  124469. /**
  124470. * Sets the value of D-pad left
  124471. */
  124472. set dPadLeft(value: number);
  124473. /**
  124474. * Gets the value of D-pad right
  124475. */
  124476. get dPadRight(): number;
  124477. /**
  124478. * Sets the value of D-pad right
  124479. */
  124480. set dPadRight(value: number);
  124481. /**
  124482. * Force the gamepad to synchronize with device values
  124483. */
  124484. update(): void;
  124485. /**
  124486. * Disposes the gamepad
  124487. */
  124488. dispose(): void;
  124489. }
  124490. }
  124491. declare module BABYLON {
  124492. /**
  124493. * Defines supported buttons for DualShock compatible gamepads
  124494. */
  124495. export enum DualShockButton {
  124496. /** Cross */
  124497. Cross = 0,
  124498. /** Circle */
  124499. Circle = 1,
  124500. /** Square */
  124501. Square = 2,
  124502. /** Triangle */
  124503. Triangle = 3,
  124504. /** L1 */
  124505. L1 = 4,
  124506. /** R1 */
  124507. R1 = 5,
  124508. /** Share */
  124509. Share = 8,
  124510. /** Options */
  124511. Options = 9,
  124512. /** Left stick */
  124513. LeftStick = 10,
  124514. /** Right stick */
  124515. RightStick = 11
  124516. }
  124517. /** Defines values for DualShock DPad */
  124518. export enum DualShockDpad {
  124519. /** Up */
  124520. Up = 12,
  124521. /** Down */
  124522. Down = 13,
  124523. /** Left */
  124524. Left = 14,
  124525. /** Right */
  124526. Right = 15
  124527. }
  124528. /**
  124529. * Defines a DualShock gamepad
  124530. */
  124531. export class DualShockPad extends Gamepad {
  124532. private _leftTrigger;
  124533. private _rightTrigger;
  124534. private _onlefttriggerchanged;
  124535. private _onrighttriggerchanged;
  124536. private _onbuttondown;
  124537. private _onbuttonup;
  124538. private _ondpaddown;
  124539. private _ondpadup;
  124540. /** Observable raised when a button is pressed */
  124541. onButtonDownObservable: Observable<DualShockButton>;
  124542. /** Observable raised when a button is released */
  124543. onButtonUpObservable: Observable<DualShockButton>;
  124544. /** Observable raised when a pad is pressed */
  124545. onPadDownObservable: Observable<DualShockDpad>;
  124546. /** Observable raised when a pad is released */
  124547. onPadUpObservable: Observable<DualShockDpad>;
  124548. private _buttonCross;
  124549. private _buttonCircle;
  124550. private _buttonSquare;
  124551. private _buttonTriangle;
  124552. private _buttonShare;
  124553. private _buttonOptions;
  124554. private _buttonL1;
  124555. private _buttonR1;
  124556. private _buttonLeftStick;
  124557. private _buttonRightStick;
  124558. private _dPadUp;
  124559. private _dPadDown;
  124560. private _dPadLeft;
  124561. private _dPadRight;
  124562. /**
  124563. * Creates a new DualShock gamepad object
  124564. * @param id defines the id of this gamepad
  124565. * @param index defines its index
  124566. * @param gamepad defines the internal HTML gamepad object
  124567. */
  124568. constructor(id: string, index: number, gamepad: any);
  124569. /**
  124570. * Defines the callback to call when left trigger is pressed
  124571. * @param callback defines the callback to use
  124572. */
  124573. onlefttriggerchanged(callback: (value: number) => void): void;
  124574. /**
  124575. * Defines the callback to call when right trigger is pressed
  124576. * @param callback defines the callback to use
  124577. */
  124578. onrighttriggerchanged(callback: (value: number) => void): void;
  124579. /**
  124580. * Gets the left trigger value
  124581. */
  124582. get leftTrigger(): number;
  124583. /**
  124584. * Sets the left trigger value
  124585. */
  124586. set leftTrigger(newValue: number);
  124587. /**
  124588. * Gets the right trigger value
  124589. */
  124590. get rightTrigger(): number;
  124591. /**
  124592. * Sets the right trigger value
  124593. */
  124594. set rightTrigger(newValue: number);
  124595. /**
  124596. * Defines the callback to call when a button is pressed
  124597. * @param callback defines the callback to use
  124598. */
  124599. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124600. /**
  124601. * Defines the callback to call when a button is released
  124602. * @param callback defines the callback to use
  124603. */
  124604. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124605. /**
  124606. * Defines the callback to call when a pad is pressed
  124607. * @param callback defines the callback to use
  124608. */
  124609. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124610. /**
  124611. * Defines the callback to call when a pad is released
  124612. * @param callback defines the callback to use
  124613. */
  124614. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124615. private _setButtonValue;
  124616. private _setDPadValue;
  124617. /**
  124618. * Gets the value of the `Cross` button
  124619. */
  124620. get buttonCross(): number;
  124621. /**
  124622. * Sets the value of the `Cross` button
  124623. */
  124624. set buttonCross(value: number);
  124625. /**
  124626. * Gets the value of the `Circle` button
  124627. */
  124628. get buttonCircle(): number;
  124629. /**
  124630. * Sets the value of the `Circle` button
  124631. */
  124632. set buttonCircle(value: number);
  124633. /**
  124634. * Gets the value of the `Square` button
  124635. */
  124636. get buttonSquare(): number;
  124637. /**
  124638. * Sets the value of the `Square` button
  124639. */
  124640. set buttonSquare(value: number);
  124641. /**
  124642. * Gets the value of the `Triangle` button
  124643. */
  124644. get buttonTriangle(): number;
  124645. /**
  124646. * Sets the value of the `Triangle` button
  124647. */
  124648. set buttonTriangle(value: number);
  124649. /**
  124650. * Gets the value of the `Options` button
  124651. */
  124652. get buttonOptions(): number;
  124653. /**
  124654. * Sets the value of the `Options` button
  124655. */
  124656. set buttonOptions(value: number);
  124657. /**
  124658. * Gets the value of the `Share` button
  124659. */
  124660. get buttonShare(): number;
  124661. /**
  124662. * Sets the value of the `Share` button
  124663. */
  124664. set buttonShare(value: number);
  124665. /**
  124666. * Gets the value of the `L1` button
  124667. */
  124668. get buttonL1(): number;
  124669. /**
  124670. * Sets the value of the `L1` button
  124671. */
  124672. set buttonL1(value: number);
  124673. /**
  124674. * Gets the value of the `R1` button
  124675. */
  124676. get buttonR1(): number;
  124677. /**
  124678. * Sets the value of the `R1` button
  124679. */
  124680. set buttonR1(value: number);
  124681. /**
  124682. * Gets the value of the Left joystick
  124683. */
  124684. get buttonLeftStick(): number;
  124685. /**
  124686. * Sets the value of the Left joystick
  124687. */
  124688. set buttonLeftStick(value: number);
  124689. /**
  124690. * Gets the value of the Right joystick
  124691. */
  124692. get buttonRightStick(): number;
  124693. /**
  124694. * Sets the value of the Right joystick
  124695. */
  124696. set buttonRightStick(value: number);
  124697. /**
  124698. * Gets the value of D-pad up
  124699. */
  124700. get dPadUp(): number;
  124701. /**
  124702. * Sets the value of D-pad up
  124703. */
  124704. set dPadUp(value: number);
  124705. /**
  124706. * Gets the value of D-pad down
  124707. */
  124708. get dPadDown(): number;
  124709. /**
  124710. * Sets the value of D-pad down
  124711. */
  124712. set dPadDown(value: number);
  124713. /**
  124714. * Gets the value of D-pad left
  124715. */
  124716. get dPadLeft(): number;
  124717. /**
  124718. * Sets the value of D-pad left
  124719. */
  124720. set dPadLeft(value: number);
  124721. /**
  124722. * Gets the value of D-pad right
  124723. */
  124724. get dPadRight(): number;
  124725. /**
  124726. * Sets the value of D-pad right
  124727. */
  124728. set dPadRight(value: number);
  124729. /**
  124730. * Force the gamepad to synchronize with device values
  124731. */
  124732. update(): void;
  124733. /**
  124734. * Disposes the gamepad
  124735. */
  124736. dispose(): void;
  124737. }
  124738. }
  124739. declare module BABYLON {
  124740. /**
  124741. * Manager for handling gamepads
  124742. */
  124743. export class GamepadManager {
  124744. private _scene?;
  124745. private _babylonGamepads;
  124746. private _oneGamepadConnected;
  124747. /** @hidden */
  124748. _isMonitoring: boolean;
  124749. private _gamepadEventSupported;
  124750. private _gamepadSupport?;
  124751. /**
  124752. * observable to be triggered when the gamepad controller has been connected
  124753. */
  124754. onGamepadConnectedObservable: Observable<Gamepad>;
  124755. /**
  124756. * observable to be triggered when the gamepad controller has been disconnected
  124757. */
  124758. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124759. private _onGamepadConnectedEvent;
  124760. private _onGamepadDisconnectedEvent;
  124761. /**
  124762. * Initializes the gamepad manager
  124763. * @param _scene BabylonJS scene
  124764. */
  124765. constructor(_scene?: Scene | undefined);
  124766. /**
  124767. * The gamepads in the game pad manager
  124768. */
  124769. get gamepads(): Gamepad[];
  124770. /**
  124771. * Get the gamepad controllers based on type
  124772. * @param type The type of gamepad controller
  124773. * @returns Nullable gamepad
  124774. */
  124775. getGamepadByType(type?: number): Nullable<Gamepad>;
  124776. /**
  124777. * Disposes the gamepad manager
  124778. */
  124779. dispose(): void;
  124780. private _addNewGamepad;
  124781. private _startMonitoringGamepads;
  124782. private _stopMonitoringGamepads;
  124783. /** @hidden */
  124784. _checkGamepadsStatus(): void;
  124785. private _updateGamepadObjects;
  124786. }
  124787. }
  124788. declare module BABYLON {
  124789. interface Scene {
  124790. /** @hidden */
  124791. _gamepadManager: Nullable<GamepadManager>;
  124792. /**
  124793. * Gets the gamepad manager associated with the scene
  124794. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124795. */
  124796. gamepadManager: GamepadManager;
  124797. }
  124798. /**
  124799. * Interface representing a free camera inputs manager
  124800. */
  124801. interface FreeCameraInputsManager {
  124802. /**
  124803. * Adds gamepad input support to the FreeCameraInputsManager.
  124804. * @returns the FreeCameraInputsManager
  124805. */
  124806. addGamepad(): FreeCameraInputsManager;
  124807. }
  124808. /**
  124809. * Interface representing an arc rotate camera inputs manager
  124810. */
  124811. interface ArcRotateCameraInputsManager {
  124812. /**
  124813. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124814. * @returns the camera inputs manager
  124815. */
  124816. addGamepad(): ArcRotateCameraInputsManager;
  124817. }
  124818. /**
  124819. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124820. */
  124821. export class GamepadSystemSceneComponent implements ISceneComponent {
  124822. /**
  124823. * The component name helpfull to identify the component in the list of scene components.
  124824. */
  124825. readonly name: string;
  124826. /**
  124827. * The scene the component belongs to.
  124828. */
  124829. scene: Scene;
  124830. /**
  124831. * Creates a new instance of the component for the given scene
  124832. * @param scene Defines the scene to register the component in
  124833. */
  124834. constructor(scene: Scene);
  124835. /**
  124836. * Registers the component in a given scene
  124837. */
  124838. register(): void;
  124839. /**
  124840. * Rebuilds the elements related to this component in case of
  124841. * context lost for instance.
  124842. */
  124843. rebuild(): void;
  124844. /**
  124845. * Disposes the component and the associated ressources
  124846. */
  124847. dispose(): void;
  124848. private _beforeCameraUpdate;
  124849. }
  124850. }
  124851. declare module BABYLON {
  124852. /**
  124853. * 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,
  124854. * which still works and will still be found in many Playgrounds.
  124855. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124856. */
  124857. export class UniversalCamera extends TouchCamera {
  124858. /**
  124859. * Defines the gamepad rotation sensiblity.
  124860. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124861. */
  124862. get gamepadAngularSensibility(): number;
  124863. set gamepadAngularSensibility(value: number);
  124864. /**
  124865. * Defines the gamepad move sensiblity.
  124866. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124867. */
  124868. get gamepadMoveSensibility(): number;
  124869. set gamepadMoveSensibility(value: number);
  124870. /**
  124871. * 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,
  124872. * which still works and will still be found in many Playgrounds.
  124873. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124874. * @param name Define the name of the camera in the scene
  124875. * @param position Define the start position of the camera in the scene
  124876. * @param scene Define the scene the camera belongs to
  124877. */
  124878. constructor(name: string, position: Vector3, scene: Scene);
  124879. /**
  124880. * Gets the current object class name.
  124881. * @return the class name
  124882. */
  124883. getClassName(): string;
  124884. }
  124885. }
  124886. declare module BABYLON {
  124887. /**
  124888. * This represents a FPS type of camera. This is only here for back compat purpose.
  124889. * Please use the UniversalCamera instead as both are identical.
  124890. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124891. */
  124892. export class GamepadCamera extends UniversalCamera {
  124893. /**
  124894. * Instantiates a new Gamepad Camera
  124895. * This represents a FPS type of camera. This is only here for back compat purpose.
  124896. * Please use the UniversalCamera instead as both are identical.
  124897. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124898. * @param name Define the name of the camera in the scene
  124899. * @param position Define the start position of the camera in the scene
  124900. * @param scene Define the scene the camera belongs to
  124901. */
  124902. constructor(name: string, position: Vector3, scene: Scene);
  124903. /**
  124904. * Gets the current object class name.
  124905. * @return the class name
  124906. */
  124907. getClassName(): string;
  124908. }
  124909. }
  124910. declare module BABYLON {
  124911. /** @hidden */
  124912. export var passPixelShader: {
  124913. name: string;
  124914. shader: string;
  124915. };
  124916. }
  124917. declare module BABYLON {
  124918. /** @hidden */
  124919. export var passCubePixelShader: {
  124920. name: string;
  124921. shader: string;
  124922. };
  124923. }
  124924. declare module BABYLON {
  124925. /**
  124926. * PassPostProcess which produces an output the same as it's input
  124927. */
  124928. export class PassPostProcess extends PostProcess {
  124929. /**
  124930. * Creates the PassPostProcess
  124931. * @param name The name of the effect.
  124932. * @param options The required width/height ratio to downsize to before computing the render pass.
  124933. * @param camera The camera to apply the render pass to.
  124934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124935. * @param engine The engine which the post process will be applied. (default: current engine)
  124936. * @param reusable If the post process can be reused on the same frame. (default: false)
  124937. * @param textureType The type of texture to be used when performing the post processing.
  124938. * @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)
  124939. */
  124940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124941. }
  124942. /**
  124943. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124944. */
  124945. export class PassCubePostProcess extends PostProcess {
  124946. private _face;
  124947. /**
  124948. * Gets or sets the cube face to display.
  124949. * * 0 is +X
  124950. * * 1 is -X
  124951. * * 2 is +Y
  124952. * * 3 is -Y
  124953. * * 4 is +Z
  124954. * * 5 is -Z
  124955. */
  124956. get face(): number;
  124957. set face(value: number);
  124958. /**
  124959. * Creates the PassCubePostProcess
  124960. * @param name The name of the effect.
  124961. * @param options The required width/height ratio to downsize to before computing the render pass.
  124962. * @param camera The camera to apply the render pass to.
  124963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124964. * @param engine The engine which the post process will be applied. (default: current engine)
  124965. * @param reusable If the post process can be reused on the same frame. (default: false)
  124966. * @param textureType The type of texture to be used when performing the post processing.
  124967. * @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)
  124968. */
  124969. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124970. }
  124971. }
  124972. declare module BABYLON {
  124973. /** @hidden */
  124974. export var anaglyphPixelShader: {
  124975. name: string;
  124976. shader: string;
  124977. };
  124978. }
  124979. declare module BABYLON {
  124980. /**
  124981. * Postprocess used to generate anaglyphic rendering
  124982. */
  124983. export class AnaglyphPostProcess extends PostProcess {
  124984. private _passedProcess;
  124985. /**
  124986. * Creates a new AnaglyphPostProcess
  124987. * @param name defines postprocess name
  124988. * @param options defines creation options or target ratio scale
  124989. * @param rigCameras defines cameras using this postprocess
  124990. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124991. * @param engine defines hosting engine
  124992. * @param reusable defines if the postprocess will be reused multiple times per frame
  124993. */
  124994. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124995. }
  124996. }
  124997. declare module BABYLON {
  124998. /**
  124999. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125000. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125001. */
  125002. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125003. /**
  125004. * Creates a new AnaglyphArcRotateCamera
  125005. * @param name defines camera name
  125006. * @param alpha defines alpha angle (in radians)
  125007. * @param beta defines beta angle (in radians)
  125008. * @param radius defines radius
  125009. * @param target defines camera target
  125010. * @param interaxialDistance defines distance between each color axis
  125011. * @param scene defines the hosting scene
  125012. */
  125013. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125014. /**
  125015. * Gets camera class name
  125016. * @returns AnaglyphArcRotateCamera
  125017. */
  125018. getClassName(): string;
  125019. }
  125020. }
  125021. declare module BABYLON {
  125022. /**
  125023. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125024. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125025. */
  125026. export class AnaglyphFreeCamera extends FreeCamera {
  125027. /**
  125028. * Creates a new AnaglyphFreeCamera
  125029. * @param name defines camera name
  125030. * @param position defines initial position
  125031. * @param interaxialDistance defines distance between each color axis
  125032. * @param scene defines the hosting scene
  125033. */
  125034. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125035. /**
  125036. * Gets camera class name
  125037. * @returns AnaglyphFreeCamera
  125038. */
  125039. getClassName(): string;
  125040. }
  125041. }
  125042. declare module BABYLON {
  125043. /**
  125044. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125045. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125046. */
  125047. export class AnaglyphGamepadCamera extends GamepadCamera {
  125048. /**
  125049. * Creates a new AnaglyphGamepadCamera
  125050. * @param name defines camera name
  125051. * @param position defines initial position
  125052. * @param interaxialDistance defines distance between each color axis
  125053. * @param scene defines the hosting scene
  125054. */
  125055. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125056. /**
  125057. * Gets camera class name
  125058. * @returns AnaglyphGamepadCamera
  125059. */
  125060. getClassName(): string;
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /**
  125065. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125066. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125067. */
  125068. export class AnaglyphUniversalCamera extends UniversalCamera {
  125069. /**
  125070. * Creates a new AnaglyphUniversalCamera
  125071. * @param name defines camera name
  125072. * @param position defines initial position
  125073. * @param interaxialDistance defines distance between each color axis
  125074. * @param scene defines the hosting scene
  125075. */
  125076. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125077. /**
  125078. * Gets camera class name
  125079. * @returns AnaglyphUniversalCamera
  125080. */
  125081. getClassName(): string;
  125082. }
  125083. }
  125084. declare module BABYLON {
  125085. /**
  125086. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125087. * @see https://doc.babylonjs.com/features/cameras
  125088. */
  125089. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125090. /**
  125091. * Creates a new StereoscopicArcRotateCamera
  125092. * @param name defines camera name
  125093. * @param alpha defines alpha angle (in radians)
  125094. * @param beta defines beta angle (in radians)
  125095. * @param radius defines radius
  125096. * @param target defines camera target
  125097. * @param interaxialDistance defines distance between each color axis
  125098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125099. * @param scene defines the hosting scene
  125100. */
  125101. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125102. /**
  125103. * Gets camera class name
  125104. * @returns StereoscopicArcRotateCamera
  125105. */
  125106. getClassName(): string;
  125107. }
  125108. }
  125109. declare module BABYLON {
  125110. /**
  125111. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125112. * @see https://doc.babylonjs.com/features/cameras
  125113. */
  125114. export class StereoscopicFreeCamera extends FreeCamera {
  125115. /**
  125116. * Creates a new StereoscopicFreeCamera
  125117. * @param name defines camera name
  125118. * @param position defines initial position
  125119. * @param interaxialDistance defines distance between each color axis
  125120. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125121. * @param scene defines the hosting scene
  125122. */
  125123. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125124. /**
  125125. * Gets camera class name
  125126. * @returns StereoscopicFreeCamera
  125127. */
  125128. getClassName(): string;
  125129. }
  125130. }
  125131. declare module BABYLON {
  125132. /**
  125133. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125134. * @see https://doc.babylonjs.com/features/cameras
  125135. */
  125136. export class StereoscopicGamepadCamera extends GamepadCamera {
  125137. /**
  125138. * Creates a new StereoscopicGamepadCamera
  125139. * @param name defines camera name
  125140. * @param position defines initial position
  125141. * @param interaxialDistance defines distance between each color axis
  125142. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125143. * @param scene defines the hosting scene
  125144. */
  125145. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125146. /**
  125147. * Gets camera class name
  125148. * @returns StereoscopicGamepadCamera
  125149. */
  125150. getClassName(): string;
  125151. }
  125152. }
  125153. declare module BABYLON {
  125154. /**
  125155. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125156. * @see https://doc.babylonjs.com/features/cameras
  125157. */
  125158. export class StereoscopicUniversalCamera extends UniversalCamera {
  125159. /**
  125160. * Creates a new StereoscopicUniversalCamera
  125161. * @param name defines camera name
  125162. * @param position defines initial position
  125163. * @param interaxialDistance defines distance between each color axis
  125164. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125165. * @param scene defines the hosting scene
  125166. */
  125167. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125168. /**
  125169. * Gets camera class name
  125170. * @returns StereoscopicUniversalCamera
  125171. */
  125172. getClassName(): string;
  125173. }
  125174. }
  125175. declare module BABYLON {
  125176. /**
  125177. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125178. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125179. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125180. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125181. */
  125182. export class VirtualJoysticksCamera extends FreeCamera {
  125183. /**
  125184. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125185. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125186. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125187. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125188. * @param name Define the name of the camera in the scene
  125189. * @param position Define the start position of the camera in the scene
  125190. * @param scene Define the scene the camera belongs to
  125191. */
  125192. constructor(name: string, position: Vector3, scene: Scene);
  125193. /**
  125194. * Gets the current object class name.
  125195. * @return the class name
  125196. */
  125197. getClassName(): string;
  125198. }
  125199. }
  125200. declare module BABYLON {
  125201. /**
  125202. * This represents all the required metrics to create a VR camera.
  125203. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125204. */
  125205. export class VRCameraMetrics {
  125206. /**
  125207. * Define the horizontal resolution off the screen.
  125208. */
  125209. hResolution: number;
  125210. /**
  125211. * Define the vertical resolution off the screen.
  125212. */
  125213. vResolution: number;
  125214. /**
  125215. * Define the horizontal screen size.
  125216. */
  125217. hScreenSize: number;
  125218. /**
  125219. * Define the vertical screen size.
  125220. */
  125221. vScreenSize: number;
  125222. /**
  125223. * Define the vertical screen center position.
  125224. */
  125225. vScreenCenter: number;
  125226. /**
  125227. * Define the distance of the eyes to the screen.
  125228. */
  125229. eyeToScreenDistance: number;
  125230. /**
  125231. * Define the distance between both lenses
  125232. */
  125233. lensSeparationDistance: number;
  125234. /**
  125235. * Define the distance between both viewer's eyes.
  125236. */
  125237. interpupillaryDistance: number;
  125238. /**
  125239. * Define the distortion factor of the VR postprocess.
  125240. * Please, touch with care.
  125241. */
  125242. distortionK: number[];
  125243. /**
  125244. * Define the chromatic aberration correction factors for the VR post process.
  125245. */
  125246. chromaAbCorrection: number[];
  125247. /**
  125248. * Define the scale factor of the post process.
  125249. * The smaller the better but the slower.
  125250. */
  125251. postProcessScaleFactor: number;
  125252. /**
  125253. * Define an offset for the lens center.
  125254. */
  125255. lensCenterOffset: number;
  125256. /**
  125257. * Define if the current vr camera should compensate the distortion of the lense or not.
  125258. */
  125259. compensateDistortion: boolean;
  125260. /**
  125261. * Defines if multiview should be enabled when rendering (Default: false)
  125262. */
  125263. multiviewEnabled: boolean;
  125264. /**
  125265. * Gets the rendering aspect ratio based on the provided resolutions.
  125266. */
  125267. get aspectRatio(): number;
  125268. /**
  125269. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125270. */
  125271. get aspectRatioFov(): number;
  125272. /**
  125273. * @hidden
  125274. */
  125275. get leftHMatrix(): Matrix;
  125276. /**
  125277. * @hidden
  125278. */
  125279. get rightHMatrix(): Matrix;
  125280. /**
  125281. * @hidden
  125282. */
  125283. get leftPreViewMatrix(): Matrix;
  125284. /**
  125285. * @hidden
  125286. */
  125287. get rightPreViewMatrix(): Matrix;
  125288. /**
  125289. * Get the default VRMetrics based on the most generic setup.
  125290. * @returns the default vr metrics
  125291. */
  125292. static GetDefault(): VRCameraMetrics;
  125293. }
  125294. }
  125295. declare module BABYLON {
  125296. /** @hidden */
  125297. export var vrDistortionCorrectionPixelShader: {
  125298. name: string;
  125299. shader: string;
  125300. };
  125301. }
  125302. declare module BABYLON {
  125303. /**
  125304. * VRDistortionCorrectionPostProcess used for mobile VR
  125305. */
  125306. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125307. private _isRightEye;
  125308. private _distortionFactors;
  125309. private _postProcessScaleFactor;
  125310. private _lensCenterOffset;
  125311. private _scaleIn;
  125312. private _scaleFactor;
  125313. private _lensCenter;
  125314. /**
  125315. * Initializes the VRDistortionCorrectionPostProcess
  125316. * @param name The name of the effect.
  125317. * @param camera The camera to apply the render pass to.
  125318. * @param isRightEye If this is for the right eye distortion
  125319. * @param vrMetrics All the required metrics for the VR camera
  125320. */
  125321. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125322. }
  125323. }
  125324. declare module BABYLON {
  125325. /**
  125326. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125327. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125328. */
  125329. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125330. /**
  125331. * Creates a new VRDeviceOrientationArcRotateCamera
  125332. * @param name defines camera name
  125333. * @param alpha defines the camera rotation along the logitudinal axis
  125334. * @param beta defines the camera rotation along the latitudinal axis
  125335. * @param radius defines the camera distance from its target
  125336. * @param target defines the camera target
  125337. * @param scene defines the scene the camera belongs to
  125338. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125339. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125340. */
  125341. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125342. /**
  125343. * Gets camera class name
  125344. * @returns VRDeviceOrientationArcRotateCamera
  125345. */
  125346. getClassName(): string;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * Camera used to simulate VR rendering (based on FreeCamera)
  125352. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125353. */
  125354. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125355. /**
  125356. * Creates a new VRDeviceOrientationFreeCamera
  125357. * @param name defines camera name
  125358. * @param position defines the start position of the camera
  125359. * @param scene defines the scene the camera belongs to
  125360. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125361. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125362. */
  125363. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125364. /**
  125365. * Gets camera class name
  125366. * @returns VRDeviceOrientationFreeCamera
  125367. */
  125368. getClassName(): string;
  125369. }
  125370. }
  125371. declare module BABYLON {
  125372. /**
  125373. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125374. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125375. */
  125376. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125377. /**
  125378. * Creates a new VRDeviceOrientationGamepadCamera
  125379. * @param name defines camera name
  125380. * @param position defines the start position of the camera
  125381. * @param scene defines the scene the camera belongs to
  125382. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125383. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125384. */
  125385. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125386. /**
  125387. * Gets camera class name
  125388. * @returns VRDeviceOrientationGamepadCamera
  125389. */
  125390. getClassName(): string;
  125391. }
  125392. }
  125393. declare module BABYLON {
  125394. /**
  125395. * A class extending Texture allowing drawing on a texture
  125396. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125397. */
  125398. export class DynamicTexture extends Texture {
  125399. private _generateMipMaps;
  125400. private _canvas;
  125401. private _context;
  125402. /**
  125403. * Creates a DynamicTexture
  125404. * @param name defines the name of the texture
  125405. * @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
  125406. * @param scene defines the scene where you want the texture
  125407. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125408. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125409. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125410. */
  125411. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125412. /**
  125413. * Get the current class name of the texture useful for serialization or dynamic coding.
  125414. * @returns "DynamicTexture"
  125415. */
  125416. getClassName(): string;
  125417. /**
  125418. * Gets the current state of canRescale
  125419. */
  125420. get canRescale(): boolean;
  125421. private _recreate;
  125422. /**
  125423. * Scales the texture
  125424. * @param ratio the scale factor to apply to both width and height
  125425. */
  125426. scale(ratio: number): void;
  125427. /**
  125428. * Resizes the texture
  125429. * @param width the new width
  125430. * @param height the new height
  125431. */
  125432. scaleTo(width: number, height: number): void;
  125433. /**
  125434. * Gets the context of the canvas used by the texture
  125435. * @returns the canvas context of the dynamic texture
  125436. */
  125437. getContext(): CanvasRenderingContext2D;
  125438. /**
  125439. * Clears the texture
  125440. */
  125441. clear(): void;
  125442. /**
  125443. * Updates the texture
  125444. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125445. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125446. */
  125447. update(invertY?: boolean, premulAlpha?: boolean): void;
  125448. /**
  125449. * Draws text onto the texture
  125450. * @param text defines the text to be drawn
  125451. * @param x defines the placement of the text from the left
  125452. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125453. * @param font defines the font to be used with font-style, font-size, font-name
  125454. * @param color defines the color used for the text
  125455. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125456. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125457. * @param update defines whether texture is immediately update (default is true)
  125458. */
  125459. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125460. /**
  125461. * Clones the texture
  125462. * @returns the clone of the texture.
  125463. */
  125464. clone(): DynamicTexture;
  125465. /**
  125466. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125467. * @returns a serialized dynamic texture object
  125468. */
  125469. serialize(): any;
  125470. private _IsCanvasElement;
  125471. /** @hidden */
  125472. _rebuild(): void;
  125473. }
  125474. }
  125475. declare module BABYLON {
  125476. /**
  125477. * Class containing static functions to help procedurally build meshes
  125478. */
  125479. export class GroundBuilder {
  125480. /**
  125481. * Creates a ground mesh
  125482. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125483. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125485. * @param name defines the name of the mesh
  125486. * @param options defines the options used to create the mesh
  125487. * @param scene defines the hosting scene
  125488. * @returns the ground mesh
  125489. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125490. */
  125491. static CreateGround(name: string, options: {
  125492. width?: number;
  125493. height?: number;
  125494. subdivisions?: number;
  125495. subdivisionsX?: number;
  125496. subdivisionsY?: number;
  125497. updatable?: boolean;
  125498. }, scene: any): Mesh;
  125499. /**
  125500. * Creates a tiled ground mesh
  125501. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125502. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125503. * * 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
  125504. * * 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
  125505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125506. * @param name defines the name of the mesh
  125507. * @param options defines the options used to create the mesh
  125508. * @param scene defines the hosting scene
  125509. * @returns the tiled ground mesh
  125510. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125511. */
  125512. static CreateTiledGround(name: string, options: {
  125513. xmin: number;
  125514. zmin: number;
  125515. xmax: number;
  125516. zmax: number;
  125517. subdivisions?: {
  125518. w: number;
  125519. h: number;
  125520. };
  125521. precision?: {
  125522. w: number;
  125523. h: number;
  125524. };
  125525. updatable?: boolean;
  125526. }, scene?: Nullable<Scene>): Mesh;
  125527. /**
  125528. * Creates a ground mesh from a height map
  125529. * * The parameter `url` sets the URL of the height map image resource.
  125530. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125531. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125532. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125533. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125534. * * 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.
  125535. * * 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).
  125536. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125538. * @param name defines the name of the mesh
  125539. * @param url defines the url to the height map
  125540. * @param options defines the options used to create the mesh
  125541. * @param scene defines the hosting scene
  125542. * @returns the ground mesh
  125543. * @see https://doc.babylonjs.com/babylon101/height_map
  125544. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125545. */
  125546. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125547. width?: number;
  125548. height?: number;
  125549. subdivisions?: number;
  125550. minHeight?: number;
  125551. maxHeight?: number;
  125552. colorFilter?: Color3;
  125553. alphaFilter?: number;
  125554. updatable?: boolean;
  125555. onReady?: (mesh: GroundMesh) => void;
  125556. }, scene?: Nullable<Scene>): GroundMesh;
  125557. }
  125558. }
  125559. declare module BABYLON {
  125560. /**
  125561. * Class containing static functions to help procedurally build meshes
  125562. */
  125563. export class TorusBuilder {
  125564. /**
  125565. * Creates a torus mesh
  125566. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125567. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125568. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125572. * @param name defines the name of the mesh
  125573. * @param options defines the options used to create the mesh
  125574. * @param scene defines the hosting scene
  125575. * @returns the torus mesh
  125576. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125577. */
  125578. static CreateTorus(name: string, options: {
  125579. diameter?: number;
  125580. thickness?: number;
  125581. tessellation?: number;
  125582. updatable?: boolean;
  125583. sideOrientation?: number;
  125584. frontUVs?: Vector4;
  125585. backUVs?: Vector4;
  125586. }, scene: any): Mesh;
  125587. }
  125588. }
  125589. declare module BABYLON {
  125590. /**
  125591. * Class containing static functions to help procedurally build meshes
  125592. */
  125593. export class CylinderBuilder {
  125594. /**
  125595. * Creates a cylinder or a cone mesh
  125596. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125597. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125598. * * 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.
  125599. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125600. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125601. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125602. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125603. * * 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).
  125604. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125605. * * 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).
  125606. * * 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
  125607. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125608. * * 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
  125609. * * 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.
  125610. * * If `enclose` is false, a ring surface is one element.
  125611. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125612. * * 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
  125613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125616. * @param name defines the name of the mesh
  125617. * @param options defines the options used to create the mesh
  125618. * @param scene defines the hosting scene
  125619. * @returns the cylinder mesh
  125620. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125621. */
  125622. static CreateCylinder(name: string, options: {
  125623. height?: number;
  125624. diameterTop?: number;
  125625. diameterBottom?: number;
  125626. diameter?: number;
  125627. tessellation?: number;
  125628. subdivisions?: number;
  125629. arc?: number;
  125630. faceColors?: Color4[];
  125631. faceUV?: Vector4[];
  125632. updatable?: boolean;
  125633. hasRings?: boolean;
  125634. enclose?: boolean;
  125635. cap?: number;
  125636. sideOrientation?: number;
  125637. frontUVs?: Vector4;
  125638. backUVs?: Vector4;
  125639. }, scene: any): Mesh;
  125640. }
  125641. }
  125642. declare module BABYLON {
  125643. /**
  125644. * States of the webXR experience
  125645. */
  125646. export enum WebXRState {
  125647. /**
  125648. * Transitioning to being in XR mode
  125649. */
  125650. ENTERING_XR = 0,
  125651. /**
  125652. * Transitioning to non XR mode
  125653. */
  125654. EXITING_XR = 1,
  125655. /**
  125656. * In XR mode and presenting
  125657. */
  125658. IN_XR = 2,
  125659. /**
  125660. * Not entered XR mode
  125661. */
  125662. NOT_IN_XR = 3
  125663. }
  125664. /**
  125665. * Abstraction of the XR render target
  125666. */
  125667. export interface WebXRRenderTarget extends IDisposable {
  125668. /**
  125669. * xrpresent context of the canvas which can be used to display/mirror xr content
  125670. */
  125671. canvasContext: WebGLRenderingContext;
  125672. /**
  125673. * xr layer for the canvas
  125674. */
  125675. xrLayer: Nullable<XRWebGLLayer>;
  125676. /**
  125677. * Initializes the xr layer for the session
  125678. * @param xrSession xr session
  125679. * @returns a promise that will resolve once the XR Layer has been created
  125680. */
  125681. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125682. }
  125683. }
  125684. declare module BABYLON {
  125685. /**
  125686. * COnfiguration object for WebXR output canvas
  125687. */
  125688. export class WebXRManagedOutputCanvasOptions {
  125689. /**
  125690. * An optional canvas in case you wish to create it yourself and provide it here.
  125691. * If not provided, a new canvas will be created
  125692. */
  125693. canvasElement?: HTMLCanvasElement;
  125694. /**
  125695. * Options for this XR Layer output
  125696. */
  125697. canvasOptions?: XRWebGLLayerOptions;
  125698. /**
  125699. * CSS styling for a newly created canvas (if not provided)
  125700. */
  125701. newCanvasCssStyle?: string;
  125702. /**
  125703. * Get the default values of the configuration object
  125704. * @returns default values of this configuration object
  125705. */
  125706. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125707. }
  125708. /**
  125709. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125710. */
  125711. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125712. private _options;
  125713. private _canvas;
  125714. private _engine;
  125715. private _originalCanvasSize;
  125716. /**
  125717. * Rendering context of the canvas which can be used to display/mirror xr content
  125718. */
  125719. canvasContext: WebGLRenderingContext;
  125720. /**
  125721. * xr layer for the canvas
  125722. */
  125723. xrLayer: Nullable<XRWebGLLayer>;
  125724. /**
  125725. * Obseervers registered here will be triggered when the xr layer was initialized
  125726. */
  125727. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125728. /**
  125729. * Initializes the canvas to be added/removed upon entering/exiting xr
  125730. * @param _xrSessionManager The XR Session manager
  125731. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125732. */
  125733. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125734. /**
  125735. * Disposes of the object
  125736. */
  125737. dispose(): void;
  125738. /**
  125739. * Initializes the xr layer for the session
  125740. * @param xrSession xr session
  125741. * @returns a promise that will resolve once the XR Layer has been created
  125742. */
  125743. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125744. private _addCanvas;
  125745. private _removeCanvas;
  125746. private _setCanvasSize;
  125747. private _setManagedOutputCanvas;
  125748. }
  125749. }
  125750. declare module BABYLON {
  125751. /**
  125752. * Manages an XRSession to work with Babylon's engine
  125753. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125754. */
  125755. export class WebXRSessionManager implements IDisposable {
  125756. /** The scene which the session should be created for */
  125757. scene: Scene;
  125758. private _referenceSpace;
  125759. private _rttProvider;
  125760. private _sessionEnded;
  125761. private _xrNavigator;
  125762. private baseLayer;
  125763. /**
  125764. * The base reference space from which the session started. good if you want to reset your
  125765. * reference space
  125766. */
  125767. baseReferenceSpace: XRReferenceSpace;
  125768. /**
  125769. * Current XR frame
  125770. */
  125771. currentFrame: Nullable<XRFrame>;
  125772. /** WebXR timestamp updated every frame */
  125773. currentTimestamp: number;
  125774. /**
  125775. * Used just in case of a failure to initialize an immersive session.
  125776. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125777. */
  125778. defaultHeightCompensation: number;
  125779. /**
  125780. * Fires every time a new xrFrame arrives which can be used to update the camera
  125781. */
  125782. onXRFrameObservable: Observable<XRFrame>;
  125783. /**
  125784. * Fires when the reference space changed
  125785. */
  125786. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125787. /**
  125788. * Fires when the xr session is ended either by the device or manually done
  125789. */
  125790. onXRSessionEnded: Observable<any>;
  125791. /**
  125792. * Fires when the xr session is ended either by the device or manually done
  125793. */
  125794. onXRSessionInit: Observable<XRSession>;
  125795. /**
  125796. * Underlying xr session
  125797. */
  125798. session: XRSession;
  125799. /**
  125800. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125801. * or get the offset the player is currently at.
  125802. */
  125803. viewerReferenceSpace: XRReferenceSpace;
  125804. /**
  125805. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125806. * @param scene The scene which the session should be created for
  125807. */
  125808. constructor(
  125809. /** The scene which the session should be created for */
  125810. scene: Scene);
  125811. /**
  125812. * The current reference space used in this session. This reference space can constantly change!
  125813. * It is mainly used to offset the camera's position.
  125814. */
  125815. get referenceSpace(): XRReferenceSpace;
  125816. /**
  125817. * Set a new reference space and triggers the observable
  125818. */
  125819. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125820. /**
  125821. * Disposes of the session manager
  125822. */
  125823. dispose(): void;
  125824. /**
  125825. * Stops the xrSession and restores the render loop
  125826. * @returns Promise which resolves after it exits XR
  125827. */
  125828. exitXRAsync(): Promise<void>;
  125829. /**
  125830. * Gets the correct render target texture to be rendered this frame for this eye
  125831. * @param eye the eye for which to get the render target
  125832. * @returns the render target for the specified eye
  125833. */
  125834. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125835. /**
  125836. * Creates a WebXRRenderTarget object for the XR session
  125837. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125838. * @param options optional options to provide when creating a new render target
  125839. * @returns a WebXR render target to which the session can render
  125840. */
  125841. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125842. /**
  125843. * Initializes the manager
  125844. * After initialization enterXR can be called to start an XR session
  125845. * @returns Promise which resolves after it is initialized
  125846. */
  125847. initializeAsync(): Promise<void>;
  125848. /**
  125849. * Initializes an xr session
  125850. * @param xrSessionMode mode to initialize
  125851. * @param xrSessionInit defines optional and required values to pass to the session builder
  125852. * @returns a promise which will resolve once the session has been initialized
  125853. */
  125854. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125855. /**
  125856. * Checks if a session would be supported for the creation options specified
  125857. * @param sessionMode session mode to check if supported eg. immersive-vr
  125858. * @returns A Promise that resolves to true if supported and false if not
  125859. */
  125860. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125861. /**
  125862. * Resets the reference space to the one started the session
  125863. */
  125864. resetReferenceSpace(): void;
  125865. /**
  125866. * Starts rendering to the xr layer
  125867. */
  125868. runXRRenderLoop(): void;
  125869. /**
  125870. * Sets the reference space on the xr session
  125871. * @param referenceSpaceType space to set
  125872. * @returns a promise that will resolve once the reference space has been set
  125873. */
  125874. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125875. /**
  125876. * Updates the render state of the session
  125877. * @param state state to set
  125878. * @returns a promise that resolves once the render state has been updated
  125879. */
  125880. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125881. /**
  125882. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125883. * @param sessionMode defines the session to test
  125884. * @returns a promise with boolean as final value
  125885. */
  125886. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125887. private _createRenderTargetTexture;
  125888. }
  125889. }
  125890. declare module BABYLON {
  125891. /**
  125892. * WebXR Camera which holds the views for the xrSession
  125893. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125894. */
  125895. export class WebXRCamera extends FreeCamera {
  125896. private _xrSessionManager;
  125897. private _firstFrame;
  125898. private _referenceQuaternion;
  125899. private _referencedPosition;
  125900. private _xrInvPositionCache;
  125901. private _xrInvQuaternionCache;
  125902. /**
  125903. * Observable raised before camera teleportation
  125904. */
  125905. onBeforeCameraTeleport: Observable<Vector3>;
  125906. /**
  125907. * Observable raised after camera teleportation
  125908. */
  125909. onAfterCameraTeleport: Observable<Vector3>;
  125910. /**
  125911. * Should position compensation execute on first frame.
  125912. * This is used when copying the position from a native (non XR) camera
  125913. */
  125914. compensateOnFirstFrame: boolean;
  125915. /**
  125916. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125917. * @param name the name of the camera
  125918. * @param scene the scene to add the camera to
  125919. * @param _xrSessionManager a constructed xr session manager
  125920. */
  125921. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125922. /**
  125923. * Return the user's height, unrelated to the current ground.
  125924. * This will be the y position of this camera, when ground level is 0.
  125925. */
  125926. get realWorldHeight(): number;
  125927. /** @hidden */
  125928. _updateForDualEyeDebugging(): void;
  125929. /**
  125930. * Sets this camera's transformation based on a non-vr camera
  125931. * @param otherCamera the non-vr camera to copy the transformation from
  125932. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125933. */
  125934. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125935. /**
  125936. * Gets the current instance class name ("WebXRCamera").
  125937. * @returns the class name
  125938. */
  125939. getClassName(): string;
  125940. private _rotate180;
  125941. private _updateFromXRSession;
  125942. private _updateNumberOfRigCameras;
  125943. private _updateReferenceSpace;
  125944. private _updateReferenceSpaceOffset;
  125945. }
  125946. }
  125947. declare module BABYLON {
  125948. /**
  125949. * Defining the interface required for a (webxr) feature
  125950. */
  125951. export interface IWebXRFeature extends IDisposable {
  125952. /**
  125953. * Is this feature attached
  125954. */
  125955. attached: boolean;
  125956. /**
  125957. * Should auto-attach be disabled?
  125958. */
  125959. disableAutoAttach: boolean;
  125960. /**
  125961. * Attach the feature to the session
  125962. * Will usually be called by the features manager
  125963. *
  125964. * @param force should attachment be forced (even when already attached)
  125965. * @returns true if successful.
  125966. */
  125967. attach(force?: boolean): boolean;
  125968. /**
  125969. * Detach the feature from the session
  125970. * Will usually be called by the features manager
  125971. *
  125972. * @returns true if successful.
  125973. */
  125974. detach(): boolean;
  125975. /**
  125976. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125977. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125978. *
  125979. * @returns whether or not the feature is compatible in this environment
  125980. */
  125981. isCompatible(): boolean;
  125982. /**
  125983. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125984. */
  125985. xrNativeFeatureName?: string;
  125986. }
  125987. /**
  125988. * A list of the currently available features without referencing them
  125989. */
  125990. export class WebXRFeatureName {
  125991. /**
  125992. * The name of the anchor system feature
  125993. */
  125994. static ANCHOR_SYSTEM: string;
  125995. /**
  125996. * The name of the background remover feature
  125997. */
  125998. static BACKGROUND_REMOVER: string;
  125999. /**
  126000. * The name of the hit test feature
  126001. */
  126002. static HIT_TEST: string;
  126003. /**
  126004. * physics impostors for xr controllers feature
  126005. */
  126006. static PHYSICS_CONTROLLERS: string;
  126007. /**
  126008. * The name of the plane detection feature
  126009. */
  126010. static PLANE_DETECTION: string;
  126011. /**
  126012. * The name of the pointer selection feature
  126013. */
  126014. static POINTER_SELECTION: string;
  126015. /**
  126016. * The name of the teleportation feature
  126017. */
  126018. static TELEPORTATION: string;
  126019. }
  126020. /**
  126021. * Defining the constructor of a feature. Used to register the modules.
  126022. */
  126023. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126024. /**
  126025. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126026. * It is mainly used in AR sessions.
  126027. *
  126028. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126029. */
  126030. export class WebXRFeaturesManager implements IDisposable {
  126031. private _xrSessionManager;
  126032. private static readonly _AvailableFeatures;
  126033. private _features;
  126034. /**
  126035. * constructs a new features manages.
  126036. *
  126037. * @param _xrSessionManager an instance of WebXRSessionManager
  126038. */
  126039. constructor(_xrSessionManager: WebXRSessionManager);
  126040. /**
  126041. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126042. * Mainly used internally.
  126043. *
  126044. * @param featureName the name of the feature to register
  126045. * @param constructorFunction the function used to construct the module
  126046. * @param version the (babylon) version of the module
  126047. * @param stable is that a stable version of this module
  126048. */
  126049. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126050. /**
  126051. * Returns a constructor of a specific feature.
  126052. *
  126053. * @param featureName the name of the feature to construct
  126054. * @param version the version of the feature to load
  126055. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126056. * @param options optional options provided to the module.
  126057. * @returns a function that, when called, will return a new instance of this feature
  126058. */
  126059. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126060. /**
  126061. * Can be used to return the list of features currently registered
  126062. *
  126063. * @returns an Array of available features
  126064. */
  126065. static GetAvailableFeatures(): string[];
  126066. /**
  126067. * Gets the versions available for a specific feature
  126068. * @param featureName the name of the feature
  126069. * @returns an array with the available versions
  126070. */
  126071. static GetAvailableVersions(featureName: string): string[];
  126072. /**
  126073. * Return the latest unstable version of this feature
  126074. * @param featureName the name of the feature to search
  126075. * @returns the version number. if not found will return -1
  126076. */
  126077. static GetLatestVersionOfFeature(featureName: string): number;
  126078. /**
  126079. * Return the latest stable version of this feature
  126080. * @param featureName the name of the feature to search
  126081. * @returns the version number. if not found will return -1
  126082. */
  126083. static GetStableVersionOfFeature(featureName: string): number;
  126084. /**
  126085. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126086. * Can be used during a session to start a feature
  126087. * @param featureName the name of feature to attach
  126088. */
  126089. attachFeature(featureName: string): void;
  126090. /**
  126091. * Can be used inside a session or when the session ends to detach a specific feature
  126092. * @param featureName the name of the feature to detach
  126093. */
  126094. detachFeature(featureName: string): void;
  126095. /**
  126096. * Used to disable an already-enabled feature
  126097. * The feature will be disposed and will be recreated once enabled.
  126098. * @param featureName the feature to disable
  126099. * @returns true if disable was successful
  126100. */
  126101. disableFeature(featureName: string | {
  126102. Name: string;
  126103. }): boolean;
  126104. /**
  126105. * dispose this features manager
  126106. */
  126107. dispose(): void;
  126108. /**
  126109. * 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.
  126110. * 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.
  126111. *
  126112. * @param featureName the name of the feature to load or the class of the feature
  126113. * @param version optional version to load. if not provided the latest version will be enabled
  126114. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126115. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126116. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126117. * @returns a new constructed feature or throws an error if feature not found.
  126118. */
  126119. enableFeature(featureName: string | {
  126120. Name: string;
  126121. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126122. /**
  126123. * get the implementation of an enabled feature.
  126124. * @param featureName the name of the feature to load
  126125. * @returns the feature class, if found
  126126. */
  126127. getEnabledFeature(featureName: string): IWebXRFeature;
  126128. /**
  126129. * Get the list of enabled features
  126130. * @returns an array of enabled features
  126131. */
  126132. getEnabledFeatures(): string[];
  126133. /**
  126134. * This function will exten the session creation configuration object with enabled features.
  126135. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126136. * according to the defined "required" variable, provided during enableFeature call
  126137. * @param xrSessionInit the xr Session init object to extend
  126138. *
  126139. * @returns an extended XRSessionInit object
  126140. */
  126141. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126142. }
  126143. }
  126144. declare module BABYLON {
  126145. /**
  126146. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126147. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126148. */
  126149. export class WebXRExperienceHelper implements IDisposable {
  126150. private scene;
  126151. private _nonVRCamera;
  126152. private _originalSceneAutoClear;
  126153. private _supported;
  126154. /**
  126155. * Camera used to render xr content
  126156. */
  126157. camera: WebXRCamera;
  126158. /** A features manager for this xr session */
  126159. featuresManager: WebXRFeaturesManager;
  126160. /**
  126161. * Observers registered here will be triggered after the camera's initial transformation is set
  126162. * This can be used to set a different ground level or an extra rotation.
  126163. *
  126164. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126165. * to the position set after this observable is done executing.
  126166. */
  126167. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126168. /**
  126169. * Fires when the state of the experience helper has changed
  126170. */
  126171. onStateChangedObservable: Observable<WebXRState>;
  126172. /** Session manager used to keep track of xr session */
  126173. sessionManager: WebXRSessionManager;
  126174. /**
  126175. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126176. */
  126177. state: WebXRState;
  126178. /**
  126179. * Creates a WebXRExperienceHelper
  126180. * @param scene The scene the helper should be created in
  126181. */
  126182. private constructor();
  126183. /**
  126184. * Creates the experience helper
  126185. * @param scene the scene to attach the experience helper to
  126186. * @returns a promise for the experience helper
  126187. */
  126188. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126189. /**
  126190. * Disposes of the experience helper
  126191. */
  126192. dispose(): void;
  126193. /**
  126194. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126195. * @param sessionMode options for the XR session
  126196. * @param referenceSpaceType frame of reference of the XR session
  126197. * @param renderTarget the output canvas that will be used to enter XR mode
  126198. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126199. * @returns promise that resolves after xr mode has entered
  126200. */
  126201. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126202. /**
  126203. * Exits XR mode and returns the scene to its original state
  126204. * @returns promise that resolves after xr mode has exited
  126205. */
  126206. exitXRAsync(): Promise<void>;
  126207. private _nonXRToXRCamera;
  126208. private _setState;
  126209. }
  126210. }
  126211. declare module BABYLON {
  126212. /**
  126213. * X-Y values for axes in WebXR
  126214. */
  126215. export interface IWebXRMotionControllerAxesValue {
  126216. /**
  126217. * The value of the x axis
  126218. */
  126219. x: number;
  126220. /**
  126221. * The value of the y-axis
  126222. */
  126223. y: number;
  126224. }
  126225. /**
  126226. * changed / previous values for the values of this component
  126227. */
  126228. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126229. /**
  126230. * current (this frame) value
  126231. */
  126232. current: T;
  126233. /**
  126234. * previous (last change) value
  126235. */
  126236. previous: T;
  126237. }
  126238. /**
  126239. * Represents changes in the component between current frame and last values recorded
  126240. */
  126241. export interface IWebXRMotionControllerComponentChanges {
  126242. /**
  126243. * will be populated with previous and current values if axes changed
  126244. */
  126245. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126246. /**
  126247. * will be populated with previous and current values if pressed changed
  126248. */
  126249. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126250. /**
  126251. * will be populated with previous and current values if touched changed
  126252. */
  126253. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126254. /**
  126255. * will be populated with previous and current values if value changed
  126256. */
  126257. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126258. }
  126259. /**
  126260. * This class represents a single component (for example button or thumbstick) of a motion controller
  126261. */
  126262. export class WebXRControllerComponent implements IDisposable {
  126263. /**
  126264. * the id of this component
  126265. */
  126266. id: string;
  126267. /**
  126268. * the type of the component
  126269. */
  126270. type: MotionControllerComponentType;
  126271. private _buttonIndex;
  126272. private _axesIndices;
  126273. private _axes;
  126274. private _changes;
  126275. private _currentValue;
  126276. private _hasChanges;
  126277. private _pressed;
  126278. private _touched;
  126279. /**
  126280. * button component type
  126281. */
  126282. static BUTTON_TYPE: MotionControllerComponentType;
  126283. /**
  126284. * squeeze component type
  126285. */
  126286. static SQUEEZE_TYPE: MotionControllerComponentType;
  126287. /**
  126288. * Thumbstick component type
  126289. */
  126290. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126291. /**
  126292. * Touchpad component type
  126293. */
  126294. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126295. /**
  126296. * trigger component type
  126297. */
  126298. static TRIGGER_TYPE: MotionControllerComponentType;
  126299. /**
  126300. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126301. * the axes data changes
  126302. */
  126303. onAxisValueChangedObservable: Observable<{
  126304. x: number;
  126305. y: number;
  126306. }>;
  126307. /**
  126308. * Observers registered here will be triggered when the state of a button changes
  126309. * State change is either pressed / touched / value
  126310. */
  126311. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126312. /**
  126313. * Creates a new component for a motion controller.
  126314. * It is created by the motion controller itself
  126315. *
  126316. * @param id the id of this component
  126317. * @param type the type of the component
  126318. * @param _buttonIndex index in the buttons array of the gamepad
  126319. * @param _axesIndices indices of the values in the axes array of the gamepad
  126320. */
  126321. constructor(
  126322. /**
  126323. * the id of this component
  126324. */
  126325. id: string,
  126326. /**
  126327. * the type of the component
  126328. */
  126329. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126330. /**
  126331. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126332. */
  126333. get axes(): IWebXRMotionControllerAxesValue;
  126334. /**
  126335. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126336. */
  126337. get changes(): IWebXRMotionControllerComponentChanges;
  126338. /**
  126339. * Return whether or not the component changed the last frame
  126340. */
  126341. get hasChanges(): boolean;
  126342. /**
  126343. * is the button currently pressed
  126344. */
  126345. get pressed(): boolean;
  126346. /**
  126347. * is the button currently touched
  126348. */
  126349. get touched(): boolean;
  126350. /**
  126351. * Get the current value of this component
  126352. */
  126353. get value(): number;
  126354. /**
  126355. * Dispose this component
  126356. */
  126357. dispose(): void;
  126358. /**
  126359. * Are there axes correlating to this component
  126360. * @return true is axes data is available
  126361. */
  126362. isAxes(): boolean;
  126363. /**
  126364. * Is this component a button (hence - pressable)
  126365. * @returns true if can be pressed
  126366. */
  126367. isButton(): boolean;
  126368. /**
  126369. * update this component using the gamepad object it is in. Called on every frame
  126370. * @param nativeController the native gamepad controller object
  126371. */
  126372. update(nativeController: IMinimalMotionControllerObject): void;
  126373. }
  126374. }
  126375. declare module BABYLON {
  126376. /**
  126377. * Interface used to represent data loading progression
  126378. */
  126379. export interface ISceneLoaderProgressEvent {
  126380. /**
  126381. * Defines if data length to load can be evaluated
  126382. */
  126383. readonly lengthComputable: boolean;
  126384. /**
  126385. * Defines the loaded data length
  126386. */
  126387. readonly loaded: number;
  126388. /**
  126389. * Defines the data length to load
  126390. */
  126391. readonly total: number;
  126392. }
  126393. /**
  126394. * Interface used by SceneLoader plugins to define supported file extensions
  126395. */
  126396. export interface ISceneLoaderPluginExtensions {
  126397. /**
  126398. * Defines the list of supported extensions
  126399. */
  126400. [extension: string]: {
  126401. isBinary: boolean;
  126402. };
  126403. }
  126404. /**
  126405. * Interface used by SceneLoader plugin factory
  126406. */
  126407. export interface ISceneLoaderPluginFactory {
  126408. /**
  126409. * Defines the name of the factory
  126410. */
  126411. name: string;
  126412. /**
  126413. * Function called to create a new plugin
  126414. * @return the new plugin
  126415. */
  126416. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126417. /**
  126418. * The callback that returns true if the data can be directly loaded.
  126419. * @param data string containing the file data
  126420. * @returns if the data can be loaded directly
  126421. */
  126422. canDirectLoad?(data: string): boolean;
  126423. }
  126424. /**
  126425. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126426. */
  126427. export interface ISceneLoaderPluginBase {
  126428. /**
  126429. * The friendly name of this plugin.
  126430. */
  126431. name: string;
  126432. /**
  126433. * The file extensions supported by this plugin.
  126434. */
  126435. extensions: string | ISceneLoaderPluginExtensions;
  126436. /**
  126437. * The callback called when loading from a url.
  126438. * @param scene scene loading this url
  126439. * @param url url to load
  126440. * @param onSuccess callback called when the file successfully loads
  126441. * @param onProgress callback called while file is loading (if the server supports this mode)
  126442. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126443. * @param onError callback called when the file fails to load
  126444. * @returns a file request object
  126445. */
  126446. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126447. /**
  126448. * The callback called when loading from a file object.
  126449. * @param scene scene loading this file
  126450. * @param file defines the file to load
  126451. * @param onSuccess defines the callback to call when data is loaded
  126452. * @param onProgress defines the callback to call during loading process
  126453. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126454. * @param onError defines the callback to call when an error occurs
  126455. * @returns a file request object
  126456. */
  126457. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126458. /**
  126459. * The callback that returns true if the data can be directly loaded.
  126460. * @param data string containing the file data
  126461. * @returns if the data can be loaded directly
  126462. */
  126463. canDirectLoad?(data: string): boolean;
  126464. /**
  126465. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126466. * @param scene scene loading this data
  126467. * @param data string containing the data
  126468. * @returns data to pass to the plugin
  126469. */
  126470. directLoad?(scene: Scene, data: string): any;
  126471. /**
  126472. * The callback that allows custom handling of the root url based on the response url.
  126473. * @param rootUrl the original root url
  126474. * @param responseURL the response url if available
  126475. * @returns the new root url
  126476. */
  126477. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126478. }
  126479. /**
  126480. * Interface used to define a SceneLoader plugin
  126481. */
  126482. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126483. /**
  126484. * Import meshes into a scene.
  126485. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126486. * @param scene The scene to import into
  126487. * @param data The data to import
  126488. * @param rootUrl The root url for scene and resources
  126489. * @param meshes The meshes array to import into
  126490. * @param particleSystems The particle systems array to import into
  126491. * @param skeletons The skeletons array to import into
  126492. * @param onError The callback when import fails
  126493. * @returns True if successful or false otherwise
  126494. */
  126495. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126496. /**
  126497. * Load into a scene.
  126498. * @param scene The scene to load into
  126499. * @param data The data to import
  126500. * @param rootUrl The root url for scene and resources
  126501. * @param onError The callback when import fails
  126502. * @returns True if successful or false otherwise
  126503. */
  126504. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126505. /**
  126506. * Load into an asset container.
  126507. * @param scene The scene to load into
  126508. * @param data The data to import
  126509. * @param rootUrl The root url for scene and resources
  126510. * @param onError The callback when import fails
  126511. * @returns The loaded asset container
  126512. */
  126513. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126514. }
  126515. /**
  126516. * Interface used to define an async SceneLoader plugin
  126517. */
  126518. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126519. /**
  126520. * Import meshes into a scene.
  126521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126522. * @param scene The scene to import into
  126523. * @param data The data to import
  126524. * @param rootUrl The root url for scene and resources
  126525. * @param onProgress The callback when the load progresses
  126526. * @param fileName Defines the name of the file to load
  126527. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126528. */
  126529. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126530. meshes: AbstractMesh[];
  126531. particleSystems: IParticleSystem[];
  126532. skeletons: Skeleton[];
  126533. animationGroups: AnimationGroup[];
  126534. }>;
  126535. /**
  126536. * Load into a scene.
  126537. * @param scene The scene to load into
  126538. * @param data The data to import
  126539. * @param rootUrl The root url for scene and resources
  126540. * @param onProgress The callback when the load progresses
  126541. * @param fileName Defines the name of the file to load
  126542. * @returns Nothing
  126543. */
  126544. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126545. /**
  126546. * Load into an asset container.
  126547. * @param scene The scene to load into
  126548. * @param data The data to import
  126549. * @param rootUrl The root url for scene and resources
  126550. * @param onProgress The callback when the load progresses
  126551. * @param fileName Defines the name of the file to load
  126552. * @returns The loaded asset container
  126553. */
  126554. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126555. }
  126556. /**
  126557. * Mode that determines how to handle old animation groups before loading new ones.
  126558. */
  126559. export enum SceneLoaderAnimationGroupLoadingMode {
  126560. /**
  126561. * Reset all old animations to initial state then dispose them.
  126562. */
  126563. Clean = 0,
  126564. /**
  126565. * Stop all old animations.
  126566. */
  126567. Stop = 1,
  126568. /**
  126569. * Restart old animations from first frame.
  126570. */
  126571. Sync = 2,
  126572. /**
  126573. * Old animations remains untouched.
  126574. */
  126575. NoSync = 3
  126576. }
  126577. /**
  126578. * Defines a plugin registered by the SceneLoader
  126579. */
  126580. interface IRegisteredPlugin {
  126581. /**
  126582. * Defines the plugin to use
  126583. */
  126584. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126585. /**
  126586. * Defines if the plugin supports binary data
  126587. */
  126588. isBinary: boolean;
  126589. }
  126590. /**
  126591. * Class used to load scene from various file formats using registered plugins
  126592. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126593. */
  126594. export class SceneLoader {
  126595. /**
  126596. * No logging while loading
  126597. */
  126598. static readonly NO_LOGGING: number;
  126599. /**
  126600. * Minimal logging while loading
  126601. */
  126602. static readonly MINIMAL_LOGGING: number;
  126603. /**
  126604. * Summary logging while loading
  126605. */
  126606. static readonly SUMMARY_LOGGING: number;
  126607. /**
  126608. * Detailled logging while loading
  126609. */
  126610. static readonly DETAILED_LOGGING: number;
  126611. /**
  126612. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126613. */
  126614. static get ForceFullSceneLoadingForIncremental(): boolean;
  126615. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126616. /**
  126617. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126618. */
  126619. static get ShowLoadingScreen(): boolean;
  126620. static set ShowLoadingScreen(value: boolean);
  126621. /**
  126622. * Defines the current logging level (while loading the scene)
  126623. * @ignorenaming
  126624. */
  126625. static get loggingLevel(): number;
  126626. static set loggingLevel(value: number);
  126627. /**
  126628. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126629. */
  126630. static get CleanBoneMatrixWeights(): boolean;
  126631. static set CleanBoneMatrixWeights(value: boolean);
  126632. /**
  126633. * Event raised when a plugin is used to load a scene
  126634. */
  126635. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126636. private static _registeredPlugins;
  126637. private static _showingLoadingScreen;
  126638. /**
  126639. * Gets the default plugin (used to load Babylon files)
  126640. * @returns the .babylon plugin
  126641. */
  126642. static GetDefaultPlugin(): IRegisteredPlugin;
  126643. private static _GetPluginForExtension;
  126644. private static _GetPluginForDirectLoad;
  126645. private static _GetPluginForFilename;
  126646. private static _GetDirectLoad;
  126647. private static _LoadData;
  126648. private static _GetFileInfo;
  126649. /**
  126650. * Gets a plugin that can load the given extension
  126651. * @param extension defines the extension to load
  126652. * @returns a plugin or null if none works
  126653. */
  126654. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126655. /**
  126656. * Gets a boolean indicating that the given extension can be loaded
  126657. * @param extension defines the extension to load
  126658. * @returns true if the extension is supported
  126659. */
  126660. static IsPluginForExtensionAvailable(extension: string): boolean;
  126661. /**
  126662. * Adds a new plugin to the list of registered plugins
  126663. * @param plugin defines the plugin to add
  126664. */
  126665. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126666. /**
  126667. * Import meshes into a scene
  126668. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126669. * @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)
  126670. * @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)
  126671. * @param scene the instance of BABYLON.Scene to append to
  126672. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126673. * @param onProgress a callback with a progress event for each file being loaded
  126674. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126675. * @param pluginExtension the extension used to determine the plugin
  126676. * @returns The loaded plugin
  126677. */
  126678. 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>;
  126679. /**
  126680. * Import meshes into a scene
  126681. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126682. * @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)
  126683. * @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)
  126684. * @param scene the instance of BABYLON.Scene to append to
  126685. * @param onProgress a callback with a progress event for each file being loaded
  126686. * @param pluginExtension the extension used to determine the plugin
  126687. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126688. */
  126689. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126690. meshes: AbstractMesh[];
  126691. particleSystems: IParticleSystem[];
  126692. skeletons: Skeleton[];
  126693. animationGroups: AnimationGroup[];
  126694. }>;
  126695. /**
  126696. * Load a scene
  126697. * @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)
  126698. * @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)
  126699. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126700. * @param onSuccess a callback with the scene when import succeeds
  126701. * @param onProgress a callback with a progress event for each file being loaded
  126702. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126703. * @param pluginExtension the extension used to determine the plugin
  126704. * @returns The loaded plugin
  126705. */
  126706. 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>;
  126707. /**
  126708. * Load a scene
  126709. * @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)
  126710. * @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)
  126711. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126712. * @param onProgress a callback with a progress event for each file being loaded
  126713. * @param pluginExtension the extension used to determine the plugin
  126714. * @returns The loaded scene
  126715. */
  126716. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126717. /**
  126718. * Append a scene
  126719. * @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)
  126720. * @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)
  126721. * @param scene is the instance of BABYLON.Scene to append to
  126722. * @param onSuccess a callback with the scene when import succeeds
  126723. * @param onProgress a callback with a progress event for each file being loaded
  126724. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126725. * @param pluginExtension the extension used to determine the plugin
  126726. * @returns The loaded plugin
  126727. */
  126728. 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>;
  126729. /**
  126730. * Append a scene
  126731. * @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)
  126732. * @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)
  126733. * @param scene is the instance of BABYLON.Scene to append to
  126734. * @param onProgress a callback with a progress event for each file being loaded
  126735. * @param pluginExtension the extension used to determine the plugin
  126736. * @returns The given scene
  126737. */
  126738. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126739. /**
  126740. * Load a scene into an asset container
  126741. * @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)
  126742. * @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)
  126743. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126744. * @param onSuccess a callback with the scene when import succeeds
  126745. * @param onProgress a callback with a progress event for each file being loaded
  126746. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126747. * @param pluginExtension the extension used to determine the plugin
  126748. * @returns The loaded plugin
  126749. */
  126750. 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>;
  126751. /**
  126752. * Load a scene into an asset container
  126753. * @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)
  126754. * @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)
  126755. * @param scene is the instance of Scene to append to
  126756. * @param onProgress a callback with a progress event for each file being loaded
  126757. * @param pluginExtension the extension used to determine the plugin
  126758. * @returns The loaded asset container
  126759. */
  126760. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126761. /**
  126762. * Import animations from a file into a scene
  126763. * @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)
  126764. * @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)
  126765. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126766. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126767. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126768. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126769. * @param onSuccess a callback with the scene when import succeeds
  126770. * @param onProgress a callback with a progress event for each file being loaded
  126771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126772. * @param pluginExtension the extension used to determine the plugin
  126773. */
  126774. 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;
  126775. /**
  126776. * Import animations from a file into a scene
  126777. * @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)
  126778. * @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)
  126779. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126780. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126781. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126782. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126783. * @param onSuccess a callback with the scene when import succeeds
  126784. * @param onProgress a callback with a progress event for each file being loaded
  126785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126786. * @param pluginExtension the extension used to determine the plugin
  126787. * @returns the updated scene with imported animations
  126788. */
  126789. 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>;
  126790. }
  126791. }
  126792. declare module BABYLON {
  126793. /**
  126794. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126795. */
  126796. export type MotionControllerHandedness = "none" | "left" | "right";
  126797. /**
  126798. * The type of components available in motion controllers.
  126799. * This is not the name of the component.
  126800. */
  126801. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126802. /**
  126803. * The state of a controller component
  126804. */
  126805. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126806. /**
  126807. * The schema of motion controller layout.
  126808. * No object will be initialized using this interface
  126809. * This is used just to define the profile.
  126810. */
  126811. export interface IMotionControllerLayout {
  126812. /**
  126813. * Path to load the assets. Usually relative to the base path
  126814. */
  126815. assetPath: string;
  126816. /**
  126817. * Available components (unsorted)
  126818. */
  126819. components: {
  126820. /**
  126821. * A map of component Ids
  126822. */
  126823. [componentId: string]: {
  126824. /**
  126825. * The type of input the component outputs
  126826. */
  126827. type: MotionControllerComponentType;
  126828. /**
  126829. * The indices of this component in the gamepad object
  126830. */
  126831. gamepadIndices: {
  126832. /**
  126833. * Index of button
  126834. */
  126835. button?: number;
  126836. /**
  126837. * If available, index of x-axis
  126838. */
  126839. xAxis?: number;
  126840. /**
  126841. * If available, index of y-axis
  126842. */
  126843. yAxis?: number;
  126844. };
  126845. /**
  126846. * The mesh's root node name
  126847. */
  126848. rootNodeName: string;
  126849. /**
  126850. * Animation definitions for this model
  126851. */
  126852. visualResponses: {
  126853. [stateKey: string]: {
  126854. /**
  126855. * What property will be animated
  126856. */
  126857. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126858. /**
  126859. * What states influence this visual response
  126860. */
  126861. states: MotionControllerComponentStateType[];
  126862. /**
  126863. * Type of animation - movement or visibility
  126864. */
  126865. valueNodeProperty: "transform" | "visibility";
  126866. /**
  126867. * Base node name to move. Its position will be calculated according to the min and max nodes
  126868. */
  126869. valueNodeName?: string;
  126870. /**
  126871. * Minimum movement node
  126872. */
  126873. minNodeName?: string;
  126874. /**
  126875. * Max movement node
  126876. */
  126877. maxNodeName?: string;
  126878. };
  126879. };
  126880. /**
  126881. * If touch enabled, what is the name of node to display user feedback
  126882. */
  126883. touchPointNodeName?: string;
  126884. };
  126885. };
  126886. /**
  126887. * Is it xr standard mapping or not
  126888. */
  126889. gamepadMapping: "" | "xr-standard";
  126890. /**
  126891. * Base root node of this entire model
  126892. */
  126893. rootNodeName: string;
  126894. /**
  126895. * Defines the main button component id
  126896. */
  126897. selectComponentId: string;
  126898. }
  126899. /**
  126900. * A definition for the layout map in the input profile
  126901. */
  126902. export interface IMotionControllerLayoutMap {
  126903. /**
  126904. * Layouts with handedness type as a key
  126905. */
  126906. [handedness: string]: IMotionControllerLayout;
  126907. }
  126908. /**
  126909. * The XR Input profile schema
  126910. * Profiles can be found here:
  126911. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126912. */
  126913. export interface IMotionControllerProfile {
  126914. /**
  126915. * fallback profiles for this profileId
  126916. */
  126917. fallbackProfileIds: string[];
  126918. /**
  126919. * The layout map, with handedness as key
  126920. */
  126921. layouts: IMotionControllerLayoutMap;
  126922. /**
  126923. * The id of this profile
  126924. * correlates to the profile(s) in the xrInput.profiles array
  126925. */
  126926. profileId: string;
  126927. }
  126928. /**
  126929. * A helper-interface for the 3 meshes needed for controller button animation
  126930. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126931. */
  126932. export interface IMotionControllerButtonMeshMap {
  126933. /**
  126934. * the mesh that defines the pressed value mesh position.
  126935. * This is used to find the max-position of this button
  126936. */
  126937. pressedMesh: AbstractMesh;
  126938. /**
  126939. * the mesh that defines the unpressed value mesh position.
  126940. * This is used to find the min (or initial) position of this button
  126941. */
  126942. unpressedMesh: AbstractMesh;
  126943. /**
  126944. * The mesh that will be changed when value changes
  126945. */
  126946. valueMesh: AbstractMesh;
  126947. }
  126948. /**
  126949. * A helper-interface for the 3 meshes needed for controller axis animation.
  126950. * This will be expanded when touchpad animations are fully supported
  126951. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126952. */
  126953. export interface IMotionControllerMeshMap {
  126954. /**
  126955. * the mesh that defines the maximum value mesh position.
  126956. */
  126957. maxMesh?: AbstractMesh;
  126958. /**
  126959. * the mesh that defines the minimum value mesh position.
  126960. */
  126961. minMesh?: AbstractMesh;
  126962. /**
  126963. * The mesh that will be changed when axis value changes
  126964. */
  126965. valueMesh: AbstractMesh;
  126966. }
  126967. /**
  126968. * The elements needed for change-detection of the gamepad objects in motion controllers
  126969. */
  126970. export interface IMinimalMotionControllerObject {
  126971. /**
  126972. * Available axes of this controller
  126973. */
  126974. axes: number[];
  126975. /**
  126976. * An array of available buttons
  126977. */
  126978. buttons: Array<{
  126979. /**
  126980. * Value of the button/trigger
  126981. */
  126982. value: number;
  126983. /**
  126984. * If the button/trigger is currently touched
  126985. */
  126986. touched: boolean;
  126987. /**
  126988. * If the button/trigger is currently pressed
  126989. */
  126990. pressed: boolean;
  126991. }>;
  126992. /**
  126993. * EXPERIMENTAL haptic support.
  126994. */
  126995. hapticActuators?: Array<{
  126996. pulse: (value: number, duration: number) => Promise<boolean>;
  126997. }>;
  126998. }
  126999. /**
  127000. * An Abstract Motion controller
  127001. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127002. * Each component has an observable to check for changes in value and state
  127003. */
  127004. export abstract class WebXRAbstractMotionController implements IDisposable {
  127005. protected scene: Scene;
  127006. protected layout: IMotionControllerLayout;
  127007. /**
  127008. * The gamepad object correlating to this controller
  127009. */
  127010. gamepadObject: IMinimalMotionControllerObject;
  127011. /**
  127012. * handedness (left/right/none) of this controller
  127013. */
  127014. handedness: MotionControllerHandedness;
  127015. private _initComponent;
  127016. private _modelReady;
  127017. /**
  127018. * A map of components (WebXRControllerComponent) in this motion controller
  127019. * Components have a ComponentType and can also have both button and axis definitions
  127020. */
  127021. readonly components: {
  127022. [id: string]: WebXRControllerComponent;
  127023. };
  127024. /**
  127025. * Disable the model's animation. Can be set at any time.
  127026. */
  127027. disableAnimation: boolean;
  127028. /**
  127029. * Observers registered here will be triggered when the model of this controller is done loading
  127030. */
  127031. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127032. /**
  127033. * The profile id of this motion controller
  127034. */
  127035. abstract profileId: string;
  127036. /**
  127037. * The root mesh of the model. It is null if the model was not yet initialized
  127038. */
  127039. rootMesh: Nullable<AbstractMesh>;
  127040. /**
  127041. * constructs a new abstract motion controller
  127042. * @param scene the scene to which the model of the controller will be added
  127043. * @param layout The profile layout to load
  127044. * @param gamepadObject The gamepad object correlating to this controller
  127045. * @param handedness handedness (left/right/none) of this controller
  127046. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127047. */
  127048. constructor(scene: Scene, layout: IMotionControllerLayout,
  127049. /**
  127050. * The gamepad object correlating to this controller
  127051. */
  127052. gamepadObject: IMinimalMotionControllerObject,
  127053. /**
  127054. * handedness (left/right/none) of this controller
  127055. */
  127056. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127057. /**
  127058. * Dispose this controller, the model mesh and all its components
  127059. */
  127060. dispose(): void;
  127061. /**
  127062. * Returns all components of specific type
  127063. * @param type the type to search for
  127064. * @return an array of components with this type
  127065. */
  127066. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127067. /**
  127068. * get a component based an its component id as defined in layout.components
  127069. * @param id the id of the component
  127070. * @returns the component correlates to the id or undefined if not found
  127071. */
  127072. getComponent(id: string): WebXRControllerComponent;
  127073. /**
  127074. * Get the list of components available in this motion controller
  127075. * @returns an array of strings correlating to available components
  127076. */
  127077. getComponentIds(): string[];
  127078. /**
  127079. * Get the first component of specific type
  127080. * @param type type of component to find
  127081. * @return a controller component or null if not found
  127082. */
  127083. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127084. /**
  127085. * Get the main (Select) component of this controller as defined in the layout
  127086. * @returns the main component of this controller
  127087. */
  127088. getMainComponent(): WebXRControllerComponent;
  127089. /**
  127090. * Loads the model correlating to this controller
  127091. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127092. * @returns A promise fulfilled with the result of the model loading
  127093. */
  127094. loadModel(): Promise<boolean>;
  127095. /**
  127096. * Update this model using the current XRFrame
  127097. * @param xrFrame the current xr frame to use and update the model
  127098. */
  127099. updateFromXRFrame(xrFrame: XRFrame): void;
  127100. /**
  127101. * Backwards compatibility due to a deeply-integrated typo
  127102. */
  127103. get handness(): XREye;
  127104. /**
  127105. * Pulse (vibrate) this controller
  127106. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127107. * Consecutive calls to this function will cancel the last pulse call
  127108. *
  127109. * @param value the strength of the pulse in 0.0...1.0 range
  127110. * @param duration Duration of the pulse in milliseconds
  127111. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127112. * @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
  127113. */
  127114. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127115. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127116. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127117. /**
  127118. * Moves the axis on the controller mesh based on its current state
  127119. * @param axis the index of the axis
  127120. * @param axisValue the value of the axis which determines the meshes new position
  127121. * @hidden
  127122. */
  127123. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127124. /**
  127125. * Update the model itself with the current frame data
  127126. * @param xrFrame the frame to use for updating the model mesh
  127127. */
  127128. protected updateModel(xrFrame: XRFrame): void;
  127129. /**
  127130. * Get the filename and path for this controller's model
  127131. * @returns a map of filename and path
  127132. */
  127133. protected abstract _getFilenameAndPath(): {
  127134. filename: string;
  127135. path: string;
  127136. };
  127137. /**
  127138. * This function is called before the mesh is loaded. It checks for loading constraints.
  127139. * For example, this function can check if the GLB loader is available
  127140. * If this function returns false, the generic controller will be loaded instead
  127141. * @returns Is the client ready to load the mesh
  127142. */
  127143. protected abstract _getModelLoadingConstraints(): boolean;
  127144. /**
  127145. * This function will be called after the model was successfully loaded and can be used
  127146. * for mesh transformations before it is available for the user
  127147. * @param meshes the loaded meshes
  127148. */
  127149. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127150. /**
  127151. * Set the root mesh for this controller. Important for the WebXR controller class
  127152. * @param meshes the loaded meshes
  127153. */
  127154. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127155. /**
  127156. * A function executed each frame that updates the mesh (if needed)
  127157. * @param xrFrame the current xrFrame
  127158. */
  127159. protected abstract _updateModel(xrFrame: XRFrame): void;
  127160. private _getGenericFilenameAndPath;
  127161. private _getGenericParentMesh;
  127162. }
  127163. }
  127164. declare module BABYLON {
  127165. /**
  127166. * A generic trigger-only motion controller for WebXR
  127167. */
  127168. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127169. /**
  127170. * Static version of the profile id of this controller
  127171. */
  127172. static ProfileId: string;
  127173. profileId: string;
  127174. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127175. protected _getFilenameAndPath(): {
  127176. filename: string;
  127177. path: string;
  127178. };
  127179. protected _getModelLoadingConstraints(): boolean;
  127180. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127181. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127182. protected _updateModel(): void;
  127183. }
  127184. }
  127185. declare module BABYLON {
  127186. /**
  127187. * Class containing static functions to help procedurally build meshes
  127188. */
  127189. export class SphereBuilder {
  127190. /**
  127191. * Creates a sphere mesh
  127192. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127193. * * 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`)
  127194. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127195. * * 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
  127196. * * 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)
  127197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127200. * @param name defines the name of the mesh
  127201. * @param options defines the options used to create the mesh
  127202. * @param scene defines the hosting scene
  127203. * @returns the sphere mesh
  127204. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127205. */
  127206. static CreateSphere(name: string, options: {
  127207. segments?: number;
  127208. diameter?: number;
  127209. diameterX?: number;
  127210. diameterY?: number;
  127211. diameterZ?: number;
  127212. arc?: number;
  127213. slice?: number;
  127214. sideOrientation?: number;
  127215. frontUVs?: Vector4;
  127216. backUVs?: Vector4;
  127217. updatable?: boolean;
  127218. }, scene?: Nullable<Scene>): Mesh;
  127219. }
  127220. }
  127221. declare module BABYLON {
  127222. /**
  127223. * A profiled motion controller has its profile loaded from an online repository.
  127224. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127225. */
  127226. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127227. private _repositoryUrl;
  127228. private _buttonMeshMapping;
  127229. private _touchDots;
  127230. /**
  127231. * The profile ID of this controller. Will be populated when the controller initializes.
  127232. */
  127233. profileId: string;
  127234. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127235. dispose(): void;
  127236. protected _getFilenameAndPath(): {
  127237. filename: string;
  127238. path: string;
  127239. };
  127240. protected _getModelLoadingConstraints(): boolean;
  127241. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127242. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127243. protected _updateModel(_xrFrame: XRFrame): void;
  127244. }
  127245. }
  127246. declare module BABYLON {
  127247. /**
  127248. * A construction function type to create a new controller based on an xrInput object
  127249. */
  127250. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127251. /**
  127252. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127253. *
  127254. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127255. * it should be replaced with auto-loaded controllers.
  127256. *
  127257. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127258. */
  127259. export class WebXRMotionControllerManager {
  127260. private static _AvailableControllers;
  127261. private static _Fallbacks;
  127262. private static _ProfileLoadingPromises;
  127263. private static _ProfilesList;
  127264. /**
  127265. * The base URL of the online controller repository. Can be changed at any time.
  127266. */
  127267. static BaseRepositoryUrl: string;
  127268. /**
  127269. * Which repository gets priority - local or online
  127270. */
  127271. static PrioritizeOnlineRepository: boolean;
  127272. /**
  127273. * Use the online repository, or use only locally-defined controllers
  127274. */
  127275. static UseOnlineRepository: boolean;
  127276. /**
  127277. * Clear the cache used for profile loading and reload when requested again
  127278. */
  127279. static ClearProfilesCache(): void;
  127280. /**
  127281. * Register the default fallbacks.
  127282. * This function is called automatically when this file is imported.
  127283. */
  127284. static DefaultFallbacks(): void;
  127285. /**
  127286. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127287. * @param profileId the profile to which a fallback needs to be found
  127288. * @return an array with corresponding fallback profiles
  127289. */
  127290. static FindFallbackWithProfileId(profileId: string): string[];
  127291. /**
  127292. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127293. * The order of search:
  127294. *
  127295. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127296. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127297. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127298. * 4) return the generic trigger controller if none were found
  127299. *
  127300. * @param xrInput the xrInput to which a new controller is initialized
  127301. * @param scene the scene to which the model will be added
  127302. * @param forceProfile force a certain profile for this controller
  127303. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127304. */
  127305. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127306. /**
  127307. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127308. *
  127309. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127310. *
  127311. * @param type the profile type to register
  127312. * @param constructFunction the function to be called when loading this profile
  127313. */
  127314. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127315. /**
  127316. * Register a fallback to a specific profile.
  127317. * @param profileId the profileId that will receive the fallbacks
  127318. * @param fallbacks A list of fallback profiles
  127319. */
  127320. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127321. /**
  127322. * Will update the list of profiles available in the repository
  127323. * @return a promise that resolves to a map of profiles available online
  127324. */
  127325. static UpdateProfilesList(): Promise<{
  127326. [profile: string]: string;
  127327. }>;
  127328. private static _LoadProfileFromRepository;
  127329. private static _LoadProfilesFromAvailableControllers;
  127330. }
  127331. }
  127332. declare module BABYLON {
  127333. /**
  127334. * Configuration options for the WebXR controller creation
  127335. */
  127336. export interface IWebXRControllerOptions {
  127337. /**
  127338. * Should the controller mesh be animated when a user interacts with it
  127339. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127340. */
  127341. disableMotionControllerAnimation?: boolean;
  127342. /**
  127343. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127344. */
  127345. doNotLoadControllerMesh?: boolean;
  127346. /**
  127347. * Force a specific controller type for this controller.
  127348. * This can be used when creating your own profile or when testing different controllers
  127349. */
  127350. forceControllerProfile?: string;
  127351. /**
  127352. * Defines a rendering group ID for meshes that will be loaded.
  127353. * This is for the default controllers only.
  127354. */
  127355. renderingGroupId?: number;
  127356. }
  127357. /**
  127358. * Represents an XR controller
  127359. */
  127360. export class WebXRInputSource {
  127361. private _scene;
  127362. /** The underlying input source for the controller */
  127363. inputSource: XRInputSource;
  127364. private _options;
  127365. private _tmpVector;
  127366. private _uniqueId;
  127367. /**
  127368. * 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
  127369. */
  127370. grip?: AbstractMesh;
  127371. /**
  127372. * If available, this is the gamepad object related to this controller.
  127373. * Using this object it is possible to get click events and trackpad changes of the
  127374. * webxr controller that is currently being used.
  127375. */
  127376. motionController?: WebXRAbstractMotionController;
  127377. /**
  127378. * Event that fires when the controller is removed/disposed.
  127379. * The object provided as event data is this controller, after associated assets were disposed.
  127380. * uniqueId is still available.
  127381. */
  127382. onDisposeObservable: Observable<WebXRInputSource>;
  127383. /**
  127384. * Will be triggered when the mesh associated with the motion controller is done loading.
  127385. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127386. * A shortened version of controller -> motion controller -> on mesh loaded.
  127387. */
  127388. onMeshLoadedObservable: Observable<AbstractMesh>;
  127389. /**
  127390. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127391. */
  127392. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127393. /**
  127394. * Pointer which can be used to select objects or attach a visible laser to
  127395. */
  127396. pointer: AbstractMesh;
  127397. /**
  127398. * Creates the input source object
  127399. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127400. * @param _scene the scene which the controller should be associated to
  127401. * @param inputSource the underlying input source for the controller
  127402. * @param _options options for this controller creation
  127403. */
  127404. constructor(_scene: Scene,
  127405. /** The underlying input source for the controller */
  127406. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127407. /**
  127408. * Get this controllers unique id
  127409. */
  127410. get uniqueId(): string;
  127411. /**
  127412. * Disposes of the object
  127413. */
  127414. dispose(): void;
  127415. /**
  127416. * Gets a world space ray coming from the pointer or grip
  127417. * @param result the resulting ray
  127418. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127419. */
  127420. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127421. /**
  127422. * Updates the controller pose based on the given XRFrame
  127423. * @param xrFrame xr frame to update the pose with
  127424. * @param referenceSpace reference space to use
  127425. */
  127426. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127427. }
  127428. }
  127429. declare module BABYLON {
  127430. /**
  127431. * The schema for initialization options of the XR Input class
  127432. */
  127433. export interface IWebXRInputOptions {
  127434. /**
  127435. * If set to true no model will be automatically loaded
  127436. */
  127437. doNotLoadControllerMeshes?: boolean;
  127438. /**
  127439. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127440. * If not found, the xr input profile data will be used.
  127441. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127442. */
  127443. forceInputProfile?: string;
  127444. /**
  127445. * Do not send a request to the controller repository to load the profile.
  127446. *
  127447. * Instead, use the controllers available in babylon itself.
  127448. */
  127449. disableOnlineControllerRepository?: boolean;
  127450. /**
  127451. * A custom URL for the controllers repository
  127452. */
  127453. customControllersRepositoryURL?: string;
  127454. /**
  127455. * Should the controller model's components not move according to the user input
  127456. */
  127457. disableControllerAnimation?: boolean;
  127458. /**
  127459. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127460. */
  127461. controllerOptions?: IWebXRControllerOptions;
  127462. }
  127463. /**
  127464. * XR input used to track XR inputs such as controllers/rays
  127465. */
  127466. export class WebXRInput implements IDisposable {
  127467. /**
  127468. * the xr session manager for this session
  127469. */
  127470. xrSessionManager: WebXRSessionManager;
  127471. /**
  127472. * the WebXR camera for this session. Mainly used for teleportation
  127473. */
  127474. xrCamera: WebXRCamera;
  127475. private readonly options;
  127476. /**
  127477. * XR controllers being tracked
  127478. */
  127479. controllers: Array<WebXRInputSource>;
  127480. private _frameObserver;
  127481. private _sessionEndedObserver;
  127482. private _sessionInitObserver;
  127483. /**
  127484. * Event when a controller has been connected/added
  127485. */
  127486. onControllerAddedObservable: Observable<WebXRInputSource>;
  127487. /**
  127488. * Event when a controller has been removed/disconnected
  127489. */
  127490. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127491. /**
  127492. * Initializes the WebXRInput
  127493. * @param xrSessionManager the xr session manager for this session
  127494. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127495. * @param options = initialization options for this xr input
  127496. */
  127497. constructor(
  127498. /**
  127499. * the xr session manager for this session
  127500. */
  127501. xrSessionManager: WebXRSessionManager,
  127502. /**
  127503. * the WebXR camera for this session. Mainly used for teleportation
  127504. */
  127505. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127506. private _onInputSourcesChange;
  127507. private _addAndRemoveControllers;
  127508. /**
  127509. * Disposes of the object
  127510. */
  127511. dispose(): void;
  127512. }
  127513. }
  127514. declare module BABYLON {
  127515. /**
  127516. * This is the base class for all WebXR features.
  127517. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127518. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127519. */
  127520. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127521. protected _xrSessionManager: WebXRSessionManager;
  127522. private _attached;
  127523. private _removeOnDetach;
  127524. /**
  127525. * Should auto-attach be disabled?
  127526. */
  127527. disableAutoAttach: boolean;
  127528. /**
  127529. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127530. */
  127531. xrNativeFeatureName: string;
  127532. /**
  127533. * Construct a new (abstract) WebXR feature
  127534. * @param _xrSessionManager the xr session manager for this feature
  127535. */
  127536. constructor(_xrSessionManager: WebXRSessionManager);
  127537. /**
  127538. * Is this feature attached
  127539. */
  127540. get attached(): boolean;
  127541. /**
  127542. * attach this feature
  127543. *
  127544. * @param force should attachment be forced (even when already attached)
  127545. * @returns true if successful, false is failed or already attached
  127546. */
  127547. attach(force?: boolean): boolean;
  127548. /**
  127549. * detach this feature.
  127550. *
  127551. * @returns true if successful, false if failed or already detached
  127552. */
  127553. detach(): boolean;
  127554. /**
  127555. * Dispose this feature and all of the resources attached
  127556. */
  127557. dispose(): void;
  127558. /**
  127559. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127560. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127561. *
  127562. * @returns whether or not the feature is compatible in this environment
  127563. */
  127564. isCompatible(): boolean;
  127565. /**
  127566. * This is used to register callbacks that will automatically be removed when detach is called.
  127567. * @param observable the observable to which the observer will be attached
  127568. * @param callback the callback to register
  127569. */
  127570. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127571. /**
  127572. * Code in this function will be executed on each xrFrame received from the browser.
  127573. * This function will not execute after the feature is detached.
  127574. * @param _xrFrame the current frame
  127575. */
  127576. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127577. }
  127578. }
  127579. declare module BABYLON {
  127580. /**
  127581. * Renders a layer on top of an existing scene
  127582. */
  127583. export class UtilityLayerRenderer implements IDisposable {
  127584. /** the original scene that will be rendered on top of */
  127585. originalScene: Scene;
  127586. private _pointerCaptures;
  127587. private _lastPointerEvents;
  127588. private static _DefaultUtilityLayer;
  127589. private static _DefaultKeepDepthUtilityLayer;
  127590. private _sharedGizmoLight;
  127591. private _renderCamera;
  127592. /**
  127593. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127594. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127595. * @returns the camera that is used when rendering the utility layer
  127596. */
  127597. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127598. /**
  127599. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127600. * @param cam the camera that should be used when rendering the utility layer
  127601. */
  127602. setRenderCamera(cam: Nullable<Camera>): void;
  127603. /**
  127604. * @hidden
  127605. * Light which used by gizmos to get light shading
  127606. */
  127607. _getSharedGizmoLight(): HemisphericLight;
  127608. /**
  127609. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127610. */
  127611. pickUtilitySceneFirst: boolean;
  127612. /**
  127613. * 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)
  127614. */
  127615. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127616. /**
  127617. * 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)
  127618. */
  127619. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127620. /**
  127621. * The scene that is rendered on top of the original scene
  127622. */
  127623. utilityLayerScene: Scene;
  127624. /**
  127625. * If the utility layer should automatically be rendered on top of existing scene
  127626. */
  127627. shouldRender: boolean;
  127628. /**
  127629. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127630. */
  127631. onlyCheckPointerDownEvents: boolean;
  127632. /**
  127633. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127634. */
  127635. processAllEvents: boolean;
  127636. /**
  127637. * Observable raised when the pointer move from the utility layer scene to the main scene
  127638. */
  127639. onPointerOutObservable: Observable<number>;
  127640. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127641. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127642. private _afterRenderObserver;
  127643. private _sceneDisposeObserver;
  127644. private _originalPointerObserver;
  127645. /**
  127646. * Instantiates a UtilityLayerRenderer
  127647. * @param originalScene the original scene that will be rendered on top of
  127648. * @param handleEvents boolean indicating if the utility layer should handle events
  127649. */
  127650. constructor(
  127651. /** the original scene that will be rendered on top of */
  127652. originalScene: Scene, handleEvents?: boolean);
  127653. private _notifyObservers;
  127654. /**
  127655. * Renders the utility layers scene on top of the original scene
  127656. */
  127657. render(): void;
  127658. /**
  127659. * Disposes of the renderer
  127660. */
  127661. dispose(): void;
  127662. private _updateCamera;
  127663. }
  127664. }
  127665. declare module BABYLON {
  127666. /**
  127667. * Options interface for the pointer selection module
  127668. */
  127669. export interface IWebXRControllerPointerSelectionOptions {
  127670. /**
  127671. * if provided, this scene will be used to render meshes.
  127672. */
  127673. customUtilityLayerScene?: Scene;
  127674. /**
  127675. * 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)
  127676. * If not disabled, the last picked point will be used to execute a pointer up event
  127677. * If disabled, pointer up event will be triggered right after the pointer down event.
  127678. * Used in screen and gaze target ray mode only
  127679. */
  127680. disablePointerUpOnTouchOut: boolean;
  127681. /**
  127682. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127683. */
  127684. forceGazeMode: boolean;
  127685. /**
  127686. * 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
  127687. * to start a new countdown to the pointer down event.
  127688. * Defaults to 1.
  127689. */
  127690. gazeModePointerMovedFactor?: number;
  127691. /**
  127692. * Different button type to use instead of the main component
  127693. */
  127694. overrideButtonId?: string;
  127695. /**
  127696. * use this rendering group id for the meshes (optional)
  127697. */
  127698. renderingGroupId?: number;
  127699. /**
  127700. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127701. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127702. * 3000 means 3 seconds between pointing at something and selecting it
  127703. */
  127704. timeToSelect?: number;
  127705. /**
  127706. * Should meshes created here be added to a utility layer or the main scene
  127707. */
  127708. useUtilityLayer?: boolean;
  127709. /**
  127710. * Optional WebXR camera to be used for gaze selection
  127711. */
  127712. gazeCamera?: WebXRCamera;
  127713. /**
  127714. * the xr input to use with this pointer selection
  127715. */
  127716. xrInput: WebXRInput;
  127717. }
  127718. /**
  127719. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127720. */
  127721. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127722. private readonly _options;
  127723. private static _idCounter;
  127724. private _attachController;
  127725. private _controllers;
  127726. private _scene;
  127727. private _tmpVectorForPickCompare;
  127728. /**
  127729. * The module's name
  127730. */
  127731. static readonly Name: string;
  127732. /**
  127733. * The (Babylon) version of this module.
  127734. * This is an integer representing the implementation version.
  127735. * This number does not correspond to the WebXR specs version
  127736. */
  127737. static readonly Version: number;
  127738. /**
  127739. * Disable lighting on the laser pointer (so it will always be visible)
  127740. */
  127741. disablePointerLighting: boolean;
  127742. /**
  127743. * Disable lighting on the selection mesh (so it will always be visible)
  127744. */
  127745. disableSelectionMeshLighting: boolean;
  127746. /**
  127747. * Should the laser pointer be displayed
  127748. */
  127749. displayLaserPointer: boolean;
  127750. /**
  127751. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127752. */
  127753. displaySelectionMesh: boolean;
  127754. /**
  127755. * This color will be set to the laser pointer when selection is triggered
  127756. */
  127757. laserPointerPickedColor: Color3;
  127758. /**
  127759. * Default color of the laser pointer
  127760. */
  127761. laserPointerDefaultColor: Color3;
  127762. /**
  127763. * default color of the selection ring
  127764. */
  127765. selectionMeshDefaultColor: Color3;
  127766. /**
  127767. * This color will be applied to the selection ring when selection is triggered
  127768. */
  127769. selectionMeshPickedColor: Color3;
  127770. /**
  127771. * Optional filter to be used for ray selection. This predicate shares behavior with
  127772. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127773. */
  127774. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127775. /**
  127776. * constructs a new background remover module
  127777. * @param _xrSessionManager the session manager for this module
  127778. * @param _options read-only options to be used in this module
  127779. */
  127780. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127781. /**
  127782. * attach this feature
  127783. * Will usually be called by the features manager
  127784. *
  127785. * @returns true if successful.
  127786. */
  127787. attach(): boolean;
  127788. /**
  127789. * detach this feature.
  127790. * Will usually be called by the features manager
  127791. *
  127792. * @returns true if successful.
  127793. */
  127794. detach(): boolean;
  127795. /**
  127796. * Will get the mesh under a specific pointer.
  127797. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127798. * @param controllerId the controllerId to check
  127799. * @returns The mesh under pointer or null if no mesh is under the pointer
  127800. */
  127801. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127802. /**
  127803. * Get the xr controller that correlates to the pointer id in the pointer event
  127804. *
  127805. * @param id the pointer id to search for
  127806. * @returns the controller that correlates to this id or null if not found
  127807. */
  127808. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127809. protected _onXRFrame(_xrFrame: XRFrame): void;
  127810. private _attachGazeMode;
  127811. private _attachScreenRayMode;
  127812. private _attachTrackedPointerRayMode;
  127813. private _convertNormalToDirectionOfRay;
  127814. private _detachController;
  127815. private _generateNewMeshPair;
  127816. private _pickingMoved;
  127817. private _updatePointerDistance;
  127818. /** @hidden */
  127819. get lasterPointerDefaultColor(): Color3;
  127820. }
  127821. }
  127822. declare module BABYLON {
  127823. /**
  127824. * Button which can be used to enter a different mode of XR
  127825. */
  127826. export class WebXREnterExitUIButton {
  127827. /** button element */
  127828. element: HTMLElement;
  127829. /** XR initialization options for the button */
  127830. sessionMode: XRSessionMode;
  127831. /** Reference space type */
  127832. referenceSpaceType: XRReferenceSpaceType;
  127833. /**
  127834. * Creates a WebXREnterExitUIButton
  127835. * @param element button element
  127836. * @param sessionMode XR initialization session mode
  127837. * @param referenceSpaceType the type of reference space to be used
  127838. */
  127839. constructor(
  127840. /** button element */
  127841. element: HTMLElement,
  127842. /** XR initialization options for the button */
  127843. sessionMode: XRSessionMode,
  127844. /** Reference space type */
  127845. referenceSpaceType: XRReferenceSpaceType);
  127846. /**
  127847. * Extendable function which can be used to update the button's visuals when the state changes
  127848. * @param activeButton the current active button in the UI
  127849. */
  127850. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127851. }
  127852. /**
  127853. * Options to create the webXR UI
  127854. */
  127855. export class WebXREnterExitUIOptions {
  127856. /**
  127857. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127858. */
  127859. customButtons?: Array<WebXREnterExitUIButton>;
  127860. /**
  127861. * A reference space type to use when creating the default button.
  127862. * Default is local-floor
  127863. */
  127864. referenceSpaceType?: XRReferenceSpaceType;
  127865. /**
  127866. * Context to enter xr with
  127867. */
  127868. renderTarget?: Nullable<WebXRRenderTarget>;
  127869. /**
  127870. * A session mode to use when creating the default button.
  127871. * Default is immersive-vr
  127872. */
  127873. sessionMode?: XRSessionMode;
  127874. /**
  127875. * A list of optional features to init the session with
  127876. */
  127877. optionalFeatures?: string[];
  127878. /**
  127879. * A list of optional features to init the session with
  127880. */
  127881. requiredFeatures?: string[];
  127882. }
  127883. /**
  127884. * UI to allow the user to enter/exit XR mode
  127885. */
  127886. export class WebXREnterExitUI implements IDisposable {
  127887. private scene;
  127888. /** version of the options passed to this UI */
  127889. options: WebXREnterExitUIOptions;
  127890. private _activeButton;
  127891. private _buttons;
  127892. private _overlay;
  127893. /**
  127894. * Fired every time the active button is changed.
  127895. *
  127896. * When xr is entered via a button that launches xr that button will be the callback parameter
  127897. *
  127898. * When exiting xr the callback parameter will be null)
  127899. */
  127900. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127901. /**
  127902. *
  127903. * @param scene babylon scene object to use
  127904. * @param options (read-only) version of the options passed to this UI
  127905. */
  127906. private constructor();
  127907. /**
  127908. * Creates UI to allow the user to enter/exit XR mode
  127909. * @param scene the scene to add the ui to
  127910. * @param helper the xr experience helper to enter/exit xr with
  127911. * @param options options to configure the UI
  127912. * @returns the created ui
  127913. */
  127914. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127915. /**
  127916. * Disposes of the XR UI component
  127917. */
  127918. dispose(): void;
  127919. private _updateButtons;
  127920. }
  127921. }
  127922. declare module BABYLON {
  127923. /**
  127924. * Class containing static functions to help procedurally build meshes
  127925. */
  127926. export class LinesBuilder {
  127927. /**
  127928. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127929. * * 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
  127930. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127931. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127932. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127933. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127934. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127935. * * 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
  127936. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127939. * @param name defines the name of the new line system
  127940. * @param options defines the options used to create the line system
  127941. * @param scene defines the hosting scene
  127942. * @returns a new line system mesh
  127943. */
  127944. static CreateLineSystem(name: string, options: {
  127945. lines: Vector3[][];
  127946. updatable?: boolean;
  127947. instance?: Nullable<LinesMesh>;
  127948. colors?: Nullable<Color4[][]>;
  127949. useVertexAlpha?: boolean;
  127950. }, scene: Nullable<Scene>): LinesMesh;
  127951. /**
  127952. * Creates a line mesh
  127953. * 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
  127954. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127955. * * The parameter `points` is an array successive Vector3
  127956. * * 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
  127957. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127958. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127959. * * When updating an instance, remember that only point positions can change, not the number of points
  127960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127962. * @param name defines the name of the new line system
  127963. * @param options defines the options used to create the line system
  127964. * @param scene defines the hosting scene
  127965. * @returns a new line mesh
  127966. */
  127967. static CreateLines(name: string, options: {
  127968. points: Vector3[];
  127969. updatable?: boolean;
  127970. instance?: Nullable<LinesMesh>;
  127971. colors?: Color4[];
  127972. useVertexAlpha?: boolean;
  127973. }, scene?: Nullable<Scene>): LinesMesh;
  127974. /**
  127975. * Creates a dashed line mesh
  127976. * * 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
  127977. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127978. * * The parameter `points` is an array successive Vector3
  127979. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127980. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127981. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127982. * * 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
  127983. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127984. * * When updating an instance, remember that only point positions can change, not the number of points
  127985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127986. * @param name defines the name of the mesh
  127987. * @param options defines the options used to create the mesh
  127988. * @param scene defines the hosting scene
  127989. * @returns the dashed line mesh
  127990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127991. */
  127992. static CreateDashedLines(name: string, options: {
  127993. points: Vector3[];
  127994. dashSize?: number;
  127995. gapSize?: number;
  127996. dashNb?: number;
  127997. updatable?: boolean;
  127998. instance?: LinesMesh;
  127999. useVertexAlpha?: boolean;
  128000. }, scene?: Nullable<Scene>): LinesMesh;
  128001. }
  128002. }
  128003. declare module BABYLON {
  128004. /**
  128005. * Construction options for a timer
  128006. */
  128007. export interface ITimerOptions<T> {
  128008. /**
  128009. * Time-to-end
  128010. */
  128011. timeout: number;
  128012. /**
  128013. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128014. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128015. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128016. */
  128017. contextObservable: Observable<T>;
  128018. /**
  128019. * Optional parameters when adding an observer to the observable
  128020. */
  128021. observableParameters?: {
  128022. mask?: number;
  128023. insertFirst?: boolean;
  128024. scope?: any;
  128025. };
  128026. /**
  128027. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128028. */
  128029. breakCondition?: (data?: ITimerData<T>) => boolean;
  128030. /**
  128031. * Will be triggered when the time condition has met
  128032. */
  128033. onEnded?: (data: ITimerData<any>) => void;
  128034. /**
  128035. * Will be triggered when the break condition has met (prematurely ended)
  128036. */
  128037. onAborted?: (data: ITimerData<any>) => void;
  128038. /**
  128039. * Optional function to execute on each tick (or count)
  128040. */
  128041. onTick?: (data: ITimerData<any>) => void;
  128042. }
  128043. /**
  128044. * An interface defining the data sent by the timer
  128045. */
  128046. export interface ITimerData<T> {
  128047. /**
  128048. * When did it start
  128049. */
  128050. startTime: number;
  128051. /**
  128052. * Time now
  128053. */
  128054. currentTime: number;
  128055. /**
  128056. * Time passed since started
  128057. */
  128058. deltaTime: number;
  128059. /**
  128060. * How much is completed, in [0.0...1.0].
  128061. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128062. */
  128063. completeRate: number;
  128064. /**
  128065. * What the registered observable sent in the last count
  128066. */
  128067. payload: T;
  128068. }
  128069. /**
  128070. * The current state of the timer
  128071. */
  128072. export enum TimerState {
  128073. /**
  128074. * Timer initialized, not yet started
  128075. */
  128076. INIT = 0,
  128077. /**
  128078. * Timer started and counting
  128079. */
  128080. STARTED = 1,
  128081. /**
  128082. * Timer ended (whether aborted or time reached)
  128083. */
  128084. ENDED = 2
  128085. }
  128086. /**
  128087. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128088. *
  128089. * @param options options with which to initialize this timer
  128090. */
  128091. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128092. /**
  128093. * An advanced implementation of a timer class
  128094. */
  128095. export class AdvancedTimer<T = any> implements IDisposable {
  128096. /**
  128097. * Will notify each time the timer calculates the remaining time
  128098. */
  128099. onEachCountObservable: Observable<ITimerData<T>>;
  128100. /**
  128101. * Will trigger when the timer was aborted due to the break condition
  128102. */
  128103. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128104. /**
  128105. * Will trigger when the timer ended successfully
  128106. */
  128107. onTimerEndedObservable: Observable<ITimerData<T>>;
  128108. /**
  128109. * Will trigger when the timer state has changed
  128110. */
  128111. onStateChangedObservable: Observable<TimerState>;
  128112. private _observer;
  128113. private _contextObservable;
  128114. private _observableParameters;
  128115. private _startTime;
  128116. private _timer;
  128117. private _state;
  128118. private _breakCondition;
  128119. private _timeToEnd;
  128120. private _breakOnNextTick;
  128121. /**
  128122. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128123. * @param options construction options for this advanced timer
  128124. */
  128125. constructor(options: ITimerOptions<T>);
  128126. /**
  128127. * set a breaking condition for this timer. Default is to never break during count
  128128. * @param predicate the new break condition. Returns true to break, false otherwise
  128129. */
  128130. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128131. /**
  128132. * Reset ALL associated observables in this advanced timer
  128133. */
  128134. clearObservables(): void;
  128135. /**
  128136. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128137. *
  128138. * @param timeToEnd how much time to measure until timer ended
  128139. */
  128140. start(timeToEnd?: number): void;
  128141. /**
  128142. * Will force a stop on the next tick.
  128143. */
  128144. stop(): void;
  128145. /**
  128146. * Dispose this timer, clearing all resources
  128147. */
  128148. dispose(): void;
  128149. private _setState;
  128150. private _tick;
  128151. private _stop;
  128152. }
  128153. }
  128154. declare module BABYLON {
  128155. /**
  128156. * The options container for the teleportation module
  128157. */
  128158. export interface IWebXRTeleportationOptions {
  128159. /**
  128160. * if provided, this scene will be used to render meshes.
  128161. */
  128162. customUtilityLayerScene?: Scene;
  128163. /**
  128164. * Values to configure the default target mesh
  128165. */
  128166. defaultTargetMeshOptions?: {
  128167. /**
  128168. * Fill color of the teleportation area
  128169. */
  128170. teleportationFillColor?: string;
  128171. /**
  128172. * Border color for the teleportation area
  128173. */
  128174. teleportationBorderColor?: string;
  128175. /**
  128176. * Disable the mesh's animation sequence
  128177. */
  128178. disableAnimation?: boolean;
  128179. /**
  128180. * Disable lighting on the material or the ring and arrow
  128181. */
  128182. disableLighting?: boolean;
  128183. /**
  128184. * Override the default material of the torus and arrow
  128185. */
  128186. torusArrowMaterial?: Material;
  128187. };
  128188. /**
  128189. * A list of meshes to use as floor meshes.
  128190. * Meshes can be added and removed after initializing the feature using the
  128191. * addFloorMesh and removeFloorMesh functions
  128192. * If empty, rotation will still work
  128193. */
  128194. floorMeshes?: AbstractMesh[];
  128195. /**
  128196. * use this rendering group id for the meshes (optional)
  128197. */
  128198. renderingGroupId?: number;
  128199. /**
  128200. * Should teleportation move only to snap points
  128201. */
  128202. snapPointsOnly?: boolean;
  128203. /**
  128204. * An array of points to which the teleportation will snap to.
  128205. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128206. */
  128207. snapPositions?: Vector3[];
  128208. /**
  128209. * How close should the teleportation ray be in order to snap to position.
  128210. * Default to 0.8 units (meters)
  128211. */
  128212. snapToPositionRadius?: number;
  128213. /**
  128214. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128215. * If you want to support rotation, make sure your mesh has a direction indicator.
  128216. *
  128217. * When left untouched, the default mesh will be initialized.
  128218. */
  128219. teleportationTargetMesh?: AbstractMesh;
  128220. /**
  128221. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128222. */
  128223. timeToTeleport?: number;
  128224. /**
  128225. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128226. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128227. */
  128228. useMainComponentOnly?: boolean;
  128229. /**
  128230. * Should meshes created here be added to a utility layer or the main scene
  128231. */
  128232. useUtilityLayer?: boolean;
  128233. /**
  128234. * Babylon XR Input class for controller
  128235. */
  128236. xrInput: WebXRInput;
  128237. }
  128238. /**
  128239. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128240. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128241. * the input of the attached controllers.
  128242. */
  128243. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128244. private _options;
  128245. private _controllers;
  128246. private _currentTeleportationControllerId;
  128247. private _floorMeshes;
  128248. private _quadraticBezierCurve;
  128249. private _selectionFeature;
  128250. private _snapToPositions;
  128251. private _snappedToPoint;
  128252. private _teleportationRingMaterial?;
  128253. private _tmpRay;
  128254. private _tmpVector;
  128255. /**
  128256. * The module's name
  128257. */
  128258. static readonly Name: string;
  128259. /**
  128260. * The (Babylon) version of this module.
  128261. * This is an integer representing the implementation version.
  128262. * This number does not correspond to the webxr specs version
  128263. */
  128264. static readonly Version: number;
  128265. /**
  128266. * Is movement backwards enabled
  128267. */
  128268. backwardsMovementEnabled: boolean;
  128269. /**
  128270. * Distance to travel when moving backwards
  128271. */
  128272. backwardsTeleportationDistance: number;
  128273. /**
  128274. * The distance from the user to the inspection point in the direction of the controller
  128275. * A higher number will allow the user to move further
  128276. * defaults to 5 (meters, in xr units)
  128277. */
  128278. parabolicCheckRadius: number;
  128279. /**
  128280. * Should the module support parabolic ray on top of direct ray
  128281. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128282. * Very helpful when moving between floors / different heights
  128283. */
  128284. parabolicRayEnabled: boolean;
  128285. /**
  128286. * How much rotation should be applied when rotating right and left
  128287. */
  128288. rotationAngle: number;
  128289. /**
  128290. * Is rotation enabled when moving forward?
  128291. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128292. */
  128293. rotationEnabled: boolean;
  128294. /**
  128295. * constructs a new anchor system
  128296. * @param _xrSessionManager an instance of WebXRSessionManager
  128297. * @param _options configuration object for this feature
  128298. */
  128299. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128300. /**
  128301. * Get the snapPointsOnly flag
  128302. */
  128303. get snapPointsOnly(): boolean;
  128304. /**
  128305. * Sets the snapPointsOnly flag
  128306. * @param snapToPoints should teleportation be exclusively to snap points
  128307. */
  128308. set snapPointsOnly(snapToPoints: boolean);
  128309. /**
  128310. * Add a new mesh to the floor meshes array
  128311. * @param mesh the mesh to use as floor mesh
  128312. */
  128313. addFloorMesh(mesh: AbstractMesh): void;
  128314. /**
  128315. * Add a new snap-to point to fix teleportation to this position
  128316. * @param newSnapPoint The new Snap-To point
  128317. */
  128318. addSnapPoint(newSnapPoint: Vector3): void;
  128319. attach(): boolean;
  128320. detach(): boolean;
  128321. dispose(): void;
  128322. /**
  128323. * Remove a mesh from the floor meshes array
  128324. * @param mesh the mesh to remove
  128325. */
  128326. removeFloorMesh(mesh: AbstractMesh): void;
  128327. /**
  128328. * Remove a mesh from the floor meshes array using its name
  128329. * @param name the mesh name to remove
  128330. */
  128331. removeFloorMeshByName(name: string): void;
  128332. /**
  128333. * 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
  128334. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128335. * @returns was the point found and removed or not
  128336. */
  128337. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128338. /**
  128339. * This function sets a selection feature that will be disabled when
  128340. * the forward ray is shown and will be reattached when hidden.
  128341. * This is used to remove the selection rays when moving.
  128342. * @param selectionFeature the feature to disable when forward movement is enabled
  128343. */
  128344. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128345. protected _onXRFrame(_xrFrame: XRFrame): void;
  128346. private _attachController;
  128347. private _createDefaultTargetMesh;
  128348. private _detachController;
  128349. private _findClosestSnapPointWithRadius;
  128350. private _setTargetMeshPosition;
  128351. private _setTargetMeshVisibility;
  128352. private _showParabolicPath;
  128353. private _teleportForward;
  128354. }
  128355. }
  128356. declare module BABYLON {
  128357. /**
  128358. * Options for the default xr helper
  128359. */
  128360. export class WebXRDefaultExperienceOptions {
  128361. /**
  128362. * Enable or disable default UI to enter XR
  128363. */
  128364. disableDefaultUI?: boolean;
  128365. /**
  128366. * Should teleportation not initialize. defaults to false.
  128367. */
  128368. disableTeleportation?: boolean;
  128369. /**
  128370. * Floor meshes that will be used for teleport
  128371. */
  128372. floorMeshes?: Array<AbstractMesh>;
  128373. /**
  128374. * If set to true, the first frame will not be used to reset position
  128375. * The first frame is mainly used when copying transformation from the old camera
  128376. * Mainly used in AR
  128377. */
  128378. ignoreNativeCameraTransformation?: boolean;
  128379. /**
  128380. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128381. */
  128382. inputOptions?: IWebXRInputOptions;
  128383. /**
  128384. * optional configuration for the output canvas
  128385. */
  128386. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128387. /**
  128388. * optional UI options. This can be used among other to change session mode and reference space type
  128389. */
  128390. uiOptions?: WebXREnterExitUIOptions;
  128391. /**
  128392. * When loading teleportation and pointer select, use stable versions instead of latest.
  128393. */
  128394. useStablePlugins?: boolean;
  128395. /**
  128396. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128397. */
  128398. renderingGroupId?: number;
  128399. /**
  128400. * A list of optional features to init the session with
  128401. * If set to true, all features we support will be added
  128402. */
  128403. optionalFeatures?: boolean | string[];
  128404. }
  128405. /**
  128406. * Default experience which provides a similar setup to the previous webVRExperience
  128407. */
  128408. export class WebXRDefaultExperience {
  128409. /**
  128410. * Base experience
  128411. */
  128412. baseExperience: WebXRExperienceHelper;
  128413. /**
  128414. * Enables ui for entering/exiting xr
  128415. */
  128416. enterExitUI: WebXREnterExitUI;
  128417. /**
  128418. * Input experience extension
  128419. */
  128420. input: WebXRInput;
  128421. /**
  128422. * Enables laser pointer and selection
  128423. */
  128424. pointerSelection: WebXRControllerPointerSelection;
  128425. /**
  128426. * Default target xr should render to
  128427. */
  128428. renderTarget: WebXRRenderTarget;
  128429. /**
  128430. * Enables teleportation
  128431. */
  128432. teleportation: WebXRMotionControllerTeleportation;
  128433. private constructor();
  128434. /**
  128435. * Creates the default xr experience
  128436. * @param scene scene
  128437. * @param options options for basic configuration
  128438. * @returns resulting WebXRDefaultExperience
  128439. */
  128440. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128441. /**
  128442. * DIsposes of the experience helper
  128443. */
  128444. dispose(): void;
  128445. }
  128446. }
  128447. declare module BABYLON {
  128448. /**
  128449. * Options to modify the vr teleportation behavior.
  128450. */
  128451. export interface VRTeleportationOptions {
  128452. /**
  128453. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128454. */
  128455. floorMeshName?: string;
  128456. /**
  128457. * A list of meshes to be used as the teleportation floor. (default: empty)
  128458. */
  128459. floorMeshes?: Mesh[];
  128460. /**
  128461. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128462. */
  128463. teleportationMode?: number;
  128464. /**
  128465. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128466. */
  128467. teleportationTime?: number;
  128468. /**
  128469. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128470. */
  128471. teleportationSpeed?: number;
  128472. /**
  128473. * The easing function used in the animation or null for Linear. (default CircleEase)
  128474. */
  128475. easingFunction?: EasingFunction;
  128476. }
  128477. /**
  128478. * Options to modify the vr experience helper's behavior.
  128479. */
  128480. export interface VRExperienceHelperOptions extends WebVROptions {
  128481. /**
  128482. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128483. */
  128484. createDeviceOrientationCamera?: boolean;
  128485. /**
  128486. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128487. */
  128488. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128489. /**
  128490. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128491. */
  128492. laserToggle?: boolean;
  128493. /**
  128494. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128495. */
  128496. floorMeshes?: Mesh[];
  128497. /**
  128498. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128499. */
  128500. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128501. /**
  128502. * Defines if WebXR should be used instead of WebVR (if available)
  128503. */
  128504. useXR?: boolean;
  128505. }
  128506. /**
  128507. * Event containing information after VR has been entered
  128508. */
  128509. export class OnAfterEnteringVRObservableEvent {
  128510. /**
  128511. * If entering vr was successful
  128512. */
  128513. success: boolean;
  128514. }
  128515. /**
  128516. * Helps to quickly add VR support to an existing scene.
  128517. * See https://doc.babylonjs.com/how_to/webvr_helper
  128518. */
  128519. export class VRExperienceHelper {
  128520. /** Options to modify the vr experience helper's behavior. */
  128521. webVROptions: VRExperienceHelperOptions;
  128522. private _scene;
  128523. private _position;
  128524. private _btnVR;
  128525. private _btnVRDisplayed;
  128526. private _webVRsupported;
  128527. private _webVRready;
  128528. private _webVRrequesting;
  128529. private _webVRpresenting;
  128530. private _hasEnteredVR;
  128531. private _fullscreenVRpresenting;
  128532. private _inputElement;
  128533. private _webVRCamera;
  128534. private _vrDeviceOrientationCamera;
  128535. private _deviceOrientationCamera;
  128536. private _existingCamera;
  128537. private _onKeyDown;
  128538. private _onVrDisplayPresentChange;
  128539. private _onVRDisplayChanged;
  128540. private _onVRRequestPresentStart;
  128541. private _onVRRequestPresentComplete;
  128542. /**
  128543. * 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)
  128544. */
  128545. enableGazeEvenWhenNoPointerLock: boolean;
  128546. /**
  128547. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128548. */
  128549. exitVROnDoubleTap: boolean;
  128550. /**
  128551. * Observable raised right before entering VR.
  128552. */
  128553. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128554. /**
  128555. * Observable raised when entering VR has completed.
  128556. */
  128557. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128558. /**
  128559. * Observable raised when exiting VR.
  128560. */
  128561. onExitingVRObservable: Observable<VRExperienceHelper>;
  128562. /**
  128563. * Observable raised when controller mesh is loaded.
  128564. */
  128565. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128566. /** Return this.onEnteringVRObservable
  128567. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128568. */
  128569. get onEnteringVR(): Observable<VRExperienceHelper>;
  128570. /** Return this.onExitingVRObservable
  128571. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128572. */
  128573. get onExitingVR(): Observable<VRExperienceHelper>;
  128574. /** Return this.onControllerMeshLoadedObservable
  128575. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128576. */
  128577. get onControllerMeshLoaded(): Observable<WebVRController>;
  128578. private _rayLength;
  128579. private _useCustomVRButton;
  128580. private _teleportationRequested;
  128581. private _teleportActive;
  128582. private _floorMeshName;
  128583. private _floorMeshesCollection;
  128584. private _teleportationMode;
  128585. private _teleportationTime;
  128586. private _teleportationSpeed;
  128587. private _teleportationEasing;
  128588. private _rotationAllowed;
  128589. private _teleportBackwardsVector;
  128590. private _teleportationTarget;
  128591. private _isDefaultTeleportationTarget;
  128592. private _postProcessMove;
  128593. private _teleportationFillColor;
  128594. private _teleportationBorderColor;
  128595. private _rotationAngle;
  128596. private _haloCenter;
  128597. private _cameraGazer;
  128598. private _padSensibilityUp;
  128599. private _padSensibilityDown;
  128600. private _leftController;
  128601. private _rightController;
  128602. private _gazeColor;
  128603. private _laserColor;
  128604. private _pickedLaserColor;
  128605. private _pickedGazeColor;
  128606. /**
  128607. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128608. */
  128609. onNewMeshSelected: Observable<AbstractMesh>;
  128610. /**
  128611. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128612. * This observable will provide the mesh and the controller used to select the mesh
  128613. */
  128614. onMeshSelectedWithController: Observable<{
  128615. mesh: AbstractMesh;
  128616. controller: WebVRController;
  128617. }>;
  128618. /**
  128619. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128620. */
  128621. onNewMeshPicked: Observable<PickingInfo>;
  128622. private _circleEase;
  128623. /**
  128624. * Observable raised before camera teleportation
  128625. */
  128626. onBeforeCameraTeleport: Observable<Vector3>;
  128627. /**
  128628. * Observable raised after camera teleportation
  128629. */
  128630. onAfterCameraTeleport: Observable<Vector3>;
  128631. /**
  128632. * Observable raised when current selected mesh gets unselected
  128633. */
  128634. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128635. private _raySelectionPredicate;
  128636. /**
  128637. * To be optionaly changed by user to define custom ray selection
  128638. */
  128639. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128640. /**
  128641. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128642. */
  128643. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128644. /**
  128645. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128646. */
  128647. teleportationEnabled: boolean;
  128648. private _defaultHeight;
  128649. private _teleportationInitialized;
  128650. private _interactionsEnabled;
  128651. private _interactionsRequested;
  128652. private _displayGaze;
  128653. private _displayLaserPointer;
  128654. /**
  128655. * The mesh used to display where the user is going to teleport.
  128656. */
  128657. get teleportationTarget(): Mesh;
  128658. /**
  128659. * Sets the mesh to be used to display where the user is going to teleport.
  128660. */
  128661. set teleportationTarget(value: Mesh);
  128662. /**
  128663. * 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
  128664. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128665. * See https://doc.babylonjs.com/resources/baking_transformations
  128666. */
  128667. get gazeTrackerMesh(): Mesh;
  128668. set gazeTrackerMesh(value: Mesh);
  128669. /**
  128670. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128671. */
  128672. updateGazeTrackerScale: boolean;
  128673. /**
  128674. * If the gaze trackers color should be updated when selecting meshes
  128675. */
  128676. updateGazeTrackerColor: boolean;
  128677. /**
  128678. * If the controller laser color should be updated when selecting meshes
  128679. */
  128680. updateControllerLaserColor: boolean;
  128681. /**
  128682. * The gaze tracking mesh corresponding to the left controller
  128683. */
  128684. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128685. /**
  128686. * The gaze tracking mesh corresponding to the right controller
  128687. */
  128688. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128689. /**
  128690. * If the ray of the gaze should be displayed.
  128691. */
  128692. get displayGaze(): boolean;
  128693. /**
  128694. * Sets if the ray of the gaze should be displayed.
  128695. */
  128696. set displayGaze(value: boolean);
  128697. /**
  128698. * If the ray of the LaserPointer should be displayed.
  128699. */
  128700. get displayLaserPointer(): boolean;
  128701. /**
  128702. * Sets if the ray of the LaserPointer should be displayed.
  128703. */
  128704. set displayLaserPointer(value: boolean);
  128705. /**
  128706. * The deviceOrientationCamera used as the camera when not in VR.
  128707. */
  128708. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128709. /**
  128710. * Based on the current WebVR support, returns the current VR camera used.
  128711. */
  128712. get currentVRCamera(): Nullable<Camera>;
  128713. /**
  128714. * The webVRCamera which is used when in VR.
  128715. */
  128716. get webVRCamera(): WebVRFreeCamera;
  128717. /**
  128718. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128719. */
  128720. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128721. /**
  128722. * The html button that is used to trigger entering into VR.
  128723. */
  128724. get vrButton(): Nullable<HTMLButtonElement>;
  128725. private get _teleportationRequestInitiated();
  128726. /**
  128727. * Defines whether or not Pointer lock should be requested when switching to
  128728. * full screen.
  128729. */
  128730. requestPointerLockOnFullScreen: boolean;
  128731. /**
  128732. * If asking to force XR, this will be populated with the default xr experience
  128733. */
  128734. xr: WebXRDefaultExperience;
  128735. /**
  128736. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128737. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128738. */
  128739. xrTestDone: boolean;
  128740. /**
  128741. * Instantiates a VRExperienceHelper.
  128742. * Helps to quickly add VR support to an existing scene.
  128743. * @param scene The scene the VRExperienceHelper belongs to.
  128744. * @param webVROptions Options to modify the vr experience helper's behavior.
  128745. */
  128746. constructor(scene: Scene,
  128747. /** Options to modify the vr experience helper's behavior. */
  128748. webVROptions?: VRExperienceHelperOptions);
  128749. private completeVRInit;
  128750. private _onDefaultMeshLoaded;
  128751. private _onResize;
  128752. private _onFullscreenChange;
  128753. /**
  128754. * Gets a value indicating if we are currently in VR mode.
  128755. */
  128756. get isInVRMode(): boolean;
  128757. private onVrDisplayPresentChange;
  128758. private onVRDisplayChanged;
  128759. private moveButtonToBottomRight;
  128760. private displayVRButton;
  128761. private updateButtonVisibility;
  128762. private _cachedAngularSensibility;
  128763. /**
  128764. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128765. * Otherwise, will use the fullscreen API.
  128766. */
  128767. enterVR(): void;
  128768. /**
  128769. * Attempt to exit VR, or fullscreen.
  128770. */
  128771. exitVR(): void;
  128772. /**
  128773. * The position of the vr experience helper.
  128774. */
  128775. get position(): Vector3;
  128776. /**
  128777. * Sets the position of the vr experience helper.
  128778. */
  128779. set position(value: Vector3);
  128780. /**
  128781. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128782. */
  128783. enableInteractions(): void;
  128784. private get _noControllerIsActive();
  128785. private beforeRender;
  128786. private _isTeleportationFloor;
  128787. /**
  128788. * Adds a floor mesh to be used for teleportation.
  128789. * @param floorMesh the mesh to be used for teleportation.
  128790. */
  128791. addFloorMesh(floorMesh: Mesh): void;
  128792. /**
  128793. * Removes a floor mesh from being used for teleportation.
  128794. * @param floorMesh the mesh to be removed.
  128795. */
  128796. removeFloorMesh(floorMesh: Mesh): void;
  128797. /**
  128798. * Enables interactions and teleportation using the VR controllers and gaze.
  128799. * @param vrTeleportationOptions options to modify teleportation behavior.
  128800. */
  128801. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128802. private _onNewGamepadConnected;
  128803. private _tryEnableInteractionOnController;
  128804. private _onNewGamepadDisconnected;
  128805. private _enableInteractionOnController;
  128806. private _checkTeleportWithRay;
  128807. private _checkRotate;
  128808. private _checkTeleportBackwards;
  128809. private _enableTeleportationOnController;
  128810. private _createTeleportationCircles;
  128811. private _displayTeleportationTarget;
  128812. private _hideTeleportationTarget;
  128813. private _rotateCamera;
  128814. private _moveTeleportationSelectorTo;
  128815. private _workingVector;
  128816. private _workingQuaternion;
  128817. private _workingMatrix;
  128818. /**
  128819. * Time Constant Teleportation Mode
  128820. */
  128821. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128822. /**
  128823. * Speed Constant Teleportation Mode
  128824. */
  128825. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128826. /**
  128827. * Teleports the users feet to the desired location
  128828. * @param location The location where the user's feet should be placed
  128829. */
  128830. teleportCamera(location: Vector3): void;
  128831. private _convertNormalToDirectionOfRay;
  128832. private _castRayAndSelectObject;
  128833. private _notifySelectedMeshUnselected;
  128834. /**
  128835. * Permanently set new colors for the laser pointer
  128836. * @param color the new laser color
  128837. * @param pickedColor the new laser color when picked mesh detected
  128838. */
  128839. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128840. /**
  128841. * Set lighting enabled / disabled on the laser pointer of both controllers
  128842. * @param enabled should the lighting be enabled on the laser pointer
  128843. */
  128844. setLaserLightingState(enabled?: boolean): void;
  128845. /**
  128846. * Permanently set new colors for the gaze pointer
  128847. * @param color the new gaze color
  128848. * @param pickedColor the new gaze color when picked mesh detected
  128849. */
  128850. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128851. /**
  128852. * Sets the color of the laser ray from the vr controllers.
  128853. * @param color new color for the ray.
  128854. */
  128855. changeLaserColor(color: Color3): void;
  128856. /**
  128857. * Sets the color of the ray from the vr headsets gaze.
  128858. * @param color new color for the ray.
  128859. */
  128860. changeGazeColor(color: Color3): void;
  128861. /**
  128862. * Exits VR and disposes of the vr experience helper
  128863. */
  128864. dispose(): void;
  128865. /**
  128866. * Gets the name of the VRExperienceHelper class
  128867. * @returns "VRExperienceHelper"
  128868. */
  128869. getClassName(): string;
  128870. }
  128871. }
  128872. declare module BABYLON {
  128873. /**
  128874. * Contains an array of blocks representing the octree
  128875. */
  128876. export interface IOctreeContainer<T> {
  128877. /**
  128878. * Blocks within the octree
  128879. */
  128880. blocks: Array<OctreeBlock<T>>;
  128881. }
  128882. /**
  128883. * Class used to store a cell in an octree
  128884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128885. */
  128886. export class OctreeBlock<T> {
  128887. /**
  128888. * Gets the content of the current block
  128889. */
  128890. entries: T[];
  128891. /**
  128892. * Gets the list of block children
  128893. */
  128894. blocks: Array<OctreeBlock<T>>;
  128895. private _depth;
  128896. private _maxDepth;
  128897. private _capacity;
  128898. private _minPoint;
  128899. private _maxPoint;
  128900. private _boundingVectors;
  128901. private _creationFunc;
  128902. /**
  128903. * Creates a new block
  128904. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128905. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128906. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128907. * @param depth defines the current depth of this block in the octree
  128908. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128909. * @param creationFunc defines a callback to call when an element is added to the block
  128910. */
  128911. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128912. /**
  128913. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128914. */
  128915. get capacity(): number;
  128916. /**
  128917. * Gets the minimum vector (in world space) of the block's bounding box
  128918. */
  128919. get minPoint(): Vector3;
  128920. /**
  128921. * Gets the maximum vector (in world space) of the block's bounding box
  128922. */
  128923. get maxPoint(): Vector3;
  128924. /**
  128925. * Add a new element to this block
  128926. * @param entry defines the element to add
  128927. */
  128928. addEntry(entry: T): void;
  128929. /**
  128930. * Remove an element from this block
  128931. * @param entry defines the element to remove
  128932. */
  128933. removeEntry(entry: T): void;
  128934. /**
  128935. * Add an array of elements to this block
  128936. * @param entries defines the array of elements to add
  128937. */
  128938. addEntries(entries: T[]): void;
  128939. /**
  128940. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128941. * @param frustumPlanes defines the frustum planes to test
  128942. * @param selection defines the array to store current content if selection is positive
  128943. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128944. */
  128945. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128946. /**
  128947. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128948. * @param sphereCenter defines the bounding sphere center
  128949. * @param sphereRadius defines the bounding sphere radius
  128950. * @param selection defines the array to store current content if selection is positive
  128951. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128952. */
  128953. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128954. /**
  128955. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128956. * @param ray defines the ray to test with
  128957. * @param selection defines the array to store current content if selection is positive
  128958. */
  128959. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128960. /**
  128961. * Subdivide the content into child blocks (this block will then be empty)
  128962. */
  128963. createInnerBlocks(): void;
  128964. /**
  128965. * @hidden
  128966. */
  128967. 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;
  128968. }
  128969. }
  128970. declare module BABYLON {
  128971. /**
  128972. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128974. */
  128975. export class Octree<T> {
  128976. /** 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.) */
  128977. maxDepth: number;
  128978. /**
  128979. * Blocks within the octree containing objects
  128980. */
  128981. blocks: Array<OctreeBlock<T>>;
  128982. /**
  128983. * Content stored in the octree
  128984. */
  128985. dynamicContent: T[];
  128986. private _maxBlockCapacity;
  128987. private _selectionContent;
  128988. private _creationFunc;
  128989. /**
  128990. * Creates a octree
  128991. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128992. * @param creationFunc function to be used to instatiate the octree
  128993. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128994. * @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.)
  128995. */
  128996. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128997. /** 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.) */
  128998. maxDepth?: number);
  128999. /**
  129000. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129001. * @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);
  129002. * @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);
  129003. * @param entries meshes to be added to the octree blocks
  129004. */
  129005. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129006. /**
  129007. * Adds a mesh to the octree
  129008. * @param entry Mesh to add to the octree
  129009. */
  129010. addMesh(entry: T): void;
  129011. /**
  129012. * Remove an element from the octree
  129013. * @param entry defines the element to remove
  129014. */
  129015. removeMesh(entry: T): void;
  129016. /**
  129017. * Selects an array of meshes within the frustum
  129018. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129019. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129020. * @returns array of meshes within the frustum
  129021. */
  129022. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129023. /**
  129024. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129025. * @param sphereCenter defines the bounding sphere center
  129026. * @param sphereRadius defines the bounding sphere radius
  129027. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129028. * @returns an array of objects that intersect the sphere
  129029. */
  129030. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129031. /**
  129032. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129033. * @param ray defines the ray to test with
  129034. * @returns array of intersected objects
  129035. */
  129036. intersectsRay(ray: Ray): SmartArray<T>;
  129037. /**
  129038. * Adds a mesh into the octree block if it intersects the block
  129039. */
  129040. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129041. /**
  129042. * Adds a submesh into the octree block if it intersects the block
  129043. */
  129044. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129045. }
  129046. }
  129047. declare module BABYLON {
  129048. interface Scene {
  129049. /**
  129050. * @hidden
  129051. * Backing Filed
  129052. */
  129053. _selectionOctree: Octree<AbstractMesh>;
  129054. /**
  129055. * Gets the octree used to boost mesh selection (picking)
  129056. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129057. */
  129058. selectionOctree: Octree<AbstractMesh>;
  129059. /**
  129060. * Creates or updates the octree used to boost selection (picking)
  129061. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129062. * @param maxCapacity defines the maximum capacity per leaf
  129063. * @param maxDepth defines the maximum depth of the octree
  129064. * @returns an octree of AbstractMesh
  129065. */
  129066. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129067. }
  129068. interface AbstractMesh {
  129069. /**
  129070. * @hidden
  129071. * Backing Field
  129072. */
  129073. _submeshesOctree: Octree<SubMesh>;
  129074. /**
  129075. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129076. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129077. * @param maxCapacity defines the maximum size of each block (64 by default)
  129078. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129079. * @returns the new octree
  129080. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129081. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129082. */
  129083. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129084. }
  129085. /**
  129086. * Defines the octree scene component responsible to manage any octrees
  129087. * in a given scene.
  129088. */
  129089. export class OctreeSceneComponent {
  129090. /**
  129091. * The component name help to identify the component in the list of scene components.
  129092. */
  129093. readonly name: string;
  129094. /**
  129095. * The scene the component belongs to.
  129096. */
  129097. scene: Scene;
  129098. /**
  129099. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129100. */
  129101. readonly checksIsEnabled: boolean;
  129102. /**
  129103. * Creates a new instance of the component for the given scene
  129104. * @param scene Defines the scene to register the component in
  129105. */
  129106. constructor(scene: Scene);
  129107. /**
  129108. * Registers the component in a given scene
  129109. */
  129110. register(): void;
  129111. /**
  129112. * Return the list of active meshes
  129113. * @returns the list of active meshes
  129114. */
  129115. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129116. /**
  129117. * Return the list of active sub meshes
  129118. * @param mesh The mesh to get the candidates sub meshes from
  129119. * @returns the list of active sub meshes
  129120. */
  129121. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129122. private _tempRay;
  129123. /**
  129124. * Return the list of sub meshes intersecting with a given local ray
  129125. * @param mesh defines the mesh to find the submesh for
  129126. * @param localRay defines the ray in local space
  129127. * @returns the list of intersecting sub meshes
  129128. */
  129129. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129130. /**
  129131. * Return the list of sub meshes colliding with a collider
  129132. * @param mesh defines the mesh to find the submesh for
  129133. * @param collider defines the collider to evaluate the collision against
  129134. * @returns the list of colliding sub meshes
  129135. */
  129136. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129137. /**
  129138. * Rebuilds the elements related to this component in case of
  129139. * context lost for instance.
  129140. */
  129141. rebuild(): void;
  129142. /**
  129143. * Disposes the component and the associated ressources.
  129144. */
  129145. dispose(): void;
  129146. }
  129147. }
  129148. declare module BABYLON {
  129149. /**
  129150. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129151. */
  129152. export class Gizmo implements IDisposable {
  129153. /** The utility layer the gizmo will be added to */
  129154. gizmoLayer: UtilityLayerRenderer;
  129155. /**
  129156. * The root mesh of the gizmo
  129157. */
  129158. _rootMesh: Mesh;
  129159. private _attachedMesh;
  129160. private _attachedNode;
  129161. /**
  129162. * Ratio for the scale of the gizmo (Default: 1)
  129163. */
  129164. scaleRatio: number;
  129165. /**
  129166. * If a custom mesh has been set (Default: false)
  129167. */
  129168. protected _customMeshSet: boolean;
  129169. /**
  129170. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129171. * * When set, interactions will be enabled
  129172. */
  129173. get attachedMesh(): Nullable<AbstractMesh>;
  129174. set attachedMesh(value: Nullable<AbstractMesh>);
  129175. /**
  129176. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129177. * * When set, interactions will be enabled
  129178. */
  129179. get attachedNode(): Nullable<Node>;
  129180. set attachedNode(value: Nullable<Node>);
  129181. /**
  129182. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129183. * @param mesh The mesh to replace the default mesh of the gizmo
  129184. */
  129185. setCustomMesh(mesh: Mesh): void;
  129186. /**
  129187. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129188. */
  129189. updateGizmoRotationToMatchAttachedMesh: boolean;
  129190. /**
  129191. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129192. */
  129193. updateGizmoPositionToMatchAttachedMesh: boolean;
  129194. /**
  129195. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129196. */
  129197. updateScale: boolean;
  129198. protected _interactionsEnabled: boolean;
  129199. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129200. private _beforeRenderObserver;
  129201. private _tempQuaternion;
  129202. private _tempVector;
  129203. private _tempVector2;
  129204. /**
  129205. * Creates a gizmo
  129206. * @param gizmoLayer The utility layer the gizmo will be added to
  129207. */
  129208. constructor(
  129209. /** The utility layer the gizmo will be added to */
  129210. gizmoLayer?: UtilityLayerRenderer);
  129211. /**
  129212. * Updates the gizmo to match the attached mesh's position/rotation
  129213. */
  129214. protected _update(): void;
  129215. /**
  129216. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129217. * @param value Node, TransformNode or mesh
  129218. */
  129219. protected _matrixChanged(): void;
  129220. /**
  129221. * Disposes of the gizmo
  129222. */
  129223. dispose(): void;
  129224. }
  129225. }
  129226. declare module BABYLON {
  129227. /**
  129228. * Single plane drag gizmo
  129229. */
  129230. export class PlaneDragGizmo extends Gizmo {
  129231. /**
  129232. * Drag behavior responsible for the gizmos dragging interactions
  129233. */
  129234. dragBehavior: PointerDragBehavior;
  129235. private _pointerObserver;
  129236. /**
  129237. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129238. */
  129239. snapDistance: number;
  129240. /**
  129241. * Event that fires each time the gizmo snaps to a new location.
  129242. * * snapDistance is the the change in distance
  129243. */
  129244. onSnapObservable: Observable<{
  129245. snapDistance: number;
  129246. }>;
  129247. private _plane;
  129248. private _coloredMaterial;
  129249. private _hoverMaterial;
  129250. private _isEnabled;
  129251. private _parent;
  129252. /** @hidden */
  129253. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129254. /** @hidden */
  129255. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129256. /**
  129257. * Creates a PlaneDragGizmo
  129258. * @param gizmoLayer The utility layer the gizmo will be added to
  129259. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129260. * @param color The color of the gizmo
  129261. */
  129262. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129263. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129264. /**
  129265. * If the gizmo is enabled
  129266. */
  129267. set isEnabled(value: boolean);
  129268. get isEnabled(): boolean;
  129269. /**
  129270. * Disposes of the gizmo
  129271. */
  129272. dispose(): void;
  129273. }
  129274. }
  129275. declare module BABYLON {
  129276. /**
  129277. * Gizmo that enables dragging a mesh along 3 axis
  129278. */
  129279. export class PositionGizmo extends Gizmo {
  129280. /**
  129281. * Internal gizmo used for interactions on the x axis
  129282. */
  129283. xGizmo: AxisDragGizmo;
  129284. /**
  129285. * Internal gizmo used for interactions on the y axis
  129286. */
  129287. yGizmo: AxisDragGizmo;
  129288. /**
  129289. * Internal gizmo used for interactions on the z axis
  129290. */
  129291. zGizmo: AxisDragGizmo;
  129292. /**
  129293. * Internal gizmo used for interactions on the yz plane
  129294. */
  129295. xPlaneGizmo: PlaneDragGizmo;
  129296. /**
  129297. * Internal gizmo used for interactions on the xz plane
  129298. */
  129299. yPlaneGizmo: PlaneDragGizmo;
  129300. /**
  129301. * Internal gizmo used for interactions on the xy plane
  129302. */
  129303. zPlaneGizmo: PlaneDragGizmo;
  129304. /**
  129305. * private variables
  129306. */
  129307. private _meshAttached;
  129308. private _nodeAttached;
  129309. private _updateGizmoRotationToMatchAttachedMesh;
  129310. private _snapDistance;
  129311. private _scaleRatio;
  129312. /** Fires an event when any of it's sub gizmos are dragged */
  129313. onDragStartObservable: Observable<unknown>;
  129314. /** Fires an event when any of it's sub gizmos are released from dragging */
  129315. onDragEndObservable: Observable<unknown>;
  129316. /**
  129317. * If set to true, planar drag is enabled
  129318. */
  129319. private _planarGizmoEnabled;
  129320. get attachedMesh(): Nullable<AbstractMesh>;
  129321. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129322. get attachedNode(): Nullable<Node>;
  129323. set attachedNode(node: Nullable<Node>);
  129324. /**
  129325. * Creates a PositionGizmo
  129326. * @param gizmoLayer The utility layer the gizmo will be added to
  129327. @param thickness display gizmo axis thickness
  129328. */
  129329. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129330. /**
  129331. * If the planar drag gizmo is enabled
  129332. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129333. */
  129334. set planarGizmoEnabled(value: boolean);
  129335. get planarGizmoEnabled(): boolean;
  129336. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129337. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129338. /**
  129339. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129340. */
  129341. set snapDistance(value: number);
  129342. get snapDistance(): number;
  129343. /**
  129344. * Ratio for the scale of the gizmo (Default: 1)
  129345. */
  129346. set scaleRatio(value: number);
  129347. get scaleRatio(): number;
  129348. /**
  129349. * Disposes of the gizmo
  129350. */
  129351. dispose(): void;
  129352. /**
  129353. * CustomMeshes are not supported by this gizmo
  129354. * @param mesh The mesh to replace the default mesh of the gizmo
  129355. */
  129356. setCustomMesh(mesh: Mesh): void;
  129357. }
  129358. }
  129359. declare module BABYLON {
  129360. /**
  129361. * Single axis drag gizmo
  129362. */
  129363. export class AxisDragGizmo extends Gizmo {
  129364. /**
  129365. * Drag behavior responsible for the gizmos dragging interactions
  129366. */
  129367. dragBehavior: PointerDragBehavior;
  129368. private _pointerObserver;
  129369. /**
  129370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129371. */
  129372. snapDistance: number;
  129373. /**
  129374. * Event that fires each time the gizmo snaps to a new location.
  129375. * * snapDistance is the the change in distance
  129376. */
  129377. onSnapObservable: Observable<{
  129378. snapDistance: number;
  129379. }>;
  129380. private _isEnabled;
  129381. private _parent;
  129382. private _arrow;
  129383. private _coloredMaterial;
  129384. private _hoverMaterial;
  129385. /** @hidden */
  129386. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129387. /** @hidden */
  129388. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129389. /**
  129390. * Creates an AxisDragGizmo
  129391. * @param gizmoLayer The utility layer the gizmo will be added to
  129392. * @param dragAxis The axis which the gizmo will be able to drag on
  129393. * @param color The color of the gizmo
  129394. * @param thickness display gizmo axis thickness
  129395. */
  129396. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129397. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129398. /**
  129399. * If the gizmo is enabled
  129400. */
  129401. set isEnabled(value: boolean);
  129402. get isEnabled(): boolean;
  129403. /**
  129404. * Disposes of the gizmo
  129405. */
  129406. dispose(): void;
  129407. }
  129408. }
  129409. declare module BABYLON.Debug {
  129410. /**
  129411. * The Axes viewer will show 3 axes in a specific point in space
  129412. */
  129413. export class AxesViewer {
  129414. private _xAxis;
  129415. private _yAxis;
  129416. private _zAxis;
  129417. private _scaleLinesFactor;
  129418. private _instanced;
  129419. /**
  129420. * Gets the hosting scene
  129421. */
  129422. scene: Scene;
  129423. /**
  129424. * Gets or sets a number used to scale line length
  129425. */
  129426. scaleLines: number;
  129427. /** Gets the node hierarchy used to render x-axis */
  129428. get xAxis(): TransformNode;
  129429. /** Gets the node hierarchy used to render y-axis */
  129430. get yAxis(): TransformNode;
  129431. /** Gets the node hierarchy used to render z-axis */
  129432. get zAxis(): TransformNode;
  129433. /**
  129434. * Creates a new AxesViewer
  129435. * @param scene defines the hosting scene
  129436. * @param scaleLines defines a number used to scale line length (1 by default)
  129437. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129438. * @param xAxis defines the node hierarchy used to render the x-axis
  129439. * @param yAxis defines the node hierarchy used to render the y-axis
  129440. * @param zAxis defines the node hierarchy used to render the z-axis
  129441. */
  129442. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129443. /**
  129444. * Force the viewer to update
  129445. * @param position defines the position of the viewer
  129446. * @param xaxis defines the x axis of the viewer
  129447. * @param yaxis defines the y axis of the viewer
  129448. * @param zaxis defines the z axis of the viewer
  129449. */
  129450. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129451. /**
  129452. * Creates an instance of this axes viewer.
  129453. * @returns a new axes viewer with instanced meshes
  129454. */
  129455. createInstance(): AxesViewer;
  129456. /** Releases resources */
  129457. dispose(): void;
  129458. private static _SetRenderingGroupId;
  129459. }
  129460. }
  129461. declare module BABYLON.Debug {
  129462. /**
  129463. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129464. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129465. */
  129466. export class BoneAxesViewer extends AxesViewer {
  129467. /**
  129468. * Gets or sets the target mesh where to display the axes viewer
  129469. */
  129470. mesh: Nullable<Mesh>;
  129471. /**
  129472. * Gets or sets the target bone where to display the axes viewer
  129473. */
  129474. bone: Nullable<Bone>;
  129475. /** Gets current position */
  129476. pos: Vector3;
  129477. /** Gets direction of X axis */
  129478. xaxis: Vector3;
  129479. /** Gets direction of Y axis */
  129480. yaxis: Vector3;
  129481. /** Gets direction of Z axis */
  129482. zaxis: Vector3;
  129483. /**
  129484. * Creates a new BoneAxesViewer
  129485. * @param scene defines the hosting scene
  129486. * @param bone defines the target bone
  129487. * @param mesh defines the target mesh
  129488. * @param scaleLines defines a scaling factor for line length (1 by default)
  129489. */
  129490. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129491. /**
  129492. * Force the viewer to update
  129493. */
  129494. update(): void;
  129495. /** Releases resources */
  129496. dispose(): void;
  129497. }
  129498. }
  129499. declare module BABYLON {
  129500. /**
  129501. * Interface used to define scene explorer extensibility option
  129502. */
  129503. export interface IExplorerExtensibilityOption {
  129504. /**
  129505. * Define the option label
  129506. */
  129507. label: string;
  129508. /**
  129509. * Defines the action to execute on click
  129510. */
  129511. action: (entity: any) => void;
  129512. }
  129513. /**
  129514. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129515. */
  129516. export interface IExplorerExtensibilityGroup {
  129517. /**
  129518. * Defines a predicate to test if a given type mut be extended
  129519. */
  129520. predicate: (entity: any) => boolean;
  129521. /**
  129522. * Gets the list of options added to a type
  129523. */
  129524. entries: IExplorerExtensibilityOption[];
  129525. }
  129526. /**
  129527. * Interface used to define the options to use to create the Inspector
  129528. */
  129529. export interface IInspectorOptions {
  129530. /**
  129531. * Display in overlay mode (default: false)
  129532. */
  129533. overlay?: boolean;
  129534. /**
  129535. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129536. */
  129537. globalRoot?: HTMLElement;
  129538. /**
  129539. * Display the Scene explorer
  129540. */
  129541. showExplorer?: boolean;
  129542. /**
  129543. * Display the property inspector
  129544. */
  129545. showInspector?: boolean;
  129546. /**
  129547. * Display in embed mode (both panes on the right)
  129548. */
  129549. embedMode?: boolean;
  129550. /**
  129551. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129552. */
  129553. handleResize?: boolean;
  129554. /**
  129555. * Allow the panes to popup (default: true)
  129556. */
  129557. enablePopup?: boolean;
  129558. /**
  129559. * Allow the panes to be closed by users (default: true)
  129560. */
  129561. enableClose?: boolean;
  129562. /**
  129563. * Optional list of extensibility entries
  129564. */
  129565. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129566. /**
  129567. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129568. */
  129569. inspectorURL?: string;
  129570. /**
  129571. * Optional initial tab (default to DebugLayerTab.Properties)
  129572. */
  129573. initialTab?: DebugLayerTab;
  129574. }
  129575. interface Scene {
  129576. /**
  129577. * @hidden
  129578. * Backing field
  129579. */
  129580. _debugLayer: DebugLayer;
  129581. /**
  129582. * Gets the debug layer (aka Inspector) associated with the scene
  129583. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129584. */
  129585. debugLayer: DebugLayer;
  129586. }
  129587. /**
  129588. * Enum of inspector action tab
  129589. */
  129590. export enum DebugLayerTab {
  129591. /**
  129592. * Properties tag (default)
  129593. */
  129594. Properties = 0,
  129595. /**
  129596. * Debug tab
  129597. */
  129598. Debug = 1,
  129599. /**
  129600. * Statistics tab
  129601. */
  129602. Statistics = 2,
  129603. /**
  129604. * Tools tab
  129605. */
  129606. Tools = 3,
  129607. /**
  129608. * Settings tab
  129609. */
  129610. Settings = 4
  129611. }
  129612. /**
  129613. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129614. * what is happening in your scene
  129615. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129616. */
  129617. export class DebugLayer {
  129618. /**
  129619. * Define the url to get the inspector script from.
  129620. * By default it uses the babylonjs CDN.
  129621. * @ignoreNaming
  129622. */
  129623. static InspectorURL: string;
  129624. private _scene;
  129625. private BJSINSPECTOR;
  129626. private _onPropertyChangedObservable?;
  129627. /**
  129628. * Observable triggered when a property is changed through the inspector.
  129629. */
  129630. get onPropertyChangedObservable(): any;
  129631. /**
  129632. * Instantiates a new debug layer.
  129633. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129634. * what is happening in your scene
  129635. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129636. * @param scene Defines the scene to inspect
  129637. */
  129638. constructor(scene: Scene);
  129639. /** Creates the inspector window. */
  129640. private _createInspector;
  129641. /**
  129642. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129643. * @param entity defines the entity to select
  129644. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129645. */
  129646. select(entity: any, lineContainerTitles?: string | string[]): void;
  129647. /** Get the inspector from bundle or global */
  129648. private _getGlobalInspector;
  129649. /**
  129650. * Get if the inspector is visible or not.
  129651. * @returns true if visible otherwise, false
  129652. */
  129653. isVisible(): boolean;
  129654. /**
  129655. * Hide the inspector and close its window.
  129656. */
  129657. hide(): void;
  129658. /**
  129659. * Update the scene in the inspector
  129660. */
  129661. setAsActiveScene(): void;
  129662. /**
  129663. * Launch the debugLayer.
  129664. * @param config Define the configuration of the inspector
  129665. * @return a promise fulfilled when the debug layer is visible
  129666. */
  129667. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129668. }
  129669. }
  129670. declare module BABYLON {
  129671. /**
  129672. * Class containing static functions to help procedurally build meshes
  129673. */
  129674. export class BoxBuilder {
  129675. /**
  129676. * Creates a box mesh
  129677. * * The parameter `size` sets the size (float) of each box side (default 1)
  129678. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129679. * * 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)
  129680. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129684. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129685. * @param name defines the name of the mesh
  129686. * @param options defines the options used to create the mesh
  129687. * @param scene defines the hosting scene
  129688. * @returns the box mesh
  129689. */
  129690. static CreateBox(name: string, options: {
  129691. size?: number;
  129692. width?: number;
  129693. height?: number;
  129694. depth?: number;
  129695. faceUV?: Vector4[];
  129696. faceColors?: Color4[];
  129697. sideOrientation?: number;
  129698. frontUVs?: Vector4;
  129699. backUVs?: Vector4;
  129700. wrap?: boolean;
  129701. topBaseAt?: number;
  129702. bottomBaseAt?: number;
  129703. updatable?: boolean;
  129704. }, scene?: Nullable<Scene>): Mesh;
  129705. }
  129706. }
  129707. declare module BABYLON.Debug {
  129708. /**
  129709. * Used to show the physics impostor around the specific mesh
  129710. */
  129711. export class PhysicsViewer {
  129712. /** @hidden */
  129713. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129714. /** @hidden */
  129715. protected _meshes: Array<Nullable<AbstractMesh>>;
  129716. /** @hidden */
  129717. protected _scene: Nullable<Scene>;
  129718. /** @hidden */
  129719. protected _numMeshes: number;
  129720. /** @hidden */
  129721. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129722. private _renderFunction;
  129723. private _utilityLayer;
  129724. private _debugBoxMesh;
  129725. private _debugSphereMesh;
  129726. private _debugCylinderMesh;
  129727. private _debugMaterial;
  129728. private _debugMeshMeshes;
  129729. /**
  129730. * Creates a new PhysicsViewer
  129731. * @param scene defines the hosting scene
  129732. */
  129733. constructor(scene: Scene);
  129734. /** @hidden */
  129735. protected _updateDebugMeshes(): void;
  129736. /**
  129737. * Renders a specified physic impostor
  129738. * @param impostor defines the impostor to render
  129739. * @param targetMesh defines the mesh represented by the impostor
  129740. * @returns the new debug mesh used to render the impostor
  129741. */
  129742. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129743. /**
  129744. * Hides a specified physic impostor
  129745. * @param impostor defines the impostor to hide
  129746. */
  129747. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129748. private _getDebugMaterial;
  129749. private _getDebugBoxMesh;
  129750. private _getDebugSphereMesh;
  129751. private _getDebugCylinderMesh;
  129752. private _getDebugMeshMesh;
  129753. private _getDebugMesh;
  129754. /** Releases all resources */
  129755. dispose(): void;
  129756. }
  129757. }
  129758. declare module BABYLON {
  129759. /**
  129760. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129761. * in order to better appreciate the issue one might have.
  129762. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129763. */
  129764. export class RayHelper {
  129765. /**
  129766. * Defines the ray we are currently tryin to visualize.
  129767. */
  129768. ray: Nullable<Ray>;
  129769. private _renderPoints;
  129770. private _renderLine;
  129771. private _renderFunction;
  129772. private _scene;
  129773. private _updateToMeshFunction;
  129774. private _onAfterStepObserver;
  129775. private _attachedToMesh;
  129776. private _meshSpaceDirection;
  129777. private _meshSpaceOrigin;
  129778. /**
  129779. * Helper function to create a colored helper in a scene in one line.
  129780. * @param ray Defines the ray we are currently tryin to visualize
  129781. * @param scene Defines the scene the ray is used in
  129782. * @param color Defines the color we want to see the ray in
  129783. * @returns The newly created ray helper.
  129784. */
  129785. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129786. /**
  129787. * Instantiate a new ray helper.
  129788. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129789. * in order to better appreciate the issue one might have.
  129790. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129791. * @param ray Defines the ray we are currently tryin to visualize
  129792. */
  129793. constructor(ray: Ray);
  129794. /**
  129795. * Shows the ray we are willing to debug.
  129796. * @param scene Defines the scene the ray needs to be rendered in
  129797. * @param color Defines the color the ray needs to be rendered in
  129798. */
  129799. show(scene: Scene, color?: Color3): void;
  129800. /**
  129801. * Hides the ray we are debugging.
  129802. */
  129803. hide(): void;
  129804. private _render;
  129805. /**
  129806. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129807. * @param mesh Defines the mesh we want the helper attached to
  129808. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129809. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129810. * @param length Defines the length of the ray
  129811. */
  129812. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129813. /**
  129814. * Detach the ray helper from the mesh it has previously been attached to.
  129815. */
  129816. detachFromMesh(): void;
  129817. private _updateToMesh;
  129818. /**
  129819. * Dispose the helper and release its associated resources.
  129820. */
  129821. dispose(): void;
  129822. }
  129823. }
  129824. declare module BABYLON {
  129825. /**
  129826. * Defines the options associated with the creation of a SkeletonViewer.
  129827. */
  129828. export interface ISkeletonViewerOptions {
  129829. /** Should the system pause animations before building the Viewer? */
  129830. pauseAnimations: boolean;
  129831. /** Should the system return the skeleton to rest before building? */
  129832. returnToRest: boolean;
  129833. /** public Display Mode of the Viewer */
  129834. displayMode: number;
  129835. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129836. displayOptions: ISkeletonViewerDisplayOptions;
  129837. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129838. computeBonesUsingShaders: boolean;
  129839. }
  129840. /**
  129841. * Defines how to display the various bone meshes for the viewer.
  129842. */
  129843. export interface ISkeletonViewerDisplayOptions {
  129844. /** How far down to start tapering the bone spurs */
  129845. midStep?: number;
  129846. /** How big is the midStep? */
  129847. midStepFactor?: number;
  129848. /** Base for the Sphere Size */
  129849. sphereBaseSize?: number;
  129850. /** The ratio of the sphere to the longest bone in units */
  129851. sphereScaleUnit?: number;
  129852. /** Ratio for the Sphere Size */
  129853. sphereFactor?: number;
  129854. }
  129855. }
  129856. declare module BABYLON {
  129857. /**
  129858. * Class containing static functions to help procedurally build meshes
  129859. */
  129860. export class RibbonBuilder {
  129861. /**
  129862. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129863. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129864. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129865. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129866. * * 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
  129867. * * 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
  129868. * * 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
  129869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129872. * * 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
  129873. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129874. * * 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
  129875. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129877. * @param name defines the name of the mesh
  129878. * @param options defines the options used to create the mesh
  129879. * @param scene defines the hosting scene
  129880. * @returns the ribbon mesh
  129881. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129882. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129883. */
  129884. static CreateRibbon(name: string, options: {
  129885. pathArray: Vector3[][];
  129886. closeArray?: boolean;
  129887. closePath?: boolean;
  129888. offset?: number;
  129889. updatable?: boolean;
  129890. sideOrientation?: number;
  129891. frontUVs?: Vector4;
  129892. backUVs?: Vector4;
  129893. instance?: Mesh;
  129894. invertUV?: boolean;
  129895. uvs?: Vector2[];
  129896. colors?: Color4[];
  129897. }, scene?: Nullable<Scene>): Mesh;
  129898. }
  129899. }
  129900. declare module BABYLON {
  129901. /**
  129902. * Class containing static functions to help procedurally build meshes
  129903. */
  129904. export class ShapeBuilder {
  129905. /**
  129906. * 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.
  129907. * * 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.
  129908. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129909. * * 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.
  129910. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129911. * * 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
  129912. * * 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
  129913. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129918. * @param name defines the name of the mesh
  129919. * @param options defines the options used to create the mesh
  129920. * @param scene defines the hosting scene
  129921. * @returns the extruded shape mesh
  129922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129924. */
  129925. static ExtrudeShape(name: string, options: {
  129926. shape: Vector3[];
  129927. path: Vector3[];
  129928. scale?: number;
  129929. rotation?: number;
  129930. cap?: number;
  129931. updatable?: boolean;
  129932. sideOrientation?: number;
  129933. frontUVs?: Vector4;
  129934. backUVs?: Vector4;
  129935. instance?: Mesh;
  129936. invertUV?: boolean;
  129937. }, scene?: Nullable<Scene>): Mesh;
  129938. /**
  129939. * Creates an custom extruded shape mesh.
  129940. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129941. * * 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.
  129942. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129943. * * 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
  129944. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129945. * * 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
  129946. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129947. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129948. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129949. * * 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
  129950. * * 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
  129951. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129956. * @param name defines the name of the mesh
  129957. * @param options defines the options used to create the mesh
  129958. * @param scene defines the hosting scene
  129959. * @returns the custom extruded shape mesh
  129960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129963. */
  129964. static ExtrudeShapeCustom(name: string, options: {
  129965. shape: Vector3[];
  129966. path: Vector3[];
  129967. scaleFunction?: any;
  129968. rotationFunction?: any;
  129969. ribbonCloseArray?: boolean;
  129970. ribbonClosePath?: boolean;
  129971. cap?: number;
  129972. updatable?: boolean;
  129973. sideOrientation?: number;
  129974. frontUVs?: Vector4;
  129975. backUVs?: Vector4;
  129976. instance?: Mesh;
  129977. invertUV?: boolean;
  129978. }, scene?: Nullable<Scene>): Mesh;
  129979. private static _ExtrudeShapeGeneric;
  129980. }
  129981. }
  129982. declare module BABYLON.Debug {
  129983. /**
  129984. * Class used to render a debug view of a given skeleton
  129985. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129986. */
  129987. export class SkeletonViewer {
  129988. /** defines the skeleton to render */
  129989. skeleton: Skeleton;
  129990. /** defines the mesh attached to the skeleton */
  129991. mesh: AbstractMesh;
  129992. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129993. autoUpdateBonesMatrices: boolean;
  129994. /** defines the rendering group id to use with the viewer */
  129995. renderingGroupId: number;
  129996. /** is the options for the viewer */
  129997. options: Partial<ISkeletonViewerOptions>;
  129998. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  129999. static readonly DISPLAY_LINES: number;
  130000. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130001. static readonly DISPLAY_SPHERES: number;
  130002. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130003. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130004. /** If SkeletonViewer scene scope. */
  130005. private _scene;
  130006. /** Gets or sets the color used to render the skeleton */
  130007. color: Color3;
  130008. /** Array of the points of the skeleton fo the line view. */
  130009. private _debugLines;
  130010. /** The SkeletonViewers Mesh. */
  130011. private _debugMesh;
  130012. /** If SkeletonViewer is enabled. */
  130013. private _isEnabled;
  130014. /** If SkeletonViewer is ready. */
  130015. private _ready;
  130016. /** SkeletonViewer render observable. */
  130017. private _obs;
  130018. /** The Utility Layer to render the gizmos in. */
  130019. private _utilityLayer;
  130020. private _boneIndices;
  130021. /** Gets the Scene. */
  130022. get scene(): Scene;
  130023. /** Gets the utilityLayer. */
  130024. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130025. /** Checks Ready Status. */
  130026. get isReady(): Boolean;
  130027. /** Sets Ready Status. */
  130028. set ready(value: boolean);
  130029. /** Gets the debugMesh */
  130030. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130031. /** Sets the debugMesh */
  130032. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130033. /** Gets the material */
  130034. get material(): StandardMaterial;
  130035. /** Sets the material */
  130036. set material(value: StandardMaterial);
  130037. /** Gets the material */
  130038. get displayMode(): number;
  130039. /** Sets the material */
  130040. set displayMode(value: number);
  130041. /**
  130042. * Creates a new SkeletonViewer
  130043. * @param skeleton defines the skeleton to render
  130044. * @param mesh defines the mesh attached to the skeleton
  130045. * @param scene defines the hosting scene
  130046. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130047. * @param renderingGroupId defines the rendering group id to use with the viewer
  130048. * @param options All of the extra constructor options for the SkeletonViewer
  130049. */
  130050. constructor(
  130051. /** defines the skeleton to render */
  130052. skeleton: Skeleton,
  130053. /** defines the mesh attached to the skeleton */
  130054. mesh: AbstractMesh,
  130055. /** The Scene scope*/
  130056. scene: Scene,
  130057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130058. autoUpdateBonesMatrices?: boolean,
  130059. /** defines the rendering group id to use with the viewer */
  130060. renderingGroupId?: number,
  130061. /** is the options for the viewer */
  130062. options?: Partial<ISkeletonViewerOptions>);
  130063. /** The Dynamic bindings for the update functions */
  130064. private _bindObs;
  130065. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130066. update(): void;
  130067. /** Gets or sets a boolean indicating if the viewer is enabled */
  130068. set isEnabled(value: boolean);
  130069. get isEnabled(): boolean;
  130070. private _getBonePosition;
  130071. private _getLinesForBonesWithLength;
  130072. private _getLinesForBonesNoLength;
  130073. /** function to revert the mesh and scene back to the initial state. */
  130074. private _revert;
  130075. /** function to build and bind sphere joint points and spur bone representations. */
  130076. private _buildSpheresAndSpurs;
  130077. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130078. private _displayLinesUpdate;
  130079. /** Changes the displayMode of the skeleton viewer
  130080. * @param mode The displayMode numerical value
  130081. */
  130082. changeDisplayMode(mode: number): void;
  130083. /** Changes the displayMode of the skeleton viewer
  130084. * @param option String of the option name
  130085. * @param value The numerical option value
  130086. */
  130087. changeDisplayOptions(option: string, value: number): void;
  130088. /** Release associated resources */
  130089. dispose(): void;
  130090. }
  130091. }
  130092. declare module BABYLON {
  130093. /**
  130094. * Enum for Device Types
  130095. */
  130096. export enum DeviceType {
  130097. /** Generic */
  130098. Generic = 0,
  130099. /** Keyboard */
  130100. Keyboard = 1,
  130101. /** Mouse */
  130102. Mouse = 2,
  130103. /** Touch Pointers */
  130104. Touch = 3,
  130105. /** PS4 Dual Shock */
  130106. DualShock = 4,
  130107. /** Xbox */
  130108. Xbox = 5,
  130109. /** Switch Controller */
  130110. Switch = 6
  130111. }
  130112. /**
  130113. * Enum for All Pointers (Touch/Mouse)
  130114. */
  130115. export enum PointerInput {
  130116. /** Horizontal Axis */
  130117. Horizontal = 0,
  130118. /** Vertical Axis */
  130119. Vertical = 1,
  130120. /** Left Click or Touch */
  130121. LeftClick = 2,
  130122. /** Middle Click */
  130123. MiddleClick = 3,
  130124. /** Right Click */
  130125. RightClick = 4,
  130126. /** Browser Back */
  130127. BrowserBack = 5,
  130128. /** Browser Forward */
  130129. BrowserForward = 6
  130130. }
  130131. /**
  130132. * Enum for Dual Shock Gamepad
  130133. */
  130134. export enum DualShockInput {
  130135. /** Cross */
  130136. Cross = 0,
  130137. /** Circle */
  130138. Circle = 1,
  130139. /** Square */
  130140. Square = 2,
  130141. /** Triangle */
  130142. Triangle = 3,
  130143. /** L1 */
  130144. L1 = 4,
  130145. /** R1 */
  130146. R1 = 5,
  130147. /** L2 */
  130148. L2 = 6,
  130149. /** R2 */
  130150. R2 = 7,
  130151. /** Share */
  130152. Share = 8,
  130153. /** Options */
  130154. Options = 9,
  130155. /** L3 */
  130156. L3 = 10,
  130157. /** R3 */
  130158. R3 = 11,
  130159. /** DPadUp */
  130160. DPadUp = 12,
  130161. /** DPadDown */
  130162. DPadDown = 13,
  130163. /** DPadLeft */
  130164. DPadLeft = 14,
  130165. /** DRight */
  130166. DPadRight = 15,
  130167. /** Home */
  130168. Home = 16,
  130169. /** TouchPad */
  130170. TouchPad = 17,
  130171. /** LStickXAxis */
  130172. LStickXAxis = 18,
  130173. /** LStickYAxis */
  130174. LStickYAxis = 19,
  130175. /** RStickXAxis */
  130176. RStickXAxis = 20,
  130177. /** RStickYAxis */
  130178. RStickYAxis = 21
  130179. }
  130180. /**
  130181. * Enum for Xbox Gamepad
  130182. */
  130183. export enum XboxInput {
  130184. /** A */
  130185. A = 0,
  130186. /** B */
  130187. B = 1,
  130188. /** X */
  130189. X = 2,
  130190. /** Y */
  130191. Y = 3,
  130192. /** LB */
  130193. LB = 4,
  130194. /** RB */
  130195. RB = 5,
  130196. /** LT */
  130197. LT = 6,
  130198. /** RT */
  130199. RT = 7,
  130200. /** Back */
  130201. Back = 8,
  130202. /** Start */
  130203. Start = 9,
  130204. /** LS */
  130205. LS = 10,
  130206. /** RS */
  130207. RS = 11,
  130208. /** DPadUp */
  130209. DPadUp = 12,
  130210. /** DPadDown */
  130211. DPadDown = 13,
  130212. /** DPadLeft */
  130213. DPadLeft = 14,
  130214. /** DRight */
  130215. DPadRight = 15,
  130216. /** Home */
  130217. Home = 16,
  130218. /** LStickXAxis */
  130219. LStickXAxis = 17,
  130220. /** LStickYAxis */
  130221. LStickYAxis = 18,
  130222. /** RStickXAxis */
  130223. RStickXAxis = 19,
  130224. /** RStickYAxis */
  130225. RStickYAxis = 20
  130226. }
  130227. /**
  130228. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130229. */
  130230. export enum SwitchInput {
  130231. /** B */
  130232. B = 0,
  130233. /** A */
  130234. A = 1,
  130235. /** Y */
  130236. Y = 2,
  130237. /** X */
  130238. X = 3,
  130239. /** L */
  130240. L = 4,
  130241. /** R */
  130242. R = 5,
  130243. /** ZL */
  130244. ZL = 6,
  130245. /** ZR */
  130246. ZR = 7,
  130247. /** Minus */
  130248. Minus = 8,
  130249. /** Plus */
  130250. Plus = 9,
  130251. /** LS */
  130252. LS = 10,
  130253. /** RS */
  130254. RS = 11,
  130255. /** DPadUp */
  130256. DPadUp = 12,
  130257. /** DPadDown */
  130258. DPadDown = 13,
  130259. /** DPadLeft */
  130260. DPadLeft = 14,
  130261. /** DRight */
  130262. DPadRight = 15,
  130263. /** Home */
  130264. Home = 16,
  130265. /** Capture */
  130266. Capture = 17,
  130267. /** LStickXAxis */
  130268. LStickXAxis = 18,
  130269. /** LStickYAxis */
  130270. LStickYAxis = 19,
  130271. /** RStickXAxis */
  130272. RStickXAxis = 20,
  130273. /** RStickYAxis */
  130274. RStickYAxis = 21
  130275. }
  130276. }
  130277. declare module BABYLON {
  130278. /**
  130279. * This class will take all inputs from Keyboard, Pointer, and
  130280. * any Gamepads and provide a polling system that all devices
  130281. * will use. This class assumes that there will only be one
  130282. * pointer device and one keyboard.
  130283. */
  130284. export class DeviceInputSystem implements IDisposable {
  130285. /**
  130286. * Callback to be triggered when a device is connected
  130287. */
  130288. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130289. /**
  130290. * Callback to be triggered when a device is disconnected
  130291. */
  130292. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130293. /**
  130294. * Callback to be triggered when event driven input is updated
  130295. */
  130296. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130297. private _inputs;
  130298. private _gamepads;
  130299. private _keyboardActive;
  130300. private _pointerActive;
  130301. private _elementToAttachTo;
  130302. private _keyboardDownEvent;
  130303. private _keyboardUpEvent;
  130304. private _pointerMoveEvent;
  130305. private _pointerDownEvent;
  130306. private _pointerUpEvent;
  130307. private _gamepadConnectedEvent;
  130308. private _gamepadDisconnectedEvent;
  130309. private static _MAX_KEYCODES;
  130310. private static _MAX_POINTER_INPUTS;
  130311. private constructor();
  130312. /**
  130313. * Creates a new DeviceInputSystem instance
  130314. * @param engine Engine to pull input element from
  130315. * @returns The new instance
  130316. */
  130317. static Create(engine: Engine): DeviceInputSystem;
  130318. /**
  130319. * Checks for current device input value, given an id and input index
  130320. * @param deviceName Id of connected device
  130321. * @param inputIndex Index of device input
  130322. * @returns Current value of input
  130323. */
  130324. /**
  130325. * Checks for current device input value, given an id and input index
  130326. * @param deviceType Enum specifiying device type
  130327. * @param deviceSlot "Slot" or index that device is referenced in
  130328. * @param inputIndex Id of input to be checked
  130329. * @returns Current value of input
  130330. */
  130331. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130332. /**
  130333. * Dispose of all the eventlisteners
  130334. */
  130335. dispose(): void;
  130336. /**
  130337. * Add device and inputs to device array
  130338. * @param deviceType Enum specifiying device type
  130339. * @param deviceSlot "Slot" or index that device is referenced in
  130340. * @param numberOfInputs Number of input entries to create for given device
  130341. */
  130342. private _registerDevice;
  130343. /**
  130344. * Given a specific device name, remove that device from the device map
  130345. * @param deviceType Enum specifiying device type
  130346. * @param deviceSlot "Slot" or index that device is referenced in
  130347. */
  130348. private _unregisterDevice;
  130349. /**
  130350. * Handle all actions that come from keyboard interaction
  130351. */
  130352. private _handleKeyActions;
  130353. /**
  130354. * Handle all actions that come from pointer interaction
  130355. */
  130356. private _handlePointerActions;
  130357. /**
  130358. * Handle all actions that come from gamepad interaction
  130359. */
  130360. private _handleGamepadActions;
  130361. /**
  130362. * Update all non-event based devices with each frame
  130363. * @param deviceType Enum specifiying device type
  130364. * @param deviceSlot "Slot" or index that device is referenced in
  130365. * @param inputIndex Id of input to be checked
  130366. */
  130367. private _updateDevice;
  130368. /**
  130369. * Gets DeviceType from the device name
  130370. * @param deviceName Name of Device from DeviceInputSystem
  130371. * @returns DeviceType enum value
  130372. */
  130373. private _getGamepadDeviceType;
  130374. }
  130375. }
  130376. declare module BABYLON {
  130377. /**
  130378. * Type to handle enforcement of inputs
  130379. */
  130380. 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;
  130381. }
  130382. declare module BABYLON {
  130383. /**
  130384. * Class that handles all input for a specific device
  130385. */
  130386. export class DeviceSource<T extends DeviceType> {
  130387. /** Type of device */
  130388. readonly deviceType: DeviceType;
  130389. /** "Slot" or index that device is referenced in */
  130390. readonly deviceSlot: number;
  130391. /**
  130392. * Observable to handle device input changes per device
  130393. */
  130394. readonly onInputChangedObservable: Observable<{
  130395. inputIndex: DeviceInput<T>;
  130396. previousState: Nullable<number>;
  130397. currentState: Nullable<number>;
  130398. }>;
  130399. private readonly _deviceInputSystem;
  130400. /**
  130401. * Default Constructor
  130402. * @param deviceInputSystem Reference to DeviceInputSystem
  130403. * @param deviceType Type of device
  130404. * @param deviceSlot "Slot" or index that device is referenced in
  130405. */
  130406. constructor(deviceInputSystem: DeviceInputSystem,
  130407. /** Type of device */
  130408. deviceType: DeviceType,
  130409. /** "Slot" or index that device is referenced in */
  130410. deviceSlot?: number);
  130411. /**
  130412. * Get input for specific input
  130413. * @param inputIndex index of specific input on device
  130414. * @returns Input value from DeviceInputSystem
  130415. */
  130416. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130417. }
  130418. /**
  130419. * Class to keep track of devices
  130420. */
  130421. export class DeviceSourceManager implements IDisposable {
  130422. /**
  130423. * Observable to be triggered when before a device is connected
  130424. */
  130425. readonly onBeforeDeviceConnectedObservable: Observable<{
  130426. deviceType: DeviceType;
  130427. deviceSlot: number;
  130428. }>;
  130429. /**
  130430. * Observable to be triggered when before a device is disconnected
  130431. */
  130432. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130433. deviceType: DeviceType;
  130434. deviceSlot: number;
  130435. }>;
  130436. /**
  130437. * Observable to be triggered when after a device is connected
  130438. */
  130439. readonly onAfterDeviceConnectedObservable: Observable<{
  130440. deviceType: DeviceType;
  130441. deviceSlot: number;
  130442. }>;
  130443. /**
  130444. * Observable to be triggered when after a device is disconnected
  130445. */
  130446. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130447. deviceType: DeviceType;
  130448. deviceSlot: number;
  130449. }>;
  130450. private readonly _devices;
  130451. private readonly _firstDevice;
  130452. private readonly _deviceInputSystem;
  130453. /**
  130454. * Default Constructor
  130455. * @param engine engine to pull input element from
  130456. */
  130457. constructor(engine: Engine);
  130458. /**
  130459. * Gets a DeviceSource, given a type and slot
  130460. * @param deviceType Enum specifying device type
  130461. * @param deviceSlot "Slot" or index that device is referenced in
  130462. * @returns DeviceSource object
  130463. */
  130464. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130465. /**
  130466. * Gets an array of DeviceSource objects for a given device type
  130467. * @param deviceType Enum specifying device type
  130468. * @returns Array of DeviceSource objects
  130469. */
  130470. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130471. /**
  130472. * Dispose of DeviceInputSystem and other parts
  130473. */
  130474. dispose(): void;
  130475. /**
  130476. * Function to add device name to device list
  130477. * @param deviceType Enum specifying device type
  130478. * @param deviceSlot "Slot" or index that device is referenced in
  130479. */
  130480. private _addDevice;
  130481. /**
  130482. * Function to remove device name to device list
  130483. * @param deviceType Enum specifying device type
  130484. * @param deviceSlot "Slot" or index that device is referenced in
  130485. */
  130486. private _removeDevice;
  130487. /**
  130488. * Updates array storing first connected device of each type
  130489. * @param type Type of Device
  130490. */
  130491. private _updateFirstDevices;
  130492. }
  130493. }
  130494. declare module BABYLON {
  130495. /**
  130496. * Options to create the null engine
  130497. */
  130498. export class NullEngineOptions {
  130499. /**
  130500. * Render width (Default: 512)
  130501. */
  130502. renderWidth: number;
  130503. /**
  130504. * Render height (Default: 256)
  130505. */
  130506. renderHeight: number;
  130507. /**
  130508. * Texture size (Default: 512)
  130509. */
  130510. textureSize: number;
  130511. /**
  130512. * If delta time between frames should be constant
  130513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130514. */
  130515. deterministicLockstep: boolean;
  130516. /**
  130517. * Maximum about of steps between frames (Default: 4)
  130518. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130519. */
  130520. lockstepMaxSteps: number;
  130521. /**
  130522. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130523. */
  130524. useHighPrecisionMatrix?: boolean;
  130525. }
  130526. /**
  130527. * The null engine class provides support for headless version of babylon.js.
  130528. * This can be used in server side scenario or for testing purposes
  130529. */
  130530. export class NullEngine extends Engine {
  130531. private _options;
  130532. /**
  130533. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130534. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130535. * @returns true if engine is in deterministic lock step mode
  130536. */
  130537. isDeterministicLockStep(): boolean;
  130538. /**
  130539. * Gets the max steps when engine is running in deterministic lock step
  130540. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130541. * @returns the max steps
  130542. */
  130543. getLockstepMaxSteps(): number;
  130544. /**
  130545. * Gets the current hardware scaling level.
  130546. * By default the hardware scaling level is computed from the window device ratio.
  130547. * 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.
  130548. * @returns a number indicating the current hardware scaling level
  130549. */
  130550. getHardwareScalingLevel(): number;
  130551. constructor(options?: NullEngineOptions);
  130552. /**
  130553. * Creates a vertex buffer
  130554. * @param vertices the data for the vertex buffer
  130555. * @returns the new WebGL static buffer
  130556. */
  130557. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130558. /**
  130559. * Creates a new index buffer
  130560. * @param indices defines the content of the index buffer
  130561. * @param updatable defines if the index buffer must be updatable
  130562. * @returns a new webGL buffer
  130563. */
  130564. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130565. /**
  130566. * Clear the current render buffer or the current render target (if any is set up)
  130567. * @param color defines the color to use
  130568. * @param backBuffer defines if the back buffer must be cleared
  130569. * @param depth defines if the depth buffer must be cleared
  130570. * @param stencil defines if the stencil buffer must be cleared
  130571. */
  130572. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130573. /**
  130574. * Gets the current render width
  130575. * @param useScreen defines if screen size must be used (or the current render target if any)
  130576. * @returns a number defining the current render width
  130577. */
  130578. getRenderWidth(useScreen?: boolean): number;
  130579. /**
  130580. * Gets the current render height
  130581. * @param useScreen defines if screen size must be used (or the current render target if any)
  130582. * @returns a number defining the current render height
  130583. */
  130584. getRenderHeight(useScreen?: boolean): number;
  130585. /**
  130586. * Set the WebGL's viewport
  130587. * @param viewport defines the viewport element to be used
  130588. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130589. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130590. */
  130591. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130593. /**
  130594. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130595. * @param pipelineContext defines the pipeline context to use
  130596. * @param uniformsNames defines the list of uniform names
  130597. * @returns an array of webGL uniform locations
  130598. */
  130599. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130600. /**
  130601. * Gets the lsit of active attributes for a given webGL program
  130602. * @param pipelineContext defines the pipeline context to use
  130603. * @param attributesNames defines the list of attribute names to get
  130604. * @returns an array of indices indicating the offset of each attribute
  130605. */
  130606. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130607. /**
  130608. * Binds an effect to the webGL context
  130609. * @param effect defines the effect to bind
  130610. */
  130611. bindSamplers(effect: Effect): void;
  130612. /**
  130613. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130614. * @param effect defines the effect to activate
  130615. */
  130616. enableEffect(effect: Effect): void;
  130617. /**
  130618. * Set various states to the webGL context
  130619. * @param culling defines backface culling state
  130620. * @param zOffset defines the value to apply to zOffset (0 by default)
  130621. * @param force defines if states must be applied even if cache is up to date
  130622. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130623. */
  130624. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130625. /**
  130626. * Set the value of an uniform to an array of int32
  130627. * @param uniform defines the webGL uniform location where to store the value
  130628. * @param array defines the array of int32 to store
  130629. */
  130630. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130631. /**
  130632. * Set the value of an uniform to an array of int32 (stored as vec2)
  130633. * @param uniform defines the webGL uniform location where to store the value
  130634. * @param array defines the array of int32 to store
  130635. */
  130636. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130637. /**
  130638. * Set the value of an uniform to an array of int32 (stored as vec3)
  130639. * @param uniform defines the webGL uniform location where to store the value
  130640. * @param array defines the array of int32 to store
  130641. */
  130642. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130643. /**
  130644. * Set the value of an uniform to an array of int32 (stored as vec4)
  130645. * @param uniform defines the webGL uniform location where to store the value
  130646. * @param array defines the array of int32 to store
  130647. */
  130648. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130649. /**
  130650. * Set the value of an uniform to an array of float32
  130651. * @param uniform defines the webGL uniform location where to store the value
  130652. * @param array defines the array of float32 to store
  130653. */
  130654. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130655. /**
  130656. * Set the value of an uniform to an array of float32 (stored as vec2)
  130657. * @param uniform defines the webGL uniform location where to store the value
  130658. * @param array defines the array of float32 to store
  130659. */
  130660. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130661. /**
  130662. * Set the value of an uniform to an array of float32 (stored as vec3)
  130663. * @param uniform defines the webGL uniform location where to store the value
  130664. * @param array defines the array of float32 to store
  130665. */
  130666. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130667. /**
  130668. * Set the value of an uniform to an array of float32 (stored as vec4)
  130669. * @param uniform defines the webGL uniform location where to store the value
  130670. * @param array defines the array of float32 to store
  130671. */
  130672. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130673. /**
  130674. * Set the value of an uniform to an array of number
  130675. * @param uniform defines the webGL uniform location where to store the value
  130676. * @param array defines the array of number to store
  130677. */
  130678. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130679. /**
  130680. * Set the value of an uniform to an array of number (stored as vec2)
  130681. * @param uniform defines the webGL uniform location where to store the value
  130682. * @param array defines the array of number to store
  130683. */
  130684. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130685. /**
  130686. * Set the value of an uniform to an array of number (stored as vec3)
  130687. * @param uniform defines the webGL uniform location where to store the value
  130688. * @param array defines the array of number to store
  130689. */
  130690. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130691. /**
  130692. * Set the value of an uniform to an array of number (stored as vec4)
  130693. * @param uniform defines the webGL uniform location where to store the value
  130694. * @param array defines the array of number to store
  130695. */
  130696. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130697. /**
  130698. * Set the value of an uniform to an array of float32 (stored as matrices)
  130699. * @param uniform defines the webGL uniform location where to store the value
  130700. * @param matrices defines the array of float32 to store
  130701. */
  130702. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130703. /**
  130704. * Set the value of an uniform to a matrix (3x3)
  130705. * @param uniform defines the webGL uniform location where to store the value
  130706. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130707. */
  130708. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130709. /**
  130710. * Set the value of an uniform to a matrix (2x2)
  130711. * @param uniform defines the webGL uniform location where to store the value
  130712. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130713. */
  130714. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130715. /**
  130716. * Set the value of an uniform to a number (float)
  130717. * @param uniform defines the webGL uniform location where to store the value
  130718. * @param value defines the float number to store
  130719. */
  130720. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130721. /**
  130722. * Set the value of an uniform to a vec2
  130723. * @param uniform defines the webGL uniform location where to store the value
  130724. * @param x defines the 1st component of the value
  130725. * @param y defines the 2nd component of the value
  130726. */
  130727. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130728. /**
  130729. * Set the value of an uniform to a vec3
  130730. * @param uniform defines the webGL uniform location where to store the value
  130731. * @param x defines the 1st component of the value
  130732. * @param y defines the 2nd component of the value
  130733. * @param z defines the 3rd component of the value
  130734. */
  130735. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130736. /**
  130737. * Set the value of an uniform to a boolean
  130738. * @param uniform defines the webGL uniform location where to store the value
  130739. * @param bool defines the boolean to store
  130740. */
  130741. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130742. /**
  130743. * Set the value of an uniform to a vec4
  130744. * @param uniform defines the webGL uniform location where to store the value
  130745. * @param x defines the 1st component of the value
  130746. * @param y defines the 2nd component of the value
  130747. * @param z defines the 3rd component of the value
  130748. * @param w defines the 4th component of the value
  130749. */
  130750. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130751. /**
  130752. * Sets the current alpha mode
  130753. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130754. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130755. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130756. */
  130757. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130758. /**
  130759. * Bind webGl buffers directly to the webGL context
  130760. * @param vertexBuffers defines the vertex buffer to bind
  130761. * @param indexBuffer defines the index buffer to bind
  130762. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130763. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130764. * @param effect defines the effect associated with the vertex buffer
  130765. */
  130766. bindBuffers(vertexBuffers: {
  130767. [key: string]: VertexBuffer;
  130768. }, indexBuffer: DataBuffer, effect: Effect): void;
  130769. /**
  130770. * Force the entire cache to be cleared
  130771. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130772. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130773. */
  130774. wipeCaches(bruteForce?: boolean): void;
  130775. /**
  130776. * Send a draw order
  130777. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130778. * @param indexStart defines the starting index
  130779. * @param indexCount defines the number of index to draw
  130780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130781. */
  130782. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130783. /**
  130784. * Draw a list of indexed primitives
  130785. * @param fillMode defines the primitive to use
  130786. * @param indexStart defines the starting index
  130787. * @param indexCount defines the number of index to draw
  130788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130789. */
  130790. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130791. /**
  130792. * Draw a list of unindexed primitives
  130793. * @param fillMode defines the primitive to use
  130794. * @param verticesStart defines the index of first vertex to draw
  130795. * @param verticesCount defines the count of vertices to draw
  130796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130797. */
  130798. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130799. /** @hidden */
  130800. _createTexture(): WebGLTexture;
  130801. /** @hidden */
  130802. _releaseTexture(texture: InternalTexture): void;
  130803. /**
  130804. * Usually called from Texture.ts.
  130805. * Passed information to create a WebGLTexture
  130806. * @param urlArg defines a value which contains one of the following:
  130807. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130808. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130809. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130811. * @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)
  130812. * @param scene needed for loading to the correct scene
  130813. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130814. * @param onLoad optional callback to be called upon successful completion
  130815. * @param onError optional callback to be called upon failure
  130816. * @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
  130817. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130818. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130819. * @param forcedExtension defines the extension to use to pick the right loader
  130820. * @param mimeType defines an optional mime type
  130821. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130822. */
  130823. 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;
  130824. /**
  130825. * Creates a new render target texture
  130826. * @param size defines the size of the texture
  130827. * @param options defines the options used to create the texture
  130828. * @returns a new render target texture stored in an InternalTexture
  130829. */
  130830. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130831. /**
  130832. * Update the sampling mode of a given texture
  130833. * @param samplingMode defines the required sampling mode
  130834. * @param texture defines the texture to update
  130835. */
  130836. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130837. /**
  130838. * Binds the frame buffer to the specified texture.
  130839. * @param texture The texture to render to or null for the default canvas
  130840. * @param faceIndex The face of the texture to render to in case of cube texture
  130841. * @param requiredWidth The width of the target to render to
  130842. * @param requiredHeight The height of the target to render to
  130843. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130844. * @param lodLevel defines le lod level to bind to the frame buffer
  130845. */
  130846. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130847. /**
  130848. * Unbind the current render target texture from the webGL context
  130849. * @param texture defines the render target texture to unbind
  130850. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130851. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130852. */
  130853. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130854. /**
  130855. * Creates a dynamic vertex buffer
  130856. * @param vertices the data for the dynamic vertex buffer
  130857. * @returns the new WebGL dynamic buffer
  130858. */
  130859. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130860. /**
  130861. * Update the content of a dynamic texture
  130862. * @param texture defines the texture to update
  130863. * @param canvas defines the canvas containing the source
  130864. * @param invertY defines if data must be stored with Y axis inverted
  130865. * @param premulAlpha defines if alpha is stored as premultiplied
  130866. * @param format defines the format of the data
  130867. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130868. */
  130869. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130870. /**
  130871. * Gets a boolean indicating if all created effects are ready
  130872. * @returns true if all effects are ready
  130873. */
  130874. areAllEffectsReady(): boolean;
  130875. /**
  130876. * @hidden
  130877. * Get the current error code of the webGL context
  130878. * @returns the error code
  130879. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130880. */
  130881. getError(): number;
  130882. /** @hidden */
  130883. _getUnpackAlignement(): number;
  130884. /** @hidden */
  130885. _unpackFlipY(value: boolean): void;
  130886. /**
  130887. * Update a dynamic index buffer
  130888. * @param indexBuffer defines the target index buffer
  130889. * @param indices defines the data to update
  130890. * @param offset defines the offset in the target index buffer where update should start
  130891. */
  130892. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130893. /**
  130894. * Updates a dynamic vertex buffer.
  130895. * @param vertexBuffer the vertex buffer to update
  130896. * @param vertices the data used to update the vertex buffer
  130897. * @param byteOffset the byte offset of the data (optional)
  130898. * @param byteLength the byte length of the data (optional)
  130899. */
  130900. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130901. /** @hidden */
  130902. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130903. /** @hidden */
  130904. _bindTexture(channel: number, texture: InternalTexture): void;
  130905. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130906. /**
  130907. * 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
  130908. */
  130909. releaseEffects(): void;
  130910. displayLoadingUI(): void;
  130911. hideLoadingUI(): void;
  130912. /** @hidden */
  130913. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130914. /** @hidden */
  130915. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130916. /** @hidden */
  130917. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130918. /** @hidden */
  130919. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130920. }
  130921. }
  130922. declare module BABYLON {
  130923. /**
  130924. * @hidden
  130925. **/
  130926. export class _TimeToken {
  130927. _startTimeQuery: Nullable<WebGLQuery>;
  130928. _endTimeQuery: Nullable<WebGLQuery>;
  130929. _timeElapsedQuery: Nullable<WebGLQuery>;
  130930. _timeElapsedQueryEnded: boolean;
  130931. }
  130932. }
  130933. declare module BABYLON {
  130934. /** @hidden */
  130935. export class _OcclusionDataStorage {
  130936. /** @hidden */
  130937. occlusionInternalRetryCounter: number;
  130938. /** @hidden */
  130939. isOcclusionQueryInProgress: boolean;
  130940. /** @hidden */
  130941. isOccluded: boolean;
  130942. /** @hidden */
  130943. occlusionRetryCount: number;
  130944. /** @hidden */
  130945. occlusionType: number;
  130946. /** @hidden */
  130947. occlusionQueryAlgorithmType: number;
  130948. }
  130949. interface Engine {
  130950. /**
  130951. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130952. * @return the new query
  130953. */
  130954. createQuery(): WebGLQuery;
  130955. /**
  130956. * Delete and release a webGL query
  130957. * @param query defines the query to delete
  130958. * @return the current engine
  130959. */
  130960. deleteQuery(query: WebGLQuery): Engine;
  130961. /**
  130962. * Check if a given query has resolved and got its value
  130963. * @param query defines the query to check
  130964. * @returns true if the query got its value
  130965. */
  130966. isQueryResultAvailable(query: WebGLQuery): boolean;
  130967. /**
  130968. * Gets the value of a given query
  130969. * @param query defines the query to check
  130970. * @returns the value of the query
  130971. */
  130972. getQueryResult(query: WebGLQuery): number;
  130973. /**
  130974. * Initiates an occlusion query
  130975. * @param algorithmType defines the algorithm to use
  130976. * @param query defines the query to use
  130977. * @returns the current engine
  130978. * @see https://doc.babylonjs.com/features/occlusionquery
  130979. */
  130980. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130981. /**
  130982. * Ends an occlusion query
  130983. * @see https://doc.babylonjs.com/features/occlusionquery
  130984. * @param algorithmType defines the algorithm to use
  130985. * @returns the current engine
  130986. */
  130987. endOcclusionQuery(algorithmType: number): Engine;
  130988. /**
  130989. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130990. * Please note that only one query can be issued at a time
  130991. * @returns a time token used to track the time span
  130992. */
  130993. startTimeQuery(): Nullable<_TimeToken>;
  130994. /**
  130995. * Ends a time query
  130996. * @param token defines the token used to measure the time span
  130997. * @returns the time spent (in ns)
  130998. */
  130999. endTimeQuery(token: _TimeToken): int;
  131000. /** @hidden */
  131001. _currentNonTimestampToken: Nullable<_TimeToken>;
  131002. /** @hidden */
  131003. _createTimeQuery(): WebGLQuery;
  131004. /** @hidden */
  131005. _deleteTimeQuery(query: WebGLQuery): void;
  131006. /** @hidden */
  131007. _getGlAlgorithmType(algorithmType: number): number;
  131008. /** @hidden */
  131009. _getTimeQueryResult(query: WebGLQuery): any;
  131010. /** @hidden */
  131011. _getTimeQueryAvailability(query: WebGLQuery): any;
  131012. }
  131013. interface AbstractMesh {
  131014. /**
  131015. * Backing filed
  131016. * @hidden
  131017. */
  131018. __occlusionDataStorage: _OcclusionDataStorage;
  131019. /**
  131020. * Access property
  131021. * @hidden
  131022. */
  131023. _occlusionDataStorage: _OcclusionDataStorage;
  131024. /**
  131025. * 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.
  131026. * The default value is -1 which means don't break the query and wait till the result
  131027. * @see https://doc.babylonjs.com/features/occlusionquery
  131028. */
  131029. occlusionRetryCount: number;
  131030. /**
  131031. * 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:
  131032. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131033. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131034. * * 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.
  131035. * @see https://doc.babylonjs.com/features/occlusionquery
  131036. */
  131037. occlusionType: number;
  131038. /**
  131039. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131040. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131041. * * 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.
  131042. * @see https://doc.babylonjs.com/features/occlusionquery
  131043. */
  131044. occlusionQueryAlgorithmType: number;
  131045. /**
  131046. * 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
  131047. * @see https://doc.babylonjs.com/features/occlusionquery
  131048. */
  131049. isOccluded: boolean;
  131050. /**
  131051. * Flag to check the progress status of the query
  131052. * @see https://doc.babylonjs.com/features/occlusionquery
  131053. */
  131054. isOcclusionQueryInProgress: boolean;
  131055. }
  131056. }
  131057. declare module BABYLON {
  131058. /** @hidden */
  131059. export var _forceTransformFeedbackToBundle: boolean;
  131060. interface Engine {
  131061. /**
  131062. * Creates a webGL transform feedback object
  131063. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131064. * @returns the webGL transform feedback object
  131065. */
  131066. createTransformFeedback(): WebGLTransformFeedback;
  131067. /**
  131068. * Delete a webGL transform feedback object
  131069. * @param value defines the webGL transform feedback object to delete
  131070. */
  131071. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131072. /**
  131073. * Bind a webGL transform feedback object to the webgl context
  131074. * @param value defines the webGL transform feedback object to bind
  131075. */
  131076. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131077. /**
  131078. * Begins a transform feedback operation
  131079. * @param usePoints defines if points or triangles must be used
  131080. */
  131081. beginTransformFeedback(usePoints: boolean): void;
  131082. /**
  131083. * Ends a transform feedback operation
  131084. */
  131085. endTransformFeedback(): void;
  131086. /**
  131087. * Specify the varyings to use with transform feedback
  131088. * @param program defines the associated webGL program
  131089. * @param value defines the list of strings representing the varying names
  131090. */
  131091. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131092. /**
  131093. * Bind a webGL buffer for a transform feedback operation
  131094. * @param value defines the webGL buffer to bind
  131095. */
  131096. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131097. }
  131098. }
  131099. declare module BABYLON {
  131100. /**
  131101. * Class used to define an additional view for the engine
  131102. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131103. */
  131104. export class EngineView {
  131105. /** Defines the canvas where to render the view */
  131106. target: HTMLCanvasElement;
  131107. /** Defines an optional camera used to render the view (will use active camera else) */
  131108. camera?: Camera;
  131109. }
  131110. interface Engine {
  131111. /**
  131112. * Gets or sets the HTML element to use for attaching events
  131113. */
  131114. inputElement: Nullable<HTMLElement>;
  131115. /**
  131116. * Gets the current engine view
  131117. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131118. */
  131119. activeView: Nullable<EngineView>;
  131120. /** Gets or sets the list of views */
  131121. views: EngineView[];
  131122. /**
  131123. * Register a new child canvas
  131124. * @param canvas defines the canvas to register
  131125. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131126. * @returns the associated view
  131127. */
  131128. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131129. /**
  131130. * Remove a registered child canvas
  131131. * @param canvas defines the canvas to remove
  131132. * @returns the current engine
  131133. */
  131134. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131135. }
  131136. }
  131137. declare module BABYLON {
  131138. interface Engine {
  131139. /** @hidden */
  131140. _excludedCompressedTextures: string[];
  131141. /** @hidden */
  131142. _textureFormatInUse: string;
  131143. /**
  131144. * Gets the list of texture formats supported
  131145. */
  131146. readonly texturesSupported: Array<string>;
  131147. /**
  131148. * Gets the texture format in use
  131149. */
  131150. readonly textureFormatInUse: Nullable<string>;
  131151. /**
  131152. * Set the compressed texture extensions or file names to skip.
  131153. *
  131154. * @param skippedFiles defines the list of those texture files you want to skip
  131155. * Example: [".dds", ".env", "myfile.png"]
  131156. */
  131157. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131158. /**
  131159. * Set the compressed texture format to use, based on the formats you have, and the formats
  131160. * supported by the hardware / browser.
  131161. *
  131162. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131163. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131164. * to API arguments needed to compressed textures. This puts the burden on the container
  131165. * generator to house the arcane code for determining these for current & future formats.
  131166. *
  131167. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131168. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131169. *
  131170. * Note: The result of this call is not taken into account when a texture is base64.
  131171. *
  131172. * @param formatsAvailable defines the list of those format families you have created
  131173. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131174. *
  131175. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131176. * @returns The extension selected.
  131177. */
  131178. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131179. }
  131180. }
  131181. declare module BABYLON {
  131182. /**
  131183. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131184. */
  131185. export interface CubeMapInfo {
  131186. /**
  131187. * The pixel array for the front face.
  131188. * This is stored in format, left to right, up to down format.
  131189. */
  131190. front: Nullable<ArrayBufferView>;
  131191. /**
  131192. * The pixel array for the back face.
  131193. * This is stored in format, left to right, up to down format.
  131194. */
  131195. back: Nullable<ArrayBufferView>;
  131196. /**
  131197. * The pixel array for the left face.
  131198. * This is stored in format, left to right, up to down format.
  131199. */
  131200. left: Nullable<ArrayBufferView>;
  131201. /**
  131202. * The pixel array for the right face.
  131203. * This is stored in format, left to right, up to down format.
  131204. */
  131205. right: Nullable<ArrayBufferView>;
  131206. /**
  131207. * The pixel array for the up face.
  131208. * This is stored in format, left to right, up to down format.
  131209. */
  131210. up: Nullable<ArrayBufferView>;
  131211. /**
  131212. * The pixel array for the down face.
  131213. * This is stored in format, left to right, up to down format.
  131214. */
  131215. down: Nullable<ArrayBufferView>;
  131216. /**
  131217. * The size of the cubemap stored.
  131218. *
  131219. * Each faces will be size * size pixels.
  131220. */
  131221. size: number;
  131222. /**
  131223. * The format of the texture.
  131224. *
  131225. * RGBA, RGB.
  131226. */
  131227. format: number;
  131228. /**
  131229. * The type of the texture data.
  131230. *
  131231. * UNSIGNED_INT, FLOAT.
  131232. */
  131233. type: number;
  131234. /**
  131235. * Specifies whether the texture is in gamma space.
  131236. */
  131237. gammaSpace: boolean;
  131238. }
  131239. /**
  131240. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131241. */
  131242. export class PanoramaToCubeMapTools {
  131243. private static FACE_LEFT;
  131244. private static FACE_RIGHT;
  131245. private static FACE_FRONT;
  131246. private static FACE_BACK;
  131247. private static FACE_DOWN;
  131248. private static FACE_UP;
  131249. /**
  131250. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131251. *
  131252. * @param float32Array The source data.
  131253. * @param inputWidth The width of the input panorama.
  131254. * @param inputHeight The height of the input panorama.
  131255. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131256. * @return The cubemap data
  131257. */
  131258. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131259. private static CreateCubemapTexture;
  131260. private static CalcProjectionSpherical;
  131261. }
  131262. }
  131263. declare module BABYLON {
  131264. /**
  131265. * Helper class dealing with the extraction of spherical polynomial dataArray
  131266. * from a cube map.
  131267. */
  131268. export class CubeMapToSphericalPolynomialTools {
  131269. private static FileFaces;
  131270. /**
  131271. * Converts a texture to the according Spherical Polynomial data.
  131272. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131273. *
  131274. * @param texture The texture to extract the information from.
  131275. * @return The Spherical Polynomial data.
  131276. */
  131277. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131278. /**
  131279. * Converts a cubemap to the according Spherical Polynomial data.
  131280. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131281. *
  131282. * @param cubeInfo The Cube map to extract the information from.
  131283. * @return The Spherical Polynomial data.
  131284. */
  131285. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131286. }
  131287. }
  131288. declare module BABYLON {
  131289. interface BaseTexture {
  131290. /**
  131291. * Get the polynomial representation of the texture data.
  131292. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131293. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131294. */
  131295. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131296. }
  131297. }
  131298. declare module BABYLON {
  131299. /** @hidden */
  131300. export var rgbdEncodePixelShader: {
  131301. name: string;
  131302. shader: string;
  131303. };
  131304. }
  131305. declare module BABYLON {
  131306. /** @hidden */
  131307. export var rgbdDecodePixelShader: {
  131308. name: string;
  131309. shader: string;
  131310. };
  131311. }
  131312. declare module BABYLON {
  131313. /**
  131314. * Raw texture data and descriptor sufficient for WebGL texture upload
  131315. */
  131316. export interface EnvironmentTextureInfo {
  131317. /**
  131318. * Version of the environment map
  131319. */
  131320. version: number;
  131321. /**
  131322. * Width of image
  131323. */
  131324. width: number;
  131325. /**
  131326. * Irradiance information stored in the file.
  131327. */
  131328. irradiance: any;
  131329. /**
  131330. * Specular information stored in the file.
  131331. */
  131332. specular: any;
  131333. }
  131334. /**
  131335. * Defines One Image in the file. It requires only the position in the file
  131336. * as well as the length.
  131337. */
  131338. interface BufferImageData {
  131339. /**
  131340. * Length of the image data.
  131341. */
  131342. length: number;
  131343. /**
  131344. * Position of the data from the null terminator delimiting the end of the JSON.
  131345. */
  131346. position: number;
  131347. }
  131348. /**
  131349. * Defines the specular data enclosed in the file.
  131350. * This corresponds to the version 1 of the data.
  131351. */
  131352. export interface EnvironmentTextureSpecularInfoV1 {
  131353. /**
  131354. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131355. */
  131356. specularDataPosition?: number;
  131357. /**
  131358. * This contains all the images data needed to reconstruct the cubemap.
  131359. */
  131360. mipmaps: Array<BufferImageData>;
  131361. /**
  131362. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131363. */
  131364. lodGenerationScale: number;
  131365. }
  131366. /**
  131367. * Sets of helpers addressing the serialization and deserialization of environment texture
  131368. * stored in a BabylonJS env file.
  131369. * Those files are usually stored as .env files.
  131370. */
  131371. export class EnvironmentTextureTools {
  131372. /**
  131373. * Magic number identifying the env file.
  131374. */
  131375. private static _MagicBytes;
  131376. /**
  131377. * Gets the environment info from an env file.
  131378. * @param data The array buffer containing the .env bytes.
  131379. * @returns the environment file info (the json header) if successfully parsed.
  131380. */
  131381. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131382. /**
  131383. * Creates an environment texture from a loaded cube texture.
  131384. * @param texture defines the cube texture to convert in env file
  131385. * @return a promise containing the environment data if succesfull.
  131386. */
  131387. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131388. /**
  131389. * Creates a JSON representation of the spherical data.
  131390. * @param texture defines the texture containing the polynomials
  131391. * @return the JSON representation of the spherical info
  131392. */
  131393. private static _CreateEnvTextureIrradiance;
  131394. /**
  131395. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131396. * @param data the image data
  131397. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131398. * @return the views described by info providing access to the underlying buffer
  131399. */
  131400. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131401. /**
  131402. * Uploads the texture info contained in the env file to the GPU.
  131403. * @param texture defines the internal texture to upload to
  131404. * @param data defines the data to load
  131405. * @param info defines the texture info retrieved through the GetEnvInfo method
  131406. * @returns a promise
  131407. */
  131408. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131409. private static _OnImageReadyAsync;
  131410. /**
  131411. * Uploads the levels of image data to the GPU.
  131412. * @param texture defines the internal texture to upload to
  131413. * @param imageData defines the array buffer views of image data [mipmap][face]
  131414. * @returns a promise
  131415. */
  131416. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131417. /**
  131418. * Uploads spherical polynomials information to the texture.
  131419. * @param texture defines the texture we are trying to upload the information to
  131420. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131421. */
  131422. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131423. /** @hidden */
  131424. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131425. }
  131426. }
  131427. declare module BABYLON {
  131428. /**
  131429. * Class used to inline functions in shader code
  131430. */
  131431. export class ShaderCodeInliner {
  131432. private static readonly _RegexpFindFunctionNameAndType;
  131433. private _sourceCode;
  131434. private _functionDescr;
  131435. private _numMaxIterations;
  131436. /** Gets or sets the token used to mark the functions to inline */
  131437. inlineToken: string;
  131438. /** Gets or sets the debug mode */
  131439. debug: boolean;
  131440. /** Gets the code after the inlining process */
  131441. get code(): string;
  131442. /**
  131443. * Initializes the inliner
  131444. * @param sourceCode shader code source to inline
  131445. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131446. */
  131447. constructor(sourceCode: string, numMaxIterations?: number);
  131448. /**
  131449. * Start the processing of the shader code
  131450. */
  131451. processCode(): void;
  131452. private _collectFunctions;
  131453. private _processInlining;
  131454. private _extractBetweenMarkers;
  131455. private _skipWhitespaces;
  131456. private _removeComments;
  131457. private _replaceFunctionCallsByCode;
  131458. private _findBackward;
  131459. private _escapeRegExp;
  131460. private _replaceNames;
  131461. }
  131462. }
  131463. declare module BABYLON {
  131464. /**
  131465. * Container for accessors for natively-stored mesh data buffers.
  131466. */
  131467. class NativeDataBuffer extends DataBuffer {
  131468. /**
  131469. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131470. */
  131471. nativeIndexBuffer?: any;
  131472. /**
  131473. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131474. */
  131475. nativeVertexBuffer?: any;
  131476. }
  131477. /** @hidden */
  131478. class NativeTexture extends InternalTexture {
  131479. getInternalTexture(): InternalTexture;
  131480. getViewCount(): number;
  131481. }
  131482. /** @hidden */
  131483. export class NativeEngine extends Engine {
  131484. private readonly _native;
  131485. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131486. private readonly INVALID_HANDLE;
  131487. private _boundBuffersVertexArray;
  131488. getHardwareScalingLevel(): number;
  131489. constructor();
  131490. dispose(): void;
  131491. /**
  131492. * Can be used to override the current requestAnimationFrame requester.
  131493. * @hidden
  131494. */
  131495. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131496. /**
  131497. * Override default engine behavior.
  131498. * @param color
  131499. * @param backBuffer
  131500. * @param depth
  131501. * @param stencil
  131502. */
  131503. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131504. /**
  131505. * Gets host document
  131506. * @returns the host document object
  131507. */
  131508. getHostDocument(): Nullable<Document>;
  131509. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131510. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131511. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131512. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  131513. [key: string]: VertexBuffer;
  131514. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131515. bindBuffers(vertexBuffers: {
  131516. [key: string]: VertexBuffer;
  131517. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131518. recordVertexArrayObject(vertexBuffers: {
  131519. [key: string]: VertexBuffer;
  131520. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131521. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131522. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131523. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131524. /**
  131525. * Draw a list of indexed primitives
  131526. * @param fillMode defines the primitive to use
  131527. * @param indexStart defines the starting index
  131528. * @param indexCount defines the number of index to draw
  131529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131530. */
  131531. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131532. /**
  131533. * Draw a list of unindexed primitives
  131534. * @param fillMode defines the primitive to use
  131535. * @param verticesStart defines the index of first vertex to draw
  131536. * @param verticesCount defines the count of vertices to draw
  131537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131538. */
  131539. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131540. createPipelineContext(): IPipelineContext;
  131541. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131542. /** @hidden */
  131543. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131544. /** @hidden */
  131545. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131546. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131547. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131548. protected _setProgram(program: WebGLProgram): void;
  131549. _releaseEffect(effect: Effect): void;
  131550. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131551. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131552. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131553. bindSamplers(effect: Effect): void;
  131554. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131555. getRenderWidth(useScreen?: boolean): number;
  131556. getRenderHeight(useScreen?: boolean): number;
  131557. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131558. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131559. /**
  131560. * Set the z offset to apply to current rendering
  131561. * @param value defines the offset to apply
  131562. */
  131563. setZOffset(value: number): void;
  131564. /**
  131565. * Gets the current value of the zOffset
  131566. * @returns the current zOffset state
  131567. */
  131568. getZOffset(): number;
  131569. /**
  131570. * Enable or disable depth buffering
  131571. * @param enable defines the state to set
  131572. */
  131573. setDepthBuffer(enable: boolean): void;
  131574. /**
  131575. * Gets a boolean indicating if depth writing is enabled
  131576. * @returns the current depth writing state
  131577. */
  131578. getDepthWrite(): boolean;
  131579. /**
  131580. * Enable or disable depth writing
  131581. * @param enable defines the state to set
  131582. */
  131583. setDepthWrite(enable: boolean): void;
  131584. /**
  131585. * Enable or disable color writing
  131586. * @param enable defines the state to set
  131587. */
  131588. setColorWrite(enable: boolean): void;
  131589. /**
  131590. * Gets a boolean indicating if color writing is enabled
  131591. * @returns the current color writing state
  131592. */
  131593. getColorWrite(): boolean;
  131594. /**
  131595. * Sets alpha constants used by some alpha blending modes
  131596. * @param r defines the red component
  131597. * @param g defines the green component
  131598. * @param b defines the blue component
  131599. * @param a defines the alpha component
  131600. */
  131601. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131602. /**
  131603. * Sets the current alpha mode
  131604. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131605. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131606. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131607. */
  131608. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131609. /**
  131610. * Gets the current alpha mode
  131611. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131612. * @returns the current alpha mode
  131613. */
  131614. getAlphaMode(): number;
  131615. setInt(uniform: WebGLUniformLocation, int: number): void;
  131616. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131617. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131618. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131619. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131620. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131621. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131622. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131623. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131624. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131625. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131626. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131627. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131628. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131629. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131630. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131631. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131632. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131633. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131634. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131635. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131636. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131637. wipeCaches(bruteForce?: boolean): void;
  131638. _createTexture(): WebGLTexture;
  131639. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131640. /**
  131641. * Usually called from Texture.ts.
  131642. * Passed information to create a WebGLTexture
  131643. * @param url defines a value which contains one of the following:
  131644. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131645. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131646. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131648. * @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)
  131649. * @param scene needed for loading to the correct scene
  131650. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131651. * @param onLoad optional callback to be called upon successful completion
  131652. * @param onError optional callback to be called upon failure
  131653. * @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
  131654. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131655. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131656. * @param forcedExtension defines the extension to use to pick the right loader
  131657. * @param mimeType defines an optional mime type
  131658. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131659. */
  131660. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  131661. /**
  131662. * Creates a cube texture
  131663. * @param rootUrl defines the url where the files to load is located
  131664. * @param scene defines the current scene
  131665. * @param files defines the list of files to load (1 per face)
  131666. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131667. * @param onLoad defines an optional callback raised when the texture is loaded
  131668. * @param onError defines an optional callback raised if there is an issue to load the texture
  131669. * @param format defines the format of the data
  131670. * @param forcedExtension defines the extension to use to pick the right loader
  131671. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131672. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131673. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131674. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131675. * @returns the cube texture as an InternalTexture
  131676. */
  131677. 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;
  131678. private _getSamplingFilter;
  131679. private static _GetNativeTextureFormat;
  131680. createRenderTargetTexture(size: number | {
  131681. width: number;
  131682. height: number;
  131683. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131684. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131685. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131686. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131687. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131688. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131689. /**
  131690. * Updates a dynamic vertex buffer.
  131691. * @param vertexBuffer the vertex buffer to update
  131692. * @param data the data used to update the vertex buffer
  131693. * @param byteOffset the byte offset of the data (optional)
  131694. * @param byteLength the byte length of the data (optional)
  131695. */
  131696. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131697. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131698. private _updateAnisotropicLevel;
  131699. private _getAddressMode;
  131700. /** @hidden */
  131701. _bindTexture(channel: number, texture: InternalTexture): void;
  131702. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131703. releaseEffects(): void;
  131704. /** @hidden */
  131705. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131706. /** @hidden */
  131707. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131708. /** @hidden */
  131709. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131710. /** @hidden */
  131711. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131712. }
  131713. }
  131714. declare module BABYLON {
  131715. /**
  131716. * Gather the list of clipboard event types as constants.
  131717. */
  131718. export class ClipboardEventTypes {
  131719. /**
  131720. * The clipboard event is fired when a copy command is active (pressed).
  131721. */
  131722. static readonly COPY: number;
  131723. /**
  131724. * The clipboard event is fired when a cut command is active (pressed).
  131725. */
  131726. static readonly CUT: number;
  131727. /**
  131728. * The clipboard event is fired when a paste command is active (pressed).
  131729. */
  131730. static readonly PASTE: number;
  131731. }
  131732. /**
  131733. * This class is used to store clipboard related info for the onClipboardObservable event.
  131734. */
  131735. export class ClipboardInfo {
  131736. /**
  131737. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131738. */
  131739. type: number;
  131740. /**
  131741. * Defines the related dom event
  131742. */
  131743. event: ClipboardEvent;
  131744. /**
  131745. *Creates an instance of ClipboardInfo.
  131746. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131747. * @param event Defines the related dom event
  131748. */
  131749. constructor(
  131750. /**
  131751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131752. */
  131753. type: number,
  131754. /**
  131755. * Defines the related dom event
  131756. */
  131757. event: ClipboardEvent);
  131758. /**
  131759. * Get the clipboard event's type from the keycode.
  131760. * @param keyCode Defines the keyCode for the current keyboard event.
  131761. * @return {number}
  131762. */
  131763. static GetTypeFromCharacter(keyCode: number): number;
  131764. }
  131765. }
  131766. declare module BABYLON {
  131767. /**
  131768. * Google Daydream controller
  131769. */
  131770. export class DaydreamController extends WebVRController {
  131771. /**
  131772. * Base Url for the controller model.
  131773. */
  131774. static MODEL_BASE_URL: string;
  131775. /**
  131776. * File name for the controller model.
  131777. */
  131778. static MODEL_FILENAME: string;
  131779. /**
  131780. * Gamepad Id prefix used to identify Daydream Controller.
  131781. */
  131782. static readonly GAMEPAD_ID_PREFIX: string;
  131783. /**
  131784. * Creates a new DaydreamController from a gamepad
  131785. * @param vrGamepad the gamepad that the controller should be created from
  131786. */
  131787. constructor(vrGamepad: any);
  131788. /**
  131789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131790. * @param scene scene in which to add meshes
  131791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131792. */
  131793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131794. /**
  131795. * Called once for each button that changed state since the last frame
  131796. * @param buttonIdx Which button index changed
  131797. * @param state New state of the button
  131798. * @param changes Which properties on the state changed since last frame
  131799. */
  131800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131801. }
  131802. }
  131803. declare module BABYLON {
  131804. /**
  131805. * Gear VR Controller
  131806. */
  131807. export class GearVRController extends WebVRController {
  131808. /**
  131809. * Base Url for the controller model.
  131810. */
  131811. static MODEL_BASE_URL: string;
  131812. /**
  131813. * File name for the controller model.
  131814. */
  131815. static MODEL_FILENAME: string;
  131816. /**
  131817. * Gamepad Id prefix used to identify this controller.
  131818. */
  131819. static readonly GAMEPAD_ID_PREFIX: string;
  131820. private readonly _buttonIndexToObservableNameMap;
  131821. /**
  131822. * Creates a new GearVRController from a gamepad
  131823. * @param vrGamepad the gamepad that the controller should be created from
  131824. */
  131825. constructor(vrGamepad: any);
  131826. /**
  131827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131828. * @param scene scene in which to add meshes
  131829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131830. */
  131831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131832. /**
  131833. * Called once for each button that changed state since the last frame
  131834. * @param buttonIdx Which button index changed
  131835. * @param state New state of the button
  131836. * @param changes Which properties on the state changed since last frame
  131837. */
  131838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131839. }
  131840. }
  131841. declare module BABYLON {
  131842. /**
  131843. * Generic Controller
  131844. */
  131845. export class GenericController extends WebVRController {
  131846. /**
  131847. * Base Url for the controller model.
  131848. */
  131849. static readonly MODEL_BASE_URL: string;
  131850. /**
  131851. * File name for the controller model.
  131852. */
  131853. static readonly MODEL_FILENAME: string;
  131854. /**
  131855. * Creates a new GenericController from a gamepad
  131856. * @param vrGamepad the gamepad that the controller should be created from
  131857. */
  131858. constructor(vrGamepad: any);
  131859. /**
  131860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131861. * @param scene scene in which to add meshes
  131862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131863. */
  131864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131865. /**
  131866. * Called once for each button that changed state since the last frame
  131867. * @param buttonIdx Which button index changed
  131868. * @param state New state of the button
  131869. * @param changes Which properties on the state changed since last frame
  131870. */
  131871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131872. }
  131873. }
  131874. declare module BABYLON {
  131875. /**
  131876. * Oculus Touch Controller
  131877. */
  131878. export class OculusTouchController extends WebVRController {
  131879. /**
  131880. * Base Url for the controller model.
  131881. */
  131882. static MODEL_BASE_URL: string;
  131883. /**
  131884. * File name for the left controller model.
  131885. */
  131886. static MODEL_LEFT_FILENAME: string;
  131887. /**
  131888. * File name for the right controller model.
  131889. */
  131890. static MODEL_RIGHT_FILENAME: string;
  131891. /**
  131892. * Base Url for the Quest controller model.
  131893. */
  131894. static QUEST_MODEL_BASE_URL: string;
  131895. /**
  131896. * @hidden
  131897. * If the controllers are running on a device that needs the updated Quest controller models
  131898. */
  131899. static _IsQuest: boolean;
  131900. /**
  131901. * Fired when the secondary trigger on this controller is modified
  131902. */
  131903. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131904. /**
  131905. * Fired when the thumb rest on this controller is modified
  131906. */
  131907. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131908. /**
  131909. * Creates a new OculusTouchController from a gamepad
  131910. * @param vrGamepad the gamepad that the controller should be created from
  131911. */
  131912. constructor(vrGamepad: any);
  131913. /**
  131914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131915. * @param scene scene in which to add meshes
  131916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131917. */
  131918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131919. /**
  131920. * Fired when the A button on this controller is modified
  131921. */
  131922. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131923. /**
  131924. * Fired when the B button on this controller is modified
  131925. */
  131926. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131927. /**
  131928. * Fired when the X button on this controller is modified
  131929. */
  131930. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131931. /**
  131932. * Fired when the Y button on this controller is modified
  131933. */
  131934. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131935. /**
  131936. * Called once for each button that changed state since the last frame
  131937. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131938. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131939. * 2) secondary trigger (same)
  131940. * 3) A (right) X (left), touch, pressed = value
  131941. * 4) B / Y
  131942. * 5) thumb rest
  131943. * @param buttonIdx Which button index changed
  131944. * @param state New state of the button
  131945. * @param changes Which properties on the state changed since last frame
  131946. */
  131947. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131948. }
  131949. }
  131950. declare module BABYLON {
  131951. /**
  131952. * Vive Controller
  131953. */
  131954. export class ViveController extends WebVRController {
  131955. /**
  131956. * Base Url for the controller model.
  131957. */
  131958. static MODEL_BASE_URL: string;
  131959. /**
  131960. * File name for the controller model.
  131961. */
  131962. static MODEL_FILENAME: string;
  131963. /**
  131964. * Creates a new ViveController from a gamepad
  131965. * @param vrGamepad the gamepad that the controller should be created from
  131966. */
  131967. constructor(vrGamepad: any);
  131968. /**
  131969. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131970. * @param scene scene in which to add meshes
  131971. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131972. */
  131973. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131974. /**
  131975. * Fired when the left button on this controller is modified
  131976. */
  131977. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131978. /**
  131979. * Fired when the right button on this controller is modified
  131980. */
  131981. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131982. /**
  131983. * Fired when the menu button on this controller is modified
  131984. */
  131985. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131986. /**
  131987. * Called once for each button that changed state since the last frame
  131988. * Vive mapping:
  131989. * 0: touchpad
  131990. * 1: trigger
  131991. * 2: left AND right buttons
  131992. * 3: menu button
  131993. * @param buttonIdx Which button index changed
  131994. * @param state New state of the button
  131995. * @param changes Which properties on the state changed since last frame
  131996. */
  131997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131998. }
  131999. }
  132000. declare module BABYLON {
  132001. /**
  132002. * Defines the WindowsMotionController object that the state of the windows motion controller
  132003. */
  132004. export class WindowsMotionController extends WebVRController {
  132005. /**
  132006. * The base url used to load the left and right controller models
  132007. */
  132008. static MODEL_BASE_URL: string;
  132009. /**
  132010. * The name of the left controller model file
  132011. */
  132012. static MODEL_LEFT_FILENAME: string;
  132013. /**
  132014. * The name of the right controller model file
  132015. */
  132016. static MODEL_RIGHT_FILENAME: string;
  132017. /**
  132018. * The controller name prefix for this controller type
  132019. */
  132020. static readonly GAMEPAD_ID_PREFIX: string;
  132021. /**
  132022. * The controller id pattern for this controller type
  132023. */
  132024. private static readonly GAMEPAD_ID_PATTERN;
  132025. private _loadedMeshInfo;
  132026. protected readonly _mapping: {
  132027. buttons: string[];
  132028. buttonMeshNames: {
  132029. trigger: string;
  132030. menu: string;
  132031. grip: string;
  132032. thumbstick: string;
  132033. trackpad: string;
  132034. };
  132035. buttonObservableNames: {
  132036. trigger: string;
  132037. menu: string;
  132038. grip: string;
  132039. thumbstick: string;
  132040. trackpad: string;
  132041. };
  132042. axisMeshNames: string[];
  132043. pointingPoseMeshName: string;
  132044. };
  132045. /**
  132046. * Fired when the trackpad on this controller is clicked
  132047. */
  132048. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132049. /**
  132050. * Fired when the trackpad on this controller is modified
  132051. */
  132052. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132053. /**
  132054. * The current x and y values of this controller's trackpad
  132055. */
  132056. trackpad: StickValues;
  132057. /**
  132058. * Creates a new WindowsMotionController from a gamepad
  132059. * @param vrGamepad the gamepad that the controller should be created from
  132060. */
  132061. constructor(vrGamepad: any);
  132062. /**
  132063. * Fired when the trigger on this controller is modified
  132064. */
  132065. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132066. /**
  132067. * Fired when the menu button on this controller is modified
  132068. */
  132069. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132070. /**
  132071. * Fired when the grip button on this controller is modified
  132072. */
  132073. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132074. /**
  132075. * Fired when the thumbstick button on this controller is modified
  132076. */
  132077. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132078. /**
  132079. * Fired when the touchpad button on this controller is modified
  132080. */
  132081. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132082. /**
  132083. * Fired when the touchpad values on this controller are modified
  132084. */
  132085. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132086. protected _updateTrackpad(): void;
  132087. /**
  132088. * Called once per frame by the engine.
  132089. */
  132090. update(): void;
  132091. /**
  132092. * Called once for each button that changed state since the last frame
  132093. * @param buttonIdx Which button index changed
  132094. * @param state New state of the button
  132095. * @param changes Which properties on the state changed since last frame
  132096. */
  132097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132098. /**
  132099. * Moves the buttons on the controller mesh based on their current state
  132100. * @param buttonName the name of the button to move
  132101. * @param buttonValue the value of the button which determines the buttons new position
  132102. */
  132103. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132104. /**
  132105. * Moves the axis on the controller mesh based on its current state
  132106. * @param axis the index of the axis
  132107. * @param axisValue the value of the axis which determines the meshes new position
  132108. * @hidden
  132109. */
  132110. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132111. /**
  132112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132113. * @param scene scene in which to add meshes
  132114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132115. */
  132116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132117. /**
  132118. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132119. * can be transformed by button presses and axes values, based on this._mapping.
  132120. *
  132121. * @param scene scene in which the meshes exist
  132122. * @param meshes list of meshes that make up the controller model to process
  132123. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132124. */
  132125. private processModel;
  132126. private createMeshInfo;
  132127. /**
  132128. * Gets the ray of the controller in the direction the controller is pointing
  132129. * @param length the length the resulting ray should be
  132130. * @returns a ray in the direction the controller is pointing
  132131. */
  132132. getForwardRay(length?: number): Ray;
  132133. /**
  132134. * Disposes of the controller
  132135. */
  132136. dispose(): void;
  132137. }
  132138. /**
  132139. * This class represents a new windows motion controller in XR.
  132140. */
  132141. export class XRWindowsMotionController extends WindowsMotionController {
  132142. /**
  132143. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132144. */
  132145. protected readonly _mapping: {
  132146. buttons: string[];
  132147. buttonMeshNames: {
  132148. trigger: string;
  132149. menu: string;
  132150. grip: string;
  132151. thumbstick: string;
  132152. trackpad: string;
  132153. };
  132154. buttonObservableNames: {
  132155. trigger: string;
  132156. menu: string;
  132157. grip: string;
  132158. thumbstick: string;
  132159. trackpad: string;
  132160. };
  132161. axisMeshNames: string[];
  132162. pointingPoseMeshName: string;
  132163. };
  132164. /**
  132165. * Construct a new XR-Based windows motion controller
  132166. *
  132167. * @param gamepadInfo the gamepad object from the browser
  132168. */
  132169. constructor(gamepadInfo: any);
  132170. /**
  132171. * holds the thumbstick values (X,Y)
  132172. */
  132173. thumbstickValues: StickValues;
  132174. /**
  132175. * Fired when the thumbstick on this controller is clicked
  132176. */
  132177. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132178. /**
  132179. * Fired when the thumbstick on this controller is modified
  132180. */
  132181. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132182. /**
  132183. * Fired when the touchpad button on this controller is modified
  132184. */
  132185. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132186. /**
  132187. * Fired when the touchpad values on this controller are modified
  132188. */
  132189. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132190. /**
  132191. * Fired when the thumbstick button on this controller is modified
  132192. * here to prevent breaking changes
  132193. */
  132194. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132195. /**
  132196. * updating the thumbstick(!) and not the trackpad.
  132197. * This is named this way due to the difference between WebVR and XR and to avoid
  132198. * changing the parent class.
  132199. */
  132200. protected _updateTrackpad(): void;
  132201. /**
  132202. * Disposes the class with joy
  132203. */
  132204. dispose(): void;
  132205. }
  132206. }
  132207. declare module BABYLON {
  132208. /**
  132209. * Class containing static functions to help procedurally build meshes
  132210. */
  132211. export class PolyhedronBuilder {
  132212. /**
  132213. * Creates a polyhedron mesh
  132214. * * 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
  132215. * * The parameter `size` (positive float, default 1) sets the polygon size
  132216. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132217. * * 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`
  132218. * * 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
  132219. * * 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)`)
  132220. * * 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
  132221. * * 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
  132222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132225. * @param name defines the name of the mesh
  132226. * @param options defines the options used to create the mesh
  132227. * @param scene defines the hosting scene
  132228. * @returns the polyhedron mesh
  132229. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132230. */
  132231. static CreatePolyhedron(name: string, options: {
  132232. type?: number;
  132233. size?: number;
  132234. sizeX?: number;
  132235. sizeY?: number;
  132236. sizeZ?: number;
  132237. custom?: any;
  132238. faceUV?: Vector4[];
  132239. faceColors?: Color4[];
  132240. flat?: boolean;
  132241. updatable?: boolean;
  132242. sideOrientation?: number;
  132243. frontUVs?: Vector4;
  132244. backUVs?: Vector4;
  132245. }, scene?: Nullable<Scene>): Mesh;
  132246. }
  132247. }
  132248. declare module BABYLON {
  132249. /**
  132250. * Gizmo that enables scaling a mesh along 3 axis
  132251. */
  132252. export class ScaleGizmo extends Gizmo {
  132253. /**
  132254. * Internal gizmo used for interactions on the x axis
  132255. */
  132256. xGizmo: AxisScaleGizmo;
  132257. /**
  132258. * Internal gizmo used for interactions on the y axis
  132259. */
  132260. yGizmo: AxisScaleGizmo;
  132261. /**
  132262. * Internal gizmo used for interactions on the z axis
  132263. */
  132264. zGizmo: AxisScaleGizmo;
  132265. /**
  132266. * Internal gizmo used to scale all axis equally
  132267. */
  132268. uniformScaleGizmo: AxisScaleGizmo;
  132269. private _meshAttached;
  132270. private _nodeAttached;
  132271. private _updateGizmoRotationToMatchAttachedMesh;
  132272. private _snapDistance;
  132273. private _scaleRatio;
  132274. private _uniformScalingMesh;
  132275. private _octahedron;
  132276. private _sensitivity;
  132277. /** Fires an event when any of it's sub gizmos are dragged */
  132278. onDragStartObservable: Observable<unknown>;
  132279. /** Fires an event when any of it's sub gizmos are released from dragging */
  132280. onDragEndObservable: Observable<unknown>;
  132281. get attachedMesh(): Nullable<AbstractMesh>;
  132282. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132283. get attachedNode(): Nullable<Node>;
  132284. set attachedNode(node: Nullable<Node>);
  132285. /**
  132286. * Creates a ScaleGizmo
  132287. * @param gizmoLayer The utility layer the gizmo will be added to
  132288. * @param thickness display gizmo axis thickness
  132289. */
  132290. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132291. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132292. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132293. /**
  132294. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132295. */
  132296. set snapDistance(value: number);
  132297. get snapDistance(): number;
  132298. /**
  132299. * Ratio for the scale of the gizmo (Default: 1)
  132300. */
  132301. set scaleRatio(value: number);
  132302. get scaleRatio(): number;
  132303. /**
  132304. * Sensitivity factor for dragging (Default: 1)
  132305. */
  132306. set sensitivity(value: number);
  132307. get sensitivity(): number;
  132308. /**
  132309. * Disposes of the gizmo
  132310. */
  132311. dispose(): void;
  132312. }
  132313. }
  132314. declare module BABYLON {
  132315. /**
  132316. * Single axis scale gizmo
  132317. */
  132318. export class AxisScaleGizmo extends Gizmo {
  132319. /**
  132320. * Drag behavior responsible for the gizmos dragging interactions
  132321. */
  132322. dragBehavior: PointerDragBehavior;
  132323. private _pointerObserver;
  132324. /**
  132325. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132326. */
  132327. snapDistance: number;
  132328. /**
  132329. * Event that fires each time the gizmo snaps to a new location.
  132330. * * snapDistance is the the change in distance
  132331. */
  132332. onSnapObservable: Observable<{
  132333. snapDistance: number;
  132334. }>;
  132335. /**
  132336. * If the scaling operation should be done on all axis (default: false)
  132337. */
  132338. uniformScaling: boolean;
  132339. /**
  132340. * Custom sensitivity value for the drag strength
  132341. */
  132342. sensitivity: number;
  132343. private _isEnabled;
  132344. private _parent;
  132345. private _arrow;
  132346. private _coloredMaterial;
  132347. private _hoverMaterial;
  132348. /**
  132349. * Creates an AxisScaleGizmo
  132350. * @param gizmoLayer The utility layer the gizmo will be added to
  132351. * @param dragAxis The axis which the gizmo will be able to scale on
  132352. * @param color The color of the gizmo
  132353. * @param thickness display gizmo axis thickness
  132354. */
  132355. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132356. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132357. /**
  132358. * If the gizmo is enabled
  132359. */
  132360. set isEnabled(value: boolean);
  132361. get isEnabled(): boolean;
  132362. /**
  132363. * Disposes of the gizmo
  132364. */
  132365. dispose(): void;
  132366. /**
  132367. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132368. * @param mesh The mesh to replace the default mesh of the gizmo
  132369. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132370. */
  132371. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132372. }
  132373. }
  132374. declare module BABYLON {
  132375. /**
  132376. * Bounding box gizmo
  132377. */
  132378. export class BoundingBoxGizmo extends Gizmo {
  132379. private _lineBoundingBox;
  132380. private _rotateSpheresParent;
  132381. private _scaleBoxesParent;
  132382. private _boundingDimensions;
  132383. private _renderObserver;
  132384. private _pointerObserver;
  132385. private _scaleDragSpeed;
  132386. private _tmpQuaternion;
  132387. private _tmpVector;
  132388. private _tmpRotationMatrix;
  132389. /**
  132390. * 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)
  132391. */
  132392. ignoreChildren: boolean;
  132393. /**
  132394. * 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)
  132395. */
  132396. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132397. /**
  132398. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132399. */
  132400. rotationSphereSize: number;
  132401. /**
  132402. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132403. */
  132404. scaleBoxSize: number;
  132405. /**
  132406. * 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)
  132407. */
  132408. fixedDragMeshScreenSize: boolean;
  132409. /**
  132410. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132411. */
  132412. fixedDragMeshScreenSizeDistanceFactor: number;
  132413. /**
  132414. * Fired when a rotation sphere or scale box is dragged
  132415. */
  132416. onDragStartObservable: Observable<{}>;
  132417. /**
  132418. * Fired when a scale box is dragged
  132419. */
  132420. onScaleBoxDragObservable: Observable<{}>;
  132421. /**
  132422. * Fired when a scale box drag is ended
  132423. */
  132424. onScaleBoxDragEndObservable: Observable<{}>;
  132425. /**
  132426. * Fired when a rotation sphere is dragged
  132427. */
  132428. onRotationSphereDragObservable: Observable<{}>;
  132429. /**
  132430. * Fired when a rotation sphere drag is ended
  132431. */
  132432. onRotationSphereDragEndObservable: Observable<{}>;
  132433. /**
  132434. * 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)
  132435. */
  132436. scalePivot: Nullable<Vector3>;
  132437. /**
  132438. * Mesh used as a pivot to rotate the attached node
  132439. */
  132440. private _anchorMesh;
  132441. private _existingMeshScale;
  132442. private _dragMesh;
  132443. private pointerDragBehavior;
  132444. private coloredMaterial;
  132445. private hoverColoredMaterial;
  132446. /**
  132447. * Sets the color of the bounding box gizmo
  132448. * @param color the color to set
  132449. */
  132450. setColor(color: Color3): void;
  132451. /**
  132452. * Creates an BoundingBoxGizmo
  132453. * @param gizmoLayer The utility layer the gizmo will be added to
  132454. * @param color The color of the gizmo
  132455. */
  132456. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132457. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132458. private _selectNode;
  132459. /**
  132460. * Updates the bounding box information for the Gizmo
  132461. */
  132462. updateBoundingBox(): void;
  132463. private _updateRotationSpheres;
  132464. private _updateScaleBoxes;
  132465. /**
  132466. * Enables rotation on the specified axis and disables rotation on the others
  132467. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132468. */
  132469. setEnabledRotationAxis(axis: string): void;
  132470. /**
  132471. * Enables/disables scaling
  132472. * @param enable if scaling should be enabled
  132473. * @param homogeneousScaling defines if scaling should only be homogeneous
  132474. */
  132475. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132476. private _updateDummy;
  132477. /**
  132478. * Enables a pointer drag behavior on the bounding box of the gizmo
  132479. */
  132480. enableDragBehavior(): void;
  132481. /**
  132482. * Disposes of the gizmo
  132483. */
  132484. dispose(): void;
  132485. /**
  132486. * 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)
  132487. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132488. * @returns the bounding box mesh with the passed in mesh as a child
  132489. */
  132490. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132491. /**
  132492. * CustomMeshes are not supported by this gizmo
  132493. * @param mesh The mesh to replace the default mesh of the gizmo
  132494. */
  132495. setCustomMesh(mesh: Mesh): void;
  132496. }
  132497. }
  132498. declare module BABYLON {
  132499. /**
  132500. * Single plane rotation gizmo
  132501. */
  132502. export class PlaneRotationGizmo extends Gizmo {
  132503. /**
  132504. * Drag behavior responsible for the gizmos dragging interactions
  132505. */
  132506. dragBehavior: PointerDragBehavior;
  132507. private _pointerObserver;
  132508. /**
  132509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132510. */
  132511. snapDistance: number;
  132512. /**
  132513. * Event that fires each time the gizmo snaps to a new location.
  132514. * * snapDistance is the the change in distance
  132515. */
  132516. onSnapObservable: Observable<{
  132517. snapDistance: number;
  132518. }>;
  132519. private _isEnabled;
  132520. private _parent;
  132521. /**
  132522. * Creates a PlaneRotationGizmo
  132523. * @param gizmoLayer The utility layer the gizmo will be added to
  132524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132525. * @param color The color of the gizmo
  132526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132528. * @param thickness display gizmo axis thickness
  132529. */
  132530. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132531. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132532. /**
  132533. * If the gizmo is enabled
  132534. */
  132535. set isEnabled(value: boolean);
  132536. get isEnabled(): boolean;
  132537. /**
  132538. * Disposes of the gizmo
  132539. */
  132540. dispose(): void;
  132541. }
  132542. }
  132543. declare module BABYLON {
  132544. /**
  132545. * Gizmo that enables rotating a mesh along 3 axis
  132546. */
  132547. export class RotationGizmo extends Gizmo {
  132548. /**
  132549. * Internal gizmo used for interactions on the x axis
  132550. */
  132551. xGizmo: PlaneRotationGizmo;
  132552. /**
  132553. * Internal gizmo used for interactions on the y axis
  132554. */
  132555. yGizmo: PlaneRotationGizmo;
  132556. /**
  132557. * Internal gizmo used for interactions on the z axis
  132558. */
  132559. zGizmo: PlaneRotationGizmo;
  132560. /** Fires an event when any of it's sub gizmos are dragged */
  132561. onDragStartObservable: Observable<unknown>;
  132562. /** Fires an event when any of it's sub gizmos are released from dragging */
  132563. onDragEndObservable: Observable<unknown>;
  132564. private _meshAttached;
  132565. private _nodeAttached;
  132566. get attachedMesh(): Nullable<AbstractMesh>;
  132567. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132568. get attachedNode(): Nullable<Node>;
  132569. set attachedNode(node: Nullable<Node>);
  132570. /**
  132571. * Creates a RotationGizmo
  132572. * @param gizmoLayer The utility layer the gizmo will be added to
  132573. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132574. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132575. * @param thickness display gizmo axis thickness
  132576. */
  132577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132578. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132579. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132580. /**
  132581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132582. */
  132583. set snapDistance(value: number);
  132584. get snapDistance(): number;
  132585. /**
  132586. * Ratio for the scale of the gizmo (Default: 1)
  132587. */
  132588. set scaleRatio(value: number);
  132589. get scaleRatio(): number;
  132590. /**
  132591. * Disposes of the gizmo
  132592. */
  132593. dispose(): void;
  132594. /**
  132595. * CustomMeshes are not supported by this gizmo
  132596. * @param mesh The mesh to replace the default mesh of the gizmo
  132597. */
  132598. setCustomMesh(mesh: Mesh): void;
  132599. }
  132600. }
  132601. declare module BABYLON {
  132602. /**
  132603. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  132604. */
  132605. export class GizmoManager implements IDisposable {
  132606. private scene;
  132607. /**
  132608. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132609. */
  132610. gizmos: {
  132611. positionGizmo: Nullable<PositionGizmo>;
  132612. rotationGizmo: Nullable<RotationGizmo>;
  132613. scaleGizmo: Nullable<ScaleGizmo>;
  132614. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132615. };
  132616. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132617. clearGizmoOnEmptyPointerEvent: boolean;
  132618. /** Fires an event when the manager is attached to a mesh */
  132619. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132620. private _gizmosEnabled;
  132621. private _pointerObserver;
  132622. private _attachedMesh;
  132623. private _boundingBoxColor;
  132624. private _defaultUtilityLayer;
  132625. private _defaultKeepDepthUtilityLayer;
  132626. private _thickness;
  132627. /**
  132628. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132629. */
  132630. boundingBoxDragBehavior: SixDofDragBehavior;
  132631. /**
  132632. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132633. */
  132634. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132635. /**
  132636. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132637. */
  132638. usePointerToAttachGizmos: boolean;
  132639. /**
  132640. * Utility layer that the bounding box gizmo belongs to
  132641. */
  132642. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132643. /**
  132644. * Utility layer that all gizmos besides bounding box belong to
  132645. */
  132646. get utilityLayer(): UtilityLayerRenderer;
  132647. /**
  132648. * Instatiates a gizmo manager
  132649. * @param scene the scene to overlay the gizmos on top of
  132650. * @param thickness display gizmo axis thickness
  132651. */
  132652. constructor(scene: Scene, thickness?: number);
  132653. /**
  132654. * Attaches a set of gizmos to the specified mesh
  132655. * @param mesh The mesh the gizmo's should be attached to
  132656. */
  132657. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132658. /**
  132659. * If the position gizmo is enabled
  132660. */
  132661. set positionGizmoEnabled(value: boolean);
  132662. get positionGizmoEnabled(): boolean;
  132663. /**
  132664. * If the rotation gizmo is enabled
  132665. */
  132666. set rotationGizmoEnabled(value: boolean);
  132667. get rotationGizmoEnabled(): boolean;
  132668. /**
  132669. * If the scale gizmo is enabled
  132670. */
  132671. set scaleGizmoEnabled(value: boolean);
  132672. get scaleGizmoEnabled(): boolean;
  132673. /**
  132674. * If the boundingBox gizmo is enabled
  132675. */
  132676. set boundingBoxGizmoEnabled(value: boolean);
  132677. get boundingBoxGizmoEnabled(): boolean;
  132678. /**
  132679. * Disposes of the gizmo manager
  132680. */
  132681. dispose(): void;
  132682. }
  132683. }
  132684. declare module BABYLON {
  132685. /**
  132686. * A directional light is defined by a direction (what a surprise!).
  132687. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132688. * 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.
  132689. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132690. */
  132691. export class DirectionalLight extends ShadowLight {
  132692. private _shadowFrustumSize;
  132693. /**
  132694. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132695. */
  132696. get shadowFrustumSize(): number;
  132697. /**
  132698. * Specifies a fix frustum size for the shadow generation.
  132699. */
  132700. set shadowFrustumSize(value: number);
  132701. private _shadowOrthoScale;
  132702. /**
  132703. * Gets the shadow projection scale against the optimal computed one.
  132704. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132705. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132706. */
  132707. get shadowOrthoScale(): number;
  132708. /**
  132709. * Sets the shadow projection scale against the optimal computed one.
  132710. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132711. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132712. */
  132713. set shadowOrthoScale(value: number);
  132714. /**
  132715. * Automatically compute the projection matrix to best fit (including all the casters)
  132716. * on each frame.
  132717. */
  132718. autoUpdateExtends: boolean;
  132719. /**
  132720. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132721. * on each frame. autoUpdateExtends must be set to true for this to work
  132722. */
  132723. autoCalcShadowZBounds: boolean;
  132724. private _orthoLeft;
  132725. private _orthoRight;
  132726. private _orthoTop;
  132727. private _orthoBottom;
  132728. /**
  132729. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132730. * The directional light is emitted from everywhere in the given direction.
  132731. * It can cast shadows.
  132732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132733. * @param name The friendly name of the light
  132734. * @param direction The direction of the light
  132735. * @param scene The scene the light belongs to
  132736. */
  132737. constructor(name: string, direction: Vector3, scene: Scene);
  132738. /**
  132739. * Returns the string "DirectionalLight".
  132740. * @return The class name
  132741. */
  132742. getClassName(): string;
  132743. /**
  132744. * Returns the integer 1.
  132745. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132746. */
  132747. getTypeID(): number;
  132748. /**
  132749. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132750. * Returns the DirectionalLight Shadow projection matrix.
  132751. */
  132752. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132753. /**
  132754. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132755. * Returns the DirectionalLight Shadow projection matrix.
  132756. */
  132757. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132758. /**
  132759. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132760. * Returns the DirectionalLight Shadow projection matrix.
  132761. */
  132762. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132763. protected _buildUniformLayout(): void;
  132764. /**
  132765. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132766. * @param effect The effect to update
  132767. * @param lightIndex The index of the light in the effect to update
  132768. * @returns The directional light
  132769. */
  132770. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132771. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132772. /**
  132773. * Gets the minZ used for shadow according to both the scene and the light.
  132774. *
  132775. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132776. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132777. * @param activeCamera The camera we are returning the min for
  132778. * @returns the depth min z
  132779. */
  132780. getDepthMinZ(activeCamera: Camera): number;
  132781. /**
  132782. * Gets the maxZ used for shadow according to both the scene and the light.
  132783. *
  132784. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132785. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132786. * @param activeCamera The camera we are returning the max for
  132787. * @returns the depth max z
  132788. */
  132789. getDepthMaxZ(activeCamera: Camera): number;
  132790. /**
  132791. * Prepares the list of defines specific to the light type.
  132792. * @param defines the list of defines
  132793. * @param lightIndex defines the index of the light for the effect
  132794. */
  132795. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132796. }
  132797. }
  132798. declare module BABYLON {
  132799. /**
  132800. * Class containing static functions to help procedurally build meshes
  132801. */
  132802. export class HemisphereBuilder {
  132803. /**
  132804. * Creates a hemisphere mesh
  132805. * @param name defines the name of the mesh
  132806. * @param options defines the options used to create the mesh
  132807. * @param scene defines the hosting scene
  132808. * @returns the hemisphere mesh
  132809. */
  132810. static CreateHemisphere(name: string, options: {
  132811. segments?: number;
  132812. diameter?: number;
  132813. sideOrientation?: number;
  132814. }, scene: any): Mesh;
  132815. }
  132816. }
  132817. declare module BABYLON {
  132818. /**
  132819. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132820. * These values define a cone of light starting from the position, emitting toward the direction.
  132821. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132822. * and the exponent defines the speed of the decay of the light with distance (reach).
  132823. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132824. */
  132825. export class SpotLight extends ShadowLight {
  132826. private _angle;
  132827. private _innerAngle;
  132828. private _cosHalfAngle;
  132829. private _lightAngleScale;
  132830. private _lightAngleOffset;
  132831. /**
  132832. * Gets the cone angle of the spot light in Radians.
  132833. */
  132834. get angle(): number;
  132835. /**
  132836. * Sets the cone angle of the spot light in Radians.
  132837. */
  132838. set angle(value: number);
  132839. /**
  132840. * Only used in gltf falloff mode, this defines the angle where
  132841. * the directional falloff will start before cutting at angle which could be seen
  132842. * as outer angle.
  132843. */
  132844. get innerAngle(): number;
  132845. /**
  132846. * Only used in gltf falloff mode, this defines the angle where
  132847. * the directional falloff will start before cutting at angle which could be seen
  132848. * as outer angle.
  132849. */
  132850. set innerAngle(value: number);
  132851. private _shadowAngleScale;
  132852. /**
  132853. * Allows scaling the angle of the light for shadow generation only.
  132854. */
  132855. get shadowAngleScale(): number;
  132856. /**
  132857. * Allows scaling the angle of the light for shadow generation only.
  132858. */
  132859. set shadowAngleScale(value: number);
  132860. /**
  132861. * The light decay speed with the distance from the emission spot.
  132862. */
  132863. exponent: number;
  132864. private _projectionTextureMatrix;
  132865. /**
  132866. * Allows reading the projecton texture
  132867. */
  132868. get projectionTextureMatrix(): Matrix;
  132869. protected _projectionTextureLightNear: number;
  132870. /**
  132871. * Gets the near clip of the Spotlight for texture projection.
  132872. */
  132873. get projectionTextureLightNear(): number;
  132874. /**
  132875. * Sets the near clip of the Spotlight for texture projection.
  132876. */
  132877. set projectionTextureLightNear(value: number);
  132878. protected _projectionTextureLightFar: number;
  132879. /**
  132880. * Gets the far clip of the Spotlight for texture projection.
  132881. */
  132882. get projectionTextureLightFar(): number;
  132883. /**
  132884. * Sets the far clip of the Spotlight for texture projection.
  132885. */
  132886. set projectionTextureLightFar(value: number);
  132887. protected _projectionTextureUpDirection: Vector3;
  132888. /**
  132889. * Gets the Up vector of the Spotlight for texture projection.
  132890. */
  132891. get projectionTextureUpDirection(): Vector3;
  132892. /**
  132893. * Sets the Up vector of the Spotlight for texture projection.
  132894. */
  132895. set projectionTextureUpDirection(value: Vector3);
  132896. private _projectionTexture;
  132897. /**
  132898. * Gets the projection texture of the light.
  132899. */
  132900. get projectionTexture(): Nullable<BaseTexture>;
  132901. /**
  132902. * Sets the projection texture of the light.
  132903. */
  132904. set projectionTexture(value: Nullable<BaseTexture>);
  132905. private _projectionTextureViewLightDirty;
  132906. private _projectionTextureProjectionLightDirty;
  132907. private _projectionTextureDirty;
  132908. private _projectionTextureViewTargetVector;
  132909. private _projectionTextureViewLightMatrix;
  132910. private _projectionTextureProjectionLightMatrix;
  132911. private _projectionTextureScalingMatrix;
  132912. /**
  132913. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132914. * It can cast shadows.
  132915. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132916. * @param name The light friendly name
  132917. * @param position The position of the spot light in the scene
  132918. * @param direction The direction of the light in the scene
  132919. * @param angle The cone angle of the light in Radians
  132920. * @param exponent The light decay speed with the distance from the emission spot
  132921. * @param scene The scene the lights belongs to
  132922. */
  132923. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132924. /**
  132925. * Returns the string "SpotLight".
  132926. * @returns the class name
  132927. */
  132928. getClassName(): string;
  132929. /**
  132930. * Returns the integer 2.
  132931. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132932. */
  132933. getTypeID(): number;
  132934. /**
  132935. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132936. */
  132937. protected _setDirection(value: Vector3): void;
  132938. /**
  132939. * Overrides the position setter to recompute the projection texture view light Matrix.
  132940. */
  132941. protected _setPosition(value: Vector3): void;
  132942. /**
  132943. * 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.
  132944. * Returns the SpotLight.
  132945. */
  132946. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132947. protected _computeProjectionTextureViewLightMatrix(): void;
  132948. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132949. /**
  132950. * Main function for light texture projection matrix computing.
  132951. */
  132952. protected _computeProjectionTextureMatrix(): void;
  132953. protected _buildUniformLayout(): void;
  132954. private _computeAngleValues;
  132955. /**
  132956. * Sets the passed Effect "effect" with the Light textures.
  132957. * @param effect The effect to update
  132958. * @param lightIndex The index of the light in the effect to update
  132959. * @returns The light
  132960. */
  132961. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132962. /**
  132963. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132964. * @param effect The effect to update
  132965. * @param lightIndex The index of the light in the effect to update
  132966. * @returns The spot light
  132967. */
  132968. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132969. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132970. /**
  132971. * Disposes the light and the associated resources.
  132972. */
  132973. dispose(): void;
  132974. /**
  132975. * Prepares the list of defines specific to the light type.
  132976. * @param defines the list of defines
  132977. * @param lightIndex defines the index of the light for the effect
  132978. */
  132979. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132980. }
  132981. }
  132982. declare module BABYLON {
  132983. /**
  132984. * Gizmo that enables viewing a light
  132985. */
  132986. export class LightGizmo extends Gizmo {
  132987. private _lightMesh;
  132988. private _material;
  132989. private _cachedPosition;
  132990. private _cachedForward;
  132991. private _attachedMeshParent;
  132992. /**
  132993. * Creates a LightGizmo
  132994. * @param gizmoLayer The utility layer the gizmo will be added to
  132995. */
  132996. constructor(gizmoLayer?: UtilityLayerRenderer);
  132997. private _light;
  132998. /**
  132999. * The light that the gizmo is attached to
  133000. */
  133001. set light(light: Nullable<Light>);
  133002. get light(): Nullable<Light>;
  133003. /**
  133004. * Gets the material used to render the light gizmo
  133005. */
  133006. get material(): StandardMaterial;
  133007. /**
  133008. * @hidden
  133009. * Updates the gizmo to match the attached mesh's position/rotation
  133010. */
  133011. protected _update(): void;
  133012. private static _Scale;
  133013. /**
  133014. * Creates the lines for a light mesh
  133015. */
  133016. private static _CreateLightLines;
  133017. /**
  133018. * Disposes of the light gizmo
  133019. */
  133020. dispose(): void;
  133021. private static _CreateHemisphericLightMesh;
  133022. private static _CreatePointLightMesh;
  133023. private static _CreateSpotLightMesh;
  133024. private static _CreateDirectionalLightMesh;
  133025. }
  133026. }
  133027. declare module BABYLON {
  133028. /** @hidden */
  133029. export var backgroundFragmentDeclaration: {
  133030. name: string;
  133031. shader: string;
  133032. };
  133033. }
  133034. declare module BABYLON {
  133035. /** @hidden */
  133036. export var backgroundUboDeclaration: {
  133037. name: string;
  133038. shader: string;
  133039. };
  133040. }
  133041. declare module BABYLON {
  133042. /** @hidden */
  133043. export var backgroundPixelShader: {
  133044. name: string;
  133045. shader: string;
  133046. };
  133047. }
  133048. declare module BABYLON {
  133049. /** @hidden */
  133050. export var backgroundVertexDeclaration: {
  133051. name: string;
  133052. shader: string;
  133053. };
  133054. }
  133055. declare module BABYLON {
  133056. /** @hidden */
  133057. export var backgroundVertexShader: {
  133058. name: string;
  133059. shader: string;
  133060. };
  133061. }
  133062. declare module BABYLON {
  133063. /**
  133064. * Background material used to create an efficient environement around your scene.
  133065. */
  133066. export class BackgroundMaterial extends PushMaterial {
  133067. /**
  133068. * Standard reflectance value at parallel view angle.
  133069. */
  133070. static StandardReflectance0: number;
  133071. /**
  133072. * Standard reflectance value at grazing angle.
  133073. */
  133074. static StandardReflectance90: number;
  133075. protected _primaryColor: Color3;
  133076. /**
  133077. * Key light Color (multiply against the environement texture)
  133078. */
  133079. primaryColor: Color3;
  133080. protected __perceptualColor: Nullable<Color3>;
  133081. /**
  133082. * Experimental Internal Use Only.
  133083. *
  133084. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133085. * This acts as a helper to set the primary color to a more "human friendly" value.
  133086. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133087. * output color as close as possible from the chosen value.
  133088. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133089. * part of lighting setup.)
  133090. */
  133091. get _perceptualColor(): Nullable<Color3>;
  133092. set _perceptualColor(value: Nullable<Color3>);
  133093. protected _primaryColorShadowLevel: float;
  133094. /**
  133095. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133096. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  133097. */
  133098. get primaryColorShadowLevel(): float;
  133099. set primaryColorShadowLevel(value: float);
  133100. protected _primaryColorHighlightLevel: float;
  133101. /**
  133102. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  133103. * The primary color is used at the level chosen to define what the white area would look.
  133104. */
  133105. get primaryColorHighlightLevel(): float;
  133106. set primaryColorHighlightLevel(value: float);
  133107. protected _reflectionTexture: Nullable<BaseTexture>;
  133108. /**
  133109. * Reflection Texture used in the material.
  133110. * Should be author in a specific way for the best result (refer to the documentation).
  133111. */
  133112. reflectionTexture: Nullable<BaseTexture>;
  133113. protected _reflectionBlur: float;
  133114. /**
  133115. * Reflection Texture level of blur.
  133116. *
  133117. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133118. * texture twice.
  133119. */
  133120. reflectionBlur: float;
  133121. protected _diffuseTexture: Nullable<BaseTexture>;
  133122. /**
  133123. * Diffuse Texture used in the material.
  133124. * Should be author in a specific way for the best result (refer to the documentation).
  133125. */
  133126. diffuseTexture: Nullable<BaseTexture>;
  133127. protected _shadowLights: Nullable<IShadowLight[]>;
  133128. /**
  133129. * Specify the list of lights casting shadow on the material.
  133130. * All scene shadow lights will be included if null.
  133131. */
  133132. shadowLights: Nullable<IShadowLight[]>;
  133133. protected _shadowLevel: float;
  133134. /**
  133135. * Helps adjusting the shadow to a softer level if required.
  133136. * 0 means black shadows and 1 means no shadows.
  133137. */
  133138. shadowLevel: float;
  133139. protected _sceneCenter: Vector3;
  133140. /**
  133141. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133142. * It is usually zero but might be interesting to modify according to your setup.
  133143. */
  133144. sceneCenter: Vector3;
  133145. protected _opacityFresnel: boolean;
  133146. /**
  133147. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133148. * This helps ensuring a nice transition when the camera goes under the ground.
  133149. */
  133150. opacityFresnel: boolean;
  133151. protected _reflectionFresnel: boolean;
  133152. /**
  133153. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133154. * This helps adding a mirror texture on the ground.
  133155. */
  133156. reflectionFresnel: boolean;
  133157. protected _reflectionFalloffDistance: number;
  133158. /**
  133159. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133160. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133161. */
  133162. reflectionFalloffDistance: number;
  133163. protected _reflectionAmount: number;
  133164. /**
  133165. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133166. */
  133167. reflectionAmount: number;
  133168. protected _reflectionReflectance0: number;
  133169. /**
  133170. * This specifies the weight of the reflection at grazing angle.
  133171. */
  133172. reflectionReflectance0: number;
  133173. protected _reflectionReflectance90: number;
  133174. /**
  133175. * This specifies the weight of the reflection at a perpendicular point of view.
  133176. */
  133177. reflectionReflectance90: number;
  133178. /**
  133179. * Sets the reflection reflectance fresnel values according to the default standard
  133180. * empirically know to work well :-)
  133181. */
  133182. set reflectionStandardFresnelWeight(value: number);
  133183. protected _useRGBColor: boolean;
  133184. /**
  133185. * Helps to directly use the maps channels instead of their level.
  133186. */
  133187. useRGBColor: boolean;
  133188. protected _enableNoise: boolean;
  133189. /**
  133190. * This helps reducing the banding effect that could occur on the background.
  133191. */
  133192. enableNoise: boolean;
  133193. /**
  133194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133195. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133196. * Recommended to be keep at 1.0 except for special cases.
  133197. */
  133198. get fovMultiplier(): number;
  133199. set fovMultiplier(value: number);
  133200. private _fovMultiplier;
  133201. /**
  133202. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133203. */
  133204. useEquirectangularFOV: boolean;
  133205. private _maxSimultaneousLights;
  133206. /**
  133207. * Number of Simultaneous lights allowed on the material.
  133208. */
  133209. maxSimultaneousLights: int;
  133210. private _shadowOnly;
  133211. /**
  133212. * Make the material only render shadows
  133213. */
  133214. shadowOnly: boolean;
  133215. /**
  133216. * Default configuration related to image processing available in the Background Material.
  133217. */
  133218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133219. /**
  133220. * Keep track of the image processing observer to allow dispose and replace.
  133221. */
  133222. private _imageProcessingObserver;
  133223. /**
  133224. * Attaches a new image processing configuration to the PBR Material.
  133225. * @param configuration (if null the scene configuration will be use)
  133226. */
  133227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133228. /**
  133229. * Gets the image processing configuration used either in this material.
  133230. */
  133231. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133232. /**
  133233. * Sets the Default image processing configuration used either in the this material.
  133234. *
  133235. * If sets to null, the scene one is in use.
  133236. */
  133237. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133238. /**
  133239. * Gets wether the color curves effect is enabled.
  133240. */
  133241. get cameraColorCurvesEnabled(): boolean;
  133242. /**
  133243. * Sets wether the color curves effect is enabled.
  133244. */
  133245. set cameraColorCurvesEnabled(value: boolean);
  133246. /**
  133247. * Gets wether the color grading effect is enabled.
  133248. */
  133249. get cameraColorGradingEnabled(): boolean;
  133250. /**
  133251. * Gets wether the color grading effect is enabled.
  133252. */
  133253. set cameraColorGradingEnabled(value: boolean);
  133254. /**
  133255. * Gets wether tonemapping is enabled or not.
  133256. */
  133257. get cameraToneMappingEnabled(): boolean;
  133258. /**
  133259. * Sets wether tonemapping is enabled or not
  133260. */
  133261. set cameraToneMappingEnabled(value: boolean);
  133262. /**
  133263. * The camera exposure used on this material.
  133264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133265. * This corresponds to a photographic exposure.
  133266. */
  133267. get cameraExposure(): float;
  133268. /**
  133269. * The camera exposure used on this material.
  133270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133271. * This corresponds to a photographic exposure.
  133272. */
  133273. set cameraExposure(value: float);
  133274. /**
  133275. * Gets The camera contrast used on this material.
  133276. */
  133277. get cameraContrast(): float;
  133278. /**
  133279. * Sets The camera contrast used on this material.
  133280. */
  133281. set cameraContrast(value: float);
  133282. /**
  133283. * Gets the Color Grading 2D Lookup Texture.
  133284. */
  133285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133286. /**
  133287. * Sets the Color Grading 2D Lookup Texture.
  133288. */
  133289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133290. /**
  133291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133293. * 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;
  133294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133295. */
  133296. get cameraColorCurves(): Nullable<ColorCurves>;
  133297. /**
  133298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133300. * 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;
  133301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133302. */
  133303. set cameraColorCurves(value: Nullable<ColorCurves>);
  133304. /**
  133305. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133306. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133307. */
  133308. switchToBGR: boolean;
  133309. private _renderTargets;
  133310. private _reflectionControls;
  133311. private _white;
  133312. private _primaryShadowColor;
  133313. private _primaryHighlightColor;
  133314. /**
  133315. * Instantiates a Background Material in the given scene
  133316. * @param name The friendly name of the material
  133317. * @param scene The scene to add the material to
  133318. */
  133319. constructor(name: string, scene: Scene);
  133320. /**
  133321. * Gets a boolean indicating that current material needs to register RTT
  133322. */
  133323. get hasRenderTargetTextures(): boolean;
  133324. /**
  133325. * The entire material has been created in order to prevent overdraw.
  133326. * @returns false
  133327. */
  133328. needAlphaTesting(): boolean;
  133329. /**
  133330. * The entire material has been created in order to prevent overdraw.
  133331. * @returns true if blending is enable
  133332. */
  133333. needAlphaBlending(): boolean;
  133334. /**
  133335. * Checks wether the material is ready to be rendered for a given mesh.
  133336. * @param mesh The mesh to render
  133337. * @param subMesh The submesh to check against
  133338. * @param useInstances Specify wether or not the material is used with instances
  133339. * @returns true if all the dependencies are ready (Textures, Effects...)
  133340. */
  133341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133342. /**
  133343. * Compute the primary color according to the chosen perceptual color.
  133344. */
  133345. private _computePrimaryColorFromPerceptualColor;
  133346. /**
  133347. * Compute the highlights and shadow colors according to their chosen levels.
  133348. */
  133349. private _computePrimaryColors;
  133350. /**
  133351. * Build the uniform buffer used in the material.
  133352. */
  133353. buildUniformLayout(): void;
  133354. /**
  133355. * Unbind the material.
  133356. */
  133357. unbind(): void;
  133358. /**
  133359. * Bind only the world matrix to the material.
  133360. * @param world The world matrix to bind.
  133361. */
  133362. bindOnlyWorldMatrix(world: Matrix): void;
  133363. /**
  133364. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133365. * @param world The world matrix to bind.
  133366. * @param subMesh The submesh to bind for.
  133367. */
  133368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133369. /**
  133370. * Checks to see if a texture is used in the material.
  133371. * @param texture - Base texture to use.
  133372. * @returns - Boolean specifying if a texture is used in the material.
  133373. */
  133374. hasTexture(texture: BaseTexture): boolean;
  133375. /**
  133376. * Dispose the material.
  133377. * @param forceDisposeEffect Force disposal of the associated effect.
  133378. * @param forceDisposeTextures Force disposal of the associated textures.
  133379. */
  133380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133381. /**
  133382. * Clones the material.
  133383. * @param name The cloned name.
  133384. * @returns The cloned material.
  133385. */
  133386. clone(name: string): BackgroundMaterial;
  133387. /**
  133388. * Serializes the current material to its JSON representation.
  133389. * @returns The JSON representation.
  133390. */
  133391. serialize(): any;
  133392. /**
  133393. * Gets the class name of the material
  133394. * @returns "BackgroundMaterial"
  133395. */
  133396. getClassName(): string;
  133397. /**
  133398. * Parse a JSON input to create back a background material.
  133399. * @param source The JSON data to parse
  133400. * @param scene The scene to create the parsed material in
  133401. * @param rootUrl The root url of the assets the material depends upon
  133402. * @returns the instantiated BackgroundMaterial.
  133403. */
  133404. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133405. }
  133406. }
  133407. declare module BABYLON {
  133408. /**
  133409. * Represents the different options available during the creation of
  133410. * a Environment helper.
  133411. *
  133412. * This can control the default ground, skybox and image processing setup of your scene.
  133413. */
  133414. export interface IEnvironmentHelperOptions {
  133415. /**
  133416. * Specifies whether or not to create a ground.
  133417. * True by default.
  133418. */
  133419. createGround: boolean;
  133420. /**
  133421. * Specifies the ground size.
  133422. * 15 by default.
  133423. */
  133424. groundSize: number;
  133425. /**
  133426. * The texture used on the ground for the main color.
  133427. * Comes from the BabylonJS CDN by default.
  133428. *
  133429. * Remarks: Can be either a texture or a url.
  133430. */
  133431. groundTexture: string | BaseTexture;
  133432. /**
  133433. * The color mixed in the ground texture by default.
  133434. * BabylonJS clearColor by default.
  133435. */
  133436. groundColor: Color3;
  133437. /**
  133438. * Specifies the ground opacity.
  133439. * 1 by default.
  133440. */
  133441. groundOpacity: number;
  133442. /**
  133443. * Enables the ground to receive shadows.
  133444. * True by default.
  133445. */
  133446. enableGroundShadow: boolean;
  133447. /**
  133448. * Helps preventing the shadow to be fully black on the ground.
  133449. * 0.5 by default.
  133450. */
  133451. groundShadowLevel: number;
  133452. /**
  133453. * Creates a mirror texture attach to the ground.
  133454. * false by default.
  133455. */
  133456. enableGroundMirror: boolean;
  133457. /**
  133458. * Specifies the ground mirror size ratio.
  133459. * 0.3 by default as the default kernel is 64.
  133460. */
  133461. groundMirrorSizeRatio: number;
  133462. /**
  133463. * Specifies the ground mirror blur kernel size.
  133464. * 64 by default.
  133465. */
  133466. groundMirrorBlurKernel: number;
  133467. /**
  133468. * Specifies the ground mirror visibility amount.
  133469. * 1 by default
  133470. */
  133471. groundMirrorAmount: number;
  133472. /**
  133473. * Specifies the ground mirror reflectance weight.
  133474. * This uses the standard weight of the background material to setup the fresnel effect
  133475. * of the mirror.
  133476. * 1 by default.
  133477. */
  133478. groundMirrorFresnelWeight: number;
  133479. /**
  133480. * Specifies the ground mirror Falloff distance.
  133481. * This can helps reducing the size of the reflection.
  133482. * 0 by Default.
  133483. */
  133484. groundMirrorFallOffDistance: number;
  133485. /**
  133486. * Specifies the ground mirror texture type.
  133487. * Unsigned Int by Default.
  133488. */
  133489. groundMirrorTextureType: number;
  133490. /**
  133491. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133492. * the shown objects.
  133493. */
  133494. groundYBias: number;
  133495. /**
  133496. * Specifies whether or not to create a skybox.
  133497. * True by default.
  133498. */
  133499. createSkybox: boolean;
  133500. /**
  133501. * Specifies the skybox size.
  133502. * 20 by default.
  133503. */
  133504. skyboxSize: number;
  133505. /**
  133506. * The texture used on the skybox for the main color.
  133507. * Comes from the BabylonJS CDN by default.
  133508. *
  133509. * Remarks: Can be either a texture or a url.
  133510. */
  133511. skyboxTexture: string | BaseTexture;
  133512. /**
  133513. * The color mixed in the skybox texture by default.
  133514. * BabylonJS clearColor by default.
  133515. */
  133516. skyboxColor: Color3;
  133517. /**
  133518. * The background rotation around the Y axis of the scene.
  133519. * This helps aligning the key lights of your scene with the background.
  133520. * 0 by default.
  133521. */
  133522. backgroundYRotation: number;
  133523. /**
  133524. * Compute automatically the size of the elements to best fit with the scene.
  133525. */
  133526. sizeAuto: boolean;
  133527. /**
  133528. * Default position of the rootMesh if autoSize is not true.
  133529. */
  133530. rootPosition: Vector3;
  133531. /**
  133532. * Sets up the image processing in the scene.
  133533. * true by default.
  133534. */
  133535. setupImageProcessing: boolean;
  133536. /**
  133537. * The texture used as your environment texture in the scene.
  133538. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133539. *
  133540. * Remarks: Can be either a texture or a url.
  133541. */
  133542. environmentTexture: string | BaseTexture;
  133543. /**
  133544. * The value of the exposure to apply to the scene.
  133545. * 0.6 by default if setupImageProcessing is true.
  133546. */
  133547. cameraExposure: number;
  133548. /**
  133549. * The value of the contrast to apply to the scene.
  133550. * 1.6 by default if setupImageProcessing is true.
  133551. */
  133552. cameraContrast: number;
  133553. /**
  133554. * Specifies whether or not tonemapping should be enabled in the scene.
  133555. * true by default if setupImageProcessing is true.
  133556. */
  133557. toneMappingEnabled: boolean;
  133558. }
  133559. /**
  133560. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133561. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133562. * It also helps with the default setup of your imageProcessing configuration.
  133563. */
  133564. export class EnvironmentHelper {
  133565. /**
  133566. * Default ground texture URL.
  133567. */
  133568. private static _groundTextureCDNUrl;
  133569. /**
  133570. * Default skybox texture URL.
  133571. */
  133572. private static _skyboxTextureCDNUrl;
  133573. /**
  133574. * Default environment texture URL.
  133575. */
  133576. private static _environmentTextureCDNUrl;
  133577. /**
  133578. * Creates the default options for the helper.
  133579. */
  133580. private static _getDefaultOptions;
  133581. private _rootMesh;
  133582. /**
  133583. * Gets the root mesh created by the helper.
  133584. */
  133585. get rootMesh(): Mesh;
  133586. private _skybox;
  133587. /**
  133588. * Gets the skybox created by the helper.
  133589. */
  133590. get skybox(): Nullable<Mesh>;
  133591. private _skyboxTexture;
  133592. /**
  133593. * Gets the skybox texture created by the helper.
  133594. */
  133595. get skyboxTexture(): Nullable<BaseTexture>;
  133596. private _skyboxMaterial;
  133597. /**
  133598. * Gets the skybox material created by the helper.
  133599. */
  133600. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133601. private _ground;
  133602. /**
  133603. * Gets the ground mesh created by the helper.
  133604. */
  133605. get ground(): Nullable<Mesh>;
  133606. private _groundTexture;
  133607. /**
  133608. * Gets the ground texture created by the helper.
  133609. */
  133610. get groundTexture(): Nullable<BaseTexture>;
  133611. private _groundMirror;
  133612. /**
  133613. * Gets the ground mirror created by the helper.
  133614. */
  133615. get groundMirror(): Nullable<MirrorTexture>;
  133616. /**
  133617. * Gets the ground mirror render list to helps pushing the meshes
  133618. * you wish in the ground reflection.
  133619. */
  133620. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133621. private _groundMaterial;
  133622. /**
  133623. * Gets the ground material created by the helper.
  133624. */
  133625. get groundMaterial(): Nullable<BackgroundMaterial>;
  133626. /**
  133627. * Stores the creation options.
  133628. */
  133629. private readonly _scene;
  133630. private _options;
  133631. /**
  133632. * This observable will be notified with any error during the creation of the environment,
  133633. * mainly texture creation errors.
  133634. */
  133635. onErrorObservable: Observable<{
  133636. message?: string;
  133637. exception?: any;
  133638. }>;
  133639. /**
  133640. * constructor
  133641. * @param options Defines the options we want to customize the helper
  133642. * @param scene The scene to add the material to
  133643. */
  133644. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133645. /**
  133646. * Updates the background according to the new options
  133647. * @param options
  133648. */
  133649. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133650. /**
  133651. * Sets the primary color of all the available elements.
  133652. * @param color the main color to affect to the ground and the background
  133653. */
  133654. setMainColor(color: Color3): void;
  133655. /**
  133656. * Setup the image processing according to the specified options.
  133657. */
  133658. private _setupImageProcessing;
  133659. /**
  133660. * Setup the environment texture according to the specified options.
  133661. */
  133662. private _setupEnvironmentTexture;
  133663. /**
  133664. * Setup the background according to the specified options.
  133665. */
  133666. private _setupBackground;
  133667. /**
  133668. * Get the scene sizes according to the setup.
  133669. */
  133670. private _getSceneSize;
  133671. /**
  133672. * Setup the ground according to the specified options.
  133673. */
  133674. private _setupGround;
  133675. /**
  133676. * Setup the ground material according to the specified options.
  133677. */
  133678. private _setupGroundMaterial;
  133679. /**
  133680. * Setup the ground diffuse texture according to the specified options.
  133681. */
  133682. private _setupGroundDiffuseTexture;
  133683. /**
  133684. * Setup the ground mirror texture according to the specified options.
  133685. */
  133686. private _setupGroundMirrorTexture;
  133687. /**
  133688. * Setup the ground to receive the mirror texture.
  133689. */
  133690. private _setupMirrorInGroundMaterial;
  133691. /**
  133692. * Setup the skybox according to the specified options.
  133693. */
  133694. private _setupSkybox;
  133695. /**
  133696. * Setup the skybox material according to the specified options.
  133697. */
  133698. private _setupSkyboxMaterial;
  133699. /**
  133700. * Setup the skybox reflection texture according to the specified options.
  133701. */
  133702. private _setupSkyboxReflectionTexture;
  133703. private _errorHandler;
  133704. /**
  133705. * Dispose all the elements created by the Helper.
  133706. */
  133707. dispose(): void;
  133708. }
  133709. }
  133710. declare module BABYLON {
  133711. /**
  133712. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133713. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133714. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133715. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133716. */
  133717. export class PhotoDome extends TransformNode {
  133718. /**
  133719. * Define the image as a Monoscopic panoramic 360 image.
  133720. */
  133721. static readonly MODE_MONOSCOPIC: number;
  133722. /**
  133723. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133724. */
  133725. static readonly MODE_TOPBOTTOM: number;
  133726. /**
  133727. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133728. */
  133729. static readonly MODE_SIDEBYSIDE: number;
  133730. private _useDirectMapping;
  133731. /**
  133732. * The texture being displayed on the sphere
  133733. */
  133734. protected _photoTexture: Texture;
  133735. /**
  133736. * Gets or sets the texture being displayed on the sphere
  133737. */
  133738. get photoTexture(): Texture;
  133739. set photoTexture(value: Texture);
  133740. /**
  133741. * Observable raised when an error occured while loading the 360 image
  133742. */
  133743. onLoadErrorObservable: Observable<string>;
  133744. /**
  133745. * The skybox material
  133746. */
  133747. protected _material: BackgroundMaterial;
  133748. /**
  133749. * The surface used for the skybox
  133750. */
  133751. protected _mesh: Mesh;
  133752. /**
  133753. * Gets the mesh used for the skybox.
  133754. */
  133755. get mesh(): Mesh;
  133756. /**
  133757. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133758. * Also see the options.resolution property.
  133759. */
  133760. get fovMultiplier(): number;
  133761. set fovMultiplier(value: number);
  133762. private _imageMode;
  133763. /**
  133764. * Gets or set the current video mode for the video. It can be:
  133765. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133766. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133767. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133768. */
  133769. get imageMode(): number;
  133770. set imageMode(value: number);
  133771. /**
  133772. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133773. * @param name Element's name, child elements will append suffixes for their own names.
  133774. * @param urlsOfPhoto defines the url of the photo to display
  133775. * @param options defines an object containing optional or exposed sub element properties
  133776. * @param onError defines a callback called when an error occured while loading the texture
  133777. */
  133778. constructor(name: string, urlOfPhoto: string, options: {
  133779. resolution?: number;
  133780. size?: number;
  133781. useDirectMapping?: boolean;
  133782. faceForward?: boolean;
  133783. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133784. private _onBeforeCameraRenderObserver;
  133785. private _changeImageMode;
  133786. /**
  133787. * Releases resources associated with this node.
  133788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133790. */
  133791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133792. }
  133793. }
  133794. declare module BABYLON {
  133795. /**
  133796. * Class used to host RGBD texture specific utilities
  133797. */
  133798. export class RGBDTextureTools {
  133799. /**
  133800. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133801. * @param texture the texture to expand.
  133802. */
  133803. static ExpandRGBDTexture(texture: Texture): void;
  133804. }
  133805. }
  133806. declare module BABYLON {
  133807. /**
  133808. * Class used to host texture specific utilities
  133809. */
  133810. export class BRDFTextureTools {
  133811. /**
  133812. * Prevents texture cache collision
  133813. */
  133814. private static _instanceNumber;
  133815. /**
  133816. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133817. * @param scene defines the hosting scene
  133818. * @returns the environment BRDF texture
  133819. */
  133820. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133821. private static _environmentBRDFBase64Texture;
  133822. }
  133823. }
  133824. declare module BABYLON {
  133825. /**
  133826. * @hidden
  133827. */
  133828. export interface IMaterialClearCoatDefines {
  133829. CLEARCOAT: boolean;
  133830. CLEARCOAT_DEFAULTIOR: boolean;
  133831. CLEARCOAT_TEXTURE: boolean;
  133832. CLEARCOAT_TEXTUREDIRECTUV: number;
  133833. CLEARCOAT_BUMP: boolean;
  133834. CLEARCOAT_BUMPDIRECTUV: number;
  133835. CLEARCOAT_TINT: boolean;
  133836. CLEARCOAT_TINT_TEXTURE: boolean;
  133837. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133838. /** @hidden */
  133839. _areTexturesDirty: boolean;
  133840. }
  133841. /**
  133842. * Define the code related to the clear coat parameters of the pbr material.
  133843. */
  133844. export class PBRClearCoatConfiguration {
  133845. /**
  133846. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133847. * The default fits with a polyurethane material.
  133848. */
  133849. private static readonly _DefaultIndexOfRefraction;
  133850. private _isEnabled;
  133851. /**
  133852. * Defines if the clear coat is enabled in the material.
  133853. */
  133854. isEnabled: boolean;
  133855. /**
  133856. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133857. */
  133858. intensity: number;
  133859. /**
  133860. * Defines the clear coat layer roughness.
  133861. */
  133862. roughness: number;
  133863. private _indexOfRefraction;
  133864. /**
  133865. * Defines the index of refraction of the clear coat.
  133866. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133867. * The default fits with a polyurethane material.
  133868. * Changing the default value is more performance intensive.
  133869. */
  133870. indexOfRefraction: number;
  133871. private _texture;
  133872. /**
  133873. * Stores the clear coat values in a texture.
  133874. */
  133875. texture: Nullable<BaseTexture>;
  133876. private _bumpTexture;
  133877. /**
  133878. * Define the clear coat specific bump texture.
  133879. */
  133880. bumpTexture: Nullable<BaseTexture>;
  133881. private _isTintEnabled;
  133882. /**
  133883. * Defines if the clear coat tint is enabled in the material.
  133884. */
  133885. isTintEnabled: boolean;
  133886. /**
  133887. * Defines the clear coat tint of the material.
  133888. * This is only use if tint is enabled
  133889. */
  133890. tintColor: Color3;
  133891. /**
  133892. * Defines the distance at which the tint color should be found in the
  133893. * clear coat media.
  133894. * This is only use if tint is enabled
  133895. */
  133896. tintColorAtDistance: number;
  133897. /**
  133898. * Defines the clear coat layer thickness.
  133899. * This is only use if tint is enabled
  133900. */
  133901. tintThickness: number;
  133902. private _tintTexture;
  133903. /**
  133904. * Stores the clear tint values in a texture.
  133905. * rgb is tint
  133906. * a is a thickness factor
  133907. */
  133908. tintTexture: Nullable<BaseTexture>;
  133909. /** @hidden */
  133910. private _internalMarkAllSubMeshesAsTexturesDirty;
  133911. /** @hidden */
  133912. _markAllSubMeshesAsTexturesDirty(): void;
  133913. /**
  133914. * Instantiate a new istance of clear coat configuration.
  133915. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133916. */
  133917. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133918. /**
  133919. * Gets wehter the submesh is ready to be used or not.
  133920. * @param defines the list of "defines" to update.
  133921. * @param scene defines the scene the material belongs to.
  133922. * @param engine defines the engine the material belongs to.
  133923. * @param disableBumpMap defines wether the material disables bump or not.
  133924. * @returns - boolean indicating that the submesh is ready or not.
  133925. */
  133926. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133927. /**
  133928. * Checks to see if a texture is used in the material.
  133929. * @param defines the list of "defines" to update.
  133930. * @param scene defines the scene to the material belongs to.
  133931. */
  133932. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133933. /**
  133934. * Binds the material data.
  133935. * @param uniformBuffer defines the Uniform buffer to fill in.
  133936. * @param scene defines the scene the material belongs to.
  133937. * @param engine defines the engine the material belongs to.
  133938. * @param disableBumpMap defines wether the material disables bump or not.
  133939. * @param isFrozen defines wether the material is frozen or not.
  133940. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133941. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133942. */
  133943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133944. /**
  133945. * Checks to see if a texture is used in the material.
  133946. * @param texture - Base texture to use.
  133947. * @returns - Boolean specifying if a texture is used in the material.
  133948. */
  133949. hasTexture(texture: BaseTexture): boolean;
  133950. /**
  133951. * Returns an array of the actively used textures.
  133952. * @param activeTextures Array of BaseTextures
  133953. */
  133954. getActiveTextures(activeTextures: BaseTexture[]): void;
  133955. /**
  133956. * Returns the animatable textures.
  133957. * @param animatables Array of animatable textures.
  133958. */
  133959. getAnimatables(animatables: IAnimatable[]): void;
  133960. /**
  133961. * Disposes the resources of the material.
  133962. * @param forceDisposeTextures - Forces the disposal of all textures.
  133963. */
  133964. dispose(forceDisposeTextures?: boolean): void;
  133965. /**
  133966. * Get the current class name of the texture useful for serialization or dynamic coding.
  133967. * @returns "PBRClearCoatConfiguration"
  133968. */
  133969. getClassName(): string;
  133970. /**
  133971. * Add fallbacks to the effect fallbacks list.
  133972. * @param defines defines the Base texture to use.
  133973. * @param fallbacks defines the current fallback list.
  133974. * @param currentRank defines the current fallback rank.
  133975. * @returns the new fallback rank.
  133976. */
  133977. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133978. /**
  133979. * Add the required uniforms to the current list.
  133980. * @param uniforms defines the current uniform list.
  133981. */
  133982. static AddUniforms(uniforms: string[]): void;
  133983. /**
  133984. * Add the required samplers to the current list.
  133985. * @param samplers defines the current sampler list.
  133986. */
  133987. static AddSamplers(samplers: string[]): void;
  133988. /**
  133989. * Add the required uniforms to the current buffer.
  133990. * @param uniformBuffer defines the current uniform buffer.
  133991. */
  133992. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133993. /**
  133994. * Makes a duplicate of the current configuration into another one.
  133995. * @param clearCoatConfiguration define the config where to copy the info
  133996. */
  133997. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133998. /**
  133999. * Serializes this clear coat configuration.
  134000. * @returns - An object with the serialized config.
  134001. */
  134002. serialize(): any;
  134003. /**
  134004. * Parses a anisotropy Configuration from a serialized object.
  134005. * @param source - Serialized object.
  134006. * @param scene Defines the scene we are parsing for
  134007. * @param rootUrl Defines the rootUrl to load from
  134008. */
  134009. parse(source: any, scene: Scene, rootUrl: string): void;
  134010. }
  134011. }
  134012. declare module BABYLON {
  134013. /**
  134014. * @hidden
  134015. */
  134016. export interface IMaterialAnisotropicDefines {
  134017. ANISOTROPIC: boolean;
  134018. ANISOTROPIC_TEXTURE: boolean;
  134019. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134020. MAINUV1: boolean;
  134021. _areTexturesDirty: boolean;
  134022. _needUVs: boolean;
  134023. }
  134024. /**
  134025. * Define the code related to the anisotropic parameters of the pbr material.
  134026. */
  134027. export class PBRAnisotropicConfiguration {
  134028. private _isEnabled;
  134029. /**
  134030. * Defines if the anisotropy is enabled in the material.
  134031. */
  134032. isEnabled: boolean;
  134033. /**
  134034. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  134035. */
  134036. intensity: number;
  134037. /**
  134038. * Defines if the effect is along the tangents, bitangents or in between.
  134039. * By default, the effect is "strectching" the highlights along the tangents.
  134040. */
  134041. direction: Vector2;
  134042. private _texture;
  134043. /**
  134044. * Stores the anisotropy values in a texture.
  134045. * rg is direction (like normal from -1 to 1)
  134046. * b is a intensity
  134047. */
  134048. texture: Nullable<BaseTexture>;
  134049. /** @hidden */
  134050. private _internalMarkAllSubMeshesAsTexturesDirty;
  134051. /** @hidden */
  134052. _markAllSubMeshesAsTexturesDirty(): void;
  134053. /**
  134054. * Instantiate a new istance of anisotropy configuration.
  134055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134056. */
  134057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134058. /**
  134059. * Specifies that the submesh is ready to be used.
  134060. * @param defines the list of "defines" to update.
  134061. * @param scene defines the scene the material belongs to.
  134062. * @returns - boolean indicating that the submesh is ready or not.
  134063. */
  134064. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  134065. /**
  134066. * Checks to see if a texture is used in the material.
  134067. * @param defines the list of "defines" to update.
  134068. * @param mesh the mesh we are preparing the defines for.
  134069. * @param scene defines the scene the material belongs to.
  134070. */
  134071. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  134072. /**
  134073. * Binds the material data.
  134074. * @param uniformBuffer defines the Uniform buffer to fill in.
  134075. * @param scene defines the scene the material belongs to.
  134076. * @param isFrozen defines wether the material is frozen or not.
  134077. */
  134078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134079. /**
  134080. * Checks to see if a texture is used in the material.
  134081. * @param texture - Base texture to use.
  134082. * @returns - Boolean specifying if a texture is used in the material.
  134083. */
  134084. hasTexture(texture: BaseTexture): boolean;
  134085. /**
  134086. * Returns an array of the actively used textures.
  134087. * @param activeTextures Array of BaseTextures
  134088. */
  134089. getActiveTextures(activeTextures: BaseTexture[]): void;
  134090. /**
  134091. * Returns the animatable textures.
  134092. * @param animatables Array of animatable textures.
  134093. */
  134094. getAnimatables(animatables: IAnimatable[]): void;
  134095. /**
  134096. * Disposes the resources of the material.
  134097. * @param forceDisposeTextures - Forces the disposal of all textures.
  134098. */
  134099. dispose(forceDisposeTextures?: boolean): void;
  134100. /**
  134101. * Get the current class name of the texture useful for serialization or dynamic coding.
  134102. * @returns "PBRAnisotropicConfiguration"
  134103. */
  134104. getClassName(): string;
  134105. /**
  134106. * Add fallbacks to the effect fallbacks list.
  134107. * @param defines defines the Base texture to use.
  134108. * @param fallbacks defines the current fallback list.
  134109. * @param currentRank defines the current fallback rank.
  134110. * @returns the new fallback rank.
  134111. */
  134112. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134113. /**
  134114. * Add the required uniforms to the current list.
  134115. * @param uniforms defines the current uniform list.
  134116. */
  134117. static AddUniforms(uniforms: string[]): void;
  134118. /**
  134119. * Add the required uniforms to the current buffer.
  134120. * @param uniformBuffer defines the current uniform buffer.
  134121. */
  134122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134123. /**
  134124. * Add the required samplers to the current list.
  134125. * @param samplers defines the current sampler list.
  134126. */
  134127. static AddSamplers(samplers: string[]): void;
  134128. /**
  134129. * Makes a duplicate of the current configuration into another one.
  134130. * @param anisotropicConfiguration define the config where to copy the info
  134131. */
  134132. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134133. /**
  134134. * Serializes this anisotropy configuration.
  134135. * @returns - An object with the serialized config.
  134136. */
  134137. serialize(): any;
  134138. /**
  134139. * Parses a anisotropy Configuration from a serialized object.
  134140. * @param source - Serialized object.
  134141. * @param scene Defines the scene we are parsing for
  134142. * @param rootUrl Defines the rootUrl to load from
  134143. */
  134144. parse(source: any, scene: Scene, rootUrl: string): void;
  134145. }
  134146. }
  134147. declare module BABYLON {
  134148. /**
  134149. * @hidden
  134150. */
  134151. export interface IMaterialBRDFDefines {
  134152. BRDF_V_HEIGHT_CORRELATED: boolean;
  134153. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134154. SPHERICAL_HARMONICS: boolean;
  134155. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134156. /** @hidden */
  134157. _areMiscDirty: boolean;
  134158. }
  134159. /**
  134160. * Define the code related to the BRDF parameters of the pbr material.
  134161. */
  134162. export class PBRBRDFConfiguration {
  134163. /**
  134164. * Default value used for the energy conservation.
  134165. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134166. */
  134167. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  134168. /**
  134169. * Default value used for the Smith Visibility Height Correlated mode.
  134170. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134171. */
  134172. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  134173. /**
  134174. * Default value used for the IBL diffuse part.
  134175. * This can help switching back to the polynomials mode globally which is a tiny bit
  134176. * less GPU intensive at the drawback of a lower quality.
  134177. */
  134178. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  134179. /**
  134180. * Default value used for activating energy conservation for the specular workflow.
  134181. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134182. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134183. */
  134184. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  134185. private _useEnergyConservation;
  134186. /**
  134187. * Defines if the material uses energy conservation.
  134188. */
  134189. useEnergyConservation: boolean;
  134190. private _useSmithVisibilityHeightCorrelated;
  134191. /**
  134192. * LEGACY Mode set to false
  134193. * Defines if the material uses height smith correlated visibility term.
  134194. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  134195. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  134196. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  134197. * Not relying on height correlated will also disable energy conservation.
  134198. */
  134199. useSmithVisibilityHeightCorrelated: boolean;
  134200. private _useSphericalHarmonics;
  134201. /**
  134202. * LEGACY Mode set to false
  134203. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  134204. * diffuse part of the IBL.
  134205. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  134206. * to the ground truth.
  134207. */
  134208. useSphericalHarmonics: boolean;
  134209. private _useSpecularGlossinessInputEnergyConservation;
  134210. /**
  134211. * Defines if the material uses energy conservation, when the specular workflow is active.
  134212. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134213. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134214. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  134215. */
  134216. useSpecularGlossinessInputEnergyConservation: boolean;
  134217. /** @hidden */
  134218. private _internalMarkAllSubMeshesAsMiscDirty;
  134219. /** @hidden */
  134220. _markAllSubMeshesAsMiscDirty(): void;
  134221. /**
  134222. * Instantiate a new istance of clear coat configuration.
  134223. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134224. */
  134225. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134226. /**
  134227. * Checks to see if a texture is used in the material.
  134228. * @param defines the list of "defines" to update.
  134229. */
  134230. prepareDefines(defines: IMaterialBRDFDefines): void;
  134231. /**
  134232. * Get the current class name of the texture useful for serialization or dynamic coding.
  134233. * @returns "PBRClearCoatConfiguration"
  134234. */
  134235. getClassName(): string;
  134236. /**
  134237. * Makes a duplicate of the current configuration into another one.
  134238. * @param brdfConfiguration define the config where to copy the info
  134239. */
  134240. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134241. /**
  134242. * Serializes this BRDF configuration.
  134243. * @returns - An object with the serialized config.
  134244. */
  134245. serialize(): any;
  134246. /**
  134247. * Parses a anisotropy Configuration from a serialized object.
  134248. * @param source - Serialized object.
  134249. * @param scene Defines the scene we are parsing for
  134250. * @param rootUrl Defines the rootUrl to load from
  134251. */
  134252. parse(source: any, scene: Scene, rootUrl: string): void;
  134253. }
  134254. }
  134255. declare module BABYLON {
  134256. /**
  134257. * @hidden
  134258. */
  134259. export interface IMaterialSheenDefines {
  134260. SHEEN: boolean;
  134261. SHEEN_TEXTURE: boolean;
  134262. SHEEN_TEXTUREDIRECTUV: number;
  134263. SHEEN_LINKWITHALBEDO: boolean;
  134264. SHEEN_ROUGHNESS: boolean;
  134265. SHEEN_ALBEDOSCALING: boolean;
  134266. /** @hidden */
  134267. _areTexturesDirty: boolean;
  134268. }
  134269. /**
  134270. * Define the code related to the Sheen parameters of the pbr material.
  134271. */
  134272. export class PBRSheenConfiguration {
  134273. private _isEnabled;
  134274. /**
  134275. * Defines if the material uses sheen.
  134276. */
  134277. isEnabled: boolean;
  134278. private _linkSheenWithAlbedo;
  134279. /**
  134280. * Defines if the sheen is linked to the sheen color.
  134281. */
  134282. linkSheenWithAlbedo: boolean;
  134283. /**
  134284. * Defines the sheen intensity.
  134285. */
  134286. intensity: number;
  134287. /**
  134288. * Defines the sheen color.
  134289. */
  134290. color: Color3;
  134291. private _texture;
  134292. /**
  134293. * Stores the sheen tint values in a texture.
  134294. * rgb is tint
  134295. * a is a intensity or roughness if roughness has been defined
  134296. */
  134297. texture: Nullable<BaseTexture>;
  134298. private _roughness;
  134299. /**
  134300. * Defines the sheen roughness.
  134301. * It is not taken into account if linkSheenWithAlbedo is true.
  134302. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134303. */
  134304. roughness: Nullable<number>;
  134305. private _albedoScaling;
  134306. /**
  134307. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134308. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134309. * making it easier to setup and tweak the effect
  134310. */
  134311. albedoScaling: boolean;
  134312. /** @hidden */
  134313. private _internalMarkAllSubMeshesAsTexturesDirty;
  134314. /** @hidden */
  134315. _markAllSubMeshesAsTexturesDirty(): void;
  134316. /**
  134317. * Instantiate a new istance of clear coat configuration.
  134318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134319. */
  134320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134321. /**
  134322. * Specifies that the submesh is ready to be used.
  134323. * @param defines the list of "defines" to update.
  134324. * @param scene defines the scene the material belongs to.
  134325. * @returns - boolean indicating that the submesh is ready or not.
  134326. */
  134327. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134328. /**
  134329. * Checks to see if a texture is used in the material.
  134330. * @param defines the list of "defines" to update.
  134331. * @param scene defines the scene the material belongs to.
  134332. */
  134333. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134334. /**
  134335. * Binds the material data.
  134336. * @param uniformBuffer defines the Uniform buffer to fill in.
  134337. * @param scene defines the scene the material belongs to.
  134338. * @param isFrozen defines wether the material is frozen or not.
  134339. */
  134340. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134341. /**
  134342. * Checks to see if a texture is used in the material.
  134343. * @param texture - Base texture to use.
  134344. * @returns - Boolean specifying if a texture is used in the material.
  134345. */
  134346. hasTexture(texture: BaseTexture): boolean;
  134347. /**
  134348. * Returns an array of the actively used textures.
  134349. * @param activeTextures Array of BaseTextures
  134350. */
  134351. getActiveTextures(activeTextures: BaseTexture[]): void;
  134352. /**
  134353. * Returns the animatable textures.
  134354. * @param animatables Array of animatable textures.
  134355. */
  134356. getAnimatables(animatables: IAnimatable[]): void;
  134357. /**
  134358. * Disposes the resources of the material.
  134359. * @param forceDisposeTextures - Forces the disposal of all textures.
  134360. */
  134361. dispose(forceDisposeTextures?: boolean): void;
  134362. /**
  134363. * Get the current class name of the texture useful for serialization or dynamic coding.
  134364. * @returns "PBRSheenConfiguration"
  134365. */
  134366. getClassName(): string;
  134367. /**
  134368. * Add fallbacks to the effect fallbacks list.
  134369. * @param defines defines the Base texture to use.
  134370. * @param fallbacks defines the current fallback list.
  134371. * @param currentRank defines the current fallback rank.
  134372. * @returns the new fallback rank.
  134373. */
  134374. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134375. /**
  134376. * Add the required uniforms to the current list.
  134377. * @param uniforms defines the current uniform list.
  134378. */
  134379. static AddUniforms(uniforms: string[]): void;
  134380. /**
  134381. * Add the required uniforms to the current buffer.
  134382. * @param uniformBuffer defines the current uniform buffer.
  134383. */
  134384. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134385. /**
  134386. * Add the required samplers to the current list.
  134387. * @param samplers defines the current sampler list.
  134388. */
  134389. static AddSamplers(samplers: string[]): void;
  134390. /**
  134391. * Makes a duplicate of the current configuration into another one.
  134392. * @param sheenConfiguration define the config where to copy the info
  134393. */
  134394. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134395. /**
  134396. * Serializes this BRDF configuration.
  134397. * @returns - An object with the serialized config.
  134398. */
  134399. serialize(): any;
  134400. /**
  134401. * Parses a anisotropy Configuration from a serialized object.
  134402. * @param source - Serialized object.
  134403. * @param scene Defines the scene we are parsing for
  134404. * @param rootUrl Defines the rootUrl to load from
  134405. */
  134406. parse(source: any, scene: Scene, rootUrl: string): void;
  134407. }
  134408. }
  134409. declare module BABYLON {
  134410. /**
  134411. * @hidden
  134412. */
  134413. export interface IMaterialSubSurfaceDefines {
  134414. SUBSURFACE: boolean;
  134415. SS_REFRACTION: boolean;
  134416. SS_TRANSLUCENCY: boolean;
  134417. SS_SCATTERING: boolean;
  134418. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134419. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134420. SS_REFRACTIONMAP_3D: boolean;
  134421. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134422. SS_LODINREFRACTIONALPHA: boolean;
  134423. SS_GAMMAREFRACTION: boolean;
  134424. SS_RGBDREFRACTION: boolean;
  134425. SS_LINEARSPECULARREFRACTION: boolean;
  134426. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134427. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134428. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134429. /** @hidden */
  134430. _areTexturesDirty: boolean;
  134431. }
  134432. /**
  134433. * Define the code related to the sub surface parameters of the pbr material.
  134434. */
  134435. export class PBRSubSurfaceConfiguration {
  134436. private _isRefractionEnabled;
  134437. /**
  134438. * Defines if the refraction is enabled in the material.
  134439. */
  134440. isRefractionEnabled: boolean;
  134441. private _isTranslucencyEnabled;
  134442. /**
  134443. * Defines if the translucency is enabled in the material.
  134444. */
  134445. isTranslucencyEnabled: boolean;
  134446. private _isScatteringEnabled;
  134447. /**
  134448. * Defines if the sub surface scattering is enabled in the material.
  134449. */
  134450. isScatteringEnabled: boolean;
  134451. private _scatteringDiffusionProfileIndex;
  134452. /**
  134453. * Diffusion profile for subsurface scattering.
  134454. * Useful for better scattering in the skins or foliages.
  134455. */
  134456. get scatteringDiffusionProfile(): Nullable<Color3>;
  134457. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134458. /**
  134459. * Defines the refraction intensity of the material.
  134460. * The refraction when enabled replaces the Diffuse part of the material.
  134461. * The intensity helps transitionning between diffuse and refraction.
  134462. */
  134463. refractionIntensity: number;
  134464. /**
  134465. * Defines the translucency intensity of the material.
  134466. * When translucency has been enabled, this defines how much of the "translucency"
  134467. * is addded to the diffuse part of the material.
  134468. */
  134469. translucencyIntensity: number;
  134470. /**
  134471. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134472. */
  134473. useAlbedoToTintRefraction: boolean;
  134474. private _thicknessTexture;
  134475. /**
  134476. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134477. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134478. * 0 would mean minimumThickness
  134479. * 1 would mean maximumThickness
  134480. * The other channels might be use as a mask to vary the different effects intensity.
  134481. */
  134482. thicknessTexture: Nullable<BaseTexture>;
  134483. private _refractionTexture;
  134484. /**
  134485. * Defines the texture to use for refraction.
  134486. */
  134487. refractionTexture: Nullable<BaseTexture>;
  134488. private _indexOfRefraction;
  134489. /**
  134490. * Index of refraction of the material base layer.
  134491. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134492. *
  134493. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134494. *
  134495. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134496. */
  134497. indexOfRefraction: number;
  134498. private _volumeIndexOfRefraction;
  134499. /**
  134500. * Index of refraction of the material's volume.
  134501. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134502. *
  134503. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134504. * the volume will use the same IOR as the surface.
  134505. */
  134506. get volumeIndexOfRefraction(): number;
  134507. set volumeIndexOfRefraction(value: number);
  134508. private _invertRefractionY;
  134509. /**
  134510. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134511. */
  134512. invertRefractionY: boolean;
  134513. private _linkRefractionWithTransparency;
  134514. /**
  134515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134516. * Materials half opaque for instance using refraction could benefit from this control.
  134517. */
  134518. linkRefractionWithTransparency: boolean;
  134519. /**
  134520. * Defines the minimum thickness stored in the thickness map.
  134521. * If no thickness map is defined, this value will be used to simulate thickness.
  134522. */
  134523. minimumThickness: number;
  134524. /**
  134525. * Defines the maximum thickness stored in the thickness map.
  134526. */
  134527. maximumThickness: number;
  134528. /**
  134529. * Defines the volume tint of the material.
  134530. * This is used for both translucency and scattering.
  134531. */
  134532. tintColor: Color3;
  134533. /**
  134534. * Defines the distance at which the tint color should be found in the media.
  134535. * This is used for refraction only.
  134536. */
  134537. tintColorAtDistance: number;
  134538. /**
  134539. * Defines how far each channel transmit through the media.
  134540. * It is defined as a color to simplify it selection.
  134541. */
  134542. diffusionDistance: Color3;
  134543. private _useMaskFromThicknessTexture;
  134544. /**
  134545. * Stores the intensity of the different subsurface effects in the thickness texture.
  134546. * * the green channel is the translucency intensity.
  134547. * * the blue channel is the scattering intensity.
  134548. * * the alpha channel is the refraction intensity.
  134549. */
  134550. useMaskFromThicknessTexture: boolean;
  134551. private _scene;
  134552. /** @hidden */
  134553. private _internalMarkAllSubMeshesAsTexturesDirty;
  134554. private _internalMarkScenePrePassDirty;
  134555. /** @hidden */
  134556. _markAllSubMeshesAsTexturesDirty(): void;
  134557. /** @hidden */
  134558. _markScenePrePassDirty(): void;
  134559. /**
  134560. * Instantiate a new istance of sub surface configuration.
  134561. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134562. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134563. * @param scene The scene
  134564. */
  134565. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134566. /**
  134567. * Gets wehter the submesh is ready to be used or not.
  134568. * @param defines the list of "defines" to update.
  134569. * @param scene defines the scene the material belongs to.
  134570. * @returns - boolean indicating that the submesh is ready or not.
  134571. */
  134572. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134573. /**
  134574. * Checks to see if a texture is used in the material.
  134575. * @param defines the list of "defines" to update.
  134576. * @param scene defines the scene to the material belongs to.
  134577. */
  134578. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134579. /**
  134580. * Binds the material data.
  134581. * @param uniformBuffer defines the Uniform buffer to fill in.
  134582. * @param scene defines the scene the material belongs to.
  134583. * @param engine defines the engine the material belongs to.
  134584. * @param isFrozen defines whether the material is frozen or not.
  134585. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134586. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134587. */
  134588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134589. /**
  134590. * Unbinds the material from the mesh.
  134591. * @param activeEffect defines the effect that should be unbound from.
  134592. * @returns true if unbound, otherwise false
  134593. */
  134594. unbind(activeEffect: Effect): boolean;
  134595. /**
  134596. * Returns the texture used for refraction or null if none is used.
  134597. * @param scene defines the scene the material belongs to.
  134598. * @returns - Refraction texture if present. If no refraction texture and refraction
  134599. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134600. */
  134601. private _getRefractionTexture;
  134602. /**
  134603. * Returns true if alpha blending should be disabled.
  134604. */
  134605. get disableAlphaBlending(): boolean;
  134606. /**
  134607. * Fills the list of render target textures.
  134608. * @param renderTargets the list of render targets to update
  134609. */
  134610. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134611. /**
  134612. * Checks to see if a texture is used in the material.
  134613. * @param texture - Base texture to use.
  134614. * @returns - Boolean specifying if a texture is used in the material.
  134615. */
  134616. hasTexture(texture: BaseTexture): boolean;
  134617. /**
  134618. * Gets a boolean indicating that current material needs to register RTT
  134619. * @returns true if this uses a render target otherwise false.
  134620. */
  134621. hasRenderTargetTextures(): boolean;
  134622. /**
  134623. * Returns an array of the actively used textures.
  134624. * @param activeTextures Array of BaseTextures
  134625. */
  134626. getActiveTextures(activeTextures: BaseTexture[]): void;
  134627. /**
  134628. * Returns the animatable textures.
  134629. * @param animatables Array of animatable textures.
  134630. */
  134631. getAnimatables(animatables: IAnimatable[]): void;
  134632. /**
  134633. * Disposes the resources of the material.
  134634. * @param forceDisposeTextures - Forces the disposal of all textures.
  134635. */
  134636. dispose(forceDisposeTextures?: boolean): void;
  134637. /**
  134638. * Get the current class name of the texture useful for serialization or dynamic coding.
  134639. * @returns "PBRSubSurfaceConfiguration"
  134640. */
  134641. getClassName(): string;
  134642. /**
  134643. * Add fallbacks to the effect fallbacks list.
  134644. * @param defines defines the Base texture to use.
  134645. * @param fallbacks defines the current fallback list.
  134646. * @param currentRank defines the current fallback rank.
  134647. * @returns the new fallback rank.
  134648. */
  134649. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134650. /**
  134651. * Add the required uniforms to the current list.
  134652. * @param uniforms defines the current uniform list.
  134653. */
  134654. static AddUniforms(uniforms: string[]): void;
  134655. /**
  134656. * Add the required samplers to the current list.
  134657. * @param samplers defines the current sampler list.
  134658. */
  134659. static AddSamplers(samplers: string[]): void;
  134660. /**
  134661. * Add the required uniforms to the current buffer.
  134662. * @param uniformBuffer defines the current uniform buffer.
  134663. */
  134664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134665. /**
  134666. * Makes a duplicate of the current configuration into another one.
  134667. * @param configuration define the config where to copy the info
  134668. */
  134669. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134670. /**
  134671. * Serializes this Sub Surface configuration.
  134672. * @returns - An object with the serialized config.
  134673. */
  134674. serialize(): any;
  134675. /**
  134676. * Parses a anisotropy Configuration from a serialized object.
  134677. * @param source - Serialized object.
  134678. * @param scene Defines the scene we are parsing for
  134679. * @param rootUrl Defines the rootUrl to load from
  134680. */
  134681. parse(source: any, scene: Scene, rootUrl: string): void;
  134682. }
  134683. }
  134684. declare module BABYLON {
  134685. /** @hidden */
  134686. export var pbrFragmentDeclaration: {
  134687. name: string;
  134688. shader: string;
  134689. };
  134690. }
  134691. declare module BABYLON {
  134692. /** @hidden */
  134693. export var pbrUboDeclaration: {
  134694. name: string;
  134695. shader: string;
  134696. };
  134697. }
  134698. declare module BABYLON {
  134699. /** @hidden */
  134700. export var pbrFragmentExtraDeclaration: {
  134701. name: string;
  134702. shader: string;
  134703. };
  134704. }
  134705. declare module BABYLON {
  134706. /** @hidden */
  134707. export var pbrFragmentSamplersDeclaration: {
  134708. name: string;
  134709. shader: string;
  134710. };
  134711. }
  134712. declare module BABYLON {
  134713. /** @hidden */
  134714. export var importanceSampling: {
  134715. name: string;
  134716. shader: string;
  134717. };
  134718. }
  134719. declare module BABYLON {
  134720. /** @hidden */
  134721. export var pbrHelperFunctions: {
  134722. name: string;
  134723. shader: string;
  134724. };
  134725. }
  134726. declare module BABYLON {
  134727. /** @hidden */
  134728. export var harmonicsFunctions: {
  134729. name: string;
  134730. shader: string;
  134731. };
  134732. }
  134733. declare module BABYLON {
  134734. /** @hidden */
  134735. export var pbrDirectLightingSetupFunctions: {
  134736. name: string;
  134737. shader: string;
  134738. };
  134739. }
  134740. declare module BABYLON {
  134741. /** @hidden */
  134742. export var pbrDirectLightingFalloffFunctions: {
  134743. name: string;
  134744. shader: string;
  134745. };
  134746. }
  134747. declare module BABYLON {
  134748. /** @hidden */
  134749. export var pbrBRDFFunctions: {
  134750. name: string;
  134751. shader: string;
  134752. };
  134753. }
  134754. declare module BABYLON {
  134755. /** @hidden */
  134756. export var hdrFilteringFunctions: {
  134757. name: string;
  134758. shader: string;
  134759. };
  134760. }
  134761. declare module BABYLON {
  134762. /** @hidden */
  134763. export var pbrDirectLightingFunctions: {
  134764. name: string;
  134765. shader: string;
  134766. };
  134767. }
  134768. declare module BABYLON {
  134769. /** @hidden */
  134770. export var pbrIBLFunctions: {
  134771. name: string;
  134772. shader: string;
  134773. };
  134774. }
  134775. declare module BABYLON {
  134776. /** @hidden */
  134777. export var pbrBlockAlbedoOpacity: {
  134778. name: string;
  134779. shader: string;
  134780. };
  134781. }
  134782. declare module BABYLON {
  134783. /** @hidden */
  134784. export var pbrBlockReflectivity: {
  134785. name: string;
  134786. shader: string;
  134787. };
  134788. }
  134789. declare module BABYLON {
  134790. /** @hidden */
  134791. export var pbrBlockAmbientOcclusion: {
  134792. name: string;
  134793. shader: string;
  134794. };
  134795. }
  134796. declare module BABYLON {
  134797. /** @hidden */
  134798. export var pbrBlockAlphaFresnel: {
  134799. name: string;
  134800. shader: string;
  134801. };
  134802. }
  134803. declare module BABYLON {
  134804. /** @hidden */
  134805. export var pbrBlockAnisotropic: {
  134806. name: string;
  134807. shader: string;
  134808. };
  134809. }
  134810. declare module BABYLON {
  134811. /** @hidden */
  134812. export var pbrBlockReflection: {
  134813. name: string;
  134814. shader: string;
  134815. };
  134816. }
  134817. declare module BABYLON {
  134818. /** @hidden */
  134819. export var pbrBlockSheen: {
  134820. name: string;
  134821. shader: string;
  134822. };
  134823. }
  134824. declare module BABYLON {
  134825. /** @hidden */
  134826. export var pbrBlockClearcoat: {
  134827. name: string;
  134828. shader: string;
  134829. };
  134830. }
  134831. declare module BABYLON {
  134832. /** @hidden */
  134833. export var pbrBlockSubSurface: {
  134834. name: string;
  134835. shader: string;
  134836. };
  134837. }
  134838. declare module BABYLON {
  134839. /** @hidden */
  134840. export var pbrBlockNormalGeometric: {
  134841. name: string;
  134842. shader: string;
  134843. };
  134844. }
  134845. declare module BABYLON {
  134846. /** @hidden */
  134847. export var pbrBlockNormalFinal: {
  134848. name: string;
  134849. shader: string;
  134850. };
  134851. }
  134852. declare module BABYLON {
  134853. /** @hidden */
  134854. export var pbrBlockLightmapInit: {
  134855. name: string;
  134856. shader: string;
  134857. };
  134858. }
  134859. declare module BABYLON {
  134860. /** @hidden */
  134861. export var pbrBlockGeometryInfo: {
  134862. name: string;
  134863. shader: string;
  134864. };
  134865. }
  134866. declare module BABYLON {
  134867. /** @hidden */
  134868. export var pbrBlockReflectance0: {
  134869. name: string;
  134870. shader: string;
  134871. };
  134872. }
  134873. declare module BABYLON {
  134874. /** @hidden */
  134875. export var pbrBlockReflectance: {
  134876. name: string;
  134877. shader: string;
  134878. };
  134879. }
  134880. declare module BABYLON {
  134881. /** @hidden */
  134882. export var pbrBlockDirectLighting: {
  134883. name: string;
  134884. shader: string;
  134885. };
  134886. }
  134887. declare module BABYLON {
  134888. /** @hidden */
  134889. export var pbrBlockFinalLitComponents: {
  134890. name: string;
  134891. shader: string;
  134892. };
  134893. }
  134894. declare module BABYLON {
  134895. /** @hidden */
  134896. export var pbrBlockFinalUnlitComponents: {
  134897. name: string;
  134898. shader: string;
  134899. };
  134900. }
  134901. declare module BABYLON {
  134902. /** @hidden */
  134903. export var pbrBlockFinalColorComposition: {
  134904. name: string;
  134905. shader: string;
  134906. };
  134907. }
  134908. declare module BABYLON {
  134909. /** @hidden */
  134910. export var pbrBlockImageProcessing: {
  134911. name: string;
  134912. shader: string;
  134913. };
  134914. }
  134915. declare module BABYLON {
  134916. /** @hidden */
  134917. export var pbrDebug: {
  134918. name: string;
  134919. shader: string;
  134920. };
  134921. }
  134922. declare module BABYLON {
  134923. /** @hidden */
  134924. export var pbrPixelShader: {
  134925. name: string;
  134926. shader: string;
  134927. };
  134928. }
  134929. declare module BABYLON {
  134930. /** @hidden */
  134931. export var pbrVertexDeclaration: {
  134932. name: string;
  134933. shader: string;
  134934. };
  134935. }
  134936. declare module BABYLON {
  134937. /** @hidden */
  134938. export var pbrVertexShader: {
  134939. name: string;
  134940. shader: string;
  134941. };
  134942. }
  134943. declare module BABYLON {
  134944. /**
  134945. * Manages the defines for the PBR Material.
  134946. * @hidden
  134947. */
  134948. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134949. PBR: boolean;
  134950. NUM_SAMPLES: string;
  134951. REALTIME_FILTERING: boolean;
  134952. MAINUV1: boolean;
  134953. MAINUV2: boolean;
  134954. UV1: boolean;
  134955. UV2: boolean;
  134956. ALBEDO: boolean;
  134957. GAMMAALBEDO: boolean;
  134958. ALBEDODIRECTUV: number;
  134959. VERTEXCOLOR: boolean;
  134960. DETAIL: boolean;
  134961. DETAILDIRECTUV: number;
  134962. DETAIL_NORMALBLENDMETHOD: number;
  134963. AMBIENT: boolean;
  134964. AMBIENTDIRECTUV: number;
  134965. AMBIENTINGRAYSCALE: boolean;
  134966. OPACITY: boolean;
  134967. VERTEXALPHA: boolean;
  134968. OPACITYDIRECTUV: number;
  134969. OPACITYRGB: boolean;
  134970. ALPHATEST: boolean;
  134971. DEPTHPREPASS: boolean;
  134972. ALPHABLEND: boolean;
  134973. ALPHAFROMALBEDO: boolean;
  134974. ALPHATESTVALUE: string;
  134975. SPECULAROVERALPHA: boolean;
  134976. RADIANCEOVERALPHA: boolean;
  134977. ALPHAFRESNEL: boolean;
  134978. LINEARALPHAFRESNEL: boolean;
  134979. PREMULTIPLYALPHA: boolean;
  134980. EMISSIVE: boolean;
  134981. EMISSIVEDIRECTUV: number;
  134982. REFLECTIVITY: boolean;
  134983. REFLECTIVITYDIRECTUV: number;
  134984. SPECULARTERM: boolean;
  134985. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134986. MICROSURFACEAUTOMATIC: boolean;
  134987. LODBASEDMICROSFURACE: boolean;
  134988. MICROSURFACEMAP: boolean;
  134989. MICROSURFACEMAPDIRECTUV: number;
  134990. METALLICWORKFLOW: boolean;
  134991. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134992. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134993. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134994. AOSTOREINMETALMAPRED: boolean;
  134995. METALLIC_REFLECTANCE: boolean;
  134996. METALLIC_REFLECTANCEDIRECTUV: number;
  134997. ENVIRONMENTBRDF: boolean;
  134998. ENVIRONMENTBRDF_RGBD: boolean;
  134999. NORMAL: boolean;
  135000. TANGENT: boolean;
  135001. BUMP: boolean;
  135002. BUMPDIRECTUV: number;
  135003. OBJECTSPACE_NORMALMAP: boolean;
  135004. PARALLAX: boolean;
  135005. PARALLAXOCCLUSION: boolean;
  135006. NORMALXYSCALE: boolean;
  135007. LIGHTMAP: boolean;
  135008. LIGHTMAPDIRECTUV: number;
  135009. USELIGHTMAPASSHADOWMAP: boolean;
  135010. GAMMALIGHTMAP: boolean;
  135011. RGBDLIGHTMAP: boolean;
  135012. REFLECTION: boolean;
  135013. REFLECTIONMAP_3D: boolean;
  135014. REFLECTIONMAP_SPHERICAL: boolean;
  135015. REFLECTIONMAP_PLANAR: boolean;
  135016. REFLECTIONMAP_CUBIC: boolean;
  135017. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135018. REFLECTIONMAP_PROJECTION: boolean;
  135019. REFLECTIONMAP_SKYBOX: boolean;
  135020. REFLECTIONMAP_EXPLICIT: boolean;
  135021. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  135022. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  135023. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  135024. INVERTCUBICMAP: boolean;
  135025. USESPHERICALFROMREFLECTIONMAP: boolean;
  135026. USEIRRADIANCEMAP: boolean;
  135027. SPHERICAL_HARMONICS: boolean;
  135028. USESPHERICALINVERTEX: boolean;
  135029. REFLECTIONMAP_OPPOSITEZ: boolean;
  135030. LODINREFLECTIONALPHA: boolean;
  135031. GAMMAREFLECTION: boolean;
  135032. RGBDREFLECTION: boolean;
  135033. LINEARSPECULARREFLECTION: boolean;
  135034. RADIANCEOCCLUSION: boolean;
  135035. HORIZONOCCLUSION: boolean;
  135036. INSTANCES: boolean;
  135037. THIN_INSTANCES: boolean;
  135038. PREPASS: boolean;
  135039. SCENE_MRT_COUNT: number;
  135040. NUM_BONE_INFLUENCERS: number;
  135041. BonesPerMesh: number;
  135042. BONETEXTURE: boolean;
  135043. NONUNIFORMSCALING: boolean;
  135044. MORPHTARGETS: boolean;
  135045. MORPHTARGETS_NORMAL: boolean;
  135046. MORPHTARGETS_TANGENT: boolean;
  135047. MORPHTARGETS_UV: boolean;
  135048. NUM_MORPH_INFLUENCERS: number;
  135049. IMAGEPROCESSING: boolean;
  135050. VIGNETTE: boolean;
  135051. VIGNETTEBLENDMODEMULTIPLY: boolean;
  135052. VIGNETTEBLENDMODEOPAQUE: boolean;
  135053. TONEMAPPING: boolean;
  135054. TONEMAPPING_ACES: boolean;
  135055. CONTRAST: boolean;
  135056. COLORCURVES: boolean;
  135057. COLORGRADING: boolean;
  135058. COLORGRADING3D: boolean;
  135059. SAMPLER3DGREENDEPTH: boolean;
  135060. SAMPLER3DBGRMAP: boolean;
  135061. IMAGEPROCESSINGPOSTPROCESS: boolean;
  135062. EXPOSURE: boolean;
  135063. MULTIVIEW: boolean;
  135064. USEPHYSICALLIGHTFALLOFF: boolean;
  135065. USEGLTFLIGHTFALLOFF: boolean;
  135066. TWOSIDEDLIGHTING: boolean;
  135067. SHADOWFLOAT: boolean;
  135068. CLIPPLANE: boolean;
  135069. CLIPPLANE2: boolean;
  135070. CLIPPLANE3: boolean;
  135071. CLIPPLANE4: boolean;
  135072. CLIPPLANE5: boolean;
  135073. CLIPPLANE6: boolean;
  135074. POINTSIZE: boolean;
  135075. FOG: boolean;
  135076. LOGARITHMICDEPTH: boolean;
  135077. FORCENORMALFORWARD: boolean;
  135078. SPECULARAA: boolean;
  135079. CLEARCOAT: boolean;
  135080. CLEARCOAT_DEFAULTIOR: boolean;
  135081. CLEARCOAT_TEXTURE: boolean;
  135082. CLEARCOAT_TEXTUREDIRECTUV: number;
  135083. CLEARCOAT_BUMP: boolean;
  135084. CLEARCOAT_BUMPDIRECTUV: number;
  135085. CLEARCOAT_TINT: boolean;
  135086. CLEARCOAT_TINT_TEXTURE: boolean;
  135087. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135088. ANISOTROPIC: boolean;
  135089. ANISOTROPIC_TEXTURE: boolean;
  135090. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135091. BRDF_V_HEIGHT_CORRELATED: boolean;
  135092. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135093. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135094. SHEEN: boolean;
  135095. SHEEN_TEXTURE: boolean;
  135096. SHEEN_TEXTUREDIRECTUV: number;
  135097. SHEEN_LINKWITHALBEDO: boolean;
  135098. SHEEN_ROUGHNESS: boolean;
  135099. SHEEN_ALBEDOSCALING: boolean;
  135100. SUBSURFACE: boolean;
  135101. SS_REFRACTION: boolean;
  135102. SS_TRANSLUCENCY: boolean;
  135103. SS_SCATTERING: boolean;
  135104. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135105. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135106. SS_REFRACTIONMAP_3D: boolean;
  135107. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135108. SS_LODINREFRACTIONALPHA: boolean;
  135109. SS_GAMMAREFRACTION: boolean;
  135110. SS_RGBDREFRACTION: boolean;
  135111. SS_LINEARSPECULARREFRACTION: boolean;
  135112. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135113. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135114. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135115. UNLIT: boolean;
  135116. DEBUGMODE: number;
  135117. /**
  135118. * Initializes the PBR Material defines.
  135119. */
  135120. constructor();
  135121. /**
  135122. * Resets the PBR Material defines.
  135123. */
  135124. reset(): void;
  135125. }
  135126. /**
  135127. * The Physically based material base class of BJS.
  135128. *
  135129. * This offers the main features of a standard PBR material.
  135130. * For more information, please refer to the documentation :
  135131. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135132. */
  135133. export abstract class PBRBaseMaterial extends PushMaterial {
  135134. /**
  135135. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135136. */
  135137. static readonly PBRMATERIAL_OPAQUE: number;
  135138. /**
  135139. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135140. */
  135141. static readonly PBRMATERIAL_ALPHATEST: number;
  135142. /**
  135143. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135144. */
  135145. static readonly PBRMATERIAL_ALPHABLEND: number;
  135146. /**
  135147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135148. * They are also discarded below the alpha cutoff threshold to improve performances.
  135149. */
  135150. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135151. /**
  135152. * Defines the default value of how much AO map is occluding the analytical lights
  135153. * (point spot...).
  135154. */
  135155. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135156. /**
  135157. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  135158. */
  135159. static readonly LIGHTFALLOFF_PHYSICAL: number;
  135160. /**
  135161. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  135162. * to enhance interoperability with other engines.
  135163. */
  135164. static readonly LIGHTFALLOFF_GLTF: number;
  135165. /**
  135166. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  135167. * to enhance interoperability with other materials.
  135168. */
  135169. static readonly LIGHTFALLOFF_STANDARD: number;
  135170. /**
  135171. * Intensity of the direct lights e.g. the four lights available in your scene.
  135172. * This impacts both the direct diffuse and specular highlights.
  135173. */
  135174. protected _directIntensity: number;
  135175. /**
  135176. * Intensity of the emissive part of the material.
  135177. * This helps controlling the emissive effect without modifying the emissive color.
  135178. */
  135179. protected _emissiveIntensity: number;
  135180. /**
  135181. * Intensity of the environment e.g. how much the environment will light the object
  135182. * either through harmonics for rough material or through the refelction for shiny ones.
  135183. */
  135184. protected _environmentIntensity: number;
  135185. /**
  135186. * This is a special control allowing the reduction of the specular highlights coming from the
  135187. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135188. */
  135189. protected _specularIntensity: number;
  135190. /**
  135191. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  135192. */
  135193. private _lightingInfos;
  135194. /**
  135195. * Debug Control allowing disabling the bump map on this material.
  135196. */
  135197. protected _disableBumpMap: boolean;
  135198. /**
  135199. * AKA Diffuse Texture in standard nomenclature.
  135200. */
  135201. protected _albedoTexture: Nullable<BaseTexture>;
  135202. /**
  135203. * AKA Occlusion Texture in other nomenclature.
  135204. */
  135205. protected _ambientTexture: Nullable<BaseTexture>;
  135206. /**
  135207. * AKA Occlusion Texture Intensity in other nomenclature.
  135208. */
  135209. protected _ambientTextureStrength: number;
  135210. /**
  135211. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135212. * 1 means it completely occludes it
  135213. * 0 mean it has no impact
  135214. */
  135215. protected _ambientTextureImpactOnAnalyticalLights: number;
  135216. /**
  135217. * Stores the alpha values in a texture.
  135218. */
  135219. protected _opacityTexture: Nullable<BaseTexture>;
  135220. /**
  135221. * Stores the reflection values in a texture.
  135222. */
  135223. protected _reflectionTexture: Nullable<BaseTexture>;
  135224. /**
  135225. * Stores the emissive values in a texture.
  135226. */
  135227. protected _emissiveTexture: Nullable<BaseTexture>;
  135228. /**
  135229. * AKA Specular texture in other nomenclature.
  135230. */
  135231. protected _reflectivityTexture: Nullable<BaseTexture>;
  135232. /**
  135233. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135234. */
  135235. protected _metallicTexture: Nullable<BaseTexture>;
  135236. /**
  135237. * Specifies the metallic scalar of the metallic/roughness workflow.
  135238. * Can also be used to scale the metalness values of the metallic texture.
  135239. */
  135240. protected _metallic: Nullable<number>;
  135241. /**
  135242. * Specifies the roughness scalar of the metallic/roughness workflow.
  135243. * Can also be used to scale the roughness values of the metallic texture.
  135244. */
  135245. protected _roughness: Nullable<number>;
  135246. /**
  135247. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135248. * By default the indexOfrefraction is used to compute F0;
  135249. *
  135250. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135251. *
  135252. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135253. * F90 = metallicReflectanceColor;
  135254. */
  135255. protected _metallicF0Factor: number;
  135256. /**
  135257. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135258. * By default the F90 is always 1;
  135259. *
  135260. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135261. *
  135262. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135263. * F90 = metallicReflectanceColor;
  135264. */
  135265. protected _metallicReflectanceColor: Color3;
  135266. /**
  135267. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135268. * This is multiply against the scalar values defined in the material.
  135269. */
  135270. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135271. /**
  135272. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135273. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135274. */
  135275. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135276. /**
  135277. * Stores surface normal data used to displace a mesh in a texture.
  135278. */
  135279. protected _bumpTexture: Nullable<BaseTexture>;
  135280. /**
  135281. * Stores the pre-calculated light information of a mesh in a texture.
  135282. */
  135283. protected _lightmapTexture: Nullable<BaseTexture>;
  135284. /**
  135285. * The color of a material in ambient lighting.
  135286. */
  135287. protected _ambientColor: Color3;
  135288. /**
  135289. * AKA Diffuse Color in other nomenclature.
  135290. */
  135291. protected _albedoColor: Color3;
  135292. /**
  135293. * AKA Specular Color in other nomenclature.
  135294. */
  135295. protected _reflectivityColor: Color3;
  135296. /**
  135297. * The color applied when light is reflected from a material.
  135298. */
  135299. protected _reflectionColor: Color3;
  135300. /**
  135301. * The color applied when light is emitted from a material.
  135302. */
  135303. protected _emissiveColor: Color3;
  135304. /**
  135305. * AKA Glossiness in other nomenclature.
  135306. */
  135307. protected _microSurface: number;
  135308. /**
  135309. * Specifies that the material will use the light map as a show map.
  135310. */
  135311. protected _useLightmapAsShadowmap: boolean;
  135312. /**
  135313. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135314. * makes the reflect vector face the model (under horizon).
  135315. */
  135316. protected _useHorizonOcclusion: boolean;
  135317. /**
  135318. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135319. * too much the area relying on ambient texture to define their ambient occlusion.
  135320. */
  135321. protected _useRadianceOcclusion: boolean;
  135322. /**
  135323. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135324. */
  135325. protected _useAlphaFromAlbedoTexture: boolean;
  135326. /**
  135327. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135328. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135329. */
  135330. protected _useSpecularOverAlpha: boolean;
  135331. /**
  135332. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135333. */
  135334. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135335. /**
  135336. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135337. */
  135338. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135339. /**
  135340. * Specifies if the metallic texture contains the roughness information in its green channel.
  135341. */
  135342. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135343. /**
  135344. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135345. */
  135346. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135347. /**
  135348. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135349. */
  135350. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135351. /**
  135352. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135353. */
  135354. protected _useAmbientInGrayScale: boolean;
  135355. /**
  135356. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135357. * The material will try to infer what glossiness each pixel should be.
  135358. */
  135359. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135360. /**
  135361. * Defines the falloff type used in this material.
  135362. * It by default is Physical.
  135363. */
  135364. protected _lightFalloff: number;
  135365. /**
  135366. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135367. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135368. */
  135369. protected _useRadianceOverAlpha: boolean;
  135370. /**
  135371. * Allows using an object space normal map (instead of tangent space).
  135372. */
  135373. protected _useObjectSpaceNormalMap: boolean;
  135374. /**
  135375. * Allows using the bump map in parallax mode.
  135376. */
  135377. protected _useParallax: boolean;
  135378. /**
  135379. * Allows using the bump map in parallax occlusion mode.
  135380. */
  135381. protected _useParallaxOcclusion: boolean;
  135382. /**
  135383. * Controls the scale bias of the parallax mode.
  135384. */
  135385. protected _parallaxScaleBias: number;
  135386. /**
  135387. * If sets to true, disables all the lights affecting the material.
  135388. */
  135389. protected _disableLighting: boolean;
  135390. /**
  135391. * Number of Simultaneous lights allowed on the material.
  135392. */
  135393. protected _maxSimultaneousLights: number;
  135394. /**
  135395. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135396. */
  135397. protected _invertNormalMapX: boolean;
  135398. /**
  135399. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135400. */
  135401. protected _invertNormalMapY: boolean;
  135402. /**
  135403. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135404. */
  135405. protected _twoSidedLighting: boolean;
  135406. /**
  135407. * Defines the alpha limits in alpha test mode.
  135408. */
  135409. protected _alphaCutOff: number;
  135410. /**
  135411. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135412. */
  135413. protected _forceAlphaTest: boolean;
  135414. /**
  135415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135416. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135417. */
  135418. protected _useAlphaFresnel: boolean;
  135419. /**
  135420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135421. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135422. */
  135423. protected _useLinearAlphaFresnel: boolean;
  135424. /**
  135425. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135426. * from cos thetav and roughness:
  135427. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135428. */
  135429. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135430. /**
  135431. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135432. */
  135433. protected _forceIrradianceInFragment: boolean;
  135434. private _realTimeFiltering;
  135435. /**
  135436. * Enables realtime filtering on the texture.
  135437. */
  135438. get realTimeFiltering(): boolean;
  135439. set realTimeFiltering(b: boolean);
  135440. private _realTimeFilteringQuality;
  135441. /**
  135442. * Quality switch for realtime filtering
  135443. */
  135444. get realTimeFilteringQuality(): number;
  135445. set realTimeFilteringQuality(n: number);
  135446. /**
  135447. * Can this material render to several textures at once
  135448. */
  135449. get canRenderToMRT(): boolean;
  135450. /**
  135451. * Force normal to face away from face.
  135452. */
  135453. protected _forceNormalForward: boolean;
  135454. /**
  135455. * Enables specular anti aliasing in the PBR shader.
  135456. * It will both interacts on the Geometry for analytical and IBL lighting.
  135457. * It also prefilter the roughness map based on the bump values.
  135458. */
  135459. protected _enableSpecularAntiAliasing: boolean;
  135460. /**
  135461. * Default configuration related to image processing available in the PBR Material.
  135462. */
  135463. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135464. /**
  135465. * Keep track of the image processing observer to allow dispose and replace.
  135466. */
  135467. private _imageProcessingObserver;
  135468. /**
  135469. * Attaches a new image processing configuration to the PBR Material.
  135470. * @param configuration
  135471. */
  135472. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135473. /**
  135474. * Stores the available render targets.
  135475. */
  135476. private _renderTargets;
  135477. /**
  135478. * Sets the global ambient color for the material used in lighting calculations.
  135479. */
  135480. private _globalAmbientColor;
  135481. /**
  135482. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135483. */
  135484. private _useLogarithmicDepth;
  135485. /**
  135486. * If set to true, no lighting calculations will be applied.
  135487. */
  135488. private _unlit;
  135489. private _debugMode;
  135490. /**
  135491. * @hidden
  135492. * This is reserved for the inspector.
  135493. * Defines the material debug mode.
  135494. * It helps seeing only some components of the material while troubleshooting.
  135495. */
  135496. debugMode: number;
  135497. /**
  135498. * @hidden
  135499. * This is reserved for the inspector.
  135500. * Specify from where on screen the debug mode should start.
  135501. * The value goes from -1 (full screen) to 1 (not visible)
  135502. * It helps with side by side comparison against the final render
  135503. * This defaults to -1
  135504. */
  135505. private debugLimit;
  135506. /**
  135507. * @hidden
  135508. * This is reserved for the inspector.
  135509. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135510. * You can use the factor to better multiply the final value.
  135511. */
  135512. private debugFactor;
  135513. /**
  135514. * Defines the clear coat layer parameters for the material.
  135515. */
  135516. readonly clearCoat: PBRClearCoatConfiguration;
  135517. /**
  135518. * Defines the anisotropic parameters for the material.
  135519. */
  135520. readonly anisotropy: PBRAnisotropicConfiguration;
  135521. /**
  135522. * Defines the BRDF parameters for the material.
  135523. */
  135524. readonly brdf: PBRBRDFConfiguration;
  135525. /**
  135526. * Defines the Sheen parameters for the material.
  135527. */
  135528. readonly sheen: PBRSheenConfiguration;
  135529. /**
  135530. * Defines the SubSurface parameters for the material.
  135531. */
  135532. readonly subSurface: PBRSubSurfaceConfiguration;
  135533. /**
  135534. * Defines the detail map parameters for the material.
  135535. */
  135536. readonly detailMap: DetailMapConfiguration;
  135537. protected _rebuildInParallel: boolean;
  135538. /**
  135539. * Instantiates a new PBRMaterial instance.
  135540. *
  135541. * @param name The material name
  135542. * @param scene The scene the material will be use in.
  135543. */
  135544. constructor(name: string, scene: Scene);
  135545. /**
  135546. * Gets a boolean indicating that current material needs to register RTT
  135547. */
  135548. get hasRenderTargetTextures(): boolean;
  135549. /**
  135550. * Gets the name of the material class.
  135551. */
  135552. getClassName(): string;
  135553. /**
  135554. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135555. */
  135556. get useLogarithmicDepth(): boolean;
  135557. /**
  135558. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135559. */
  135560. set useLogarithmicDepth(value: boolean);
  135561. /**
  135562. * Returns true if alpha blending should be disabled.
  135563. */
  135564. protected get _disableAlphaBlending(): boolean;
  135565. /**
  135566. * Specifies whether or not this material should be rendered in alpha blend mode.
  135567. */
  135568. needAlphaBlending(): boolean;
  135569. /**
  135570. * Specifies whether or not this material should be rendered in alpha test mode.
  135571. */
  135572. needAlphaTesting(): boolean;
  135573. /**
  135574. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135575. */
  135576. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135577. /**
  135578. * Gets the texture used for the alpha test.
  135579. */
  135580. getAlphaTestTexture(): Nullable<BaseTexture>;
  135581. /**
  135582. * Specifies that the submesh is ready to be used.
  135583. * @param mesh - BJS mesh.
  135584. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135585. * @param useInstances - Specifies that instances should be used.
  135586. * @returns - boolean indicating that the submesh is ready or not.
  135587. */
  135588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135589. /**
  135590. * Specifies if the material uses metallic roughness workflow.
  135591. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135592. */
  135593. isMetallicWorkflow(): boolean;
  135594. private _prepareEffect;
  135595. private _prepareDefines;
  135596. /**
  135597. * Force shader compilation
  135598. */
  135599. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135600. /**
  135601. * Initializes the uniform buffer layout for the shader.
  135602. */
  135603. buildUniformLayout(): void;
  135604. /**
  135605. * Unbinds the material from the mesh
  135606. */
  135607. unbind(): void;
  135608. /**
  135609. * Binds the submesh data.
  135610. * @param world - The world matrix.
  135611. * @param mesh - The BJS mesh.
  135612. * @param subMesh - A submesh of the BJS mesh.
  135613. */
  135614. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135615. /**
  135616. * Returns the animatable textures.
  135617. * @returns - Array of animatable textures.
  135618. */
  135619. getAnimatables(): IAnimatable[];
  135620. /**
  135621. * Returns the texture used for reflections.
  135622. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135623. */
  135624. private _getReflectionTexture;
  135625. /**
  135626. * Returns an array of the actively used textures.
  135627. * @returns - Array of BaseTextures
  135628. */
  135629. getActiveTextures(): BaseTexture[];
  135630. /**
  135631. * Checks to see if a texture is used in the material.
  135632. * @param texture - Base texture to use.
  135633. * @returns - Boolean specifying if a texture is used in the material.
  135634. */
  135635. hasTexture(texture: BaseTexture): boolean;
  135636. /**
  135637. * Sets the required values to the prepass renderer.
  135638. * @param prePassRenderer defines the prepass renderer to setup
  135639. */
  135640. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135641. /**
  135642. * Disposes the resources of the material.
  135643. * @param forceDisposeEffect - Forces the disposal of effects.
  135644. * @param forceDisposeTextures - Forces the disposal of all textures.
  135645. */
  135646. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135647. }
  135648. }
  135649. declare module BABYLON {
  135650. /**
  135651. * The Physically based material of BJS.
  135652. *
  135653. * This offers the main features of a standard PBR material.
  135654. * For more information, please refer to the documentation :
  135655. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135656. */
  135657. export class PBRMaterial extends PBRBaseMaterial {
  135658. /**
  135659. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135660. */
  135661. static readonly PBRMATERIAL_OPAQUE: number;
  135662. /**
  135663. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135664. */
  135665. static readonly PBRMATERIAL_ALPHATEST: number;
  135666. /**
  135667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135668. */
  135669. static readonly PBRMATERIAL_ALPHABLEND: number;
  135670. /**
  135671. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135672. * They are also discarded below the alpha cutoff threshold to improve performances.
  135673. */
  135674. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135675. /**
  135676. * Defines the default value of how much AO map is occluding the analytical lights
  135677. * (point spot...).
  135678. */
  135679. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135680. /**
  135681. * Intensity of the direct lights e.g. the four lights available in your scene.
  135682. * This impacts both the direct diffuse and specular highlights.
  135683. */
  135684. directIntensity: number;
  135685. /**
  135686. * Intensity of the emissive part of the material.
  135687. * This helps controlling the emissive effect without modifying the emissive color.
  135688. */
  135689. emissiveIntensity: number;
  135690. /**
  135691. * Intensity of the environment e.g. how much the environment will light the object
  135692. * either through harmonics for rough material or through the refelction for shiny ones.
  135693. */
  135694. environmentIntensity: number;
  135695. /**
  135696. * This is a special control allowing the reduction of the specular highlights coming from the
  135697. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135698. */
  135699. specularIntensity: number;
  135700. /**
  135701. * Debug Control allowing disabling the bump map on this material.
  135702. */
  135703. disableBumpMap: boolean;
  135704. /**
  135705. * AKA Diffuse Texture in standard nomenclature.
  135706. */
  135707. albedoTexture: BaseTexture;
  135708. /**
  135709. * AKA Occlusion Texture in other nomenclature.
  135710. */
  135711. ambientTexture: BaseTexture;
  135712. /**
  135713. * AKA Occlusion Texture Intensity in other nomenclature.
  135714. */
  135715. ambientTextureStrength: number;
  135716. /**
  135717. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135718. * 1 means it completely occludes it
  135719. * 0 mean it has no impact
  135720. */
  135721. ambientTextureImpactOnAnalyticalLights: number;
  135722. /**
  135723. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135724. */
  135725. opacityTexture: BaseTexture;
  135726. /**
  135727. * Stores the reflection values in a texture.
  135728. */
  135729. reflectionTexture: Nullable<BaseTexture>;
  135730. /**
  135731. * Stores the emissive values in a texture.
  135732. */
  135733. emissiveTexture: BaseTexture;
  135734. /**
  135735. * AKA Specular texture in other nomenclature.
  135736. */
  135737. reflectivityTexture: BaseTexture;
  135738. /**
  135739. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135740. */
  135741. metallicTexture: BaseTexture;
  135742. /**
  135743. * Specifies the metallic scalar of the metallic/roughness workflow.
  135744. * Can also be used to scale the metalness values of the metallic texture.
  135745. */
  135746. metallic: Nullable<number>;
  135747. /**
  135748. * Specifies the roughness scalar of the metallic/roughness workflow.
  135749. * Can also be used to scale the roughness values of the metallic texture.
  135750. */
  135751. roughness: Nullable<number>;
  135752. /**
  135753. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135754. * By default the indexOfrefraction is used to compute F0;
  135755. *
  135756. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135757. *
  135758. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135759. * F90 = metallicReflectanceColor;
  135760. */
  135761. metallicF0Factor: number;
  135762. /**
  135763. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135764. * By default the F90 is always 1;
  135765. *
  135766. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135767. *
  135768. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135769. * F90 = metallicReflectanceColor;
  135770. */
  135771. metallicReflectanceColor: Color3;
  135772. /**
  135773. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135774. * This is multiply against the scalar values defined in the material.
  135775. */
  135776. metallicReflectanceTexture: Nullable<BaseTexture>;
  135777. /**
  135778. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135779. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135780. */
  135781. microSurfaceTexture: BaseTexture;
  135782. /**
  135783. * Stores surface normal data used to displace a mesh in a texture.
  135784. */
  135785. bumpTexture: BaseTexture;
  135786. /**
  135787. * Stores the pre-calculated light information of a mesh in a texture.
  135788. */
  135789. lightmapTexture: BaseTexture;
  135790. /**
  135791. * Stores the refracted light information in a texture.
  135792. */
  135793. get refractionTexture(): Nullable<BaseTexture>;
  135794. set refractionTexture(value: Nullable<BaseTexture>);
  135795. /**
  135796. * The color of a material in ambient lighting.
  135797. */
  135798. ambientColor: Color3;
  135799. /**
  135800. * AKA Diffuse Color in other nomenclature.
  135801. */
  135802. albedoColor: Color3;
  135803. /**
  135804. * AKA Specular Color in other nomenclature.
  135805. */
  135806. reflectivityColor: Color3;
  135807. /**
  135808. * The color reflected from the material.
  135809. */
  135810. reflectionColor: Color3;
  135811. /**
  135812. * The color emitted from the material.
  135813. */
  135814. emissiveColor: Color3;
  135815. /**
  135816. * AKA Glossiness in other nomenclature.
  135817. */
  135818. microSurface: number;
  135819. /**
  135820. * Index of refraction of the material base layer.
  135821. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135822. *
  135823. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135824. *
  135825. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135826. */
  135827. get indexOfRefraction(): number;
  135828. set indexOfRefraction(value: number);
  135829. /**
  135830. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135831. */
  135832. get invertRefractionY(): boolean;
  135833. set invertRefractionY(value: boolean);
  135834. /**
  135835. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135836. * Materials half opaque for instance using refraction could benefit from this control.
  135837. */
  135838. get linkRefractionWithTransparency(): boolean;
  135839. set linkRefractionWithTransparency(value: boolean);
  135840. /**
  135841. * If true, the light map contains occlusion information instead of lighting info.
  135842. */
  135843. useLightmapAsShadowmap: boolean;
  135844. /**
  135845. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135846. */
  135847. useAlphaFromAlbedoTexture: boolean;
  135848. /**
  135849. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135850. */
  135851. forceAlphaTest: boolean;
  135852. /**
  135853. * Defines the alpha limits in alpha test mode.
  135854. */
  135855. alphaCutOff: number;
  135856. /**
  135857. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135858. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135859. */
  135860. useSpecularOverAlpha: boolean;
  135861. /**
  135862. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135863. */
  135864. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135865. /**
  135866. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135867. */
  135868. useRoughnessFromMetallicTextureAlpha: boolean;
  135869. /**
  135870. * Specifies if the metallic texture contains the roughness information in its green channel.
  135871. */
  135872. useRoughnessFromMetallicTextureGreen: boolean;
  135873. /**
  135874. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135875. */
  135876. useMetallnessFromMetallicTextureBlue: boolean;
  135877. /**
  135878. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135879. */
  135880. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135881. /**
  135882. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135883. */
  135884. useAmbientInGrayScale: boolean;
  135885. /**
  135886. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135887. * The material will try to infer what glossiness each pixel should be.
  135888. */
  135889. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135890. /**
  135891. * BJS is using an harcoded light falloff based on a manually sets up range.
  135892. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135893. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135894. */
  135895. get usePhysicalLightFalloff(): boolean;
  135896. /**
  135897. * BJS is using an harcoded light falloff based on a manually sets up range.
  135898. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135899. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135900. */
  135901. set usePhysicalLightFalloff(value: boolean);
  135902. /**
  135903. * In order to support the falloff compatibility with gltf, a special mode has been added
  135904. * to reproduce the gltf light falloff.
  135905. */
  135906. get useGLTFLightFalloff(): boolean;
  135907. /**
  135908. * In order to support the falloff compatibility with gltf, a special mode has been added
  135909. * to reproduce the gltf light falloff.
  135910. */
  135911. set useGLTFLightFalloff(value: boolean);
  135912. /**
  135913. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135914. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135915. */
  135916. useRadianceOverAlpha: boolean;
  135917. /**
  135918. * Allows using an object space normal map (instead of tangent space).
  135919. */
  135920. useObjectSpaceNormalMap: boolean;
  135921. /**
  135922. * Allows using the bump map in parallax mode.
  135923. */
  135924. useParallax: boolean;
  135925. /**
  135926. * Allows using the bump map in parallax occlusion mode.
  135927. */
  135928. useParallaxOcclusion: boolean;
  135929. /**
  135930. * Controls the scale bias of the parallax mode.
  135931. */
  135932. parallaxScaleBias: number;
  135933. /**
  135934. * If sets to true, disables all the lights affecting the material.
  135935. */
  135936. disableLighting: boolean;
  135937. /**
  135938. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135939. */
  135940. forceIrradianceInFragment: boolean;
  135941. /**
  135942. * Number of Simultaneous lights allowed on the material.
  135943. */
  135944. maxSimultaneousLights: number;
  135945. /**
  135946. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135947. */
  135948. invertNormalMapX: boolean;
  135949. /**
  135950. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135951. */
  135952. invertNormalMapY: boolean;
  135953. /**
  135954. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135955. */
  135956. twoSidedLighting: boolean;
  135957. /**
  135958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135959. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135960. */
  135961. useAlphaFresnel: boolean;
  135962. /**
  135963. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135964. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135965. */
  135966. useLinearAlphaFresnel: boolean;
  135967. /**
  135968. * Let user defines the brdf lookup texture used for IBL.
  135969. * A default 8bit version is embedded but you could point at :
  135970. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135971. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135972. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135973. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135974. */
  135975. environmentBRDFTexture: Nullable<BaseTexture>;
  135976. /**
  135977. * Force normal to face away from face.
  135978. */
  135979. forceNormalForward: boolean;
  135980. /**
  135981. * Enables specular anti aliasing in the PBR shader.
  135982. * It will both interacts on the Geometry for analytical and IBL lighting.
  135983. * It also prefilter the roughness map based on the bump values.
  135984. */
  135985. enableSpecularAntiAliasing: boolean;
  135986. /**
  135987. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135988. * makes the reflect vector face the model (under horizon).
  135989. */
  135990. useHorizonOcclusion: boolean;
  135991. /**
  135992. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135993. * too much the area relying on ambient texture to define their ambient occlusion.
  135994. */
  135995. useRadianceOcclusion: boolean;
  135996. /**
  135997. * If set to true, no lighting calculations will be applied.
  135998. */
  135999. unlit: boolean;
  136000. /**
  136001. * Gets the image processing configuration used either in this material.
  136002. */
  136003. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136004. /**
  136005. * Sets the Default image processing configuration used either in the this material.
  136006. *
  136007. * If sets to null, the scene one is in use.
  136008. */
  136009. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136010. /**
  136011. * Gets wether the color curves effect is enabled.
  136012. */
  136013. get cameraColorCurvesEnabled(): boolean;
  136014. /**
  136015. * Sets wether the color curves effect is enabled.
  136016. */
  136017. set cameraColorCurvesEnabled(value: boolean);
  136018. /**
  136019. * Gets wether the color grading effect is enabled.
  136020. */
  136021. get cameraColorGradingEnabled(): boolean;
  136022. /**
  136023. * Gets wether the color grading effect is enabled.
  136024. */
  136025. set cameraColorGradingEnabled(value: boolean);
  136026. /**
  136027. * Gets wether tonemapping is enabled or not.
  136028. */
  136029. get cameraToneMappingEnabled(): boolean;
  136030. /**
  136031. * Sets wether tonemapping is enabled or not
  136032. */
  136033. set cameraToneMappingEnabled(value: boolean);
  136034. /**
  136035. * The camera exposure used on this material.
  136036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136037. * This corresponds to a photographic exposure.
  136038. */
  136039. get cameraExposure(): number;
  136040. /**
  136041. * The camera exposure used on this material.
  136042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136043. * This corresponds to a photographic exposure.
  136044. */
  136045. set cameraExposure(value: number);
  136046. /**
  136047. * Gets The camera contrast used on this material.
  136048. */
  136049. get cameraContrast(): number;
  136050. /**
  136051. * Sets The camera contrast used on this material.
  136052. */
  136053. set cameraContrast(value: number);
  136054. /**
  136055. * Gets the Color Grading 2D Lookup Texture.
  136056. */
  136057. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  136058. /**
  136059. * Sets the Color Grading 2D Lookup Texture.
  136060. */
  136061. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  136062. /**
  136063. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136064. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136065. * 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;
  136066. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136067. */
  136068. get cameraColorCurves(): Nullable<ColorCurves>;
  136069. /**
  136070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136072. * 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;
  136073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136074. */
  136075. set cameraColorCurves(value: Nullable<ColorCurves>);
  136076. /**
  136077. * Instantiates a new PBRMaterial instance.
  136078. *
  136079. * @param name The material name
  136080. * @param scene The scene the material will be use in.
  136081. */
  136082. constructor(name: string, scene: Scene);
  136083. /**
  136084. * Returns the name of this material class.
  136085. */
  136086. getClassName(): string;
  136087. /**
  136088. * Makes a duplicate of the current material.
  136089. * @param name - name to use for the new material.
  136090. */
  136091. clone(name: string): PBRMaterial;
  136092. /**
  136093. * Serializes this PBR Material.
  136094. * @returns - An object with the serialized material.
  136095. */
  136096. serialize(): any;
  136097. /**
  136098. * Parses a PBR Material from a serialized object.
  136099. * @param source - Serialized object.
  136100. * @param scene - BJS scene instance.
  136101. * @param rootUrl - url for the scene object
  136102. * @returns - PBRMaterial
  136103. */
  136104. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  136105. }
  136106. }
  136107. declare module BABYLON {
  136108. /**
  136109. * Direct draw surface info
  136110. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  136111. */
  136112. export interface DDSInfo {
  136113. /**
  136114. * Width of the texture
  136115. */
  136116. width: number;
  136117. /**
  136118. * Width of the texture
  136119. */
  136120. height: number;
  136121. /**
  136122. * Number of Mipmaps for the texture
  136123. * @see https://en.wikipedia.org/wiki/Mipmap
  136124. */
  136125. mipmapCount: number;
  136126. /**
  136127. * If the textures format is a known fourCC format
  136128. * @see https://www.fourcc.org/
  136129. */
  136130. isFourCC: boolean;
  136131. /**
  136132. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136133. */
  136134. isRGB: boolean;
  136135. /**
  136136. * If the texture is a lumincance format
  136137. */
  136138. isLuminance: boolean;
  136139. /**
  136140. * If this is a cube texture
  136141. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  136142. */
  136143. isCube: boolean;
  136144. /**
  136145. * If the texture is a compressed format eg. FOURCC_DXT1
  136146. */
  136147. isCompressed: boolean;
  136148. /**
  136149. * The dxgiFormat of the texture
  136150. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  136151. */
  136152. dxgiFormat: number;
  136153. /**
  136154. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  136155. */
  136156. textureType: number;
  136157. /**
  136158. * Sphericle polynomial created for the dds texture
  136159. */
  136160. sphericalPolynomial?: SphericalPolynomial;
  136161. }
  136162. /**
  136163. * Class used to provide DDS decompression tools
  136164. */
  136165. export class DDSTools {
  136166. /**
  136167. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  136168. */
  136169. static StoreLODInAlphaChannel: boolean;
  136170. /**
  136171. * Gets DDS information from an array buffer
  136172. * @param data defines the array buffer view to read data from
  136173. * @returns the DDS information
  136174. */
  136175. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  136176. private static _FloatView;
  136177. private static _Int32View;
  136178. private static _ToHalfFloat;
  136179. private static _FromHalfFloat;
  136180. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  136181. private static _GetHalfFloatRGBAArrayBuffer;
  136182. private static _GetFloatRGBAArrayBuffer;
  136183. private static _GetFloatAsUIntRGBAArrayBuffer;
  136184. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  136185. private static _GetRGBAArrayBuffer;
  136186. private static _ExtractLongWordOrder;
  136187. private static _GetRGBArrayBuffer;
  136188. private static _GetLuminanceArrayBuffer;
  136189. /**
  136190. * Uploads DDS Levels to a Babylon Texture
  136191. * @hidden
  136192. */
  136193. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  136194. }
  136195. interface ThinEngine {
  136196. /**
  136197. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  136198. * @param rootUrl defines the url where the file to load is located
  136199. * @param scene defines the current scene
  136200. * @param lodScale defines scale to apply to the mip map selection
  136201. * @param lodOffset defines offset to apply to the mip map selection
  136202. * @param onLoad defines an optional callback raised when the texture is loaded
  136203. * @param onError defines an optional callback raised if there is an issue to load the texture
  136204. * @param format defines the format of the data
  136205. * @param forcedExtension defines the extension to use to pick the right loader
  136206. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  136207. * @returns the cube texture as an InternalTexture
  136208. */
  136209. 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;
  136210. }
  136211. }
  136212. declare module BABYLON {
  136213. /**
  136214. * Implementation of the DDS Texture Loader.
  136215. * @hidden
  136216. */
  136217. export class _DDSTextureLoader implements IInternalTextureLoader {
  136218. /**
  136219. * Defines wether the loader supports cascade loading the different faces.
  136220. */
  136221. readonly supportCascades: boolean;
  136222. /**
  136223. * This returns if the loader support the current file information.
  136224. * @param extension defines the file extension of the file being loaded
  136225. * @returns true if the loader can load the specified file
  136226. */
  136227. canLoad(extension: string): boolean;
  136228. /**
  136229. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136230. * @param data contains the texture data
  136231. * @param texture defines the BabylonJS internal texture
  136232. * @param createPolynomials will be true if polynomials have been requested
  136233. * @param onLoad defines the callback to trigger once the texture is ready
  136234. * @param onError defines the callback to trigger in case of error
  136235. */
  136236. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136237. /**
  136238. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136239. * @param data contains the texture data
  136240. * @param texture defines the BabylonJS internal texture
  136241. * @param callback defines the method to call once ready to upload
  136242. */
  136243. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136244. }
  136245. }
  136246. declare module BABYLON {
  136247. /**
  136248. * Implementation of the ENV Texture Loader.
  136249. * @hidden
  136250. */
  136251. export class _ENVTextureLoader implements IInternalTextureLoader {
  136252. /**
  136253. * Defines wether the loader supports cascade loading the different faces.
  136254. */
  136255. readonly supportCascades: boolean;
  136256. /**
  136257. * This returns if the loader support the current file information.
  136258. * @param extension defines the file extension of the file being loaded
  136259. * @returns true if the loader can load the specified file
  136260. */
  136261. canLoad(extension: string): boolean;
  136262. /**
  136263. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136264. * @param data contains the texture data
  136265. * @param texture defines the BabylonJS internal texture
  136266. * @param createPolynomials will be true if polynomials have been requested
  136267. * @param onLoad defines the callback to trigger once the texture is ready
  136268. * @param onError defines the callback to trigger in case of error
  136269. */
  136270. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136271. /**
  136272. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136273. * @param data contains the texture data
  136274. * @param texture defines the BabylonJS internal texture
  136275. * @param callback defines the method to call once ready to upload
  136276. */
  136277. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136278. }
  136279. }
  136280. declare module BABYLON {
  136281. /**
  136282. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136283. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136284. */
  136285. export class KhronosTextureContainer {
  136286. /** contents of the KTX container file */
  136287. data: ArrayBufferView;
  136288. private static HEADER_LEN;
  136289. private static COMPRESSED_2D;
  136290. private static COMPRESSED_3D;
  136291. private static TEX_2D;
  136292. private static TEX_3D;
  136293. /**
  136294. * Gets the openGL type
  136295. */
  136296. glType: number;
  136297. /**
  136298. * Gets the openGL type size
  136299. */
  136300. glTypeSize: number;
  136301. /**
  136302. * Gets the openGL format
  136303. */
  136304. glFormat: number;
  136305. /**
  136306. * Gets the openGL internal format
  136307. */
  136308. glInternalFormat: number;
  136309. /**
  136310. * Gets the base internal format
  136311. */
  136312. glBaseInternalFormat: number;
  136313. /**
  136314. * Gets image width in pixel
  136315. */
  136316. pixelWidth: number;
  136317. /**
  136318. * Gets image height in pixel
  136319. */
  136320. pixelHeight: number;
  136321. /**
  136322. * Gets image depth in pixels
  136323. */
  136324. pixelDepth: number;
  136325. /**
  136326. * Gets the number of array elements
  136327. */
  136328. numberOfArrayElements: number;
  136329. /**
  136330. * Gets the number of faces
  136331. */
  136332. numberOfFaces: number;
  136333. /**
  136334. * Gets the number of mipmap levels
  136335. */
  136336. numberOfMipmapLevels: number;
  136337. /**
  136338. * Gets the bytes of key value data
  136339. */
  136340. bytesOfKeyValueData: number;
  136341. /**
  136342. * Gets the load type
  136343. */
  136344. loadType: number;
  136345. /**
  136346. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136347. */
  136348. isInvalid: boolean;
  136349. /**
  136350. * Creates a new KhronosTextureContainer
  136351. * @param data contents of the KTX container file
  136352. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136353. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136354. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136355. */
  136356. constructor(
  136357. /** contents of the KTX container file */
  136358. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136359. /**
  136360. * Uploads KTX content to a Babylon Texture.
  136361. * It is assumed that the texture has already been created & is currently bound
  136362. * @hidden
  136363. */
  136364. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136365. private _upload2DCompressedLevels;
  136366. /**
  136367. * Checks if the given data starts with a KTX file identifier.
  136368. * @param data the data to check
  136369. * @returns true if the data is a KTX file or false otherwise
  136370. */
  136371. static IsValid(data: ArrayBufferView): boolean;
  136372. }
  136373. }
  136374. declare module BABYLON {
  136375. /**
  136376. * Class for loading KTX2 files
  136377. * !!! Experimental Extension Subject to Changes !!!
  136378. * @hidden
  136379. */
  136380. export class KhronosTextureContainer2 {
  136381. private static _ModulePromise;
  136382. private static _TranscodeFormat;
  136383. constructor(engine: ThinEngine);
  136384. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136385. private _determineTranscodeFormat;
  136386. /**
  136387. * Checks if the given data starts with a KTX2 file identifier.
  136388. * @param data the data to check
  136389. * @returns true if the data is a KTX2 file or false otherwise
  136390. */
  136391. static IsValid(data: ArrayBufferView): boolean;
  136392. }
  136393. }
  136394. declare module BABYLON {
  136395. /**
  136396. * Implementation of the KTX Texture Loader.
  136397. * @hidden
  136398. */
  136399. export class _KTXTextureLoader implements IInternalTextureLoader {
  136400. /**
  136401. * Defines wether the loader supports cascade loading the different faces.
  136402. */
  136403. readonly supportCascades: boolean;
  136404. /**
  136405. * This returns if the loader support the current file information.
  136406. * @param extension defines the file extension of the file being loaded
  136407. * @param mimeType defines the optional mime type of the file being loaded
  136408. * @returns true if the loader can load the specified file
  136409. */
  136410. canLoad(extension: string, mimeType?: string): boolean;
  136411. /**
  136412. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136413. * @param data contains the texture data
  136414. * @param texture defines the BabylonJS internal texture
  136415. * @param createPolynomials will be true if polynomials have been requested
  136416. * @param onLoad defines the callback to trigger once the texture is ready
  136417. * @param onError defines the callback to trigger in case of error
  136418. */
  136419. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136420. /**
  136421. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136422. * @param data contains the texture data
  136423. * @param texture defines the BabylonJS internal texture
  136424. * @param callback defines the method to call once ready to upload
  136425. */
  136426. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136427. }
  136428. }
  136429. declare module BABYLON {
  136430. /** @hidden */
  136431. export var _forceSceneHelpersToBundle: boolean;
  136432. interface Scene {
  136433. /**
  136434. * Creates a default light for the scene.
  136435. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136436. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136437. */
  136438. createDefaultLight(replace?: boolean): void;
  136439. /**
  136440. * Creates a default camera for the scene.
  136441. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136442. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136443. * @param replace has default false, when true replaces the active camera in the scene
  136444. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136445. */
  136446. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136447. /**
  136448. * Creates a default camera and a default light.
  136449. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136450. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136451. * @param replace has the default false, when true replaces the active camera/light in the scene
  136452. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136453. */
  136454. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136455. /**
  136456. * Creates a new sky box
  136457. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136458. * @param environmentTexture defines the texture to use as environment texture
  136459. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136460. * @param scale defines the overall scale of the skybox
  136461. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136462. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136463. * @returns a new mesh holding the sky box
  136464. */
  136465. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136466. /**
  136467. * Creates a new environment
  136468. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136469. * @param options defines the options you can use to configure the environment
  136470. * @returns the new EnvironmentHelper
  136471. */
  136472. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136473. /**
  136474. * Creates a new VREXperienceHelper
  136475. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136476. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136477. * @returns a new VREXperienceHelper
  136478. */
  136479. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136480. /**
  136481. * Creates a new WebXRDefaultExperience
  136482. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136483. * @param options experience options
  136484. * @returns a promise for a new WebXRDefaultExperience
  136485. */
  136486. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136487. }
  136488. }
  136489. declare module BABYLON {
  136490. /**
  136491. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136492. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136493. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136494. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136495. */
  136496. export class VideoDome extends TransformNode {
  136497. /**
  136498. * Define the video source as a Monoscopic panoramic 360 video.
  136499. */
  136500. static readonly MODE_MONOSCOPIC: number;
  136501. /**
  136502. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136503. */
  136504. static readonly MODE_TOPBOTTOM: number;
  136505. /**
  136506. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136507. */
  136508. static readonly MODE_SIDEBYSIDE: number;
  136509. private _halfDome;
  136510. private _useDirectMapping;
  136511. /**
  136512. * The video texture being displayed on the sphere
  136513. */
  136514. protected _videoTexture: VideoTexture;
  136515. /**
  136516. * Gets the video texture being displayed on the sphere
  136517. */
  136518. get videoTexture(): VideoTexture;
  136519. /**
  136520. * The skybox material
  136521. */
  136522. protected _material: BackgroundMaterial;
  136523. /**
  136524. * The surface used for the video dome
  136525. */
  136526. protected _mesh: Mesh;
  136527. /**
  136528. * Gets the mesh used for the video dome.
  136529. */
  136530. get mesh(): Mesh;
  136531. /**
  136532. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136533. */
  136534. private _halfDomeMask;
  136535. /**
  136536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136537. * Also see the options.resolution property.
  136538. */
  136539. get fovMultiplier(): number;
  136540. set fovMultiplier(value: number);
  136541. private _videoMode;
  136542. /**
  136543. * Gets or set the current video mode for the video. It can be:
  136544. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136545. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136546. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136547. */
  136548. get videoMode(): number;
  136549. set videoMode(value: number);
  136550. /**
  136551. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136552. *
  136553. */
  136554. get halfDome(): boolean;
  136555. /**
  136556. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136557. */
  136558. set halfDome(enabled: boolean);
  136559. /**
  136560. * Oberserver used in Stereoscopic VR Mode.
  136561. */
  136562. private _onBeforeCameraRenderObserver;
  136563. /**
  136564. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136565. * @param name Element's name, child elements will append suffixes for their own names.
  136566. * @param urlsOrVideo defines the url(s) or the video element to use
  136567. * @param options An object containing optional or exposed sub element properties
  136568. */
  136569. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136570. resolution?: number;
  136571. clickToPlay?: boolean;
  136572. autoPlay?: boolean;
  136573. loop?: boolean;
  136574. size?: number;
  136575. poster?: string;
  136576. faceForward?: boolean;
  136577. useDirectMapping?: boolean;
  136578. halfDomeMode?: boolean;
  136579. }, scene: Scene);
  136580. private _changeVideoMode;
  136581. /**
  136582. * Releases resources associated with this node.
  136583. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136584. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136585. */
  136586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136587. }
  136588. }
  136589. declare module BABYLON {
  136590. /**
  136591. * This class can be used to get instrumentation data from a Babylon engine
  136592. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136593. */
  136594. export class EngineInstrumentation implements IDisposable {
  136595. /**
  136596. * Define the instrumented engine.
  136597. */
  136598. engine: Engine;
  136599. private _captureGPUFrameTime;
  136600. private _gpuFrameTimeToken;
  136601. private _gpuFrameTime;
  136602. private _captureShaderCompilationTime;
  136603. private _shaderCompilationTime;
  136604. private _onBeginFrameObserver;
  136605. private _onEndFrameObserver;
  136606. private _onBeforeShaderCompilationObserver;
  136607. private _onAfterShaderCompilationObserver;
  136608. /**
  136609. * Gets the perf counter used for GPU frame time
  136610. */
  136611. get gpuFrameTimeCounter(): PerfCounter;
  136612. /**
  136613. * Gets the GPU frame time capture status
  136614. */
  136615. get captureGPUFrameTime(): boolean;
  136616. /**
  136617. * Enable or disable the GPU frame time capture
  136618. */
  136619. set captureGPUFrameTime(value: boolean);
  136620. /**
  136621. * Gets the perf counter used for shader compilation time
  136622. */
  136623. get shaderCompilationTimeCounter(): PerfCounter;
  136624. /**
  136625. * Gets the shader compilation time capture status
  136626. */
  136627. get captureShaderCompilationTime(): boolean;
  136628. /**
  136629. * Enable or disable the shader compilation time capture
  136630. */
  136631. set captureShaderCompilationTime(value: boolean);
  136632. /**
  136633. * Instantiates a new engine instrumentation.
  136634. * This class can be used to get instrumentation data from a Babylon engine
  136635. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136636. * @param engine Defines the engine to instrument
  136637. */
  136638. constructor(
  136639. /**
  136640. * Define the instrumented engine.
  136641. */
  136642. engine: Engine);
  136643. /**
  136644. * Dispose and release associated resources.
  136645. */
  136646. dispose(): void;
  136647. }
  136648. }
  136649. declare module BABYLON {
  136650. /**
  136651. * This class can be used to get instrumentation data from a Babylon engine
  136652. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136653. */
  136654. export class SceneInstrumentation implements IDisposable {
  136655. /**
  136656. * Defines the scene to instrument
  136657. */
  136658. scene: Scene;
  136659. private _captureActiveMeshesEvaluationTime;
  136660. private _activeMeshesEvaluationTime;
  136661. private _captureRenderTargetsRenderTime;
  136662. private _renderTargetsRenderTime;
  136663. private _captureFrameTime;
  136664. private _frameTime;
  136665. private _captureRenderTime;
  136666. private _renderTime;
  136667. private _captureInterFrameTime;
  136668. private _interFrameTime;
  136669. private _captureParticlesRenderTime;
  136670. private _particlesRenderTime;
  136671. private _captureSpritesRenderTime;
  136672. private _spritesRenderTime;
  136673. private _capturePhysicsTime;
  136674. private _physicsTime;
  136675. private _captureAnimationsTime;
  136676. private _animationsTime;
  136677. private _captureCameraRenderTime;
  136678. private _cameraRenderTime;
  136679. private _onBeforeActiveMeshesEvaluationObserver;
  136680. private _onAfterActiveMeshesEvaluationObserver;
  136681. private _onBeforeRenderTargetsRenderObserver;
  136682. private _onAfterRenderTargetsRenderObserver;
  136683. private _onAfterRenderObserver;
  136684. private _onBeforeDrawPhaseObserver;
  136685. private _onAfterDrawPhaseObserver;
  136686. private _onBeforeAnimationsObserver;
  136687. private _onBeforeParticlesRenderingObserver;
  136688. private _onAfterParticlesRenderingObserver;
  136689. private _onBeforeSpritesRenderingObserver;
  136690. private _onAfterSpritesRenderingObserver;
  136691. private _onBeforePhysicsObserver;
  136692. private _onAfterPhysicsObserver;
  136693. private _onAfterAnimationsObserver;
  136694. private _onBeforeCameraRenderObserver;
  136695. private _onAfterCameraRenderObserver;
  136696. /**
  136697. * Gets the perf counter used for active meshes evaluation time
  136698. */
  136699. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136700. /**
  136701. * Gets the active meshes evaluation time capture status
  136702. */
  136703. get captureActiveMeshesEvaluationTime(): boolean;
  136704. /**
  136705. * Enable or disable the active meshes evaluation time capture
  136706. */
  136707. set captureActiveMeshesEvaluationTime(value: boolean);
  136708. /**
  136709. * Gets the perf counter used for render targets render time
  136710. */
  136711. get renderTargetsRenderTimeCounter(): PerfCounter;
  136712. /**
  136713. * Gets the render targets render time capture status
  136714. */
  136715. get captureRenderTargetsRenderTime(): boolean;
  136716. /**
  136717. * Enable or disable the render targets render time capture
  136718. */
  136719. set captureRenderTargetsRenderTime(value: boolean);
  136720. /**
  136721. * Gets the perf counter used for particles render time
  136722. */
  136723. get particlesRenderTimeCounter(): PerfCounter;
  136724. /**
  136725. * Gets the particles render time capture status
  136726. */
  136727. get captureParticlesRenderTime(): boolean;
  136728. /**
  136729. * Enable or disable the particles render time capture
  136730. */
  136731. set captureParticlesRenderTime(value: boolean);
  136732. /**
  136733. * Gets the perf counter used for sprites render time
  136734. */
  136735. get spritesRenderTimeCounter(): PerfCounter;
  136736. /**
  136737. * Gets the sprites render time capture status
  136738. */
  136739. get captureSpritesRenderTime(): boolean;
  136740. /**
  136741. * Enable or disable the sprites render time capture
  136742. */
  136743. set captureSpritesRenderTime(value: boolean);
  136744. /**
  136745. * Gets the perf counter used for physics time
  136746. */
  136747. get physicsTimeCounter(): PerfCounter;
  136748. /**
  136749. * Gets the physics time capture status
  136750. */
  136751. get capturePhysicsTime(): boolean;
  136752. /**
  136753. * Enable or disable the physics time capture
  136754. */
  136755. set capturePhysicsTime(value: boolean);
  136756. /**
  136757. * Gets the perf counter used for animations time
  136758. */
  136759. get animationsTimeCounter(): PerfCounter;
  136760. /**
  136761. * Gets the animations time capture status
  136762. */
  136763. get captureAnimationsTime(): boolean;
  136764. /**
  136765. * Enable or disable the animations time capture
  136766. */
  136767. set captureAnimationsTime(value: boolean);
  136768. /**
  136769. * Gets the perf counter used for frame time capture
  136770. */
  136771. get frameTimeCounter(): PerfCounter;
  136772. /**
  136773. * Gets the frame time capture status
  136774. */
  136775. get captureFrameTime(): boolean;
  136776. /**
  136777. * Enable or disable the frame time capture
  136778. */
  136779. set captureFrameTime(value: boolean);
  136780. /**
  136781. * Gets the perf counter used for inter-frames time capture
  136782. */
  136783. get interFrameTimeCounter(): PerfCounter;
  136784. /**
  136785. * Gets the inter-frames time capture status
  136786. */
  136787. get captureInterFrameTime(): boolean;
  136788. /**
  136789. * Enable or disable the inter-frames time capture
  136790. */
  136791. set captureInterFrameTime(value: boolean);
  136792. /**
  136793. * Gets the perf counter used for render time capture
  136794. */
  136795. get renderTimeCounter(): PerfCounter;
  136796. /**
  136797. * Gets the render time capture status
  136798. */
  136799. get captureRenderTime(): boolean;
  136800. /**
  136801. * Enable or disable the render time capture
  136802. */
  136803. set captureRenderTime(value: boolean);
  136804. /**
  136805. * Gets the perf counter used for camera render time capture
  136806. */
  136807. get cameraRenderTimeCounter(): PerfCounter;
  136808. /**
  136809. * Gets the camera render time capture status
  136810. */
  136811. get captureCameraRenderTime(): boolean;
  136812. /**
  136813. * Enable or disable the camera render time capture
  136814. */
  136815. set captureCameraRenderTime(value: boolean);
  136816. /**
  136817. * Gets the perf counter used for draw calls
  136818. */
  136819. get drawCallsCounter(): PerfCounter;
  136820. /**
  136821. * Instantiates a new scene instrumentation.
  136822. * This class can be used to get instrumentation data from a Babylon engine
  136823. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136824. * @param scene Defines the scene to instrument
  136825. */
  136826. constructor(
  136827. /**
  136828. * Defines the scene to instrument
  136829. */
  136830. scene: Scene);
  136831. /**
  136832. * Dispose and release associated resources.
  136833. */
  136834. dispose(): void;
  136835. }
  136836. }
  136837. declare module BABYLON {
  136838. /** @hidden */
  136839. export var glowMapGenerationPixelShader: {
  136840. name: string;
  136841. shader: string;
  136842. };
  136843. }
  136844. declare module BABYLON {
  136845. /** @hidden */
  136846. export var glowMapGenerationVertexShader: {
  136847. name: string;
  136848. shader: string;
  136849. };
  136850. }
  136851. declare module BABYLON {
  136852. /**
  136853. * Effect layer options. This helps customizing the behaviour
  136854. * of the effect layer.
  136855. */
  136856. export interface IEffectLayerOptions {
  136857. /**
  136858. * Multiplication factor apply to the canvas size to compute the render target size
  136859. * used to generated the objects (the smaller the faster).
  136860. */
  136861. mainTextureRatio: number;
  136862. /**
  136863. * Enforces a fixed size texture to ensure effect stability across devices.
  136864. */
  136865. mainTextureFixedSize?: number;
  136866. /**
  136867. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136868. */
  136869. alphaBlendingMode: number;
  136870. /**
  136871. * The camera attached to the layer.
  136872. */
  136873. camera: Nullable<Camera>;
  136874. /**
  136875. * The rendering group to draw the layer in.
  136876. */
  136877. renderingGroupId: number;
  136878. }
  136879. /**
  136880. * The effect layer Helps adding post process effect blended with the main pass.
  136881. *
  136882. * This can be for instance use to generate glow or higlight effects on the scene.
  136883. *
  136884. * The effect layer class can not be used directly and is intented to inherited from to be
  136885. * customized per effects.
  136886. */
  136887. export abstract class EffectLayer {
  136888. private _vertexBuffers;
  136889. private _indexBuffer;
  136890. private _cachedDefines;
  136891. private _effectLayerMapGenerationEffect;
  136892. private _effectLayerOptions;
  136893. private _mergeEffect;
  136894. protected _scene: Scene;
  136895. protected _engine: Engine;
  136896. protected _maxSize: number;
  136897. protected _mainTextureDesiredSize: ISize;
  136898. protected _mainTexture: RenderTargetTexture;
  136899. protected _shouldRender: boolean;
  136900. protected _postProcesses: PostProcess[];
  136901. protected _textures: BaseTexture[];
  136902. protected _emissiveTextureAndColor: {
  136903. texture: Nullable<BaseTexture>;
  136904. color: Color4;
  136905. };
  136906. /**
  136907. * The name of the layer
  136908. */
  136909. name: string;
  136910. /**
  136911. * The clear color of the texture used to generate the glow map.
  136912. */
  136913. neutralColor: Color4;
  136914. /**
  136915. * Specifies whether the highlight layer is enabled or not.
  136916. */
  136917. isEnabled: boolean;
  136918. /**
  136919. * Gets the camera attached to the layer.
  136920. */
  136921. get camera(): Nullable<Camera>;
  136922. /**
  136923. * Gets the rendering group id the layer should render in.
  136924. */
  136925. get renderingGroupId(): number;
  136926. set renderingGroupId(renderingGroupId: number);
  136927. /**
  136928. * An event triggered when the effect layer has been disposed.
  136929. */
  136930. onDisposeObservable: Observable<EffectLayer>;
  136931. /**
  136932. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136933. */
  136934. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136935. /**
  136936. * An event triggered when the generated texture is being merged in the scene.
  136937. */
  136938. onBeforeComposeObservable: Observable<EffectLayer>;
  136939. /**
  136940. * An event triggered when the mesh is rendered into the effect render target.
  136941. */
  136942. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136943. /**
  136944. * An event triggered after the mesh has been rendered into the effect render target.
  136945. */
  136946. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136947. /**
  136948. * An event triggered when the generated texture has been merged in the scene.
  136949. */
  136950. onAfterComposeObservable: Observable<EffectLayer>;
  136951. /**
  136952. * An event triggered when the efffect layer changes its size.
  136953. */
  136954. onSizeChangedObservable: Observable<EffectLayer>;
  136955. /** @hidden */
  136956. static _SceneComponentInitialization: (scene: Scene) => void;
  136957. /**
  136958. * Instantiates a new effect Layer and references it in the scene.
  136959. * @param name The name of the layer
  136960. * @param scene The scene to use the layer in
  136961. */
  136962. constructor(
  136963. /** The Friendly of the effect in the scene */
  136964. name: string, scene: Scene);
  136965. /**
  136966. * Get the effect name of the layer.
  136967. * @return The effect name
  136968. */
  136969. abstract getEffectName(): string;
  136970. /**
  136971. * Checks for the readiness of the element composing the layer.
  136972. * @param subMesh the mesh to check for
  136973. * @param useInstances specify whether or not to use instances to render the mesh
  136974. * @return true if ready otherwise, false
  136975. */
  136976. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136977. /**
  136978. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136979. * @returns true if the effect requires stencil during the main canvas render pass.
  136980. */
  136981. abstract needStencil(): boolean;
  136982. /**
  136983. * Create the merge effect. This is the shader use to blit the information back
  136984. * to the main canvas at the end of the scene rendering.
  136985. * @returns The effect containing the shader used to merge the effect on the main canvas
  136986. */
  136987. protected abstract _createMergeEffect(): Effect;
  136988. /**
  136989. * Creates the render target textures and post processes used in the effect layer.
  136990. */
  136991. protected abstract _createTextureAndPostProcesses(): void;
  136992. /**
  136993. * Implementation specific of rendering the generating effect on the main canvas.
  136994. * @param effect The effect used to render through
  136995. */
  136996. protected abstract _internalRender(effect: Effect): void;
  136997. /**
  136998. * Sets the required values for both the emissive texture and and the main color.
  136999. */
  137000. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137001. /**
  137002. * Free any resources and references associated to a mesh.
  137003. * Internal use
  137004. * @param mesh The mesh to free.
  137005. */
  137006. abstract _disposeMesh(mesh: Mesh): void;
  137007. /**
  137008. * Serializes this layer (Glow or Highlight for example)
  137009. * @returns a serialized layer object
  137010. */
  137011. abstract serialize?(): any;
  137012. /**
  137013. * Initializes the effect layer with the required options.
  137014. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137015. */
  137016. protected _init(options: Partial<IEffectLayerOptions>): void;
  137017. /**
  137018. * Generates the index buffer of the full screen quad blending to the main canvas.
  137019. */
  137020. private _generateIndexBuffer;
  137021. /**
  137022. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137023. */
  137024. private _generateVertexBuffer;
  137025. /**
  137026. * Sets the main texture desired size which is the closest power of two
  137027. * of the engine canvas size.
  137028. */
  137029. private _setMainTextureSize;
  137030. /**
  137031. * Creates the main texture for the effect layer.
  137032. */
  137033. protected _createMainTexture(): void;
  137034. /**
  137035. * Adds specific effects defines.
  137036. * @param defines The defines to add specifics to.
  137037. */
  137038. protected _addCustomEffectDefines(defines: string[]): void;
  137039. /**
  137040. * Checks for the readiness of the element composing the layer.
  137041. * @param subMesh the mesh to check for
  137042. * @param useInstances specify whether or not to use instances to render the mesh
  137043. * @param emissiveTexture the associated emissive texture used to generate the glow
  137044. * @return true if ready otherwise, false
  137045. */
  137046. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137047. /**
  137048. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137049. */
  137050. render(): void;
  137051. /**
  137052. * Determine if a given mesh will be used in the current effect.
  137053. * @param mesh mesh to test
  137054. * @returns true if the mesh will be used
  137055. */
  137056. hasMesh(mesh: AbstractMesh): boolean;
  137057. /**
  137058. * Returns true if the layer contains information to display, otherwise false.
  137059. * @returns true if the glow layer should be rendered
  137060. */
  137061. shouldRender(): boolean;
  137062. /**
  137063. * Returns true if the mesh should render, otherwise false.
  137064. * @param mesh The mesh to render
  137065. * @returns true if it should render otherwise false
  137066. */
  137067. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137068. /**
  137069. * Returns true if the mesh can be rendered, otherwise false.
  137070. * @param mesh The mesh to render
  137071. * @param material The material used on the mesh
  137072. * @returns true if it can be rendered otherwise false
  137073. */
  137074. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137075. /**
  137076. * Returns true if the mesh should render, otherwise false.
  137077. * @param mesh The mesh to render
  137078. * @returns true if it should render otherwise false
  137079. */
  137080. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137081. /**
  137082. * Renders the submesh passed in parameter to the generation map.
  137083. */
  137084. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  137085. /**
  137086. * Defines whether the current material of the mesh should be use to render the effect.
  137087. * @param mesh defines the current mesh to render
  137088. */
  137089. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137090. /**
  137091. * Rebuild the required buffers.
  137092. * @hidden Internal use only.
  137093. */
  137094. _rebuild(): void;
  137095. /**
  137096. * Dispose only the render target textures and post process.
  137097. */
  137098. private _disposeTextureAndPostProcesses;
  137099. /**
  137100. * Dispose the highlight layer and free resources.
  137101. */
  137102. dispose(): void;
  137103. /**
  137104. * Gets the class name of the effect layer
  137105. * @returns the string with the class name of the effect layer
  137106. */
  137107. getClassName(): string;
  137108. /**
  137109. * Creates an effect layer from parsed effect layer data
  137110. * @param parsedEffectLayer defines effect layer data
  137111. * @param scene defines the current scene
  137112. * @param rootUrl defines the root URL containing the effect layer information
  137113. * @returns a parsed effect Layer
  137114. */
  137115. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  137116. }
  137117. }
  137118. declare module BABYLON {
  137119. interface AbstractScene {
  137120. /**
  137121. * The list of effect layers (highlights/glow) added to the scene
  137122. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137123. * @see https://doc.babylonjs.com/how_to/glow_layer
  137124. */
  137125. effectLayers: Array<EffectLayer>;
  137126. /**
  137127. * Removes the given effect layer from this scene.
  137128. * @param toRemove defines the effect layer to remove
  137129. * @returns the index of the removed effect layer
  137130. */
  137131. removeEffectLayer(toRemove: EffectLayer): number;
  137132. /**
  137133. * Adds the given effect layer to this scene
  137134. * @param newEffectLayer defines the effect layer to add
  137135. */
  137136. addEffectLayer(newEffectLayer: EffectLayer): void;
  137137. }
  137138. /**
  137139. * Defines the layer scene component responsible to manage any effect layers
  137140. * in a given scene.
  137141. */
  137142. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137143. /**
  137144. * The component name helpfull to identify the component in the list of scene components.
  137145. */
  137146. readonly name: string;
  137147. /**
  137148. * The scene the component belongs to.
  137149. */
  137150. scene: Scene;
  137151. private _engine;
  137152. private _renderEffects;
  137153. private _needStencil;
  137154. private _previousStencilState;
  137155. /**
  137156. * Creates a new instance of the component for the given scene
  137157. * @param scene Defines the scene to register the component in
  137158. */
  137159. constructor(scene: Scene);
  137160. /**
  137161. * Registers the component in a given scene
  137162. */
  137163. register(): void;
  137164. /**
  137165. * Rebuilds the elements related to this component in case of
  137166. * context lost for instance.
  137167. */
  137168. rebuild(): void;
  137169. /**
  137170. * Serializes the component data to the specified json object
  137171. * @param serializationObject The object to serialize to
  137172. */
  137173. serialize(serializationObject: any): void;
  137174. /**
  137175. * Adds all the elements from the container to the scene
  137176. * @param container the container holding the elements
  137177. */
  137178. addFromContainer(container: AbstractScene): void;
  137179. /**
  137180. * Removes all the elements in the container from the scene
  137181. * @param container contains the elements to remove
  137182. * @param dispose if the removed element should be disposed (default: false)
  137183. */
  137184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137185. /**
  137186. * Disposes the component and the associated ressources.
  137187. */
  137188. dispose(): void;
  137189. private _isReadyForMesh;
  137190. private _renderMainTexture;
  137191. private _setStencil;
  137192. private _setStencilBack;
  137193. private _draw;
  137194. private _drawCamera;
  137195. private _drawRenderingGroup;
  137196. }
  137197. }
  137198. declare module BABYLON {
  137199. /** @hidden */
  137200. export var glowMapMergePixelShader: {
  137201. name: string;
  137202. shader: string;
  137203. };
  137204. }
  137205. declare module BABYLON {
  137206. /** @hidden */
  137207. export var glowMapMergeVertexShader: {
  137208. name: string;
  137209. shader: string;
  137210. };
  137211. }
  137212. declare module BABYLON {
  137213. interface AbstractScene {
  137214. /**
  137215. * Return a the first highlight layer of the scene with a given name.
  137216. * @param name The name of the highlight layer to look for.
  137217. * @return The highlight layer if found otherwise null.
  137218. */
  137219. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  137220. }
  137221. /**
  137222. * Glow layer options. This helps customizing the behaviour
  137223. * of the glow layer.
  137224. */
  137225. export interface IGlowLayerOptions {
  137226. /**
  137227. * Multiplication factor apply to the canvas size to compute the render target size
  137228. * used to generated the glowing objects (the smaller the faster).
  137229. */
  137230. mainTextureRatio: number;
  137231. /**
  137232. * Enforces a fixed size texture to ensure resize independant blur.
  137233. */
  137234. mainTextureFixedSize?: number;
  137235. /**
  137236. * How big is the kernel of the blur texture.
  137237. */
  137238. blurKernelSize: number;
  137239. /**
  137240. * The camera attached to the layer.
  137241. */
  137242. camera: Nullable<Camera>;
  137243. /**
  137244. * Enable MSAA by chosing the number of samples.
  137245. */
  137246. mainTextureSamples?: number;
  137247. /**
  137248. * The rendering group to draw the layer in.
  137249. */
  137250. renderingGroupId: number;
  137251. }
  137252. /**
  137253. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137254. *
  137255. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137256. *
  137257. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137258. */
  137259. export class GlowLayer extends EffectLayer {
  137260. /**
  137261. * Effect Name of the layer.
  137262. */
  137263. static readonly EffectName: string;
  137264. /**
  137265. * The default blur kernel size used for the glow.
  137266. */
  137267. static DefaultBlurKernelSize: number;
  137268. /**
  137269. * The default texture size ratio used for the glow.
  137270. */
  137271. static DefaultTextureRatio: number;
  137272. /**
  137273. * Sets the kernel size of the blur.
  137274. */
  137275. set blurKernelSize(value: number);
  137276. /**
  137277. * Gets the kernel size of the blur.
  137278. */
  137279. get blurKernelSize(): number;
  137280. /**
  137281. * Sets the glow intensity.
  137282. */
  137283. set intensity(value: number);
  137284. /**
  137285. * Gets the glow intensity.
  137286. */
  137287. get intensity(): number;
  137288. private _options;
  137289. private _intensity;
  137290. private _horizontalBlurPostprocess1;
  137291. private _verticalBlurPostprocess1;
  137292. private _horizontalBlurPostprocess2;
  137293. private _verticalBlurPostprocess2;
  137294. private _blurTexture1;
  137295. private _blurTexture2;
  137296. private _postProcesses1;
  137297. private _postProcesses2;
  137298. private _includedOnlyMeshes;
  137299. private _excludedMeshes;
  137300. private _meshesUsingTheirOwnMaterials;
  137301. /**
  137302. * Callback used to let the user override the color selection on a per mesh basis
  137303. */
  137304. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137305. /**
  137306. * Callback used to let the user override the texture selection on a per mesh basis
  137307. */
  137308. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137309. /**
  137310. * Instantiates a new glow Layer and references it to the scene.
  137311. * @param name The name of the layer
  137312. * @param scene The scene to use the layer in
  137313. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137314. */
  137315. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137316. /**
  137317. * Get the effect name of the layer.
  137318. * @return The effect name
  137319. */
  137320. getEffectName(): string;
  137321. /**
  137322. * Create the merge effect. This is the shader use to blit the information back
  137323. * to the main canvas at the end of the scene rendering.
  137324. */
  137325. protected _createMergeEffect(): Effect;
  137326. /**
  137327. * Creates the render target textures and post processes used in the glow layer.
  137328. */
  137329. protected _createTextureAndPostProcesses(): void;
  137330. /**
  137331. * Checks for the readiness of the element composing the layer.
  137332. * @param subMesh the mesh to check for
  137333. * @param useInstances specify wether or not to use instances to render the mesh
  137334. * @param emissiveTexture the associated emissive texture used to generate the glow
  137335. * @return true if ready otherwise, false
  137336. */
  137337. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137338. /**
  137339. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137340. */
  137341. needStencil(): boolean;
  137342. /**
  137343. * Returns true if the mesh can be rendered, otherwise false.
  137344. * @param mesh The mesh to render
  137345. * @param material The material used on the mesh
  137346. * @returns true if it can be rendered otherwise false
  137347. */
  137348. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137349. /**
  137350. * Implementation specific of rendering the generating effect on the main canvas.
  137351. * @param effect The effect used to render through
  137352. */
  137353. protected _internalRender(effect: Effect): void;
  137354. /**
  137355. * Sets the required values for both the emissive texture and and the main color.
  137356. */
  137357. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137358. /**
  137359. * Returns true if the mesh should render, otherwise false.
  137360. * @param mesh The mesh to render
  137361. * @returns true if it should render otherwise false
  137362. */
  137363. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137364. /**
  137365. * Adds specific effects defines.
  137366. * @param defines The defines to add specifics to.
  137367. */
  137368. protected _addCustomEffectDefines(defines: string[]): void;
  137369. /**
  137370. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137371. * @param mesh The mesh to exclude from the glow layer
  137372. */
  137373. addExcludedMesh(mesh: Mesh): void;
  137374. /**
  137375. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137376. * @param mesh The mesh to remove
  137377. */
  137378. removeExcludedMesh(mesh: Mesh): void;
  137379. /**
  137380. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137381. * @param mesh The mesh to include in the glow layer
  137382. */
  137383. addIncludedOnlyMesh(mesh: Mesh): void;
  137384. /**
  137385. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137386. * @param mesh The mesh to remove
  137387. */
  137388. removeIncludedOnlyMesh(mesh: Mesh): void;
  137389. /**
  137390. * Determine if a given mesh will be used in the glow layer
  137391. * @param mesh The mesh to test
  137392. * @returns true if the mesh will be highlighted by the current glow layer
  137393. */
  137394. hasMesh(mesh: AbstractMesh): boolean;
  137395. /**
  137396. * Defines whether the current material of the mesh should be use to render the effect.
  137397. * @param mesh defines the current mesh to render
  137398. */
  137399. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137400. /**
  137401. * Add a mesh to be rendered through its own material and not with emissive only.
  137402. * @param mesh The mesh for which we need to use its material
  137403. */
  137404. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137405. /**
  137406. * Remove a mesh from being rendered through its own material and not with emissive only.
  137407. * @param mesh The mesh for which we need to not use its material
  137408. */
  137409. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137410. /**
  137411. * Free any resources and references associated to a mesh.
  137412. * Internal use
  137413. * @param mesh The mesh to free.
  137414. * @hidden
  137415. */
  137416. _disposeMesh(mesh: Mesh): void;
  137417. /**
  137418. * Gets the class name of the effect layer
  137419. * @returns the string with the class name of the effect layer
  137420. */
  137421. getClassName(): string;
  137422. /**
  137423. * Serializes this glow layer
  137424. * @returns a serialized glow layer object
  137425. */
  137426. serialize(): any;
  137427. /**
  137428. * Creates a Glow Layer from parsed glow layer data
  137429. * @param parsedGlowLayer defines glow layer data
  137430. * @param scene defines the current scene
  137431. * @param rootUrl defines the root URL containing the glow layer information
  137432. * @returns a parsed Glow Layer
  137433. */
  137434. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137435. }
  137436. }
  137437. declare module BABYLON {
  137438. /** @hidden */
  137439. export var glowBlurPostProcessPixelShader: {
  137440. name: string;
  137441. shader: string;
  137442. };
  137443. }
  137444. declare module BABYLON {
  137445. interface AbstractScene {
  137446. /**
  137447. * Return a the first highlight layer of the scene with a given name.
  137448. * @param name The name of the highlight layer to look for.
  137449. * @return The highlight layer if found otherwise null.
  137450. */
  137451. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137452. }
  137453. /**
  137454. * Highlight layer options. This helps customizing the behaviour
  137455. * of the highlight layer.
  137456. */
  137457. export interface IHighlightLayerOptions {
  137458. /**
  137459. * Multiplication factor apply to the canvas size to compute the render target size
  137460. * used to generated the glowing objects (the smaller the faster).
  137461. */
  137462. mainTextureRatio: number;
  137463. /**
  137464. * Enforces a fixed size texture to ensure resize independant blur.
  137465. */
  137466. mainTextureFixedSize?: number;
  137467. /**
  137468. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137469. * of the picture to blur (the smaller the faster).
  137470. */
  137471. blurTextureSizeRatio: number;
  137472. /**
  137473. * How big in texel of the blur texture is the vertical blur.
  137474. */
  137475. blurVerticalSize: number;
  137476. /**
  137477. * How big in texel of the blur texture is the horizontal blur.
  137478. */
  137479. blurHorizontalSize: number;
  137480. /**
  137481. * Alpha blending mode used to apply the blur. Default is combine.
  137482. */
  137483. alphaBlendingMode: number;
  137484. /**
  137485. * The camera attached to the layer.
  137486. */
  137487. camera: Nullable<Camera>;
  137488. /**
  137489. * Should we display highlight as a solid stroke?
  137490. */
  137491. isStroke?: boolean;
  137492. /**
  137493. * The rendering group to draw the layer in.
  137494. */
  137495. renderingGroupId: number;
  137496. }
  137497. /**
  137498. * The highlight layer Helps adding a glow effect around a mesh.
  137499. *
  137500. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137501. * glowy meshes to your scene.
  137502. *
  137503. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137504. */
  137505. export class HighlightLayer extends EffectLayer {
  137506. name: string;
  137507. /**
  137508. * Effect Name of the highlight layer.
  137509. */
  137510. static readonly EffectName: string;
  137511. /**
  137512. * The neutral color used during the preparation of the glow effect.
  137513. * This is black by default as the blend operation is a blend operation.
  137514. */
  137515. static NeutralColor: Color4;
  137516. /**
  137517. * Stencil value used for glowing meshes.
  137518. */
  137519. static GlowingMeshStencilReference: number;
  137520. /**
  137521. * Stencil value used for the other meshes in the scene.
  137522. */
  137523. static NormalMeshStencilReference: number;
  137524. /**
  137525. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137526. */
  137527. innerGlow: boolean;
  137528. /**
  137529. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137530. */
  137531. outerGlow: boolean;
  137532. /**
  137533. * Specifies the horizontal size of the blur.
  137534. */
  137535. set blurHorizontalSize(value: number);
  137536. /**
  137537. * Specifies the vertical size of the blur.
  137538. */
  137539. set blurVerticalSize(value: number);
  137540. /**
  137541. * Gets the horizontal size of the blur.
  137542. */
  137543. get blurHorizontalSize(): number;
  137544. /**
  137545. * Gets the vertical size of the blur.
  137546. */
  137547. get blurVerticalSize(): number;
  137548. /**
  137549. * An event triggered when the highlight layer is being blurred.
  137550. */
  137551. onBeforeBlurObservable: Observable<HighlightLayer>;
  137552. /**
  137553. * An event triggered when the highlight layer has been blurred.
  137554. */
  137555. onAfterBlurObservable: Observable<HighlightLayer>;
  137556. private _instanceGlowingMeshStencilReference;
  137557. private _options;
  137558. private _downSamplePostprocess;
  137559. private _horizontalBlurPostprocess;
  137560. private _verticalBlurPostprocess;
  137561. private _blurTexture;
  137562. private _meshes;
  137563. private _excludedMeshes;
  137564. /**
  137565. * Instantiates a new highlight Layer and references it to the scene..
  137566. * @param name The name of the layer
  137567. * @param scene The scene to use the layer in
  137568. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137569. */
  137570. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137571. /**
  137572. * Get the effect name of the layer.
  137573. * @return The effect name
  137574. */
  137575. getEffectName(): string;
  137576. /**
  137577. * Create the merge effect. This is the shader use to blit the information back
  137578. * to the main canvas at the end of the scene rendering.
  137579. */
  137580. protected _createMergeEffect(): Effect;
  137581. /**
  137582. * Creates the render target textures and post processes used in the highlight layer.
  137583. */
  137584. protected _createTextureAndPostProcesses(): void;
  137585. /**
  137586. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137587. */
  137588. needStencil(): boolean;
  137589. /**
  137590. * Checks for the readiness of the element composing the layer.
  137591. * @param subMesh the mesh to check for
  137592. * @param useInstances specify wether or not to use instances to render the mesh
  137593. * @param emissiveTexture the associated emissive texture used to generate the glow
  137594. * @return true if ready otherwise, false
  137595. */
  137596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137597. /**
  137598. * Implementation specific of rendering the generating effect on the main canvas.
  137599. * @param effect The effect used to render through
  137600. */
  137601. protected _internalRender(effect: Effect): void;
  137602. /**
  137603. * Returns true if the layer contains information to display, otherwise false.
  137604. */
  137605. shouldRender(): boolean;
  137606. /**
  137607. * Returns true if the mesh should render, otherwise false.
  137608. * @param mesh The mesh to render
  137609. * @returns true if it should render otherwise false
  137610. */
  137611. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137612. /**
  137613. * Returns true if the mesh can be rendered, otherwise false.
  137614. * @param mesh The mesh to render
  137615. * @param material The material used on the mesh
  137616. * @returns true if it can be rendered otherwise false
  137617. */
  137618. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137619. /**
  137620. * Adds specific effects defines.
  137621. * @param defines The defines to add specifics to.
  137622. */
  137623. protected _addCustomEffectDefines(defines: string[]): void;
  137624. /**
  137625. * Sets the required values for both the emissive texture and and the main color.
  137626. */
  137627. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137628. /**
  137629. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137630. * @param mesh The mesh to exclude from the highlight layer
  137631. */
  137632. addExcludedMesh(mesh: Mesh): void;
  137633. /**
  137634. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137635. * @param mesh The mesh to highlight
  137636. */
  137637. removeExcludedMesh(mesh: Mesh): void;
  137638. /**
  137639. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137640. * @param mesh mesh to test
  137641. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137642. */
  137643. hasMesh(mesh: AbstractMesh): boolean;
  137644. /**
  137645. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137646. * @param mesh The mesh to highlight
  137647. * @param color The color of the highlight
  137648. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137649. */
  137650. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137651. /**
  137652. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137653. * @param mesh The mesh to highlight
  137654. */
  137655. removeMesh(mesh: Mesh): void;
  137656. /**
  137657. * Remove all the meshes currently referenced in the highlight layer
  137658. */
  137659. removeAllMeshes(): void;
  137660. /**
  137661. * Force the stencil to the normal expected value for none glowing parts
  137662. */
  137663. private _defaultStencilReference;
  137664. /**
  137665. * Free any resources and references associated to a mesh.
  137666. * Internal use
  137667. * @param mesh The mesh to free.
  137668. * @hidden
  137669. */
  137670. _disposeMesh(mesh: Mesh): void;
  137671. /**
  137672. * Dispose the highlight layer and free resources.
  137673. */
  137674. dispose(): void;
  137675. /**
  137676. * Gets the class name of the effect layer
  137677. * @returns the string with the class name of the effect layer
  137678. */
  137679. getClassName(): string;
  137680. /**
  137681. * Serializes this Highlight layer
  137682. * @returns a serialized Highlight layer object
  137683. */
  137684. serialize(): any;
  137685. /**
  137686. * Creates a Highlight layer from parsed Highlight layer data
  137687. * @param parsedHightlightLayer defines the Highlight layer data
  137688. * @param scene defines the current scene
  137689. * @param rootUrl defines the root URL containing the Highlight layer information
  137690. * @returns a parsed Highlight layer
  137691. */
  137692. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137693. }
  137694. }
  137695. declare module BABYLON {
  137696. interface AbstractScene {
  137697. /**
  137698. * The list of layers (background and foreground) of the scene
  137699. */
  137700. layers: Array<Layer>;
  137701. }
  137702. /**
  137703. * Defines the layer scene component responsible to manage any layers
  137704. * in a given scene.
  137705. */
  137706. export class LayerSceneComponent implements ISceneComponent {
  137707. /**
  137708. * The component name helpfull to identify the component in the list of scene components.
  137709. */
  137710. readonly name: string;
  137711. /**
  137712. * The scene the component belongs to.
  137713. */
  137714. scene: Scene;
  137715. private _engine;
  137716. /**
  137717. * Creates a new instance of the component for the given scene
  137718. * @param scene Defines the scene to register the component in
  137719. */
  137720. constructor(scene: Scene);
  137721. /**
  137722. * Registers the component in a given scene
  137723. */
  137724. register(): void;
  137725. /**
  137726. * Rebuilds the elements related to this component in case of
  137727. * context lost for instance.
  137728. */
  137729. rebuild(): void;
  137730. /**
  137731. * Disposes the component and the associated ressources.
  137732. */
  137733. dispose(): void;
  137734. private _draw;
  137735. private _drawCameraPredicate;
  137736. private _drawCameraBackground;
  137737. private _drawCameraForeground;
  137738. private _drawRenderTargetPredicate;
  137739. private _drawRenderTargetBackground;
  137740. private _drawRenderTargetForeground;
  137741. /**
  137742. * Adds all the elements from the container to the scene
  137743. * @param container the container holding the elements
  137744. */
  137745. addFromContainer(container: AbstractScene): void;
  137746. /**
  137747. * Removes all the elements in the container from the scene
  137748. * @param container contains the elements to remove
  137749. * @param dispose if the removed element should be disposed (default: false)
  137750. */
  137751. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137752. }
  137753. }
  137754. declare module BABYLON {
  137755. /** @hidden */
  137756. export var layerPixelShader: {
  137757. name: string;
  137758. shader: string;
  137759. };
  137760. }
  137761. declare module BABYLON {
  137762. /** @hidden */
  137763. export var layerVertexShader: {
  137764. name: string;
  137765. shader: string;
  137766. };
  137767. }
  137768. declare module BABYLON {
  137769. /**
  137770. * This represents a full screen 2d layer.
  137771. * This can be useful to display a picture in the background of your scene for instance.
  137772. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137773. */
  137774. export class Layer {
  137775. /**
  137776. * Define the name of the layer.
  137777. */
  137778. name: string;
  137779. /**
  137780. * Define the texture the layer should display.
  137781. */
  137782. texture: Nullable<Texture>;
  137783. /**
  137784. * Is the layer in background or foreground.
  137785. */
  137786. isBackground: boolean;
  137787. /**
  137788. * Define the color of the layer (instead of texture).
  137789. */
  137790. color: Color4;
  137791. /**
  137792. * Define the scale of the layer in order to zoom in out of the texture.
  137793. */
  137794. scale: Vector2;
  137795. /**
  137796. * Define an offset for the layer in order to shift the texture.
  137797. */
  137798. offset: Vector2;
  137799. /**
  137800. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137801. */
  137802. alphaBlendingMode: number;
  137803. /**
  137804. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137805. * Alpha test will not mix with the background color in case of transparency.
  137806. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137807. */
  137808. alphaTest: boolean;
  137809. /**
  137810. * Define a mask to restrict the layer to only some of the scene cameras.
  137811. */
  137812. layerMask: number;
  137813. /**
  137814. * Define the list of render target the layer is visible into.
  137815. */
  137816. renderTargetTextures: RenderTargetTexture[];
  137817. /**
  137818. * Define if the layer is only used in renderTarget or if it also
  137819. * renders in the main frame buffer of the canvas.
  137820. */
  137821. renderOnlyInRenderTargetTextures: boolean;
  137822. private _scene;
  137823. private _vertexBuffers;
  137824. private _indexBuffer;
  137825. private _effect;
  137826. private _previousDefines;
  137827. /**
  137828. * An event triggered when the layer is disposed.
  137829. */
  137830. onDisposeObservable: Observable<Layer>;
  137831. private _onDisposeObserver;
  137832. /**
  137833. * Back compatibility with callback before the onDisposeObservable existed.
  137834. * The set callback will be triggered when the layer has been disposed.
  137835. */
  137836. set onDispose(callback: () => void);
  137837. /**
  137838. * An event triggered before rendering the scene
  137839. */
  137840. onBeforeRenderObservable: Observable<Layer>;
  137841. private _onBeforeRenderObserver;
  137842. /**
  137843. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137844. * The set callback will be triggered just before rendering the layer.
  137845. */
  137846. set onBeforeRender(callback: () => void);
  137847. /**
  137848. * An event triggered after rendering the scene
  137849. */
  137850. onAfterRenderObservable: Observable<Layer>;
  137851. private _onAfterRenderObserver;
  137852. /**
  137853. * Back compatibility with callback before the onAfterRenderObservable existed.
  137854. * The set callback will be triggered just after rendering the layer.
  137855. */
  137856. set onAfterRender(callback: () => void);
  137857. /**
  137858. * Instantiates a new layer.
  137859. * This represents a full screen 2d layer.
  137860. * This can be useful to display a picture in the background of your scene for instance.
  137861. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137862. * @param name Define the name of the layer in the scene
  137863. * @param imgUrl Define the url of the texture to display in the layer
  137864. * @param scene Define the scene the layer belongs to
  137865. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137866. * @param color Defines a color for the layer
  137867. */
  137868. constructor(
  137869. /**
  137870. * Define the name of the layer.
  137871. */
  137872. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137873. private _createIndexBuffer;
  137874. /** @hidden */
  137875. _rebuild(): void;
  137876. /**
  137877. * Renders the layer in the scene.
  137878. */
  137879. render(): void;
  137880. /**
  137881. * Disposes and releases the associated ressources.
  137882. */
  137883. dispose(): void;
  137884. }
  137885. }
  137886. declare module BABYLON {
  137887. /** @hidden */
  137888. export var lensFlarePixelShader: {
  137889. name: string;
  137890. shader: string;
  137891. };
  137892. }
  137893. declare module BABYLON {
  137894. /** @hidden */
  137895. export var lensFlareVertexShader: {
  137896. name: string;
  137897. shader: string;
  137898. };
  137899. }
  137900. declare module BABYLON {
  137901. /**
  137902. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137903. * It is usually composed of several `lensFlare`.
  137904. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137905. */
  137906. export class LensFlareSystem {
  137907. /**
  137908. * Define the name of the lens flare system
  137909. */
  137910. name: string;
  137911. /**
  137912. * List of lens flares used in this system.
  137913. */
  137914. lensFlares: LensFlare[];
  137915. /**
  137916. * Define a limit from the border the lens flare can be visible.
  137917. */
  137918. borderLimit: number;
  137919. /**
  137920. * Define a viewport border we do not want to see the lens flare in.
  137921. */
  137922. viewportBorder: number;
  137923. /**
  137924. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137925. */
  137926. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137927. /**
  137928. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137929. */
  137930. layerMask: number;
  137931. /**
  137932. * Define the id of the lens flare system in the scene.
  137933. * (equal to name by default)
  137934. */
  137935. id: string;
  137936. private _scene;
  137937. private _emitter;
  137938. private _vertexBuffers;
  137939. private _indexBuffer;
  137940. private _effect;
  137941. private _positionX;
  137942. private _positionY;
  137943. private _isEnabled;
  137944. /** @hidden */
  137945. static _SceneComponentInitialization: (scene: Scene) => void;
  137946. /**
  137947. * Instantiates a lens flare system.
  137948. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137949. * It is usually composed of several `lensFlare`.
  137950. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137951. * @param name Define the name of the lens flare system in the scene
  137952. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137953. * @param scene Define the scene the lens flare system belongs to
  137954. */
  137955. constructor(
  137956. /**
  137957. * Define the name of the lens flare system
  137958. */
  137959. name: string, emitter: any, scene: Scene);
  137960. /**
  137961. * Define if the lens flare system is enabled.
  137962. */
  137963. get isEnabled(): boolean;
  137964. set isEnabled(value: boolean);
  137965. /**
  137966. * Get the scene the effects belongs to.
  137967. * @returns the scene holding the lens flare system
  137968. */
  137969. getScene(): Scene;
  137970. /**
  137971. * Get the emitter of the lens flare system.
  137972. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137973. * @returns the emitter of the lens flare system
  137974. */
  137975. getEmitter(): any;
  137976. /**
  137977. * Set the emitter of the lens flare system.
  137978. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137979. * @param newEmitter Define the new emitter of the system
  137980. */
  137981. setEmitter(newEmitter: any): void;
  137982. /**
  137983. * Get the lens flare system emitter position.
  137984. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137985. * @returns the position
  137986. */
  137987. getEmitterPosition(): Vector3;
  137988. /**
  137989. * @hidden
  137990. */
  137991. computeEffectivePosition(globalViewport: Viewport): boolean;
  137992. /** @hidden */
  137993. _isVisible(): boolean;
  137994. /**
  137995. * @hidden
  137996. */
  137997. render(): boolean;
  137998. /**
  137999. * Dispose and release the lens flare with its associated resources.
  138000. */
  138001. dispose(): void;
  138002. /**
  138003. * Parse a lens flare system from a JSON repressentation
  138004. * @param parsedLensFlareSystem Define the JSON to parse
  138005. * @param scene Define the scene the parsed system should be instantiated in
  138006. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138007. * @returns the parsed system
  138008. */
  138009. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138010. /**
  138011. * Serialize the current Lens Flare System into a JSON representation.
  138012. * @returns the serialized JSON
  138013. */
  138014. serialize(): any;
  138015. }
  138016. }
  138017. declare module BABYLON {
  138018. /**
  138019. * This represents one of the lens effect in a `lensFlareSystem`.
  138020. * It controls one of the indiviual texture used in the effect.
  138021. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138022. */
  138023. export class LensFlare {
  138024. /**
  138025. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138026. */
  138027. size: number;
  138028. /**
  138029. * 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.
  138030. */
  138031. position: number;
  138032. /**
  138033. * Define the lens color.
  138034. */
  138035. color: Color3;
  138036. /**
  138037. * Define the lens texture.
  138038. */
  138039. texture: Nullable<Texture>;
  138040. /**
  138041. * Define the alpha mode to render this particular lens.
  138042. */
  138043. alphaMode: number;
  138044. private _system;
  138045. /**
  138046. * Creates a new Lens Flare.
  138047. * This represents one of the lens effect in a `lensFlareSystem`.
  138048. * It controls one of the indiviual texture used in the effect.
  138049. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138050. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138051. * @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.
  138052. * @param color Define the lens color
  138053. * @param imgUrl Define the lens texture url
  138054. * @param system Define the `lensFlareSystem` this flare is part of
  138055. * @returns The newly created Lens Flare
  138056. */
  138057. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138058. /**
  138059. * Instantiates a new Lens Flare.
  138060. * This represents one of the lens effect in a `lensFlareSystem`.
  138061. * It controls one of the indiviual texture used in the effect.
  138062. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138063. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138064. * @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.
  138065. * @param color Define the lens color
  138066. * @param imgUrl Define the lens texture url
  138067. * @param system Define the `lensFlareSystem` this flare is part of
  138068. */
  138069. constructor(
  138070. /**
  138071. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138072. */
  138073. size: number,
  138074. /**
  138075. * 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.
  138076. */
  138077. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138078. /**
  138079. * Dispose and release the lens flare with its associated resources.
  138080. */
  138081. dispose(): void;
  138082. }
  138083. }
  138084. declare module BABYLON {
  138085. interface AbstractScene {
  138086. /**
  138087. * The list of lens flare system added to the scene
  138088. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138089. */
  138090. lensFlareSystems: Array<LensFlareSystem>;
  138091. /**
  138092. * Removes the given lens flare system from this scene.
  138093. * @param toRemove The lens flare system to remove
  138094. * @returns The index of the removed lens flare system
  138095. */
  138096. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  138097. /**
  138098. * Adds the given lens flare system to this scene
  138099. * @param newLensFlareSystem The lens flare system to add
  138100. */
  138101. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  138102. /**
  138103. * Gets a lens flare system using its name
  138104. * @param name defines the name to look for
  138105. * @returns the lens flare system or null if not found
  138106. */
  138107. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  138108. /**
  138109. * Gets a lens flare system using its id
  138110. * @param id defines the id to look for
  138111. * @returns the lens flare system or null if not found
  138112. */
  138113. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  138114. }
  138115. /**
  138116. * Defines the lens flare scene component responsible to manage any lens flares
  138117. * in a given scene.
  138118. */
  138119. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138120. /**
  138121. * The component name helpfull to identify the component in the list of scene components.
  138122. */
  138123. readonly name: string;
  138124. /**
  138125. * The scene the component belongs to.
  138126. */
  138127. scene: Scene;
  138128. /**
  138129. * Creates a new instance of the component for the given scene
  138130. * @param scene Defines the scene to register the component in
  138131. */
  138132. constructor(scene: Scene);
  138133. /**
  138134. * Registers the component in a given scene
  138135. */
  138136. register(): void;
  138137. /**
  138138. * Rebuilds the elements related to this component in case of
  138139. * context lost for instance.
  138140. */
  138141. rebuild(): void;
  138142. /**
  138143. * Adds all the elements from the container to the scene
  138144. * @param container the container holding the elements
  138145. */
  138146. addFromContainer(container: AbstractScene): void;
  138147. /**
  138148. * Removes all the elements in the container from the scene
  138149. * @param container contains the elements to remove
  138150. * @param dispose if the removed element should be disposed (default: false)
  138151. */
  138152. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138153. /**
  138154. * Serializes the component data to the specified json object
  138155. * @param serializationObject The object to serialize to
  138156. */
  138157. serialize(serializationObject: any): void;
  138158. /**
  138159. * Disposes the component and the associated ressources.
  138160. */
  138161. dispose(): void;
  138162. private _draw;
  138163. }
  138164. }
  138165. declare module BABYLON {
  138166. /** @hidden */
  138167. export var depthPixelShader: {
  138168. name: string;
  138169. shader: string;
  138170. };
  138171. }
  138172. declare module BABYLON {
  138173. /** @hidden */
  138174. export var depthVertexShader: {
  138175. name: string;
  138176. shader: string;
  138177. };
  138178. }
  138179. declare module BABYLON {
  138180. /**
  138181. * This represents a depth renderer in Babylon.
  138182. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138183. */
  138184. export class DepthRenderer {
  138185. private _scene;
  138186. private _depthMap;
  138187. private _effect;
  138188. private readonly _storeNonLinearDepth;
  138189. private readonly _clearColor;
  138190. /** Get if the depth renderer is using packed depth or not */
  138191. readonly isPacked: boolean;
  138192. private _cachedDefines;
  138193. private _camera;
  138194. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138195. enabled: boolean;
  138196. /**
  138197. * Specifiess that the depth renderer will only be used within
  138198. * the camera it is created for.
  138199. * This can help forcing its rendering during the camera processing.
  138200. */
  138201. useOnlyInActiveCamera: boolean;
  138202. /** @hidden */
  138203. static _SceneComponentInitialization: (scene: Scene) => void;
  138204. /**
  138205. * Instantiates a depth renderer
  138206. * @param scene The scene the renderer belongs to
  138207. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  138208. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  138209. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138210. */
  138211. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  138212. /**
  138213. * Creates the depth rendering effect and checks if the effect is ready.
  138214. * @param subMesh The submesh to be used to render the depth map of
  138215. * @param useInstances If multiple world instances should be used
  138216. * @returns if the depth renderer is ready to render the depth map
  138217. */
  138218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138219. /**
  138220. * Gets the texture which the depth map will be written to.
  138221. * @returns The depth map texture
  138222. */
  138223. getDepthMap(): RenderTargetTexture;
  138224. /**
  138225. * Disposes of the depth renderer.
  138226. */
  138227. dispose(): void;
  138228. }
  138229. }
  138230. declare module BABYLON {
  138231. /** @hidden */
  138232. export var minmaxReduxPixelShader: {
  138233. name: string;
  138234. shader: string;
  138235. };
  138236. }
  138237. declare module BABYLON {
  138238. /**
  138239. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138240. * and maximum values from all values of the texture.
  138241. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138242. * The source values are read from the red channel of the texture.
  138243. */
  138244. export class MinMaxReducer {
  138245. /**
  138246. * Observable triggered when the computation has been performed
  138247. */
  138248. onAfterReductionPerformed: Observable<{
  138249. min: number;
  138250. max: number;
  138251. }>;
  138252. protected _camera: Camera;
  138253. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138254. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138255. protected _postProcessManager: PostProcessManager;
  138256. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138257. protected _forceFullscreenViewport: boolean;
  138258. /**
  138259. * Creates a min/max reducer
  138260. * @param camera The camera to use for the post processes
  138261. */
  138262. constructor(camera: Camera);
  138263. /**
  138264. * Gets the texture used to read the values from.
  138265. */
  138266. get sourceTexture(): Nullable<RenderTargetTexture>;
  138267. /**
  138268. * Sets the source texture to read the values from.
  138269. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138270. * because in such textures '1' value must not be taken into account to compute the maximum
  138271. * as this value is used to clear the texture.
  138272. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138273. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138274. * @param depthRedux Indicates if the texture is a depth texture or not
  138275. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138276. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138277. */
  138278. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138279. /**
  138280. * Defines the refresh rate of the computation.
  138281. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138282. */
  138283. get refreshRate(): number;
  138284. set refreshRate(value: number);
  138285. protected _activated: boolean;
  138286. /**
  138287. * Gets the activation status of the reducer
  138288. */
  138289. get activated(): boolean;
  138290. /**
  138291. * Activates the reduction computation.
  138292. * When activated, the observers registered in onAfterReductionPerformed are
  138293. * called after the compuation is performed
  138294. */
  138295. activate(): void;
  138296. /**
  138297. * Deactivates the reduction computation.
  138298. */
  138299. deactivate(): void;
  138300. /**
  138301. * Disposes the min/max reducer
  138302. * @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.
  138303. */
  138304. dispose(disposeAll?: boolean): void;
  138305. }
  138306. }
  138307. declare module BABYLON {
  138308. /**
  138309. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138310. */
  138311. export class DepthReducer extends MinMaxReducer {
  138312. private _depthRenderer;
  138313. private _depthRendererId;
  138314. /**
  138315. * Gets the depth renderer used for the computation.
  138316. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138317. */
  138318. get depthRenderer(): Nullable<DepthRenderer>;
  138319. /**
  138320. * Creates a depth reducer
  138321. * @param camera The camera used to render the depth texture
  138322. */
  138323. constructor(camera: Camera);
  138324. /**
  138325. * Sets the depth renderer to use to generate the depth map
  138326. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138327. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138328. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138329. */
  138330. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138331. /** @hidden */
  138332. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138333. /**
  138334. * Activates the reduction computation.
  138335. * When activated, the observers registered in onAfterReductionPerformed are
  138336. * called after the compuation is performed
  138337. */
  138338. activate(): void;
  138339. /**
  138340. * Deactivates the reduction computation.
  138341. */
  138342. deactivate(): void;
  138343. /**
  138344. * Disposes the depth reducer
  138345. * @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.
  138346. */
  138347. dispose(disposeAll?: boolean): void;
  138348. }
  138349. }
  138350. declare module BABYLON {
  138351. /**
  138352. * A CSM implementation allowing casting shadows on large scenes.
  138353. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138354. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138355. */
  138356. export class CascadedShadowGenerator extends ShadowGenerator {
  138357. private static readonly frustumCornersNDCSpace;
  138358. /**
  138359. * Name of the CSM class
  138360. */
  138361. static CLASSNAME: string;
  138362. /**
  138363. * Defines the default number of cascades used by the CSM.
  138364. */
  138365. static readonly DEFAULT_CASCADES_COUNT: number;
  138366. /**
  138367. * Defines the minimum number of cascades used by the CSM.
  138368. */
  138369. static readonly MIN_CASCADES_COUNT: number;
  138370. /**
  138371. * Defines the maximum number of cascades used by the CSM.
  138372. */
  138373. static readonly MAX_CASCADES_COUNT: number;
  138374. protected _validateFilter(filter: number): number;
  138375. /**
  138376. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138377. */
  138378. penumbraDarkness: number;
  138379. private _numCascades;
  138380. /**
  138381. * Gets or set the number of cascades used by the CSM.
  138382. */
  138383. get numCascades(): number;
  138384. set numCascades(value: number);
  138385. /**
  138386. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138387. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138388. */
  138389. stabilizeCascades: boolean;
  138390. private _freezeShadowCastersBoundingInfo;
  138391. private _freezeShadowCastersBoundingInfoObservable;
  138392. /**
  138393. * Enables or disables the shadow casters bounding info computation.
  138394. * If your shadow casters don't move, you can disable this feature.
  138395. * If it is enabled, the bounding box computation is done every frame.
  138396. */
  138397. get freezeShadowCastersBoundingInfo(): boolean;
  138398. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138399. private _scbiMin;
  138400. private _scbiMax;
  138401. protected _computeShadowCastersBoundingInfo(): void;
  138402. protected _shadowCastersBoundingInfo: BoundingInfo;
  138403. /**
  138404. * Gets or sets the shadow casters bounding info.
  138405. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138406. * so that the system won't overwrite the bounds you provide
  138407. */
  138408. get shadowCastersBoundingInfo(): BoundingInfo;
  138409. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138410. protected _breaksAreDirty: boolean;
  138411. protected _minDistance: number;
  138412. protected _maxDistance: number;
  138413. /**
  138414. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138415. *
  138416. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138417. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138418. * @param min minimal distance for the breaks (default to 0.)
  138419. * @param max maximal distance for the breaks (default to 1.)
  138420. */
  138421. setMinMaxDistance(min: number, max: number): void;
  138422. /** Gets the minimal distance used in the cascade break computation */
  138423. get minDistance(): number;
  138424. /** Gets the maximal distance used in the cascade break computation */
  138425. get maxDistance(): number;
  138426. /**
  138427. * Gets the class name of that object
  138428. * @returns "CascadedShadowGenerator"
  138429. */
  138430. getClassName(): string;
  138431. private _cascadeMinExtents;
  138432. private _cascadeMaxExtents;
  138433. /**
  138434. * Gets a cascade minimum extents
  138435. * @param cascadeIndex index of the cascade
  138436. * @returns the minimum cascade extents
  138437. */
  138438. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138439. /**
  138440. * Gets a cascade maximum extents
  138441. * @param cascadeIndex index of the cascade
  138442. * @returns the maximum cascade extents
  138443. */
  138444. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138445. private _cascades;
  138446. private _currentLayer;
  138447. private _viewSpaceFrustumsZ;
  138448. private _viewMatrices;
  138449. private _projectionMatrices;
  138450. private _transformMatrices;
  138451. private _transformMatricesAsArray;
  138452. private _frustumLengths;
  138453. private _lightSizeUVCorrection;
  138454. private _depthCorrection;
  138455. private _frustumCornersWorldSpace;
  138456. private _frustumCenter;
  138457. private _shadowCameraPos;
  138458. private _shadowMaxZ;
  138459. /**
  138460. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138461. * It defaults to camera.maxZ
  138462. */
  138463. get shadowMaxZ(): number;
  138464. /**
  138465. * Sets the shadow max z distance.
  138466. */
  138467. set shadowMaxZ(value: number);
  138468. protected _debug: boolean;
  138469. /**
  138470. * Gets or sets the debug flag.
  138471. * When enabled, the cascades are materialized by different colors on the screen.
  138472. */
  138473. get debug(): boolean;
  138474. set debug(dbg: boolean);
  138475. private _depthClamp;
  138476. /**
  138477. * Gets or sets the depth clamping value.
  138478. *
  138479. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138480. * to account for the shadow casters far away.
  138481. *
  138482. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138483. */
  138484. get depthClamp(): boolean;
  138485. set depthClamp(value: boolean);
  138486. private _cascadeBlendPercentage;
  138487. /**
  138488. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138489. * It defaults to 0.1 (10% blending).
  138490. */
  138491. get cascadeBlendPercentage(): number;
  138492. set cascadeBlendPercentage(value: number);
  138493. private _lambda;
  138494. /**
  138495. * Gets or set the lambda parameter.
  138496. * This parameter is used to split the camera frustum and create the cascades.
  138497. * 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.
  138498. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138499. */
  138500. get lambda(): number;
  138501. set lambda(value: number);
  138502. /**
  138503. * Gets the view matrix corresponding to a given cascade
  138504. * @param cascadeNum cascade to retrieve the view matrix from
  138505. * @returns the cascade view matrix
  138506. */
  138507. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138508. /**
  138509. * Gets the projection matrix corresponding to a given cascade
  138510. * @param cascadeNum cascade to retrieve the projection matrix from
  138511. * @returns the cascade projection matrix
  138512. */
  138513. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138514. /**
  138515. * Gets the transformation matrix corresponding to a given cascade
  138516. * @param cascadeNum cascade to retrieve the transformation matrix from
  138517. * @returns the cascade transformation matrix
  138518. */
  138519. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138520. private _depthRenderer;
  138521. /**
  138522. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138523. *
  138524. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138525. *
  138526. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138527. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138528. * @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
  138529. */
  138530. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138531. private _depthReducer;
  138532. private _autoCalcDepthBounds;
  138533. /**
  138534. * Gets or sets the autoCalcDepthBounds property.
  138535. *
  138536. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138537. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138538. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138539. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138540. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138541. */
  138542. get autoCalcDepthBounds(): boolean;
  138543. set autoCalcDepthBounds(value: boolean);
  138544. /**
  138545. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138546. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138547. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138548. * for setting the refresh rate on the renderer yourself!
  138549. */
  138550. get autoCalcDepthBoundsRefreshRate(): number;
  138551. set autoCalcDepthBoundsRefreshRate(value: number);
  138552. /**
  138553. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138554. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138555. * you change the camera near/far planes!
  138556. */
  138557. splitFrustum(): void;
  138558. private _splitFrustum;
  138559. private _computeMatrices;
  138560. private _computeFrustumInWorldSpace;
  138561. private _computeCascadeFrustum;
  138562. /**
  138563. * Support test.
  138564. */
  138565. static get IsSupported(): boolean;
  138566. /** @hidden */
  138567. static _SceneComponentInitialization: (scene: Scene) => void;
  138568. /**
  138569. * Creates a Cascaded Shadow Generator object.
  138570. * A ShadowGenerator is the required tool to use the shadows.
  138571. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138572. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138573. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138574. * @param light The directional light object generating the shadows.
  138575. * @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.
  138576. */
  138577. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138578. protected _initializeGenerator(): void;
  138579. protected _createTargetRenderTexture(): void;
  138580. protected _initializeShadowMap(): void;
  138581. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138582. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138583. /**
  138584. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138585. * @param defines Defines of the material we want to update
  138586. * @param lightIndex Index of the light in the enabled light list of the material
  138587. */
  138588. prepareDefines(defines: any, lightIndex: number): void;
  138589. /**
  138590. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138591. * defined in the generator but impacting the effect).
  138592. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138593. * @param effect The effect we are binfing the information for
  138594. */
  138595. bindShadowLight(lightIndex: string, effect: Effect): void;
  138596. /**
  138597. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138598. * (eq to view projection * shadow projection matrices)
  138599. * @returns The transform matrix used to create the shadow map
  138600. */
  138601. getTransformMatrix(): Matrix;
  138602. /**
  138603. * Disposes the ShadowGenerator.
  138604. * Returns nothing.
  138605. */
  138606. dispose(): void;
  138607. /**
  138608. * Serializes the shadow generator setup to a json object.
  138609. * @returns The serialized JSON object
  138610. */
  138611. serialize(): any;
  138612. /**
  138613. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138614. * @param parsedShadowGenerator The JSON object to parse
  138615. * @param scene The scene to create the shadow map for
  138616. * @returns The parsed shadow generator
  138617. */
  138618. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138619. }
  138620. }
  138621. declare module BABYLON {
  138622. /**
  138623. * Defines the shadow generator component responsible to manage any shadow generators
  138624. * in a given scene.
  138625. */
  138626. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138627. /**
  138628. * The component name helpfull to identify the component in the list of scene components.
  138629. */
  138630. readonly name: string;
  138631. /**
  138632. * The scene the component belongs to.
  138633. */
  138634. scene: Scene;
  138635. /**
  138636. * Creates a new instance of the component for the given scene
  138637. * @param scene Defines the scene to register the component in
  138638. */
  138639. constructor(scene: Scene);
  138640. /**
  138641. * Registers the component in a given scene
  138642. */
  138643. register(): void;
  138644. /**
  138645. * Rebuilds the elements related to this component in case of
  138646. * context lost for instance.
  138647. */
  138648. rebuild(): void;
  138649. /**
  138650. * Serializes the component data to the specified json object
  138651. * @param serializationObject The object to serialize to
  138652. */
  138653. serialize(serializationObject: any): void;
  138654. /**
  138655. * Adds all the elements from the container to the scene
  138656. * @param container the container holding the elements
  138657. */
  138658. addFromContainer(container: AbstractScene): void;
  138659. /**
  138660. * Removes all the elements in the container from the scene
  138661. * @param container contains the elements to remove
  138662. * @param dispose if the removed element should be disposed (default: false)
  138663. */
  138664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138665. /**
  138666. * Rebuilds the elements related to this component in case of
  138667. * context lost for instance.
  138668. */
  138669. dispose(): void;
  138670. private _gatherRenderTargets;
  138671. }
  138672. }
  138673. declare module BABYLON {
  138674. /**
  138675. * A point light is a light defined by an unique point in world space.
  138676. * The light is emitted in every direction from this point.
  138677. * A good example of a point light is a standard light bulb.
  138678. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138679. */
  138680. export class PointLight extends ShadowLight {
  138681. private _shadowAngle;
  138682. /**
  138683. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138684. * This specifies what angle the shadow will use to be created.
  138685. *
  138686. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138687. */
  138688. get shadowAngle(): number;
  138689. /**
  138690. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138691. * This specifies what angle the shadow will use to be created.
  138692. *
  138693. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138694. */
  138695. set shadowAngle(value: number);
  138696. /**
  138697. * Gets the direction if it has been set.
  138698. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138699. */
  138700. get direction(): Vector3;
  138701. /**
  138702. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138703. */
  138704. set direction(value: Vector3);
  138705. /**
  138706. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138707. * A PointLight emits the light in every direction.
  138708. * It can cast shadows.
  138709. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138710. * ```javascript
  138711. * var pointLight = new PointLight("pl", camera.position, scene);
  138712. * ```
  138713. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138714. * @param name The light friendly name
  138715. * @param position The position of the point light in the scene
  138716. * @param scene The scene the lights belongs to
  138717. */
  138718. constructor(name: string, position: Vector3, scene: Scene);
  138719. /**
  138720. * Returns the string "PointLight"
  138721. * @returns the class name
  138722. */
  138723. getClassName(): string;
  138724. /**
  138725. * Returns the integer 0.
  138726. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138727. */
  138728. getTypeID(): number;
  138729. /**
  138730. * Specifies wether or not the shadowmap should be a cube texture.
  138731. * @returns true if the shadowmap needs to be a cube texture.
  138732. */
  138733. needCube(): boolean;
  138734. /**
  138735. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138736. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138737. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138738. */
  138739. getShadowDirection(faceIndex?: number): Vector3;
  138740. /**
  138741. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138742. * - fov = PI / 2
  138743. * - aspect ratio : 1.0
  138744. * - z-near and far equal to the active camera minZ and maxZ.
  138745. * Returns the PointLight.
  138746. */
  138747. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138748. protected _buildUniformLayout(): void;
  138749. /**
  138750. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138751. * @param effect The effect to update
  138752. * @param lightIndex The index of the light in the effect to update
  138753. * @returns The point light
  138754. */
  138755. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138756. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138757. /**
  138758. * Prepares the list of defines specific to the light type.
  138759. * @param defines the list of defines
  138760. * @param lightIndex defines the index of the light for the effect
  138761. */
  138762. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138763. }
  138764. }
  138765. declare module BABYLON {
  138766. /**
  138767. * Header information of HDR texture files.
  138768. */
  138769. export interface HDRInfo {
  138770. /**
  138771. * The height of the texture in pixels.
  138772. */
  138773. height: number;
  138774. /**
  138775. * The width of the texture in pixels.
  138776. */
  138777. width: number;
  138778. /**
  138779. * The index of the beginning of the data in the binary file.
  138780. */
  138781. dataPosition: number;
  138782. }
  138783. /**
  138784. * This groups tools to convert HDR texture to native colors array.
  138785. */
  138786. export class HDRTools {
  138787. private static Ldexp;
  138788. private static Rgbe2float;
  138789. private static readStringLine;
  138790. /**
  138791. * Reads header information from an RGBE texture stored in a native array.
  138792. * More information on this format are available here:
  138793. * https://en.wikipedia.org/wiki/RGBE_image_format
  138794. *
  138795. * @param uint8array The binary file stored in native array.
  138796. * @return The header information.
  138797. */
  138798. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138799. /**
  138800. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138801. * This RGBE texture needs to store the information as a panorama.
  138802. *
  138803. * More information on this format are available here:
  138804. * https://en.wikipedia.org/wiki/RGBE_image_format
  138805. *
  138806. * @param buffer The binary file stored in an array buffer.
  138807. * @param size The expected size of the extracted cubemap.
  138808. * @return The Cube Map information.
  138809. */
  138810. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138811. /**
  138812. * Returns the pixels data extracted from an RGBE texture.
  138813. * This pixels will be stored left to right up to down in the R G B order in one array.
  138814. *
  138815. * More information on this format are available here:
  138816. * https://en.wikipedia.org/wiki/RGBE_image_format
  138817. *
  138818. * @param uint8array The binary file stored in an array buffer.
  138819. * @param hdrInfo The header information of the file.
  138820. * @return The pixels data in RGB right to left up to down order.
  138821. */
  138822. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138823. private static RGBE_ReadPixels_RLE;
  138824. private static RGBE_ReadPixels_NOT_RLE;
  138825. }
  138826. }
  138827. declare module BABYLON {
  138828. /**
  138829. * Effect Render Options
  138830. */
  138831. export interface IEffectRendererOptions {
  138832. /**
  138833. * Defines the vertices positions.
  138834. */
  138835. positions?: number[];
  138836. /**
  138837. * Defines the indices.
  138838. */
  138839. indices?: number[];
  138840. }
  138841. /**
  138842. * Helper class to render one or more effects.
  138843. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138844. */
  138845. export class EffectRenderer {
  138846. private engine;
  138847. private static _DefaultOptions;
  138848. private _vertexBuffers;
  138849. private _indexBuffer;
  138850. private _fullscreenViewport;
  138851. /**
  138852. * Creates an effect renderer
  138853. * @param engine the engine to use for rendering
  138854. * @param options defines the options of the effect renderer
  138855. */
  138856. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138857. /**
  138858. * Sets the current viewport in normalized coordinates 0-1
  138859. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138860. */
  138861. setViewport(viewport?: Viewport): void;
  138862. /**
  138863. * Binds the embedded attributes buffer to the effect.
  138864. * @param effect Defines the effect to bind the attributes for
  138865. */
  138866. bindBuffers(effect: Effect): void;
  138867. /**
  138868. * Sets the current effect wrapper to use during draw.
  138869. * The effect needs to be ready before calling this api.
  138870. * This also sets the default full screen position attribute.
  138871. * @param effectWrapper Defines the effect to draw with
  138872. */
  138873. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138874. /**
  138875. * Restores engine states
  138876. */
  138877. restoreStates(): void;
  138878. /**
  138879. * Draws a full screen quad.
  138880. */
  138881. draw(): void;
  138882. private isRenderTargetTexture;
  138883. /**
  138884. * renders one or more effects to a specified texture
  138885. * @param effectWrapper the effect to renderer
  138886. * @param outputTexture texture to draw to, if null it will render to the screen.
  138887. */
  138888. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138889. /**
  138890. * Disposes of the effect renderer
  138891. */
  138892. dispose(): void;
  138893. }
  138894. /**
  138895. * Options to create an EffectWrapper
  138896. */
  138897. interface EffectWrapperCreationOptions {
  138898. /**
  138899. * Engine to use to create the effect
  138900. */
  138901. engine: ThinEngine;
  138902. /**
  138903. * Fragment shader for the effect
  138904. */
  138905. fragmentShader: string;
  138906. /**
  138907. * Use the shader store instead of direct source code
  138908. */
  138909. useShaderStore?: boolean;
  138910. /**
  138911. * Vertex shader for the effect
  138912. */
  138913. vertexShader?: string;
  138914. /**
  138915. * Attributes to use in the shader
  138916. */
  138917. attributeNames?: Array<string>;
  138918. /**
  138919. * Uniforms to use in the shader
  138920. */
  138921. uniformNames?: Array<string>;
  138922. /**
  138923. * Texture sampler names to use in the shader
  138924. */
  138925. samplerNames?: Array<string>;
  138926. /**
  138927. * Defines to use in the shader
  138928. */
  138929. defines?: Array<string>;
  138930. /**
  138931. * Callback when effect is compiled
  138932. */
  138933. onCompiled?: Nullable<(effect: Effect) => void>;
  138934. /**
  138935. * The friendly name of the effect displayed in Spector.
  138936. */
  138937. name?: string;
  138938. }
  138939. /**
  138940. * Wraps an effect to be used for rendering
  138941. */
  138942. export class EffectWrapper {
  138943. /**
  138944. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138945. */
  138946. onApplyObservable: Observable<{}>;
  138947. /**
  138948. * The underlying effect
  138949. */
  138950. effect: Effect;
  138951. /**
  138952. * Creates an effect to be renderer
  138953. * @param creationOptions options to create the effect
  138954. */
  138955. constructor(creationOptions: EffectWrapperCreationOptions);
  138956. /**
  138957. * Disposes of the effect wrapper
  138958. */
  138959. dispose(): void;
  138960. }
  138961. }
  138962. declare module BABYLON {
  138963. /** @hidden */
  138964. export var hdrFilteringVertexShader: {
  138965. name: string;
  138966. shader: string;
  138967. };
  138968. }
  138969. declare module BABYLON {
  138970. /** @hidden */
  138971. export var hdrFilteringPixelShader: {
  138972. name: string;
  138973. shader: string;
  138974. };
  138975. }
  138976. declare module BABYLON {
  138977. /**
  138978. * Options for texture filtering
  138979. */
  138980. interface IHDRFilteringOptions {
  138981. /**
  138982. * Scales pixel intensity for the input HDR map.
  138983. */
  138984. hdrScale?: number;
  138985. /**
  138986. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138987. */
  138988. quality?: number;
  138989. }
  138990. /**
  138991. * Filters HDR maps to get correct renderings of PBR reflections
  138992. */
  138993. export class HDRFiltering {
  138994. private _engine;
  138995. private _effectRenderer;
  138996. private _effectWrapper;
  138997. private _lodGenerationOffset;
  138998. private _lodGenerationScale;
  138999. /**
  139000. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139001. * you care about baking speed.
  139002. */
  139003. quality: number;
  139004. /**
  139005. * Scales pixel intensity for the input HDR map.
  139006. */
  139007. hdrScale: number;
  139008. /**
  139009. * Instantiates HDR filter for reflection maps
  139010. *
  139011. * @param engine Thin engine
  139012. * @param options Options
  139013. */
  139014. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139015. private _createRenderTarget;
  139016. private _prefilterInternal;
  139017. private _createEffect;
  139018. /**
  139019. * Get a value indicating if the filter is ready to be used
  139020. * @param texture Texture to filter
  139021. * @returns true if the filter is ready
  139022. */
  139023. isReady(texture: BaseTexture): boolean;
  139024. /**
  139025. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139026. * Prefiltering will be invoked at the end of next rendering pass.
  139027. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139028. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139029. * @param texture Texture to filter
  139030. * @param onFinished Callback when filtering is done
  139031. * @return Promise called when prefiltering is done
  139032. */
  139033. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139034. }
  139035. }
  139036. declare module BABYLON {
  139037. /**
  139038. * This represents a texture coming from an HDR input.
  139039. *
  139040. * The only supported format is currently panorama picture stored in RGBE format.
  139041. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139042. */
  139043. export class HDRCubeTexture extends BaseTexture {
  139044. private static _facesMapping;
  139045. private _generateHarmonics;
  139046. private _noMipmap;
  139047. private _prefilterOnLoad;
  139048. private _textureMatrix;
  139049. private _size;
  139050. private _onLoad;
  139051. private _onError;
  139052. /**
  139053. * The texture URL.
  139054. */
  139055. url: string;
  139056. /**
  139057. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  139058. */
  139059. coordinatesMode: number;
  139060. protected _isBlocking: boolean;
  139061. /**
  139062. * Sets wether or not the texture is blocking during loading.
  139063. */
  139064. set isBlocking(value: boolean);
  139065. /**
  139066. * Gets wether or not the texture is blocking during loading.
  139067. */
  139068. get isBlocking(): boolean;
  139069. protected _rotationY: number;
  139070. /**
  139071. * Sets texture matrix rotation angle around Y axis in radians.
  139072. */
  139073. set rotationY(value: number);
  139074. /**
  139075. * Gets texture matrix rotation angle around Y axis radians.
  139076. */
  139077. get rotationY(): number;
  139078. /**
  139079. * Gets or sets the center of the bounding box associated with the cube texture
  139080. * It must define where the camera used to render the texture was set
  139081. */
  139082. boundingBoxPosition: Vector3;
  139083. private _boundingBoxSize;
  139084. /**
  139085. * Gets or sets the size of the bounding box associated with the cube texture
  139086. * When defined, the cubemap will switch to local mode
  139087. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139088. * @example https://www.babylonjs-playground.com/#RNASML
  139089. */
  139090. set boundingBoxSize(value: Vector3);
  139091. get boundingBoxSize(): Vector3;
  139092. /**
  139093. * Instantiates an HDRTexture from the following parameters.
  139094. *
  139095. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  139096. * @param sceneOrEngine The scene or engine the texture will be used in
  139097. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139098. * @param noMipmap Forces to not generate the mipmap if true
  139099. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  139100. * @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)
  139101. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  139102. */
  139103. 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>);
  139104. /**
  139105. * Get the current class name of the texture useful for serialization or dynamic coding.
  139106. * @returns "HDRCubeTexture"
  139107. */
  139108. getClassName(): string;
  139109. /**
  139110. * Occurs when the file is raw .hdr file.
  139111. */
  139112. private loadTexture;
  139113. clone(): HDRCubeTexture;
  139114. delayLoad(): void;
  139115. /**
  139116. * Get the texture reflection matrix used to rotate/transform the reflection.
  139117. * @returns the reflection matrix
  139118. */
  139119. getReflectionTextureMatrix(): Matrix;
  139120. /**
  139121. * Set the texture reflection matrix used to rotate/transform the reflection.
  139122. * @param value Define the reflection matrix to set
  139123. */
  139124. setReflectionTextureMatrix(value: Matrix): void;
  139125. /**
  139126. * Parses a JSON representation of an HDR Texture in order to create the texture
  139127. * @param parsedTexture Define the JSON representation
  139128. * @param scene Define the scene the texture should be created in
  139129. * @param rootUrl Define the root url in case we need to load relative dependencies
  139130. * @returns the newly created texture after parsing
  139131. */
  139132. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139133. serialize(): any;
  139134. }
  139135. }
  139136. declare module BABYLON {
  139137. /**
  139138. * Class used to control physics engine
  139139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139140. */
  139141. export class PhysicsEngine implements IPhysicsEngine {
  139142. private _physicsPlugin;
  139143. /**
  139144. * Global value used to control the smallest number supported by the simulation
  139145. */
  139146. static Epsilon: number;
  139147. private _impostors;
  139148. private _joints;
  139149. private _subTimeStep;
  139150. /**
  139151. * Gets the gravity vector used by the simulation
  139152. */
  139153. gravity: Vector3;
  139154. /**
  139155. * Factory used to create the default physics plugin.
  139156. * @returns The default physics plugin
  139157. */
  139158. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139159. /**
  139160. * Creates a new Physics Engine
  139161. * @param gravity defines the gravity vector used by the simulation
  139162. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139163. */
  139164. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139165. /**
  139166. * Sets the gravity vector used by the simulation
  139167. * @param gravity defines the gravity vector to use
  139168. */
  139169. setGravity(gravity: Vector3): void;
  139170. /**
  139171. * Set the time step of the physics engine.
  139172. * Default is 1/60.
  139173. * To slow it down, enter 1/600 for example.
  139174. * To speed it up, 1/30
  139175. * @param newTimeStep defines the new timestep to apply to this world.
  139176. */
  139177. setTimeStep(newTimeStep?: number): void;
  139178. /**
  139179. * Get the time step of the physics engine.
  139180. * @returns the current time step
  139181. */
  139182. getTimeStep(): number;
  139183. /**
  139184. * Set the sub time step of the physics engine.
  139185. * Default is 0 meaning there is no sub steps
  139186. * To increase physics resolution precision, set a small value (like 1 ms)
  139187. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139188. */
  139189. setSubTimeStep(subTimeStep?: number): void;
  139190. /**
  139191. * Get the sub time step of the physics engine.
  139192. * @returns the current sub time step
  139193. */
  139194. getSubTimeStep(): number;
  139195. /**
  139196. * Release all resources
  139197. */
  139198. dispose(): void;
  139199. /**
  139200. * Gets the name of the current physics plugin
  139201. * @returns the name of the plugin
  139202. */
  139203. getPhysicsPluginName(): string;
  139204. /**
  139205. * Adding a new impostor for the impostor tracking.
  139206. * This will be done by the impostor itself.
  139207. * @param impostor the impostor to add
  139208. */
  139209. addImpostor(impostor: PhysicsImpostor): void;
  139210. /**
  139211. * Remove an impostor from the engine.
  139212. * This impostor and its mesh will not longer be updated by the physics engine.
  139213. * @param impostor the impostor to remove
  139214. */
  139215. removeImpostor(impostor: PhysicsImpostor): void;
  139216. /**
  139217. * Add a joint to the physics engine
  139218. * @param mainImpostor defines the main impostor to which the joint is added.
  139219. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  139220. * @param joint defines the joint that will connect both impostors.
  139221. */
  139222. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139223. /**
  139224. * Removes a joint from the simulation
  139225. * @param mainImpostor defines the impostor used with the joint
  139226. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139227. * @param joint defines the joint to remove
  139228. */
  139229. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139230. /**
  139231. * Called by the scene. No need to call it.
  139232. * @param delta defines the timespam between frames
  139233. */
  139234. _step(delta: number): void;
  139235. /**
  139236. * Gets the current plugin used to run the simulation
  139237. * @returns current plugin
  139238. */
  139239. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139240. /**
  139241. * Gets the list of physic impostors
  139242. * @returns an array of PhysicsImpostor
  139243. */
  139244. getImpostors(): Array<PhysicsImpostor>;
  139245. /**
  139246. * Gets the impostor for a physics enabled object
  139247. * @param object defines the object impersonated by the impostor
  139248. * @returns the PhysicsImpostor or null if not found
  139249. */
  139250. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139251. /**
  139252. * Gets the impostor for a physics body object
  139253. * @param body defines physics body used by the impostor
  139254. * @returns the PhysicsImpostor or null if not found
  139255. */
  139256. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139257. /**
  139258. * Does a raycast in the physics world
  139259. * @param from when should the ray start?
  139260. * @param to when should the ray end?
  139261. * @returns PhysicsRaycastResult
  139262. */
  139263. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139264. }
  139265. }
  139266. declare module BABYLON {
  139267. /** @hidden */
  139268. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139269. private _useDeltaForWorldStep;
  139270. world: any;
  139271. name: string;
  139272. private _physicsMaterials;
  139273. private _fixedTimeStep;
  139274. private _cannonRaycastResult;
  139275. private _raycastResult;
  139276. private _physicsBodysToRemoveAfterStep;
  139277. private _firstFrame;
  139278. BJSCANNON: any;
  139279. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139280. setGravity(gravity: Vector3): void;
  139281. setTimeStep(timeStep: number): void;
  139282. getTimeStep(): number;
  139283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139284. private _removeMarkedPhysicsBodiesFromWorld;
  139285. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139286. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139288. private _processChildMeshes;
  139289. removePhysicsBody(impostor: PhysicsImpostor): void;
  139290. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139291. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139292. private _addMaterial;
  139293. private _checkWithEpsilon;
  139294. private _createShape;
  139295. private _createHeightmap;
  139296. private _minus90X;
  139297. private _plus90X;
  139298. private _tmpPosition;
  139299. private _tmpDeltaPosition;
  139300. private _tmpUnityRotation;
  139301. private _updatePhysicsBodyTransformation;
  139302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139304. isSupported(): boolean;
  139305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139310. getBodyMass(impostor: PhysicsImpostor): number;
  139311. getBodyFriction(impostor: PhysicsImpostor): number;
  139312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139313. getBodyRestitution(impostor: PhysicsImpostor): number;
  139314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139315. sleepBody(impostor: PhysicsImpostor): void;
  139316. wakeUpBody(impostor: PhysicsImpostor): void;
  139317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139318. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139321. getRadius(impostor: PhysicsImpostor): number;
  139322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139323. dispose(): void;
  139324. private _extendNamespace;
  139325. /**
  139326. * Does a raycast in the physics world
  139327. * @param from when should the ray start?
  139328. * @param to when should the ray end?
  139329. * @returns PhysicsRaycastResult
  139330. */
  139331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139332. }
  139333. }
  139334. declare module BABYLON {
  139335. /** @hidden */
  139336. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139337. private _useDeltaForWorldStep;
  139338. world: any;
  139339. name: string;
  139340. BJSOIMO: any;
  139341. private _raycastResult;
  139342. private _fixedTimeStep;
  139343. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139344. setGravity(gravity: Vector3): void;
  139345. setTimeStep(timeStep: number): void;
  139346. getTimeStep(): number;
  139347. private _tmpImpostorsArray;
  139348. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139352. private _tmpPositionVector;
  139353. removePhysicsBody(impostor: PhysicsImpostor): void;
  139354. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139356. isSupported(): boolean;
  139357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139358. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139359. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139360. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139363. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139364. getBodyMass(impostor: PhysicsImpostor): number;
  139365. getBodyFriction(impostor: PhysicsImpostor): number;
  139366. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139367. getBodyRestitution(impostor: PhysicsImpostor): number;
  139368. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139369. sleepBody(impostor: PhysicsImpostor): void;
  139370. wakeUpBody(impostor: PhysicsImpostor): void;
  139371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139372. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139373. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139375. getRadius(impostor: PhysicsImpostor): number;
  139376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139377. dispose(): void;
  139378. /**
  139379. * Does a raycast in the physics world
  139380. * @param from when should the ray start?
  139381. * @param to when should the ray end?
  139382. * @returns PhysicsRaycastResult
  139383. */
  139384. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139385. }
  139386. }
  139387. declare module BABYLON {
  139388. /**
  139389. * AmmoJS Physics plugin
  139390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139391. * @see https://github.com/kripken/ammo.js/
  139392. */
  139393. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139394. private _useDeltaForWorldStep;
  139395. /**
  139396. * Reference to the Ammo library
  139397. */
  139398. bjsAMMO: any;
  139399. /**
  139400. * Created ammoJS world which physics bodies are added to
  139401. */
  139402. world: any;
  139403. /**
  139404. * Name of the plugin
  139405. */
  139406. name: string;
  139407. private _timeStep;
  139408. private _fixedTimeStep;
  139409. private _maxSteps;
  139410. private _tmpQuaternion;
  139411. private _tmpAmmoTransform;
  139412. private _tmpAmmoQuaternion;
  139413. private _tmpAmmoConcreteContactResultCallback;
  139414. private _collisionConfiguration;
  139415. private _dispatcher;
  139416. private _overlappingPairCache;
  139417. private _solver;
  139418. private _softBodySolver;
  139419. private _tmpAmmoVectorA;
  139420. private _tmpAmmoVectorB;
  139421. private _tmpAmmoVectorC;
  139422. private _tmpAmmoVectorD;
  139423. private _tmpContactCallbackResult;
  139424. private _tmpAmmoVectorRCA;
  139425. private _tmpAmmoVectorRCB;
  139426. private _raycastResult;
  139427. private static readonly DISABLE_COLLISION_FLAG;
  139428. private static readonly KINEMATIC_FLAG;
  139429. private static readonly DISABLE_DEACTIVATION_FLAG;
  139430. /**
  139431. * Initializes the ammoJS plugin
  139432. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139433. * @param ammoInjection can be used to inject your own ammo reference
  139434. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139435. */
  139436. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139437. /**
  139438. * Sets the gravity of the physics world (m/(s^2))
  139439. * @param gravity Gravity to set
  139440. */
  139441. setGravity(gravity: Vector3): void;
  139442. /**
  139443. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139444. * @param timeStep timestep to use in seconds
  139445. */
  139446. setTimeStep(timeStep: number): void;
  139447. /**
  139448. * 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)
  139449. * @param fixedTimeStep fixedTimeStep to use in seconds
  139450. */
  139451. setFixedTimeStep(fixedTimeStep: number): void;
  139452. /**
  139453. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139454. * @param maxSteps the maximum number of steps by the physics engine per frame
  139455. */
  139456. setMaxSteps(maxSteps: number): void;
  139457. /**
  139458. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139459. * @returns the current timestep in seconds
  139460. */
  139461. getTimeStep(): number;
  139462. /**
  139463. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139464. */
  139465. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139466. private _isImpostorInContact;
  139467. private _isImpostorPairInContact;
  139468. private _stepSimulation;
  139469. /**
  139470. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139471. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139472. * After the step the babylon meshes are set to the position of the physics imposters
  139473. * @param delta amount of time to step forward
  139474. * @param impostors array of imposters to update before/after the step
  139475. */
  139476. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139477. /**
  139478. * Update babylon mesh to match physics world object
  139479. * @param impostor imposter to match
  139480. */
  139481. private _afterSoftStep;
  139482. /**
  139483. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139484. * @param impostor imposter to match
  139485. */
  139486. private _ropeStep;
  139487. /**
  139488. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139489. * @param impostor imposter to match
  139490. */
  139491. private _softbodyOrClothStep;
  139492. private _tmpMatrix;
  139493. /**
  139494. * Applies an impulse on the imposter
  139495. * @param impostor imposter to apply impulse to
  139496. * @param force amount of force to be applied to the imposter
  139497. * @param contactPoint the location to apply the impulse on the imposter
  139498. */
  139499. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139500. /**
  139501. * Applies a force on the imposter
  139502. * @param impostor imposter to apply force
  139503. * @param force amount of force to be applied to the imposter
  139504. * @param contactPoint the location to apply the force on the imposter
  139505. */
  139506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139507. /**
  139508. * Creates a physics body using the plugin
  139509. * @param impostor the imposter to create the physics body on
  139510. */
  139511. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139512. /**
  139513. * Removes the physics body from the imposter and disposes of the body's memory
  139514. * @param impostor imposter to remove the physics body from
  139515. */
  139516. removePhysicsBody(impostor: PhysicsImpostor): void;
  139517. /**
  139518. * Generates a joint
  139519. * @param impostorJoint the imposter joint to create the joint with
  139520. */
  139521. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139522. /**
  139523. * Removes a joint
  139524. * @param impostorJoint the imposter joint to remove the joint from
  139525. */
  139526. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139527. private _addMeshVerts;
  139528. /**
  139529. * Initialise the soft body vertices to match its object's (mesh) vertices
  139530. * Softbody vertices (nodes) are in world space and to match this
  139531. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139532. * @param impostor to create the softbody for
  139533. */
  139534. private _softVertexData;
  139535. /**
  139536. * Create an impostor's soft body
  139537. * @param impostor to create the softbody for
  139538. */
  139539. private _createSoftbody;
  139540. /**
  139541. * Create cloth for an impostor
  139542. * @param impostor to create the softbody for
  139543. */
  139544. private _createCloth;
  139545. /**
  139546. * Create rope for an impostor
  139547. * @param impostor to create the softbody for
  139548. */
  139549. private _createRope;
  139550. /**
  139551. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139552. * @param impostor to create the custom physics shape for
  139553. */
  139554. private _createCustom;
  139555. private _addHullVerts;
  139556. private _createShape;
  139557. /**
  139558. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139559. * @param impostor imposter containing the physics body and babylon object
  139560. */
  139561. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139562. /**
  139563. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139564. * @param impostor imposter containing the physics body and babylon object
  139565. * @param newPosition new position
  139566. * @param newRotation new rotation
  139567. */
  139568. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139569. /**
  139570. * If this plugin is supported
  139571. * @returns true if its supported
  139572. */
  139573. isSupported(): boolean;
  139574. /**
  139575. * Sets the linear velocity of the physics body
  139576. * @param impostor imposter to set the velocity on
  139577. * @param velocity velocity to set
  139578. */
  139579. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139580. /**
  139581. * Sets the angular velocity of the physics body
  139582. * @param impostor imposter to set the velocity on
  139583. * @param velocity velocity to set
  139584. */
  139585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139586. /**
  139587. * gets the linear velocity
  139588. * @param impostor imposter to get linear velocity from
  139589. * @returns linear velocity
  139590. */
  139591. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139592. /**
  139593. * gets the angular velocity
  139594. * @param impostor imposter to get angular velocity from
  139595. * @returns angular velocity
  139596. */
  139597. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139598. /**
  139599. * Sets the mass of physics body
  139600. * @param impostor imposter to set the mass on
  139601. * @param mass mass to set
  139602. */
  139603. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139604. /**
  139605. * Gets the mass of the physics body
  139606. * @param impostor imposter to get the mass from
  139607. * @returns mass
  139608. */
  139609. getBodyMass(impostor: PhysicsImpostor): number;
  139610. /**
  139611. * Gets friction of the impostor
  139612. * @param impostor impostor to get friction from
  139613. * @returns friction value
  139614. */
  139615. getBodyFriction(impostor: PhysicsImpostor): number;
  139616. /**
  139617. * Sets friction of the impostor
  139618. * @param impostor impostor to set friction on
  139619. * @param friction friction value
  139620. */
  139621. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139622. /**
  139623. * Gets restitution of the impostor
  139624. * @param impostor impostor to get restitution from
  139625. * @returns restitution value
  139626. */
  139627. getBodyRestitution(impostor: PhysicsImpostor): number;
  139628. /**
  139629. * Sets resitution of the impostor
  139630. * @param impostor impostor to set resitution on
  139631. * @param restitution resitution value
  139632. */
  139633. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139634. /**
  139635. * Gets pressure inside the impostor
  139636. * @param impostor impostor to get pressure from
  139637. * @returns pressure value
  139638. */
  139639. getBodyPressure(impostor: PhysicsImpostor): number;
  139640. /**
  139641. * Sets pressure inside a soft body impostor
  139642. * Cloth and rope must remain 0 pressure
  139643. * @param impostor impostor to set pressure on
  139644. * @param pressure pressure value
  139645. */
  139646. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139647. /**
  139648. * Gets stiffness of the impostor
  139649. * @param impostor impostor to get stiffness from
  139650. * @returns pressure value
  139651. */
  139652. getBodyStiffness(impostor: PhysicsImpostor): number;
  139653. /**
  139654. * Sets stiffness of the impostor
  139655. * @param impostor impostor to set stiffness on
  139656. * @param stiffness stiffness value from 0 to 1
  139657. */
  139658. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139659. /**
  139660. * Gets velocityIterations of the impostor
  139661. * @param impostor impostor to get velocity iterations from
  139662. * @returns velocityIterations value
  139663. */
  139664. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139665. /**
  139666. * Sets velocityIterations of the impostor
  139667. * @param impostor impostor to set velocity iterations on
  139668. * @param velocityIterations velocityIterations value
  139669. */
  139670. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139671. /**
  139672. * Gets positionIterations of the impostor
  139673. * @param impostor impostor to get position iterations from
  139674. * @returns positionIterations value
  139675. */
  139676. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139677. /**
  139678. * Sets positionIterations of the impostor
  139679. * @param impostor impostor to set position on
  139680. * @param positionIterations positionIterations value
  139681. */
  139682. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139683. /**
  139684. * Append an anchor to a cloth object
  139685. * @param impostor is the cloth impostor to add anchor to
  139686. * @param otherImpostor is the rigid impostor to anchor to
  139687. * @param width ratio across width from 0 to 1
  139688. * @param height ratio up height from 0 to 1
  139689. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139690. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139691. */
  139692. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139693. /**
  139694. * Append an hook to a rope object
  139695. * @param impostor is the rope impostor to add hook to
  139696. * @param otherImpostor is the rigid impostor to hook to
  139697. * @param length ratio along the rope from 0 to 1
  139698. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139699. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139700. */
  139701. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139702. /**
  139703. * Sleeps the physics body and stops it from being active
  139704. * @param impostor impostor to sleep
  139705. */
  139706. sleepBody(impostor: PhysicsImpostor): void;
  139707. /**
  139708. * Activates the physics body
  139709. * @param impostor impostor to activate
  139710. */
  139711. wakeUpBody(impostor: PhysicsImpostor): void;
  139712. /**
  139713. * Updates the distance parameters of the joint
  139714. * @param joint joint to update
  139715. * @param maxDistance maximum distance of the joint
  139716. * @param minDistance minimum distance of the joint
  139717. */
  139718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139719. /**
  139720. * Sets a motor on the joint
  139721. * @param joint joint to set motor on
  139722. * @param speed speed of the motor
  139723. * @param maxForce maximum force of the motor
  139724. * @param motorIndex index of the motor
  139725. */
  139726. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139727. /**
  139728. * Sets the motors limit
  139729. * @param joint joint to set limit on
  139730. * @param upperLimit upper limit
  139731. * @param lowerLimit lower limit
  139732. */
  139733. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139734. /**
  139735. * Syncs the position and rotation of a mesh with the impostor
  139736. * @param mesh mesh to sync
  139737. * @param impostor impostor to update the mesh with
  139738. */
  139739. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139740. /**
  139741. * Gets the radius of the impostor
  139742. * @param impostor impostor to get radius from
  139743. * @returns the radius
  139744. */
  139745. getRadius(impostor: PhysicsImpostor): number;
  139746. /**
  139747. * Gets the box size of the impostor
  139748. * @param impostor impostor to get box size from
  139749. * @param result the resulting box size
  139750. */
  139751. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139752. /**
  139753. * Disposes of the impostor
  139754. */
  139755. dispose(): void;
  139756. /**
  139757. * Does a raycast in the physics world
  139758. * @param from when should the ray start?
  139759. * @param to when should the ray end?
  139760. * @returns PhysicsRaycastResult
  139761. */
  139762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139763. }
  139764. }
  139765. declare module BABYLON {
  139766. interface AbstractScene {
  139767. /**
  139768. * The list of reflection probes added to the scene
  139769. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139770. */
  139771. reflectionProbes: Array<ReflectionProbe>;
  139772. /**
  139773. * Removes the given reflection probe from this scene.
  139774. * @param toRemove The reflection probe to remove
  139775. * @returns The index of the removed reflection probe
  139776. */
  139777. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139778. /**
  139779. * Adds the given reflection probe to this scene.
  139780. * @param newReflectionProbe The reflection probe to add
  139781. */
  139782. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139783. }
  139784. /**
  139785. * Class used to generate realtime reflection / refraction cube textures
  139786. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139787. */
  139788. export class ReflectionProbe {
  139789. /** defines the name of the probe */
  139790. name: string;
  139791. private _scene;
  139792. private _renderTargetTexture;
  139793. private _projectionMatrix;
  139794. private _viewMatrix;
  139795. private _target;
  139796. private _add;
  139797. private _attachedMesh;
  139798. private _invertYAxis;
  139799. /** Gets or sets probe position (center of the cube map) */
  139800. position: Vector3;
  139801. /**
  139802. * Creates a new reflection probe
  139803. * @param name defines the name of the probe
  139804. * @param size defines the texture resolution (for each face)
  139805. * @param scene defines the hosting scene
  139806. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139807. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139808. */
  139809. constructor(
  139810. /** defines the name of the probe */
  139811. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139812. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139813. get samples(): number;
  139814. set samples(value: number);
  139815. /** Gets or sets the refresh rate to use (on every frame by default) */
  139816. get refreshRate(): number;
  139817. set refreshRate(value: number);
  139818. /**
  139819. * Gets the hosting scene
  139820. * @returns a Scene
  139821. */
  139822. getScene(): Scene;
  139823. /** Gets the internal CubeTexture used to render to */
  139824. get cubeTexture(): RenderTargetTexture;
  139825. /** Gets the list of meshes to render */
  139826. get renderList(): Nullable<AbstractMesh[]>;
  139827. /**
  139828. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139829. * @param mesh defines the mesh to attach to
  139830. */
  139831. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139832. /**
  139833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139834. * @param renderingGroupId The rendering group id corresponding to its index
  139835. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139836. */
  139837. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139838. /**
  139839. * Clean all associated resources
  139840. */
  139841. dispose(): void;
  139842. /**
  139843. * Converts the reflection probe information to a readable string for debug purpose.
  139844. * @param fullDetails Supports for multiple levels of logging within scene loading
  139845. * @returns the human readable reflection probe info
  139846. */
  139847. toString(fullDetails?: boolean): string;
  139848. /**
  139849. * Get the class name of the relfection probe.
  139850. * @returns "ReflectionProbe"
  139851. */
  139852. getClassName(): string;
  139853. /**
  139854. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139855. * @returns The JSON representation of the texture
  139856. */
  139857. serialize(): any;
  139858. /**
  139859. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139860. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139861. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139862. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139863. * @returns The parsed reflection probe if successful
  139864. */
  139865. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139866. }
  139867. }
  139868. declare module BABYLON {
  139869. /** @hidden */
  139870. export var _BabylonLoaderRegistered: boolean;
  139871. /**
  139872. * Helps setting up some configuration for the babylon file loader.
  139873. */
  139874. export class BabylonFileLoaderConfiguration {
  139875. /**
  139876. * The loader does not allow injecting custom physix engine into the plugins.
  139877. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139878. * So you could set this variable to your engine import to make it work.
  139879. */
  139880. static LoaderInjectedPhysicsEngine: any;
  139881. }
  139882. }
  139883. declare module BABYLON {
  139884. /**
  139885. * The Physically based simple base material of BJS.
  139886. *
  139887. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139888. * It is used as the base class for both the specGloss and metalRough conventions.
  139889. */
  139890. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139891. /**
  139892. * Number of Simultaneous lights allowed on the material.
  139893. */
  139894. maxSimultaneousLights: number;
  139895. /**
  139896. * If sets to true, disables all the lights affecting the material.
  139897. */
  139898. disableLighting: boolean;
  139899. /**
  139900. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139901. */
  139902. environmentTexture: BaseTexture;
  139903. /**
  139904. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139905. */
  139906. invertNormalMapX: boolean;
  139907. /**
  139908. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139909. */
  139910. invertNormalMapY: boolean;
  139911. /**
  139912. * Normal map used in the model.
  139913. */
  139914. normalTexture: BaseTexture;
  139915. /**
  139916. * Emissivie color used to self-illuminate the model.
  139917. */
  139918. emissiveColor: Color3;
  139919. /**
  139920. * Emissivie texture used to self-illuminate the model.
  139921. */
  139922. emissiveTexture: BaseTexture;
  139923. /**
  139924. * Occlusion Channel Strenght.
  139925. */
  139926. occlusionStrength: number;
  139927. /**
  139928. * Occlusion Texture of the material (adding extra occlusion effects).
  139929. */
  139930. occlusionTexture: BaseTexture;
  139931. /**
  139932. * Defines the alpha limits in alpha test mode.
  139933. */
  139934. alphaCutOff: number;
  139935. /**
  139936. * Gets the current double sided mode.
  139937. */
  139938. get doubleSided(): boolean;
  139939. /**
  139940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139941. */
  139942. set doubleSided(value: boolean);
  139943. /**
  139944. * Stores the pre-calculated light information of a mesh in a texture.
  139945. */
  139946. lightmapTexture: BaseTexture;
  139947. /**
  139948. * If true, the light map contains occlusion information instead of lighting info.
  139949. */
  139950. useLightmapAsShadowmap: boolean;
  139951. /**
  139952. * Instantiates a new PBRMaterial instance.
  139953. *
  139954. * @param name The material name
  139955. * @param scene The scene the material will be use in.
  139956. */
  139957. constructor(name: string, scene: Scene);
  139958. getClassName(): string;
  139959. }
  139960. }
  139961. declare module BABYLON {
  139962. /**
  139963. * The PBR material of BJS following the metal roughness convention.
  139964. *
  139965. * This fits to the PBR convention in the GLTF definition:
  139966. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139967. */
  139968. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139969. /**
  139970. * The base color has two different interpretations depending on the value of metalness.
  139971. * When the material is a metal, the base color is the specific measured reflectance value
  139972. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139973. * of the material.
  139974. */
  139975. baseColor: Color3;
  139976. /**
  139977. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139978. * well as opacity information in the alpha channel.
  139979. */
  139980. baseTexture: BaseTexture;
  139981. /**
  139982. * Specifies the metallic scalar value of the material.
  139983. * Can also be used to scale the metalness values of the metallic texture.
  139984. */
  139985. metallic: number;
  139986. /**
  139987. * Specifies the roughness scalar value of the material.
  139988. * Can also be used to scale the roughness values of the metallic texture.
  139989. */
  139990. roughness: number;
  139991. /**
  139992. * Texture containing both the metallic value in the B channel and the
  139993. * roughness value in the G channel to keep better precision.
  139994. */
  139995. metallicRoughnessTexture: BaseTexture;
  139996. /**
  139997. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139998. *
  139999. * @param name The material name
  140000. * @param scene The scene the material will be use in.
  140001. */
  140002. constructor(name: string, scene: Scene);
  140003. /**
  140004. * Return the currrent class name of the material.
  140005. */
  140006. getClassName(): string;
  140007. /**
  140008. * Makes a duplicate of the current material.
  140009. * @param name - name to use for the new material.
  140010. */
  140011. clone(name: string): PBRMetallicRoughnessMaterial;
  140012. /**
  140013. * Serialize the material to a parsable JSON object.
  140014. */
  140015. serialize(): any;
  140016. /**
  140017. * Parses a JSON object correponding to the serialize function.
  140018. */
  140019. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140020. }
  140021. }
  140022. declare module BABYLON {
  140023. /**
  140024. * The PBR material of BJS following the specular glossiness convention.
  140025. *
  140026. * This fits to the PBR convention in the GLTF definition:
  140027. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140028. */
  140029. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140030. /**
  140031. * Specifies the diffuse color of the material.
  140032. */
  140033. diffuseColor: Color3;
  140034. /**
  140035. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140036. * channel.
  140037. */
  140038. diffuseTexture: BaseTexture;
  140039. /**
  140040. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140041. */
  140042. specularColor: Color3;
  140043. /**
  140044. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140045. */
  140046. glossiness: number;
  140047. /**
  140048. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140049. */
  140050. specularGlossinessTexture: BaseTexture;
  140051. /**
  140052. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140053. *
  140054. * @param name The material name
  140055. * @param scene The scene the material will be use in.
  140056. */
  140057. constructor(name: string, scene: Scene);
  140058. /**
  140059. * Return the currrent class name of the material.
  140060. */
  140061. getClassName(): string;
  140062. /**
  140063. * Makes a duplicate of the current material.
  140064. * @param name - name to use for the new material.
  140065. */
  140066. clone(name: string): PBRSpecularGlossinessMaterial;
  140067. /**
  140068. * Serialize the material to a parsable JSON object.
  140069. */
  140070. serialize(): any;
  140071. /**
  140072. * Parses a JSON object correponding to the serialize function.
  140073. */
  140074. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140075. }
  140076. }
  140077. declare module BABYLON {
  140078. /**
  140079. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140080. * It can help converting any input color in a desired output one. This can then be used to create effects
  140081. * from sepia, black and white to sixties or futuristic rendering...
  140082. *
  140083. * The only supported format is currently 3dl.
  140084. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140085. */
  140086. export class ColorGradingTexture extends BaseTexture {
  140087. /**
  140088. * The texture URL.
  140089. */
  140090. url: string;
  140091. /**
  140092. * Empty line regex stored for GC.
  140093. */
  140094. private static _noneEmptyLineRegex;
  140095. private _textureMatrix;
  140096. private _onLoad;
  140097. /**
  140098. * Instantiates a ColorGradingTexture from the following parameters.
  140099. *
  140100. * @param url The location of the color gradind data (currently only supporting 3dl)
  140101. * @param sceneOrEngine The scene or engine the texture will be used in
  140102. * @param onLoad defines a callback triggered when the texture has been loaded
  140103. */
  140104. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  140105. /**
  140106. * Fires the onload event from the constructor if requested.
  140107. */
  140108. private _triggerOnLoad;
  140109. /**
  140110. * Returns the texture matrix used in most of the material.
  140111. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  140112. */
  140113. getTextureMatrix(): Matrix;
  140114. /**
  140115. * Occurs when the file being loaded is a .3dl LUT file.
  140116. */
  140117. private load3dlTexture;
  140118. /**
  140119. * Starts the loading process of the texture.
  140120. */
  140121. private loadTexture;
  140122. /**
  140123. * Clones the color gradind texture.
  140124. */
  140125. clone(): ColorGradingTexture;
  140126. /**
  140127. * Called during delayed load for textures.
  140128. */
  140129. delayLoad(): void;
  140130. /**
  140131. * Parses a color grading texture serialized by Babylon.
  140132. * @param parsedTexture The texture information being parsedTexture
  140133. * @param scene The scene to load the texture in
  140134. * @param rootUrl The root url of the data assets to load
  140135. * @return A color gradind texture
  140136. */
  140137. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140138. /**
  140139. * Serializes the LUT texture to json format.
  140140. */
  140141. serialize(): any;
  140142. }
  140143. }
  140144. declare module BABYLON {
  140145. /**
  140146. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140147. */
  140148. export class EquiRectangularCubeTexture extends BaseTexture {
  140149. /** The six faces of the cube. */
  140150. private static _FacesMapping;
  140151. private _noMipmap;
  140152. private _onLoad;
  140153. private _onError;
  140154. /** The size of the cubemap. */
  140155. private _size;
  140156. /** The buffer of the image. */
  140157. private _buffer;
  140158. /** The width of the input image. */
  140159. private _width;
  140160. /** The height of the input image. */
  140161. private _height;
  140162. /** The URL to the image. */
  140163. url: string;
  140164. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140165. coordinatesMode: number;
  140166. /**
  140167. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140168. * @param url The location of the image
  140169. * @param scene The scene the texture will be used in
  140170. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140171. * @param noMipmap Forces to not generate the mipmap if true
  140172. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140173. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140174. * @param onLoad — defines a callback called when texture is loaded
  140175. * @param onError — defines a callback called if there is an error
  140176. */
  140177. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140178. /**
  140179. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140180. */
  140181. private loadImage;
  140182. /**
  140183. * Convert the image buffer into a cubemap and create a CubeTexture.
  140184. */
  140185. private loadTexture;
  140186. /**
  140187. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140188. * @param buffer The ArrayBuffer that should be converted.
  140189. * @returns The buffer as Float32Array.
  140190. */
  140191. private getFloat32ArrayFromArrayBuffer;
  140192. /**
  140193. * Get the current class name of the texture useful for serialization or dynamic coding.
  140194. * @returns "EquiRectangularCubeTexture"
  140195. */
  140196. getClassName(): string;
  140197. /**
  140198. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140199. * @returns A clone of the current EquiRectangularCubeTexture.
  140200. */
  140201. clone(): EquiRectangularCubeTexture;
  140202. }
  140203. }
  140204. declare module BABYLON {
  140205. /**
  140206. * Defines the options related to the creation of an HtmlElementTexture
  140207. */
  140208. export interface IHtmlElementTextureOptions {
  140209. /**
  140210. * Defines wether mip maps should be created or not.
  140211. */
  140212. generateMipMaps?: boolean;
  140213. /**
  140214. * Defines the sampling mode of the texture.
  140215. */
  140216. samplingMode?: number;
  140217. /**
  140218. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  140219. */
  140220. engine: Nullable<ThinEngine>;
  140221. /**
  140222. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  140223. */
  140224. scene: Nullable<Scene>;
  140225. }
  140226. /**
  140227. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140228. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140229. * is automatically managed.
  140230. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140231. * in your application.
  140232. *
  140233. * As the update is not automatic, you need to call them manually.
  140234. */
  140235. export class HtmlElementTexture extends BaseTexture {
  140236. /**
  140237. * The texture URL.
  140238. */
  140239. element: HTMLVideoElement | HTMLCanvasElement;
  140240. private static readonly DefaultOptions;
  140241. private _textureMatrix;
  140242. private _isVideo;
  140243. private _generateMipMaps;
  140244. private _samplingMode;
  140245. /**
  140246. * Instantiates a HtmlElementTexture from the following parameters.
  140247. *
  140248. * @param name Defines the name of the texture
  140249. * @param element Defines the video or canvas the texture is filled with
  140250. * @param options Defines the other none mandatory texture creation options
  140251. */
  140252. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140253. private _createInternalTexture;
  140254. /**
  140255. * Returns the texture matrix used in most of the material.
  140256. */
  140257. getTextureMatrix(): Matrix;
  140258. /**
  140259. * Updates the content of the texture.
  140260. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140261. */
  140262. update(invertY?: Nullable<boolean>): void;
  140263. }
  140264. }
  140265. declare module BABYLON {
  140266. /**
  140267. * Based on jsTGALoader - Javascript loader for TGA file
  140268. * By Vincent Thibault
  140269. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140270. */
  140271. export class TGATools {
  140272. private static _TYPE_INDEXED;
  140273. private static _TYPE_RGB;
  140274. private static _TYPE_GREY;
  140275. private static _TYPE_RLE_INDEXED;
  140276. private static _TYPE_RLE_RGB;
  140277. private static _TYPE_RLE_GREY;
  140278. private static _ORIGIN_MASK;
  140279. private static _ORIGIN_SHIFT;
  140280. private static _ORIGIN_BL;
  140281. private static _ORIGIN_BR;
  140282. private static _ORIGIN_UL;
  140283. private static _ORIGIN_UR;
  140284. /**
  140285. * Gets the header of a TGA file
  140286. * @param data defines the TGA data
  140287. * @returns the header
  140288. */
  140289. static GetTGAHeader(data: Uint8Array): any;
  140290. /**
  140291. * Uploads TGA content to a Babylon Texture
  140292. * @hidden
  140293. */
  140294. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140295. /** @hidden */
  140296. 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;
  140297. /** @hidden */
  140298. 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;
  140299. /** @hidden */
  140300. 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;
  140301. /** @hidden */
  140302. 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;
  140303. /** @hidden */
  140304. 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;
  140305. /** @hidden */
  140306. 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;
  140307. }
  140308. }
  140309. declare module BABYLON {
  140310. /**
  140311. * Implementation of the TGA Texture Loader.
  140312. * @hidden
  140313. */
  140314. export class _TGATextureLoader implements IInternalTextureLoader {
  140315. /**
  140316. * Defines wether the loader supports cascade loading the different faces.
  140317. */
  140318. readonly supportCascades: boolean;
  140319. /**
  140320. * This returns if the loader support the current file information.
  140321. * @param extension defines the file extension of the file being loaded
  140322. * @returns true if the loader can load the specified file
  140323. */
  140324. canLoad(extension: string): boolean;
  140325. /**
  140326. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140327. * @param data contains the texture data
  140328. * @param texture defines the BabylonJS internal texture
  140329. * @param createPolynomials will be true if polynomials have been requested
  140330. * @param onLoad defines the callback to trigger once the texture is ready
  140331. * @param onError defines the callback to trigger in case of error
  140332. */
  140333. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140334. /**
  140335. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140336. * @param data contains the texture data
  140337. * @param texture defines the BabylonJS internal texture
  140338. * @param callback defines the method to call once ready to upload
  140339. */
  140340. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140341. }
  140342. }
  140343. declare module BABYLON {
  140344. /**
  140345. * Info about the .basis files
  140346. */
  140347. class BasisFileInfo {
  140348. /**
  140349. * If the file has alpha
  140350. */
  140351. hasAlpha: boolean;
  140352. /**
  140353. * Info about each image of the basis file
  140354. */
  140355. images: Array<{
  140356. levels: Array<{
  140357. width: number;
  140358. height: number;
  140359. transcodedPixels: ArrayBufferView;
  140360. }>;
  140361. }>;
  140362. }
  140363. /**
  140364. * Result of transcoding a basis file
  140365. */
  140366. class TranscodeResult {
  140367. /**
  140368. * Info about the .basis file
  140369. */
  140370. fileInfo: BasisFileInfo;
  140371. /**
  140372. * Format to use when loading the file
  140373. */
  140374. format: number;
  140375. }
  140376. /**
  140377. * Configuration options for the Basis transcoder
  140378. */
  140379. export class BasisTranscodeConfiguration {
  140380. /**
  140381. * Supported compression formats used to determine the supported output format of the transcoder
  140382. */
  140383. supportedCompressionFormats?: {
  140384. /**
  140385. * etc1 compression format
  140386. */
  140387. etc1?: boolean;
  140388. /**
  140389. * s3tc compression format
  140390. */
  140391. s3tc?: boolean;
  140392. /**
  140393. * pvrtc compression format
  140394. */
  140395. pvrtc?: boolean;
  140396. /**
  140397. * etc2 compression format
  140398. */
  140399. etc2?: boolean;
  140400. };
  140401. /**
  140402. * If mipmap levels should be loaded for transcoded images (Default: true)
  140403. */
  140404. loadMipmapLevels?: boolean;
  140405. /**
  140406. * Index of a single image to load (Default: all images)
  140407. */
  140408. loadSingleImage?: number;
  140409. }
  140410. /**
  140411. * Used to load .Basis files
  140412. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140413. */
  140414. export class BasisTools {
  140415. private static _IgnoreSupportedFormats;
  140416. /**
  140417. * URL to use when loading the basis transcoder
  140418. */
  140419. static JSModuleURL: string;
  140420. /**
  140421. * URL to use when loading the wasm module for the transcoder
  140422. */
  140423. static WasmModuleURL: string;
  140424. /**
  140425. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140426. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140427. * @returns internal format corresponding to the Basis format
  140428. */
  140429. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140430. private static _WorkerPromise;
  140431. private static _Worker;
  140432. private static _actionId;
  140433. private static _CreateWorkerAsync;
  140434. /**
  140435. * Transcodes a loaded image file to compressed pixel data
  140436. * @param data image data to transcode
  140437. * @param config configuration options for the transcoding
  140438. * @returns a promise resulting in the transcoded image
  140439. */
  140440. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140441. /**
  140442. * Loads a texture from the transcode result
  140443. * @param texture texture load to
  140444. * @param transcodeResult the result of transcoding the basis file to load from
  140445. */
  140446. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140447. }
  140448. }
  140449. declare module BABYLON {
  140450. /**
  140451. * Loader for .basis file format
  140452. */
  140453. export class _BasisTextureLoader implements IInternalTextureLoader {
  140454. /**
  140455. * Defines whether the loader supports cascade loading the different faces.
  140456. */
  140457. readonly supportCascades: boolean;
  140458. /**
  140459. * This returns if the loader support the current file information.
  140460. * @param extension defines the file extension of the file being loaded
  140461. * @returns true if the loader can load the specified file
  140462. */
  140463. canLoad(extension: string): boolean;
  140464. /**
  140465. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140466. * @param data contains the texture data
  140467. * @param texture defines the BabylonJS internal texture
  140468. * @param createPolynomials will be true if polynomials have been requested
  140469. * @param onLoad defines the callback to trigger once the texture is ready
  140470. * @param onError defines the callback to trigger in case of error
  140471. */
  140472. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140473. /**
  140474. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140475. * @param data contains the texture data
  140476. * @param texture defines the BabylonJS internal texture
  140477. * @param callback defines the method to call once ready to upload
  140478. */
  140479. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140480. }
  140481. }
  140482. declare module BABYLON {
  140483. /**
  140484. * Defines the basic options interface of a TexturePacker Frame
  140485. */
  140486. export interface ITexturePackerFrame {
  140487. /**
  140488. * The frame ID
  140489. */
  140490. id: number;
  140491. /**
  140492. * The frames Scale
  140493. */
  140494. scale: Vector2;
  140495. /**
  140496. * The Frames offset
  140497. */
  140498. offset: Vector2;
  140499. }
  140500. /**
  140501. * This is a support class for frame Data on texture packer sets.
  140502. */
  140503. export class TexturePackerFrame implements ITexturePackerFrame {
  140504. /**
  140505. * The frame ID
  140506. */
  140507. id: number;
  140508. /**
  140509. * The frames Scale
  140510. */
  140511. scale: Vector2;
  140512. /**
  140513. * The Frames offset
  140514. */
  140515. offset: Vector2;
  140516. /**
  140517. * Initializes a texture package frame.
  140518. * @param id The numerical frame identifier
  140519. * @param scale Scalar Vector2 for UV frame
  140520. * @param offset Vector2 for the frame position in UV units.
  140521. * @returns TexturePackerFrame
  140522. */
  140523. constructor(id: number, scale: Vector2, offset: Vector2);
  140524. }
  140525. }
  140526. declare module BABYLON {
  140527. /**
  140528. * Defines the basic options interface of a TexturePacker
  140529. */
  140530. export interface ITexturePackerOptions {
  140531. /**
  140532. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140533. */
  140534. map?: string[];
  140535. /**
  140536. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140537. */
  140538. uvsIn?: string;
  140539. /**
  140540. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140541. */
  140542. uvsOut?: string;
  140543. /**
  140544. * number representing the layout style. Defaults to LAYOUT_STRIP
  140545. */
  140546. layout?: number;
  140547. /**
  140548. * number of columns if using custom column count layout(2). This defaults to 4.
  140549. */
  140550. colnum?: number;
  140551. /**
  140552. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140553. */
  140554. updateInputMeshes?: boolean;
  140555. /**
  140556. * boolean flag to dispose all the source textures. Defaults to true.
  140557. */
  140558. disposeSources?: boolean;
  140559. /**
  140560. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140561. */
  140562. fillBlanks?: boolean;
  140563. /**
  140564. * string value representing the context fill style color. Defaults to 'black'.
  140565. */
  140566. customFillColor?: string;
  140567. /**
  140568. * Width and Height Value of each Frame in the TexturePacker Sets
  140569. */
  140570. frameSize?: number;
  140571. /**
  140572. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140573. */
  140574. paddingRatio?: number;
  140575. /**
  140576. * Number that declares the fill method for the padding gutter.
  140577. */
  140578. paddingMode?: number;
  140579. /**
  140580. * If in SUBUV_COLOR padding mode what color to use.
  140581. */
  140582. paddingColor?: Color3 | Color4;
  140583. }
  140584. /**
  140585. * Defines the basic interface of a TexturePacker JSON File
  140586. */
  140587. export interface ITexturePackerJSON {
  140588. /**
  140589. * The frame ID
  140590. */
  140591. name: string;
  140592. /**
  140593. * The base64 channel data
  140594. */
  140595. sets: any;
  140596. /**
  140597. * The options of the Packer
  140598. */
  140599. options: ITexturePackerOptions;
  140600. /**
  140601. * The frame data of the Packer
  140602. */
  140603. frames: Array<number>;
  140604. }
  140605. /**
  140606. * This is a support class that generates a series of packed texture sets.
  140607. * @see https://doc.babylonjs.com/babylon101/materials
  140608. */
  140609. export class TexturePacker {
  140610. /** Packer Layout Constant 0 */
  140611. static readonly LAYOUT_STRIP: number;
  140612. /** Packer Layout Constant 1 */
  140613. static readonly LAYOUT_POWER2: number;
  140614. /** Packer Layout Constant 2 */
  140615. static readonly LAYOUT_COLNUM: number;
  140616. /** Packer Layout Constant 0 */
  140617. static readonly SUBUV_WRAP: number;
  140618. /** Packer Layout Constant 1 */
  140619. static readonly SUBUV_EXTEND: number;
  140620. /** Packer Layout Constant 2 */
  140621. static readonly SUBUV_COLOR: number;
  140622. /** The Name of the Texture Package */
  140623. name: string;
  140624. /** The scene scope of the TexturePacker */
  140625. scene: Scene;
  140626. /** The Meshes to target */
  140627. meshes: AbstractMesh[];
  140628. /** Arguments passed with the Constructor */
  140629. options: ITexturePackerOptions;
  140630. /** The promise that is started upon initialization */
  140631. promise: Nullable<Promise<TexturePacker | string>>;
  140632. /** The Container object for the channel sets that are generated */
  140633. sets: object;
  140634. /** The Container array for the frames that are generated */
  140635. frames: TexturePackerFrame[];
  140636. /** The expected number of textures the system is parsing. */
  140637. private _expecting;
  140638. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140639. private _paddingValue;
  140640. /**
  140641. * Initializes a texture package series from an array of meshes or a single mesh.
  140642. * @param name The name of the package
  140643. * @param meshes The target meshes to compose the package from
  140644. * @param options The arguments that texture packer should follow while building.
  140645. * @param scene The scene which the textures are scoped to.
  140646. * @returns TexturePacker
  140647. */
  140648. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140649. /**
  140650. * Starts the package process
  140651. * @param resolve The promises resolution function
  140652. * @returns TexturePacker
  140653. */
  140654. private _createFrames;
  140655. /**
  140656. * Calculates the Size of the Channel Sets
  140657. * @returns Vector2
  140658. */
  140659. private _calculateSize;
  140660. /**
  140661. * Calculates the UV data for the frames.
  140662. * @param baseSize the base frameSize
  140663. * @param padding the base frame padding
  140664. * @param dtSize size of the Dynamic Texture for that channel
  140665. * @param dtUnits is 1/dtSize
  140666. * @param update flag to update the input meshes
  140667. */
  140668. private _calculateMeshUVFrames;
  140669. /**
  140670. * Calculates the frames Offset.
  140671. * @param index of the frame
  140672. * @returns Vector2
  140673. */
  140674. private _getFrameOffset;
  140675. /**
  140676. * Updates a Mesh to the frame data
  140677. * @param mesh that is the target
  140678. * @param frameID or the frame index
  140679. */
  140680. private _updateMeshUV;
  140681. /**
  140682. * Updates a Meshes materials to use the texture packer channels
  140683. * @param m is the mesh to target
  140684. * @param force all channels on the packer to be set.
  140685. */
  140686. private _updateTextureReferences;
  140687. /**
  140688. * Public method to set a Mesh to a frame
  140689. * @param m that is the target
  140690. * @param frameID or the frame index
  140691. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140692. */
  140693. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140694. /**
  140695. * Starts the async promise to compile the texture packer.
  140696. * @returns Promise<void>
  140697. */
  140698. processAsync(): Promise<void>;
  140699. /**
  140700. * Disposes all textures associated with this packer
  140701. */
  140702. dispose(): void;
  140703. /**
  140704. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140705. * @param imageType is the image type to use.
  140706. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140707. */
  140708. download(imageType?: string, quality?: number): void;
  140709. /**
  140710. * Public method to load a texturePacker JSON file.
  140711. * @param data of the JSON file in string format.
  140712. */
  140713. updateFromJSON(data: string): void;
  140714. }
  140715. }
  140716. declare module BABYLON {
  140717. /**
  140718. * 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.
  140719. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140720. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140721. */
  140722. export class CustomProceduralTexture extends ProceduralTexture {
  140723. private _animate;
  140724. private _time;
  140725. private _config;
  140726. private _texturePath;
  140727. /**
  140728. * Instantiates a new Custom Procedural Texture.
  140729. * 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.
  140730. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140731. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140732. * @param name Define the name of the texture
  140733. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140734. * @param size Define the size of the texture to create
  140735. * @param scene Define the scene the texture belongs to
  140736. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140737. * @param generateMipMaps Define if the texture should creates mip maps or not
  140738. */
  140739. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140740. private _loadJson;
  140741. /**
  140742. * Is the texture ready to be used ? (rendered at least once)
  140743. * @returns true if ready, otherwise, false.
  140744. */
  140745. isReady(): boolean;
  140746. /**
  140747. * Render the texture to its associated render target.
  140748. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140749. */
  140750. render(useCameraPostProcess?: boolean): void;
  140751. /**
  140752. * Update the list of dependant textures samplers in the shader.
  140753. */
  140754. updateTextures(): void;
  140755. /**
  140756. * Update the uniform values of the procedural texture in the shader.
  140757. */
  140758. updateShaderUniforms(): void;
  140759. /**
  140760. * Define if the texture animates or not.
  140761. */
  140762. get animate(): boolean;
  140763. set animate(value: boolean);
  140764. }
  140765. }
  140766. declare module BABYLON {
  140767. /** @hidden */
  140768. export var noisePixelShader: {
  140769. name: string;
  140770. shader: string;
  140771. };
  140772. }
  140773. declare module BABYLON {
  140774. /**
  140775. * Class used to generate noise procedural textures
  140776. */
  140777. export class NoiseProceduralTexture extends ProceduralTexture {
  140778. private _time;
  140779. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140780. brightness: number;
  140781. /** Defines the number of octaves to process */
  140782. octaves: number;
  140783. /** Defines the level of persistence (0.8 by default) */
  140784. persistence: number;
  140785. /** Gets or sets animation speed factor (default is 1) */
  140786. animationSpeedFactor: number;
  140787. /**
  140788. * Creates a new NoiseProceduralTexture
  140789. * @param name defines the name fo the texture
  140790. * @param size defines the size of the texture (default is 256)
  140791. * @param scene defines the hosting scene
  140792. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140793. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140794. */
  140795. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140796. private _updateShaderUniforms;
  140797. protected _getDefines(): string;
  140798. /** Generate the current state of the procedural texture */
  140799. render(useCameraPostProcess?: boolean): void;
  140800. /**
  140801. * Serializes this noise procedural texture
  140802. * @returns a serialized noise procedural texture object
  140803. */
  140804. serialize(): any;
  140805. /**
  140806. * Clone the texture.
  140807. * @returns the cloned texture
  140808. */
  140809. clone(): NoiseProceduralTexture;
  140810. /**
  140811. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140812. * @param parsedTexture defines parsed texture data
  140813. * @param scene defines the current scene
  140814. * @param rootUrl defines the root URL containing noise procedural texture information
  140815. * @returns a parsed NoiseProceduralTexture
  140816. */
  140817. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140818. }
  140819. }
  140820. declare module BABYLON {
  140821. /**
  140822. * Raw cube texture where the raw buffers are passed in
  140823. */
  140824. export class RawCubeTexture extends CubeTexture {
  140825. /**
  140826. * Creates a cube texture where the raw buffers are passed in.
  140827. * @param scene defines the scene the texture is attached to
  140828. * @param data defines the array of data to use to create each face
  140829. * @param size defines the size of the textures
  140830. * @param format defines the format of the data
  140831. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140832. * @param generateMipMaps defines if the engine should generate the mip levels
  140833. * @param invertY defines if data must be stored with Y axis inverted
  140834. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140835. * @param compression defines the compression used (null by default)
  140836. */
  140837. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140838. /**
  140839. * Updates the raw cube texture.
  140840. * @param data defines the data to store
  140841. * @param format defines the data format
  140842. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140843. * @param invertY defines if data must be stored with Y axis inverted
  140844. * @param compression defines the compression used (null by default)
  140845. * @param level defines which level of the texture to update
  140846. */
  140847. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140848. /**
  140849. * Updates a raw cube texture with RGBD encoded data.
  140850. * @param data defines the array of data [mipmap][face] to use to create each face
  140851. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140852. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140853. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140854. * @returns a promsie that resolves when the operation is complete
  140855. */
  140856. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140857. /**
  140858. * Clones the raw cube texture.
  140859. * @return a new cube texture
  140860. */
  140861. clone(): CubeTexture;
  140862. /** @hidden */
  140863. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140864. }
  140865. }
  140866. declare module BABYLON {
  140867. /**
  140868. * Class used to store 2D array textures containing user data
  140869. */
  140870. export class RawTexture2DArray extends Texture {
  140871. /** Gets or sets the texture format to use */
  140872. format: number;
  140873. /**
  140874. * Create a new RawTexture2DArray
  140875. * @param data defines the data of the texture
  140876. * @param width defines the width of the texture
  140877. * @param height defines the height of the texture
  140878. * @param depth defines the number of layers of the texture
  140879. * @param format defines the texture format to use
  140880. * @param scene defines the hosting scene
  140881. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140882. * @param invertY defines if texture must be stored with Y axis inverted
  140883. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140884. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140885. */
  140886. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140887. /** Gets or sets the texture format to use */
  140888. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140889. /**
  140890. * Update the texture with new data
  140891. * @param data defines the data to store in the texture
  140892. */
  140893. update(data: ArrayBufferView): void;
  140894. }
  140895. }
  140896. declare module BABYLON {
  140897. /**
  140898. * Class used to store 3D textures containing user data
  140899. */
  140900. export class RawTexture3D extends Texture {
  140901. /** Gets or sets the texture format to use */
  140902. format: number;
  140903. /**
  140904. * Create a new RawTexture3D
  140905. * @param data defines the data of the texture
  140906. * @param width defines the width of the texture
  140907. * @param height defines the height of the texture
  140908. * @param depth defines the depth of the texture
  140909. * @param format defines the texture format to use
  140910. * @param scene defines the hosting scene
  140911. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140912. * @param invertY defines if texture must be stored with Y axis inverted
  140913. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140914. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140915. */
  140916. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140917. /** Gets or sets the texture format to use */
  140918. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140919. /**
  140920. * Update the texture with new data
  140921. * @param data defines the data to store in the texture
  140922. */
  140923. update(data: ArrayBufferView): void;
  140924. }
  140925. }
  140926. declare module BABYLON {
  140927. /**
  140928. * Creates a refraction texture used by refraction channel of the standard material.
  140929. * It is like a mirror but to see through a material.
  140930. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140931. */
  140932. export class RefractionTexture extends RenderTargetTexture {
  140933. /**
  140934. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140935. * 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.
  140936. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140937. */
  140938. refractionPlane: Plane;
  140939. /**
  140940. * Define how deep under the surface we should see.
  140941. */
  140942. depth: number;
  140943. /**
  140944. * Creates a refraction texture used by refraction channel of the standard material.
  140945. * It is like a mirror but to see through a material.
  140946. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140947. * @param name Define the texture name
  140948. * @param size Define the size of the underlying texture
  140949. * @param scene Define the scene the refraction belongs to
  140950. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140951. */
  140952. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140953. /**
  140954. * Clone the refraction texture.
  140955. * @returns the cloned texture
  140956. */
  140957. clone(): RefractionTexture;
  140958. /**
  140959. * Serialize the texture to a JSON representation you could use in Parse later on
  140960. * @returns the serialized JSON representation
  140961. */
  140962. serialize(): any;
  140963. }
  140964. }
  140965. declare module BABYLON {
  140966. /**
  140967. * Block used to add support for vertex skinning (bones)
  140968. */
  140969. export class BonesBlock extends NodeMaterialBlock {
  140970. /**
  140971. * Creates a new BonesBlock
  140972. * @param name defines the block name
  140973. */
  140974. constructor(name: string);
  140975. /**
  140976. * Initialize the block and prepare the context for build
  140977. * @param state defines the state that will be used for the build
  140978. */
  140979. initialize(state: NodeMaterialBuildState): void;
  140980. /**
  140981. * Gets the current class name
  140982. * @returns the class name
  140983. */
  140984. getClassName(): string;
  140985. /**
  140986. * Gets the matrix indices input component
  140987. */
  140988. get matricesIndices(): NodeMaterialConnectionPoint;
  140989. /**
  140990. * Gets the matrix weights input component
  140991. */
  140992. get matricesWeights(): NodeMaterialConnectionPoint;
  140993. /**
  140994. * Gets the extra matrix indices input component
  140995. */
  140996. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140997. /**
  140998. * Gets the extra matrix weights input component
  140999. */
  141000. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141001. /**
  141002. * Gets the world input component
  141003. */
  141004. get world(): NodeMaterialConnectionPoint;
  141005. /**
  141006. * Gets the output component
  141007. */
  141008. get output(): NodeMaterialConnectionPoint;
  141009. autoConfigure(material: NodeMaterial): void;
  141010. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141013. protected _buildBlock(state: NodeMaterialBuildState): this;
  141014. }
  141015. }
  141016. declare module BABYLON {
  141017. /**
  141018. * Block used to add support for instances
  141019. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141020. */
  141021. export class InstancesBlock extends NodeMaterialBlock {
  141022. /**
  141023. * Creates a new InstancesBlock
  141024. * @param name defines the block name
  141025. */
  141026. constructor(name: string);
  141027. /**
  141028. * Gets the current class name
  141029. * @returns the class name
  141030. */
  141031. getClassName(): string;
  141032. /**
  141033. * Gets the first world row input component
  141034. */
  141035. get world0(): NodeMaterialConnectionPoint;
  141036. /**
  141037. * Gets the second world row input component
  141038. */
  141039. get world1(): NodeMaterialConnectionPoint;
  141040. /**
  141041. * Gets the third world row input component
  141042. */
  141043. get world2(): NodeMaterialConnectionPoint;
  141044. /**
  141045. * Gets the forth world row input component
  141046. */
  141047. get world3(): NodeMaterialConnectionPoint;
  141048. /**
  141049. * Gets the world input component
  141050. */
  141051. get world(): NodeMaterialConnectionPoint;
  141052. /**
  141053. * Gets the output component
  141054. */
  141055. get output(): NodeMaterialConnectionPoint;
  141056. /**
  141057. * Gets the isntanceID component
  141058. */
  141059. get instanceID(): NodeMaterialConnectionPoint;
  141060. autoConfigure(material: NodeMaterial): void;
  141061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141062. protected _buildBlock(state: NodeMaterialBuildState): this;
  141063. }
  141064. }
  141065. declare module BABYLON {
  141066. /**
  141067. * Block used to add morph targets support to vertex shader
  141068. */
  141069. export class MorphTargetsBlock extends NodeMaterialBlock {
  141070. private _repeatableContentAnchor;
  141071. /**
  141072. * Create a new MorphTargetsBlock
  141073. * @param name defines the block name
  141074. */
  141075. constructor(name: string);
  141076. /**
  141077. * Gets the current class name
  141078. * @returns the class name
  141079. */
  141080. getClassName(): string;
  141081. /**
  141082. * Gets the position input component
  141083. */
  141084. get position(): NodeMaterialConnectionPoint;
  141085. /**
  141086. * Gets the normal input component
  141087. */
  141088. get normal(): NodeMaterialConnectionPoint;
  141089. /**
  141090. * Gets the tangent input component
  141091. */
  141092. get tangent(): NodeMaterialConnectionPoint;
  141093. /**
  141094. * Gets the tangent input component
  141095. */
  141096. get uv(): NodeMaterialConnectionPoint;
  141097. /**
  141098. * Gets the position output component
  141099. */
  141100. get positionOutput(): NodeMaterialConnectionPoint;
  141101. /**
  141102. * Gets the normal output component
  141103. */
  141104. get normalOutput(): NodeMaterialConnectionPoint;
  141105. /**
  141106. * Gets the tangent output component
  141107. */
  141108. get tangentOutput(): NodeMaterialConnectionPoint;
  141109. /**
  141110. * Gets the tangent output component
  141111. */
  141112. get uvOutput(): NodeMaterialConnectionPoint;
  141113. initialize(state: NodeMaterialBuildState): void;
  141114. autoConfigure(material: NodeMaterial): void;
  141115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141117. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141118. protected _buildBlock(state: NodeMaterialBuildState): this;
  141119. }
  141120. }
  141121. declare module BABYLON {
  141122. /**
  141123. * Block used to get data information from a light
  141124. */
  141125. export class LightInformationBlock extends NodeMaterialBlock {
  141126. private _lightDataUniformName;
  141127. private _lightColorUniformName;
  141128. private _lightTypeDefineName;
  141129. /**
  141130. * Gets or sets the light associated with this block
  141131. */
  141132. light: Nullable<Light>;
  141133. /**
  141134. * Creates a new LightInformationBlock
  141135. * @param name defines the block name
  141136. */
  141137. constructor(name: string);
  141138. /**
  141139. * Gets the current class name
  141140. * @returns the class name
  141141. */
  141142. getClassName(): string;
  141143. /**
  141144. * Gets the world position input component
  141145. */
  141146. get worldPosition(): NodeMaterialConnectionPoint;
  141147. /**
  141148. * Gets the direction output component
  141149. */
  141150. get direction(): NodeMaterialConnectionPoint;
  141151. /**
  141152. * Gets the direction output component
  141153. */
  141154. get color(): NodeMaterialConnectionPoint;
  141155. /**
  141156. * Gets the direction output component
  141157. */
  141158. get intensity(): NodeMaterialConnectionPoint;
  141159. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141160. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141161. protected _buildBlock(state: NodeMaterialBuildState): this;
  141162. serialize(): any;
  141163. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141164. }
  141165. }
  141166. declare module BABYLON {
  141167. /**
  141168. * Block used to add image processing support to fragment shader
  141169. */
  141170. export class ImageProcessingBlock extends NodeMaterialBlock {
  141171. /**
  141172. * Create a new ImageProcessingBlock
  141173. * @param name defines the block name
  141174. */
  141175. constructor(name: string);
  141176. /**
  141177. * Gets the current class name
  141178. * @returns the class name
  141179. */
  141180. getClassName(): string;
  141181. /**
  141182. * Gets the color input component
  141183. */
  141184. get color(): NodeMaterialConnectionPoint;
  141185. /**
  141186. * Gets the output component
  141187. */
  141188. get output(): NodeMaterialConnectionPoint;
  141189. /**
  141190. * Initialize the block and prepare the context for build
  141191. * @param state defines the state that will be used for the build
  141192. */
  141193. initialize(state: NodeMaterialBuildState): void;
  141194. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141197. protected _buildBlock(state: NodeMaterialBuildState): this;
  141198. }
  141199. }
  141200. declare module BABYLON {
  141201. /**
  141202. * Block used to pertub normals based on a normal map
  141203. */
  141204. export class PerturbNormalBlock extends NodeMaterialBlock {
  141205. private _tangentSpaceParameterName;
  141206. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141207. invertX: boolean;
  141208. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  141209. invertY: boolean;
  141210. /**
  141211. * Create a new PerturbNormalBlock
  141212. * @param name defines the block name
  141213. */
  141214. constructor(name: string);
  141215. /**
  141216. * Gets the current class name
  141217. * @returns the class name
  141218. */
  141219. getClassName(): string;
  141220. /**
  141221. * Gets the world position input component
  141222. */
  141223. get worldPosition(): NodeMaterialConnectionPoint;
  141224. /**
  141225. * Gets the world normal input component
  141226. */
  141227. get worldNormal(): NodeMaterialConnectionPoint;
  141228. /**
  141229. * Gets the world tangent input component
  141230. */
  141231. get worldTangent(): NodeMaterialConnectionPoint;
  141232. /**
  141233. * Gets the uv input component
  141234. */
  141235. get uv(): NodeMaterialConnectionPoint;
  141236. /**
  141237. * Gets the normal map color input component
  141238. */
  141239. get normalMapColor(): NodeMaterialConnectionPoint;
  141240. /**
  141241. * Gets the strength input component
  141242. */
  141243. get strength(): NodeMaterialConnectionPoint;
  141244. /**
  141245. * Gets the output component
  141246. */
  141247. get output(): NodeMaterialConnectionPoint;
  141248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141250. autoConfigure(material: NodeMaterial): void;
  141251. protected _buildBlock(state: NodeMaterialBuildState): this;
  141252. protected _dumpPropertiesCode(): string;
  141253. serialize(): any;
  141254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141255. }
  141256. }
  141257. declare module BABYLON {
  141258. /**
  141259. * Block used to discard a pixel if a value is smaller than a cutoff
  141260. */
  141261. export class DiscardBlock extends NodeMaterialBlock {
  141262. /**
  141263. * Create a new DiscardBlock
  141264. * @param name defines the block name
  141265. */
  141266. constructor(name: string);
  141267. /**
  141268. * Gets the current class name
  141269. * @returns the class name
  141270. */
  141271. getClassName(): string;
  141272. /**
  141273. * Gets the color input component
  141274. */
  141275. get value(): NodeMaterialConnectionPoint;
  141276. /**
  141277. * Gets the cutoff input component
  141278. */
  141279. get cutoff(): NodeMaterialConnectionPoint;
  141280. protected _buildBlock(state: NodeMaterialBuildState): this;
  141281. }
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * Block used to test if the fragment shader is front facing
  141286. */
  141287. export class FrontFacingBlock extends NodeMaterialBlock {
  141288. /**
  141289. * Creates a new FrontFacingBlock
  141290. * @param name defines the block name
  141291. */
  141292. constructor(name: string);
  141293. /**
  141294. * Gets the current class name
  141295. * @returns the class name
  141296. */
  141297. getClassName(): string;
  141298. /**
  141299. * Gets the output component
  141300. */
  141301. get output(): NodeMaterialConnectionPoint;
  141302. protected _buildBlock(state: NodeMaterialBuildState): this;
  141303. }
  141304. }
  141305. declare module BABYLON {
  141306. /**
  141307. * Block used to get the derivative value on x and y of a given input
  141308. */
  141309. export class DerivativeBlock extends NodeMaterialBlock {
  141310. /**
  141311. * Create a new DerivativeBlock
  141312. * @param name defines the block name
  141313. */
  141314. constructor(name: string);
  141315. /**
  141316. * Gets the current class name
  141317. * @returns the class name
  141318. */
  141319. getClassName(): string;
  141320. /**
  141321. * Gets the input component
  141322. */
  141323. get input(): NodeMaterialConnectionPoint;
  141324. /**
  141325. * Gets the derivative output on x
  141326. */
  141327. get dx(): NodeMaterialConnectionPoint;
  141328. /**
  141329. * Gets the derivative output on y
  141330. */
  141331. get dy(): NodeMaterialConnectionPoint;
  141332. protected _buildBlock(state: NodeMaterialBuildState): this;
  141333. }
  141334. }
  141335. declare module BABYLON {
  141336. /**
  141337. * Block used to make gl_FragCoord available
  141338. */
  141339. export class FragCoordBlock extends NodeMaterialBlock {
  141340. /**
  141341. * Creates a new FragCoordBlock
  141342. * @param name defines the block name
  141343. */
  141344. constructor(name: string);
  141345. /**
  141346. * Gets the current class name
  141347. * @returns the class name
  141348. */
  141349. getClassName(): string;
  141350. /**
  141351. * Gets the xy component
  141352. */
  141353. get xy(): NodeMaterialConnectionPoint;
  141354. /**
  141355. * Gets the xyz component
  141356. */
  141357. get xyz(): NodeMaterialConnectionPoint;
  141358. /**
  141359. * Gets the xyzw component
  141360. */
  141361. get xyzw(): NodeMaterialConnectionPoint;
  141362. /**
  141363. * Gets the x component
  141364. */
  141365. get x(): NodeMaterialConnectionPoint;
  141366. /**
  141367. * Gets the y component
  141368. */
  141369. get y(): NodeMaterialConnectionPoint;
  141370. /**
  141371. * Gets the z component
  141372. */
  141373. get z(): NodeMaterialConnectionPoint;
  141374. /**
  141375. * Gets the w component
  141376. */
  141377. get output(): NodeMaterialConnectionPoint;
  141378. protected writeOutputs(state: NodeMaterialBuildState): string;
  141379. protected _buildBlock(state: NodeMaterialBuildState): this;
  141380. }
  141381. }
  141382. declare module BABYLON {
  141383. /**
  141384. * Block used to get the screen sizes
  141385. */
  141386. export class ScreenSizeBlock extends NodeMaterialBlock {
  141387. private _varName;
  141388. private _scene;
  141389. /**
  141390. * Creates a new ScreenSizeBlock
  141391. * @param name defines the block name
  141392. */
  141393. constructor(name: string);
  141394. /**
  141395. * Gets the current class name
  141396. * @returns the class name
  141397. */
  141398. getClassName(): string;
  141399. /**
  141400. * Gets the xy component
  141401. */
  141402. get xy(): NodeMaterialConnectionPoint;
  141403. /**
  141404. * Gets the x component
  141405. */
  141406. get x(): NodeMaterialConnectionPoint;
  141407. /**
  141408. * Gets the y component
  141409. */
  141410. get y(): NodeMaterialConnectionPoint;
  141411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141412. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141413. protected _buildBlock(state: NodeMaterialBuildState): this;
  141414. }
  141415. }
  141416. declare module BABYLON {
  141417. /**
  141418. * Block used to add support for scene fog
  141419. */
  141420. export class FogBlock extends NodeMaterialBlock {
  141421. private _fogDistanceName;
  141422. private _fogParameters;
  141423. /**
  141424. * Create a new FogBlock
  141425. * @param name defines the block name
  141426. */
  141427. constructor(name: string);
  141428. /**
  141429. * Gets the current class name
  141430. * @returns the class name
  141431. */
  141432. getClassName(): string;
  141433. /**
  141434. * Gets the world position input component
  141435. */
  141436. get worldPosition(): NodeMaterialConnectionPoint;
  141437. /**
  141438. * Gets the view input component
  141439. */
  141440. get view(): NodeMaterialConnectionPoint;
  141441. /**
  141442. * Gets the color input component
  141443. */
  141444. get input(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the fog color input component
  141447. */
  141448. get fogColor(): NodeMaterialConnectionPoint;
  141449. /**
  141450. * Gets the output component
  141451. */
  141452. get output(): NodeMaterialConnectionPoint;
  141453. autoConfigure(material: NodeMaterial): void;
  141454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141456. protected _buildBlock(state: NodeMaterialBuildState): this;
  141457. }
  141458. }
  141459. declare module BABYLON {
  141460. /**
  141461. * Block used to add light in the fragment shader
  141462. */
  141463. export class LightBlock extends NodeMaterialBlock {
  141464. private _lightId;
  141465. /**
  141466. * Gets or sets the light associated with this block
  141467. */
  141468. light: Nullable<Light>;
  141469. /**
  141470. * Create a new LightBlock
  141471. * @param name defines the block name
  141472. */
  141473. constructor(name: string);
  141474. /**
  141475. * Gets the current class name
  141476. * @returns the class name
  141477. */
  141478. getClassName(): string;
  141479. /**
  141480. * Gets the world position input component
  141481. */
  141482. get worldPosition(): NodeMaterialConnectionPoint;
  141483. /**
  141484. * Gets the world normal input component
  141485. */
  141486. get worldNormal(): NodeMaterialConnectionPoint;
  141487. /**
  141488. * Gets the camera (or eye) position component
  141489. */
  141490. get cameraPosition(): NodeMaterialConnectionPoint;
  141491. /**
  141492. * Gets the glossiness component
  141493. */
  141494. get glossiness(): NodeMaterialConnectionPoint;
  141495. /**
  141496. * Gets the glossinness power component
  141497. */
  141498. get glossPower(): NodeMaterialConnectionPoint;
  141499. /**
  141500. * Gets the diffuse color component
  141501. */
  141502. get diffuseColor(): NodeMaterialConnectionPoint;
  141503. /**
  141504. * Gets the specular color component
  141505. */
  141506. get specularColor(): NodeMaterialConnectionPoint;
  141507. /**
  141508. * Gets the diffuse output component
  141509. */
  141510. get diffuseOutput(): NodeMaterialConnectionPoint;
  141511. /**
  141512. * Gets the specular output component
  141513. */
  141514. get specularOutput(): NodeMaterialConnectionPoint;
  141515. /**
  141516. * Gets the shadow output component
  141517. */
  141518. get shadow(): NodeMaterialConnectionPoint;
  141519. autoConfigure(material: NodeMaterial): void;
  141520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141521. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141523. private _injectVertexCode;
  141524. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141525. serialize(): any;
  141526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141527. }
  141528. }
  141529. declare module BABYLON {
  141530. /**
  141531. * Block used to read a reflection texture from a sampler
  141532. */
  141533. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141534. /**
  141535. * Create a new ReflectionTextureBlock
  141536. * @param name defines the block name
  141537. */
  141538. constructor(name: string);
  141539. /**
  141540. * Gets the current class name
  141541. * @returns the class name
  141542. */
  141543. getClassName(): string;
  141544. /**
  141545. * Gets the world position input component
  141546. */
  141547. get position(): NodeMaterialConnectionPoint;
  141548. /**
  141549. * Gets the world position input component
  141550. */
  141551. get worldPosition(): NodeMaterialConnectionPoint;
  141552. /**
  141553. * Gets the world normal input component
  141554. */
  141555. get worldNormal(): NodeMaterialConnectionPoint;
  141556. /**
  141557. * Gets the world input component
  141558. */
  141559. get world(): NodeMaterialConnectionPoint;
  141560. /**
  141561. * Gets the camera (or eye) position component
  141562. */
  141563. get cameraPosition(): NodeMaterialConnectionPoint;
  141564. /**
  141565. * Gets the view input component
  141566. */
  141567. get view(): NodeMaterialConnectionPoint;
  141568. /**
  141569. * Gets the rgb output component
  141570. */
  141571. get rgb(): NodeMaterialConnectionPoint;
  141572. /**
  141573. * Gets the rgba output component
  141574. */
  141575. get rgba(): NodeMaterialConnectionPoint;
  141576. /**
  141577. * Gets the r output component
  141578. */
  141579. get r(): NodeMaterialConnectionPoint;
  141580. /**
  141581. * Gets the g output component
  141582. */
  141583. get g(): NodeMaterialConnectionPoint;
  141584. /**
  141585. * Gets the b output component
  141586. */
  141587. get b(): NodeMaterialConnectionPoint;
  141588. /**
  141589. * Gets the a output component
  141590. */
  141591. get a(): NodeMaterialConnectionPoint;
  141592. autoConfigure(material: NodeMaterial): void;
  141593. protected _buildBlock(state: NodeMaterialBuildState): this;
  141594. }
  141595. }
  141596. declare module BABYLON {
  141597. /**
  141598. * Block used to add 2 vectors
  141599. */
  141600. export class AddBlock extends NodeMaterialBlock {
  141601. /**
  141602. * Creates a new AddBlock
  141603. * @param name defines the block name
  141604. */
  141605. constructor(name: string);
  141606. /**
  141607. * Gets the current class name
  141608. * @returns the class name
  141609. */
  141610. getClassName(): string;
  141611. /**
  141612. * Gets the left operand input component
  141613. */
  141614. get left(): NodeMaterialConnectionPoint;
  141615. /**
  141616. * Gets the right operand input component
  141617. */
  141618. get right(): NodeMaterialConnectionPoint;
  141619. /**
  141620. * Gets the output component
  141621. */
  141622. get output(): NodeMaterialConnectionPoint;
  141623. protected _buildBlock(state: NodeMaterialBuildState): this;
  141624. }
  141625. }
  141626. declare module BABYLON {
  141627. /**
  141628. * Block used to scale a vector by a float
  141629. */
  141630. export class ScaleBlock extends NodeMaterialBlock {
  141631. /**
  141632. * Creates a new ScaleBlock
  141633. * @param name defines the block name
  141634. */
  141635. constructor(name: string);
  141636. /**
  141637. * Gets the current class name
  141638. * @returns the class name
  141639. */
  141640. getClassName(): string;
  141641. /**
  141642. * Gets the input component
  141643. */
  141644. get input(): NodeMaterialConnectionPoint;
  141645. /**
  141646. * Gets the factor input component
  141647. */
  141648. get factor(): NodeMaterialConnectionPoint;
  141649. /**
  141650. * Gets the output component
  141651. */
  141652. get output(): NodeMaterialConnectionPoint;
  141653. protected _buildBlock(state: NodeMaterialBuildState): this;
  141654. }
  141655. }
  141656. declare module BABYLON {
  141657. /**
  141658. * Block used to clamp a float
  141659. */
  141660. export class ClampBlock extends NodeMaterialBlock {
  141661. /** Gets or sets the minimum range */
  141662. minimum: number;
  141663. /** Gets or sets the maximum range */
  141664. maximum: number;
  141665. /**
  141666. * Creates a new ClampBlock
  141667. * @param name defines the block name
  141668. */
  141669. constructor(name: string);
  141670. /**
  141671. * Gets the current class name
  141672. * @returns the class name
  141673. */
  141674. getClassName(): string;
  141675. /**
  141676. * Gets the value input component
  141677. */
  141678. get value(): NodeMaterialConnectionPoint;
  141679. /**
  141680. * Gets the output component
  141681. */
  141682. get output(): NodeMaterialConnectionPoint;
  141683. protected _buildBlock(state: NodeMaterialBuildState): this;
  141684. protected _dumpPropertiesCode(): string;
  141685. serialize(): any;
  141686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141687. }
  141688. }
  141689. declare module BABYLON {
  141690. /**
  141691. * Block used to apply a cross product between 2 vectors
  141692. */
  141693. export class CrossBlock extends NodeMaterialBlock {
  141694. /**
  141695. * Creates a new CrossBlock
  141696. * @param name defines the block name
  141697. */
  141698. constructor(name: string);
  141699. /**
  141700. * Gets the current class name
  141701. * @returns the class name
  141702. */
  141703. getClassName(): string;
  141704. /**
  141705. * Gets the left operand input component
  141706. */
  141707. get left(): NodeMaterialConnectionPoint;
  141708. /**
  141709. * Gets the right operand input component
  141710. */
  141711. get right(): NodeMaterialConnectionPoint;
  141712. /**
  141713. * Gets the output component
  141714. */
  141715. get output(): NodeMaterialConnectionPoint;
  141716. protected _buildBlock(state: NodeMaterialBuildState): this;
  141717. }
  141718. }
  141719. declare module BABYLON {
  141720. /**
  141721. * Block used to apply a dot product between 2 vectors
  141722. */
  141723. export class DotBlock extends NodeMaterialBlock {
  141724. /**
  141725. * Creates a new DotBlock
  141726. * @param name defines the block name
  141727. */
  141728. constructor(name: string);
  141729. /**
  141730. * Gets the current class name
  141731. * @returns the class name
  141732. */
  141733. getClassName(): string;
  141734. /**
  141735. * Gets the left operand input component
  141736. */
  141737. get left(): NodeMaterialConnectionPoint;
  141738. /**
  141739. * Gets the right operand input component
  141740. */
  141741. get right(): NodeMaterialConnectionPoint;
  141742. /**
  141743. * Gets the output component
  141744. */
  141745. get output(): NodeMaterialConnectionPoint;
  141746. protected _buildBlock(state: NodeMaterialBuildState): this;
  141747. }
  141748. }
  141749. declare module BABYLON {
  141750. /**
  141751. * Block used to normalize a vector
  141752. */
  141753. export class NormalizeBlock extends NodeMaterialBlock {
  141754. /**
  141755. * Creates a new NormalizeBlock
  141756. * @param name defines the block name
  141757. */
  141758. constructor(name: string);
  141759. /**
  141760. * Gets the current class name
  141761. * @returns the class name
  141762. */
  141763. getClassName(): string;
  141764. /**
  141765. * Gets the input component
  141766. */
  141767. get input(): NodeMaterialConnectionPoint;
  141768. /**
  141769. * Gets the output component
  141770. */
  141771. get output(): NodeMaterialConnectionPoint;
  141772. protected _buildBlock(state: NodeMaterialBuildState): this;
  141773. }
  141774. }
  141775. declare module BABYLON {
  141776. /**
  141777. * Operations supported by the Trigonometry block
  141778. */
  141779. export enum TrigonometryBlockOperations {
  141780. /** Cos */
  141781. Cos = 0,
  141782. /** Sin */
  141783. Sin = 1,
  141784. /** Abs */
  141785. Abs = 2,
  141786. /** Exp */
  141787. Exp = 3,
  141788. /** Exp2 */
  141789. Exp2 = 4,
  141790. /** Round */
  141791. Round = 5,
  141792. /** Floor */
  141793. Floor = 6,
  141794. /** Ceiling */
  141795. Ceiling = 7,
  141796. /** Square root */
  141797. Sqrt = 8,
  141798. /** Log */
  141799. Log = 9,
  141800. /** Tangent */
  141801. Tan = 10,
  141802. /** Arc tangent */
  141803. ArcTan = 11,
  141804. /** Arc cosinus */
  141805. ArcCos = 12,
  141806. /** Arc sinus */
  141807. ArcSin = 13,
  141808. /** Fraction */
  141809. Fract = 14,
  141810. /** Sign */
  141811. Sign = 15,
  141812. /** To radians (from degrees) */
  141813. Radians = 16,
  141814. /** To degrees (from radians) */
  141815. Degrees = 17
  141816. }
  141817. /**
  141818. * Block used to apply trigonometry operation to floats
  141819. */
  141820. export class TrigonometryBlock extends NodeMaterialBlock {
  141821. /**
  141822. * Gets or sets the operation applied by the block
  141823. */
  141824. operation: TrigonometryBlockOperations;
  141825. /**
  141826. * Creates a new TrigonometryBlock
  141827. * @param name defines the block name
  141828. */
  141829. constructor(name: string);
  141830. /**
  141831. * Gets the current class name
  141832. * @returns the class name
  141833. */
  141834. getClassName(): string;
  141835. /**
  141836. * Gets the input component
  141837. */
  141838. get input(): NodeMaterialConnectionPoint;
  141839. /**
  141840. * Gets the output component
  141841. */
  141842. get output(): NodeMaterialConnectionPoint;
  141843. protected _buildBlock(state: NodeMaterialBuildState): this;
  141844. serialize(): any;
  141845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141846. protected _dumpPropertiesCode(): string;
  141847. }
  141848. }
  141849. declare module BABYLON {
  141850. /**
  141851. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141852. */
  141853. export class ColorMergerBlock extends NodeMaterialBlock {
  141854. /**
  141855. * Create a new ColorMergerBlock
  141856. * @param name defines the block name
  141857. */
  141858. constructor(name: string);
  141859. /**
  141860. * Gets the current class name
  141861. * @returns the class name
  141862. */
  141863. getClassName(): string;
  141864. /**
  141865. * Gets the rgb component (input)
  141866. */
  141867. get rgbIn(): NodeMaterialConnectionPoint;
  141868. /**
  141869. * Gets the r component (input)
  141870. */
  141871. get r(): NodeMaterialConnectionPoint;
  141872. /**
  141873. * Gets the g component (input)
  141874. */
  141875. get g(): NodeMaterialConnectionPoint;
  141876. /**
  141877. * Gets the b component (input)
  141878. */
  141879. get b(): NodeMaterialConnectionPoint;
  141880. /**
  141881. * Gets the a component (input)
  141882. */
  141883. get a(): NodeMaterialConnectionPoint;
  141884. /**
  141885. * Gets the rgba component (output)
  141886. */
  141887. get rgba(): NodeMaterialConnectionPoint;
  141888. /**
  141889. * Gets the rgb component (output)
  141890. */
  141891. get rgbOut(): NodeMaterialConnectionPoint;
  141892. /**
  141893. * Gets the rgb component (output)
  141894. * @deprecated Please use rgbOut instead.
  141895. */
  141896. get rgb(): NodeMaterialConnectionPoint;
  141897. protected _buildBlock(state: NodeMaterialBuildState): this;
  141898. }
  141899. }
  141900. declare module BABYLON {
  141901. /**
  141902. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141903. */
  141904. export class VectorSplitterBlock extends NodeMaterialBlock {
  141905. /**
  141906. * Create a new VectorSplitterBlock
  141907. * @param name defines the block name
  141908. */
  141909. constructor(name: string);
  141910. /**
  141911. * Gets the current class name
  141912. * @returns the class name
  141913. */
  141914. getClassName(): string;
  141915. /**
  141916. * Gets the xyzw component (input)
  141917. */
  141918. get xyzw(): NodeMaterialConnectionPoint;
  141919. /**
  141920. * Gets the xyz component (input)
  141921. */
  141922. get xyzIn(): NodeMaterialConnectionPoint;
  141923. /**
  141924. * Gets the xy component (input)
  141925. */
  141926. get xyIn(): NodeMaterialConnectionPoint;
  141927. /**
  141928. * Gets the xyz component (output)
  141929. */
  141930. get xyzOut(): NodeMaterialConnectionPoint;
  141931. /**
  141932. * Gets the xy component (output)
  141933. */
  141934. get xyOut(): NodeMaterialConnectionPoint;
  141935. /**
  141936. * Gets the x component (output)
  141937. */
  141938. get x(): NodeMaterialConnectionPoint;
  141939. /**
  141940. * Gets the y component (output)
  141941. */
  141942. get y(): NodeMaterialConnectionPoint;
  141943. /**
  141944. * Gets the z component (output)
  141945. */
  141946. get z(): NodeMaterialConnectionPoint;
  141947. /**
  141948. * Gets the w component (output)
  141949. */
  141950. get w(): NodeMaterialConnectionPoint;
  141951. protected _inputRename(name: string): string;
  141952. protected _outputRename(name: string): string;
  141953. protected _buildBlock(state: NodeMaterialBuildState): this;
  141954. }
  141955. }
  141956. declare module BABYLON {
  141957. /**
  141958. * Block used to lerp between 2 values
  141959. */
  141960. export class LerpBlock extends NodeMaterialBlock {
  141961. /**
  141962. * Creates a new LerpBlock
  141963. * @param name defines the block name
  141964. */
  141965. constructor(name: string);
  141966. /**
  141967. * Gets the current class name
  141968. * @returns the class name
  141969. */
  141970. getClassName(): string;
  141971. /**
  141972. * Gets the left operand input component
  141973. */
  141974. get left(): NodeMaterialConnectionPoint;
  141975. /**
  141976. * Gets the right operand input component
  141977. */
  141978. get right(): NodeMaterialConnectionPoint;
  141979. /**
  141980. * Gets the gradient operand input component
  141981. */
  141982. get gradient(): NodeMaterialConnectionPoint;
  141983. /**
  141984. * Gets the output component
  141985. */
  141986. get output(): NodeMaterialConnectionPoint;
  141987. protected _buildBlock(state: NodeMaterialBuildState): this;
  141988. }
  141989. }
  141990. declare module BABYLON {
  141991. /**
  141992. * Block used to divide 2 vectors
  141993. */
  141994. export class DivideBlock extends NodeMaterialBlock {
  141995. /**
  141996. * Creates a new DivideBlock
  141997. * @param name defines the block name
  141998. */
  141999. constructor(name: string);
  142000. /**
  142001. * Gets the current class name
  142002. * @returns the class name
  142003. */
  142004. getClassName(): string;
  142005. /**
  142006. * Gets the left operand input component
  142007. */
  142008. get left(): NodeMaterialConnectionPoint;
  142009. /**
  142010. * Gets the right operand input component
  142011. */
  142012. get right(): NodeMaterialConnectionPoint;
  142013. /**
  142014. * Gets the output component
  142015. */
  142016. get output(): NodeMaterialConnectionPoint;
  142017. protected _buildBlock(state: NodeMaterialBuildState): this;
  142018. }
  142019. }
  142020. declare module BABYLON {
  142021. /**
  142022. * Block used to subtract 2 vectors
  142023. */
  142024. export class SubtractBlock extends NodeMaterialBlock {
  142025. /**
  142026. * Creates a new SubtractBlock
  142027. * @param name defines the block name
  142028. */
  142029. constructor(name: string);
  142030. /**
  142031. * Gets the current class name
  142032. * @returns the class name
  142033. */
  142034. getClassName(): string;
  142035. /**
  142036. * Gets the left operand input component
  142037. */
  142038. get left(): NodeMaterialConnectionPoint;
  142039. /**
  142040. * Gets the right operand input component
  142041. */
  142042. get right(): NodeMaterialConnectionPoint;
  142043. /**
  142044. * Gets the output component
  142045. */
  142046. get output(): NodeMaterialConnectionPoint;
  142047. protected _buildBlock(state: NodeMaterialBuildState): this;
  142048. }
  142049. }
  142050. declare module BABYLON {
  142051. /**
  142052. * Block used to step a value
  142053. */
  142054. export class StepBlock extends NodeMaterialBlock {
  142055. /**
  142056. * Creates a new StepBlock
  142057. * @param name defines the block name
  142058. */
  142059. constructor(name: string);
  142060. /**
  142061. * Gets the current class name
  142062. * @returns the class name
  142063. */
  142064. getClassName(): string;
  142065. /**
  142066. * Gets the value operand input component
  142067. */
  142068. get value(): NodeMaterialConnectionPoint;
  142069. /**
  142070. * Gets the edge operand input component
  142071. */
  142072. get edge(): NodeMaterialConnectionPoint;
  142073. /**
  142074. * Gets the output component
  142075. */
  142076. get output(): NodeMaterialConnectionPoint;
  142077. protected _buildBlock(state: NodeMaterialBuildState): this;
  142078. }
  142079. }
  142080. declare module BABYLON {
  142081. /**
  142082. * Block used to get the opposite (1 - x) of a value
  142083. */
  142084. export class OneMinusBlock extends NodeMaterialBlock {
  142085. /**
  142086. * Creates a new OneMinusBlock
  142087. * @param name defines the block name
  142088. */
  142089. constructor(name: string);
  142090. /**
  142091. * Gets the current class name
  142092. * @returns the class name
  142093. */
  142094. getClassName(): string;
  142095. /**
  142096. * Gets the input component
  142097. */
  142098. get input(): NodeMaterialConnectionPoint;
  142099. /**
  142100. * Gets the output component
  142101. */
  142102. get output(): NodeMaterialConnectionPoint;
  142103. protected _buildBlock(state: NodeMaterialBuildState): this;
  142104. }
  142105. }
  142106. declare module BABYLON {
  142107. /**
  142108. * Block used to get the view direction
  142109. */
  142110. export class ViewDirectionBlock extends NodeMaterialBlock {
  142111. /**
  142112. * Creates a new ViewDirectionBlock
  142113. * @param name defines the block name
  142114. */
  142115. constructor(name: string);
  142116. /**
  142117. * Gets the current class name
  142118. * @returns the class name
  142119. */
  142120. getClassName(): string;
  142121. /**
  142122. * Gets the world position component
  142123. */
  142124. get worldPosition(): NodeMaterialConnectionPoint;
  142125. /**
  142126. * Gets the camera position component
  142127. */
  142128. get cameraPosition(): NodeMaterialConnectionPoint;
  142129. /**
  142130. * Gets the output component
  142131. */
  142132. get output(): NodeMaterialConnectionPoint;
  142133. autoConfigure(material: NodeMaterial): void;
  142134. protected _buildBlock(state: NodeMaterialBuildState): this;
  142135. }
  142136. }
  142137. declare module BABYLON {
  142138. /**
  142139. * Block used to compute fresnel value
  142140. */
  142141. export class FresnelBlock extends NodeMaterialBlock {
  142142. /**
  142143. * Create a new FresnelBlock
  142144. * @param name defines the block name
  142145. */
  142146. constructor(name: string);
  142147. /**
  142148. * Gets the current class name
  142149. * @returns the class name
  142150. */
  142151. getClassName(): string;
  142152. /**
  142153. * Gets the world normal input component
  142154. */
  142155. get worldNormal(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the view direction input component
  142158. */
  142159. get viewDirection(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the bias input component
  142162. */
  142163. get bias(): NodeMaterialConnectionPoint;
  142164. /**
  142165. * Gets the camera (or eye) position component
  142166. */
  142167. get power(): NodeMaterialConnectionPoint;
  142168. /**
  142169. * Gets the fresnel output component
  142170. */
  142171. get fresnel(): NodeMaterialConnectionPoint;
  142172. autoConfigure(material: NodeMaterial): void;
  142173. protected _buildBlock(state: NodeMaterialBuildState): this;
  142174. }
  142175. }
  142176. declare module BABYLON {
  142177. /**
  142178. * Block used to get the max of 2 values
  142179. */
  142180. export class MaxBlock extends NodeMaterialBlock {
  142181. /**
  142182. * Creates a new MaxBlock
  142183. * @param name defines the block name
  142184. */
  142185. constructor(name: string);
  142186. /**
  142187. * Gets the current class name
  142188. * @returns the class name
  142189. */
  142190. getClassName(): string;
  142191. /**
  142192. * Gets the left operand input component
  142193. */
  142194. get left(): NodeMaterialConnectionPoint;
  142195. /**
  142196. * Gets the right operand input component
  142197. */
  142198. get right(): NodeMaterialConnectionPoint;
  142199. /**
  142200. * Gets the output component
  142201. */
  142202. get output(): NodeMaterialConnectionPoint;
  142203. protected _buildBlock(state: NodeMaterialBuildState): this;
  142204. }
  142205. }
  142206. declare module BABYLON {
  142207. /**
  142208. * Block used to get the min of 2 values
  142209. */
  142210. export class MinBlock extends NodeMaterialBlock {
  142211. /**
  142212. * Creates a new MinBlock
  142213. * @param name defines the block name
  142214. */
  142215. constructor(name: string);
  142216. /**
  142217. * Gets the current class name
  142218. * @returns the class name
  142219. */
  142220. getClassName(): string;
  142221. /**
  142222. * Gets the left operand input component
  142223. */
  142224. get left(): NodeMaterialConnectionPoint;
  142225. /**
  142226. * Gets the right operand input component
  142227. */
  142228. get right(): NodeMaterialConnectionPoint;
  142229. /**
  142230. * Gets the output component
  142231. */
  142232. get output(): NodeMaterialConnectionPoint;
  142233. protected _buildBlock(state: NodeMaterialBuildState): this;
  142234. }
  142235. }
  142236. declare module BABYLON {
  142237. /**
  142238. * Block used to get the distance between 2 values
  142239. */
  142240. export class DistanceBlock extends NodeMaterialBlock {
  142241. /**
  142242. * Creates a new DistanceBlock
  142243. * @param name defines the block name
  142244. */
  142245. constructor(name: string);
  142246. /**
  142247. * Gets the current class name
  142248. * @returns the class name
  142249. */
  142250. getClassName(): string;
  142251. /**
  142252. * Gets the left operand input component
  142253. */
  142254. get left(): NodeMaterialConnectionPoint;
  142255. /**
  142256. * Gets the right operand input component
  142257. */
  142258. get right(): NodeMaterialConnectionPoint;
  142259. /**
  142260. * Gets the output component
  142261. */
  142262. get output(): NodeMaterialConnectionPoint;
  142263. protected _buildBlock(state: NodeMaterialBuildState): this;
  142264. }
  142265. }
  142266. declare module BABYLON {
  142267. /**
  142268. * Block used to get the length of a vector
  142269. */
  142270. export class LengthBlock extends NodeMaterialBlock {
  142271. /**
  142272. * Creates a new LengthBlock
  142273. * @param name defines the block name
  142274. */
  142275. constructor(name: string);
  142276. /**
  142277. * Gets the current class name
  142278. * @returns the class name
  142279. */
  142280. getClassName(): string;
  142281. /**
  142282. * Gets the value input component
  142283. */
  142284. get value(): NodeMaterialConnectionPoint;
  142285. /**
  142286. * Gets the output component
  142287. */
  142288. get output(): NodeMaterialConnectionPoint;
  142289. protected _buildBlock(state: NodeMaterialBuildState): this;
  142290. }
  142291. }
  142292. declare module BABYLON {
  142293. /**
  142294. * Block used to get negative version of a value (i.e. x * -1)
  142295. */
  142296. export class NegateBlock extends NodeMaterialBlock {
  142297. /**
  142298. * Creates a new NegateBlock
  142299. * @param name defines the block name
  142300. */
  142301. constructor(name: string);
  142302. /**
  142303. * Gets the current class name
  142304. * @returns the class name
  142305. */
  142306. getClassName(): string;
  142307. /**
  142308. * Gets the value input component
  142309. */
  142310. get value(): NodeMaterialConnectionPoint;
  142311. /**
  142312. * Gets the output component
  142313. */
  142314. get output(): NodeMaterialConnectionPoint;
  142315. protected _buildBlock(state: NodeMaterialBuildState): this;
  142316. }
  142317. }
  142318. declare module BABYLON {
  142319. /**
  142320. * Block used to get the value of the first parameter raised to the power of the second
  142321. */
  142322. export class PowBlock extends NodeMaterialBlock {
  142323. /**
  142324. * Creates a new PowBlock
  142325. * @param name defines the block name
  142326. */
  142327. constructor(name: string);
  142328. /**
  142329. * Gets the current class name
  142330. * @returns the class name
  142331. */
  142332. getClassName(): string;
  142333. /**
  142334. * Gets the value operand input component
  142335. */
  142336. get value(): NodeMaterialConnectionPoint;
  142337. /**
  142338. * Gets the power operand input component
  142339. */
  142340. get power(): NodeMaterialConnectionPoint;
  142341. /**
  142342. * Gets the output component
  142343. */
  142344. get output(): NodeMaterialConnectionPoint;
  142345. protected _buildBlock(state: NodeMaterialBuildState): this;
  142346. }
  142347. }
  142348. declare module BABYLON {
  142349. /**
  142350. * Block used to get a random number
  142351. */
  142352. export class RandomNumberBlock extends NodeMaterialBlock {
  142353. /**
  142354. * Creates a new RandomNumberBlock
  142355. * @param name defines the block name
  142356. */
  142357. constructor(name: string);
  142358. /**
  142359. * Gets the current class name
  142360. * @returns the class name
  142361. */
  142362. getClassName(): string;
  142363. /**
  142364. * Gets the seed input component
  142365. */
  142366. get seed(): NodeMaterialConnectionPoint;
  142367. /**
  142368. * Gets the output component
  142369. */
  142370. get output(): NodeMaterialConnectionPoint;
  142371. protected _buildBlock(state: NodeMaterialBuildState): this;
  142372. }
  142373. }
  142374. declare module BABYLON {
  142375. /**
  142376. * Block used to compute arc tangent of 2 values
  142377. */
  142378. export class ArcTan2Block extends NodeMaterialBlock {
  142379. /**
  142380. * Creates a new ArcTan2Block
  142381. * @param name defines the block name
  142382. */
  142383. constructor(name: string);
  142384. /**
  142385. * Gets the current class name
  142386. * @returns the class name
  142387. */
  142388. getClassName(): string;
  142389. /**
  142390. * Gets the x operand input component
  142391. */
  142392. get x(): NodeMaterialConnectionPoint;
  142393. /**
  142394. * Gets the y operand input component
  142395. */
  142396. get y(): NodeMaterialConnectionPoint;
  142397. /**
  142398. * Gets the output component
  142399. */
  142400. get output(): NodeMaterialConnectionPoint;
  142401. protected _buildBlock(state: NodeMaterialBuildState): this;
  142402. }
  142403. }
  142404. declare module BABYLON {
  142405. /**
  142406. * Block used to smooth step a value
  142407. */
  142408. export class SmoothStepBlock extends NodeMaterialBlock {
  142409. /**
  142410. * Creates a new SmoothStepBlock
  142411. * @param name defines the block name
  142412. */
  142413. constructor(name: string);
  142414. /**
  142415. * Gets the current class name
  142416. * @returns the class name
  142417. */
  142418. getClassName(): string;
  142419. /**
  142420. * Gets the value operand input component
  142421. */
  142422. get value(): NodeMaterialConnectionPoint;
  142423. /**
  142424. * Gets the first edge operand input component
  142425. */
  142426. get edge0(): NodeMaterialConnectionPoint;
  142427. /**
  142428. * Gets the second edge operand input component
  142429. */
  142430. get edge1(): NodeMaterialConnectionPoint;
  142431. /**
  142432. * Gets the output component
  142433. */
  142434. get output(): NodeMaterialConnectionPoint;
  142435. protected _buildBlock(state: NodeMaterialBuildState): this;
  142436. }
  142437. }
  142438. declare module BABYLON {
  142439. /**
  142440. * Block used to get the reciprocal (1 / x) of a value
  142441. */
  142442. export class ReciprocalBlock extends NodeMaterialBlock {
  142443. /**
  142444. * Creates a new ReciprocalBlock
  142445. * @param name defines the block name
  142446. */
  142447. constructor(name: string);
  142448. /**
  142449. * Gets the current class name
  142450. * @returns the class name
  142451. */
  142452. getClassName(): string;
  142453. /**
  142454. * Gets the input component
  142455. */
  142456. get input(): NodeMaterialConnectionPoint;
  142457. /**
  142458. * Gets the output component
  142459. */
  142460. get output(): NodeMaterialConnectionPoint;
  142461. protected _buildBlock(state: NodeMaterialBuildState): this;
  142462. }
  142463. }
  142464. declare module BABYLON {
  142465. /**
  142466. * Block used to replace a color by another one
  142467. */
  142468. export class ReplaceColorBlock extends NodeMaterialBlock {
  142469. /**
  142470. * Creates a new ReplaceColorBlock
  142471. * @param name defines the block name
  142472. */
  142473. constructor(name: string);
  142474. /**
  142475. * Gets the current class name
  142476. * @returns the class name
  142477. */
  142478. getClassName(): string;
  142479. /**
  142480. * Gets the value input component
  142481. */
  142482. get value(): NodeMaterialConnectionPoint;
  142483. /**
  142484. * Gets the reference input component
  142485. */
  142486. get reference(): NodeMaterialConnectionPoint;
  142487. /**
  142488. * Gets the distance input component
  142489. */
  142490. get distance(): NodeMaterialConnectionPoint;
  142491. /**
  142492. * Gets the replacement input component
  142493. */
  142494. get replacement(): NodeMaterialConnectionPoint;
  142495. /**
  142496. * Gets the output component
  142497. */
  142498. get output(): NodeMaterialConnectionPoint;
  142499. protected _buildBlock(state: NodeMaterialBuildState): this;
  142500. }
  142501. }
  142502. declare module BABYLON {
  142503. /**
  142504. * Block used to posterize a value
  142505. * @see https://en.wikipedia.org/wiki/Posterization
  142506. */
  142507. export class PosterizeBlock extends NodeMaterialBlock {
  142508. /**
  142509. * Creates a new PosterizeBlock
  142510. * @param name defines the block name
  142511. */
  142512. constructor(name: string);
  142513. /**
  142514. * Gets the current class name
  142515. * @returns the class name
  142516. */
  142517. getClassName(): string;
  142518. /**
  142519. * Gets the value input component
  142520. */
  142521. get value(): NodeMaterialConnectionPoint;
  142522. /**
  142523. * Gets the steps input component
  142524. */
  142525. get steps(): NodeMaterialConnectionPoint;
  142526. /**
  142527. * Gets the output component
  142528. */
  142529. get output(): NodeMaterialConnectionPoint;
  142530. protected _buildBlock(state: NodeMaterialBuildState): this;
  142531. }
  142532. }
  142533. declare module BABYLON {
  142534. /**
  142535. * Operations supported by the Wave block
  142536. */
  142537. export enum WaveBlockKind {
  142538. /** SawTooth */
  142539. SawTooth = 0,
  142540. /** Square */
  142541. Square = 1,
  142542. /** Triangle */
  142543. Triangle = 2
  142544. }
  142545. /**
  142546. * Block used to apply wave operation to floats
  142547. */
  142548. export class WaveBlock extends NodeMaterialBlock {
  142549. /**
  142550. * Gets or sets the kibnd of wave to be applied by the block
  142551. */
  142552. kind: WaveBlockKind;
  142553. /**
  142554. * Creates a new WaveBlock
  142555. * @param name defines the block name
  142556. */
  142557. constructor(name: string);
  142558. /**
  142559. * Gets the current class name
  142560. * @returns the class name
  142561. */
  142562. getClassName(): string;
  142563. /**
  142564. * Gets the input component
  142565. */
  142566. get input(): NodeMaterialConnectionPoint;
  142567. /**
  142568. * Gets the output component
  142569. */
  142570. get output(): NodeMaterialConnectionPoint;
  142571. protected _buildBlock(state: NodeMaterialBuildState): this;
  142572. serialize(): any;
  142573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142574. }
  142575. }
  142576. declare module BABYLON {
  142577. /**
  142578. * Class used to store a color step for the GradientBlock
  142579. */
  142580. export class GradientBlockColorStep {
  142581. /**
  142582. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142583. */
  142584. step: number;
  142585. /**
  142586. * Gets or sets the color associated with this step
  142587. */
  142588. color: Color3;
  142589. /**
  142590. * Creates a new GradientBlockColorStep
  142591. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142592. * @param color defines the color associated with this step
  142593. */
  142594. constructor(
  142595. /**
  142596. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142597. */
  142598. step: number,
  142599. /**
  142600. * Gets or sets the color associated with this step
  142601. */
  142602. color: Color3);
  142603. }
  142604. /**
  142605. * Block used to return a color from a gradient based on an input value between 0 and 1
  142606. */
  142607. export class GradientBlock extends NodeMaterialBlock {
  142608. /**
  142609. * Gets or sets the list of color steps
  142610. */
  142611. colorSteps: GradientBlockColorStep[];
  142612. /**
  142613. * Creates a new GradientBlock
  142614. * @param name defines the block name
  142615. */
  142616. constructor(name: string);
  142617. /**
  142618. * Gets the current class name
  142619. * @returns the class name
  142620. */
  142621. getClassName(): string;
  142622. /**
  142623. * Gets the gradient input component
  142624. */
  142625. get gradient(): NodeMaterialConnectionPoint;
  142626. /**
  142627. * Gets the output component
  142628. */
  142629. get output(): NodeMaterialConnectionPoint;
  142630. private _writeColorConstant;
  142631. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142632. serialize(): any;
  142633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142634. protected _dumpPropertiesCode(): string;
  142635. }
  142636. }
  142637. declare module BABYLON {
  142638. /**
  142639. * Block used to normalize lerp between 2 values
  142640. */
  142641. export class NLerpBlock extends NodeMaterialBlock {
  142642. /**
  142643. * Creates a new NLerpBlock
  142644. * @param name defines the block name
  142645. */
  142646. constructor(name: string);
  142647. /**
  142648. * Gets the current class name
  142649. * @returns the class name
  142650. */
  142651. getClassName(): string;
  142652. /**
  142653. * Gets the left operand input component
  142654. */
  142655. get left(): NodeMaterialConnectionPoint;
  142656. /**
  142657. * Gets the right operand input component
  142658. */
  142659. get right(): NodeMaterialConnectionPoint;
  142660. /**
  142661. * Gets the gradient operand input component
  142662. */
  142663. get gradient(): NodeMaterialConnectionPoint;
  142664. /**
  142665. * Gets the output component
  142666. */
  142667. get output(): NodeMaterialConnectionPoint;
  142668. protected _buildBlock(state: NodeMaterialBuildState): this;
  142669. }
  142670. }
  142671. declare module BABYLON {
  142672. /**
  142673. * block used to Generate a Worley Noise 3D Noise Pattern
  142674. */
  142675. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142676. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142677. manhattanDistance: boolean;
  142678. /**
  142679. * Creates a new WorleyNoise3DBlock
  142680. * @param name defines the block name
  142681. */
  142682. constructor(name: string);
  142683. /**
  142684. * Gets the current class name
  142685. * @returns the class name
  142686. */
  142687. getClassName(): string;
  142688. /**
  142689. * Gets the seed input component
  142690. */
  142691. get seed(): NodeMaterialConnectionPoint;
  142692. /**
  142693. * Gets the jitter input component
  142694. */
  142695. get jitter(): NodeMaterialConnectionPoint;
  142696. /**
  142697. * Gets the output component
  142698. */
  142699. get output(): NodeMaterialConnectionPoint;
  142700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142701. /**
  142702. * Exposes the properties to the UI?
  142703. */
  142704. protected _dumpPropertiesCode(): string;
  142705. /**
  142706. * Exposes the properties to the Seralize?
  142707. */
  142708. serialize(): any;
  142709. /**
  142710. * Exposes the properties to the deseralize?
  142711. */
  142712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142713. }
  142714. }
  142715. declare module BABYLON {
  142716. /**
  142717. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142718. */
  142719. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142720. /**
  142721. * Creates a new SimplexPerlin3DBlock
  142722. * @param name defines the block name
  142723. */
  142724. constructor(name: string);
  142725. /**
  142726. * Gets the current class name
  142727. * @returns the class name
  142728. */
  142729. getClassName(): string;
  142730. /**
  142731. * Gets the seed operand input component
  142732. */
  142733. get seed(): NodeMaterialConnectionPoint;
  142734. /**
  142735. * Gets the output component
  142736. */
  142737. get output(): NodeMaterialConnectionPoint;
  142738. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142739. }
  142740. }
  142741. declare module BABYLON {
  142742. /**
  142743. * Block used to blend normals
  142744. */
  142745. export class NormalBlendBlock extends NodeMaterialBlock {
  142746. /**
  142747. * Creates a new NormalBlendBlock
  142748. * @param name defines the block name
  142749. */
  142750. constructor(name: string);
  142751. /**
  142752. * Gets the current class name
  142753. * @returns the class name
  142754. */
  142755. getClassName(): string;
  142756. /**
  142757. * Gets the first input component
  142758. */
  142759. get normalMap0(): NodeMaterialConnectionPoint;
  142760. /**
  142761. * Gets the second input component
  142762. */
  142763. get normalMap1(): NodeMaterialConnectionPoint;
  142764. /**
  142765. * Gets the output component
  142766. */
  142767. get output(): NodeMaterialConnectionPoint;
  142768. protected _buildBlock(state: NodeMaterialBuildState): this;
  142769. }
  142770. }
  142771. declare module BABYLON {
  142772. /**
  142773. * Block used to rotate a 2d vector by a given angle
  142774. */
  142775. export class Rotate2dBlock extends NodeMaterialBlock {
  142776. /**
  142777. * Creates a new Rotate2dBlock
  142778. * @param name defines the block name
  142779. */
  142780. constructor(name: string);
  142781. /**
  142782. * Gets the current class name
  142783. * @returns the class name
  142784. */
  142785. getClassName(): string;
  142786. /**
  142787. * Gets the input vector
  142788. */
  142789. get input(): NodeMaterialConnectionPoint;
  142790. /**
  142791. * Gets the input angle
  142792. */
  142793. get angle(): NodeMaterialConnectionPoint;
  142794. /**
  142795. * Gets the output component
  142796. */
  142797. get output(): NodeMaterialConnectionPoint;
  142798. autoConfigure(material: NodeMaterial): void;
  142799. protected _buildBlock(state: NodeMaterialBuildState): this;
  142800. }
  142801. }
  142802. declare module BABYLON {
  142803. /**
  142804. * Block used to get the reflected vector from a direction and a normal
  142805. */
  142806. export class ReflectBlock extends NodeMaterialBlock {
  142807. /**
  142808. * Creates a new ReflectBlock
  142809. * @param name defines the block name
  142810. */
  142811. constructor(name: string);
  142812. /**
  142813. * Gets the current class name
  142814. * @returns the class name
  142815. */
  142816. getClassName(): string;
  142817. /**
  142818. * Gets the incident component
  142819. */
  142820. get incident(): NodeMaterialConnectionPoint;
  142821. /**
  142822. * Gets the normal component
  142823. */
  142824. get normal(): NodeMaterialConnectionPoint;
  142825. /**
  142826. * Gets the output component
  142827. */
  142828. get output(): NodeMaterialConnectionPoint;
  142829. protected _buildBlock(state: NodeMaterialBuildState): this;
  142830. }
  142831. }
  142832. declare module BABYLON {
  142833. /**
  142834. * Block used to get the refracted vector from a direction and a normal
  142835. */
  142836. export class RefractBlock extends NodeMaterialBlock {
  142837. /**
  142838. * Creates a new RefractBlock
  142839. * @param name defines the block name
  142840. */
  142841. constructor(name: string);
  142842. /**
  142843. * Gets the current class name
  142844. * @returns the class name
  142845. */
  142846. getClassName(): string;
  142847. /**
  142848. * Gets the incident component
  142849. */
  142850. get incident(): NodeMaterialConnectionPoint;
  142851. /**
  142852. * Gets the normal component
  142853. */
  142854. get normal(): NodeMaterialConnectionPoint;
  142855. /**
  142856. * Gets the index of refraction component
  142857. */
  142858. get ior(): NodeMaterialConnectionPoint;
  142859. /**
  142860. * Gets the output component
  142861. */
  142862. get output(): NodeMaterialConnectionPoint;
  142863. protected _buildBlock(state: NodeMaterialBuildState): this;
  142864. }
  142865. }
  142866. declare module BABYLON {
  142867. /**
  142868. * Block used to desaturate a color
  142869. */
  142870. export class DesaturateBlock extends NodeMaterialBlock {
  142871. /**
  142872. * Creates a new DesaturateBlock
  142873. * @param name defines the block name
  142874. */
  142875. constructor(name: string);
  142876. /**
  142877. * Gets the current class name
  142878. * @returns the class name
  142879. */
  142880. getClassName(): string;
  142881. /**
  142882. * Gets the color operand input component
  142883. */
  142884. get color(): NodeMaterialConnectionPoint;
  142885. /**
  142886. * Gets the level operand input component
  142887. */
  142888. get level(): NodeMaterialConnectionPoint;
  142889. /**
  142890. * Gets the output component
  142891. */
  142892. get output(): NodeMaterialConnectionPoint;
  142893. protected _buildBlock(state: NodeMaterialBuildState): this;
  142894. }
  142895. }
  142896. declare module BABYLON {
  142897. /**
  142898. * Block used to implement the ambient occlusion module of the PBR material
  142899. */
  142900. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142901. /**
  142902. * Create a new AmbientOcclusionBlock
  142903. * @param name defines the block name
  142904. */
  142905. constructor(name: string);
  142906. /**
  142907. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142908. */
  142909. useAmbientInGrayScale: boolean;
  142910. /**
  142911. * Initialize the block and prepare the context for build
  142912. * @param state defines the state that will be used for the build
  142913. */
  142914. initialize(state: NodeMaterialBuildState): void;
  142915. /**
  142916. * Gets the current class name
  142917. * @returns the class name
  142918. */
  142919. getClassName(): string;
  142920. /**
  142921. * Gets the texture input component
  142922. */
  142923. get texture(): NodeMaterialConnectionPoint;
  142924. /**
  142925. * Gets the texture intensity component
  142926. */
  142927. get intensity(): NodeMaterialConnectionPoint;
  142928. /**
  142929. * Gets the direct light intensity input component
  142930. */
  142931. get directLightIntensity(): NodeMaterialConnectionPoint;
  142932. /**
  142933. * Gets the ambient occlusion object output component
  142934. */
  142935. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142936. /**
  142937. * Gets the main code of the block (fragment side)
  142938. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142939. * @returns the shader code
  142940. */
  142941. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142943. protected _buildBlock(state: NodeMaterialBuildState): this;
  142944. protected _dumpPropertiesCode(): string;
  142945. serialize(): any;
  142946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142947. }
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * Block used to implement the reflection module of the PBR material
  142952. */
  142953. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142954. /** @hidden */
  142955. _defineLODReflectionAlpha: string;
  142956. /** @hidden */
  142957. _defineLinearSpecularReflection: string;
  142958. private _vEnvironmentIrradianceName;
  142959. /** @hidden */
  142960. _vReflectionMicrosurfaceInfosName: string;
  142961. /** @hidden */
  142962. _vReflectionInfosName: string;
  142963. /** @hidden */
  142964. _vReflectionFilteringInfoName: string;
  142965. private _scene;
  142966. /**
  142967. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142968. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142969. * It's less burden on the user side in the editor part.
  142970. */
  142971. /** @hidden */
  142972. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142973. /** @hidden */
  142974. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142975. /** @hidden */
  142976. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142977. /**
  142978. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142979. * diffuse part of the IBL.
  142980. */
  142981. useSphericalHarmonics: boolean;
  142982. /**
  142983. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142984. */
  142985. forceIrradianceInFragment: boolean;
  142986. /**
  142987. * Create a new ReflectionBlock
  142988. * @param name defines the block name
  142989. */
  142990. constructor(name: string);
  142991. /**
  142992. * Gets the current class name
  142993. * @returns the class name
  142994. */
  142995. getClassName(): string;
  142996. /**
  142997. * Gets the position input component
  142998. */
  142999. get position(): NodeMaterialConnectionPoint;
  143000. /**
  143001. * Gets the world position input component
  143002. */
  143003. get worldPosition(): NodeMaterialConnectionPoint;
  143004. /**
  143005. * Gets the world normal input component
  143006. */
  143007. get worldNormal(): NodeMaterialConnectionPoint;
  143008. /**
  143009. * Gets the world input component
  143010. */
  143011. get world(): NodeMaterialConnectionPoint;
  143012. /**
  143013. * Gets the camera (or eye) position component
  143014. */
  143015. get cameraPosition(): NodeMaterialConnectionPoint;
  143016. /**
  143017. * Gets the view input component
  143018. */
  143019. get view(): NodeMaterialConnectionPoint;
  143020. /**
  143021. * Gets the color input component
  143022. */
  143023. get color(): NodeMaterialConnectionPoint;
  143024. /**
  143025. * Gets the reflection object output component
  143026. */
  143027. get reflection(): NodeMaterialConnectionPoint;
  143028. /**
  143029. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143030. */
  143031. get hasTexture(): boolean;
  143032. /**
  143033. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143034. */
  143035. get reflectionColor(): string;
  143036. protected _getTexture(): Nullable<BaseTexture>;
  143037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143039. /**
  143040. * Gets the code to inject in the vertex shader
  143041. * @param state current state of the node material building
  143042. * @returns the shader code
  143043. */
  143044. handleVertexSide(state: NodeMaterialBuildState): string;
  143045. /**
  143046. * Gets the main code of the block (fragment side)
  143047. * @param state current state of the node material building
  143048. * @param normalVarName name of the existing variable corresponding to the normal
  143049. * @returns the shader code
  143050. */
  143051. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143052. protected _buildBlock(state: NodeMaterialBuildState): this;
  143053. protected _dumpPropertiesCode(): string;
  143054. serialize(): any;
  143055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143056. }
  143057. }
  143058. declare module BABYLON {
  143059. /**
  143060. * Block used to implement the sheen module of the PBR material
  143061. */
  143062. export class SheenBlock extends NodeMaterialBlock {
  143063. /**
  143064. * Create a new SheenBlock
  143065. * @param name defines the block name
  143066. */
  143067. constructor(name: string);
  143068. /**
  143069. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143070. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143071. * making it easier to setup and tweak the effect
  143072. */
  143073. albedoScaling: boolean;
  143074. /**
  143075. * Defines if the sheen is linked to the sheen color.
  143076. */
  143077. linkSheenWithAlbedo: boolean;
  143078. /**
  143079. * Initialize the block and prepare the context for build
  143080. * @param state defines the state that will be used for the build
  143081. */
  143082. initialize(state: NodeMaterialBuildState): void;
  143083. /**
  143084. * Gets the current class name
  143085. * @returns the class name
  143086. */
  143087. getClassName(): string;
  143088. /**
  143089. * Gets the intensity input component
  143090. */
  143091. get intensity(): NodeMaterialConnectionPoint;
  143092. /**
  143093. * Gets the color input component
  143094. */
  143095. get color(): NodeMaterialConnectionPoint;
  143096. /**
  143097. * Gets the roughness input component
  143098. */
  143099. get roughness(): NodeMaterialConnectionPoint;
  143100. /**
  143101. * Gets the sheen object output component
  143102. */
  143103. get sheen(): NodeMaterialConnectionPoint;
  143104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143105. /**
  143106. * Gets the main code of the block (fragment side)
  143107. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143108. * @returns the shader code
  143109. */
  143110. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  143111. protected _buildBlock(state: NodeMaterialBuildState): this;
  143112. protected _dumpPropertiesCode(): string;
  143113. serialize(): any;
  143114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143115. }
  143116. }
  143117. declare module BABYLON {
  143118. /**
  143119. * Block used to implement the reflectivity module of the PBR material
  143120. */
  143121. export class ReflectivityBlock extends NodeMaterialBlock {
  143122. private _metallicReflectanceColor;
  143123. private _metallicF0Factor;
  143124. /** @hidden */
  143125. _vMetallicReflectanceFactorsName: string;
  143126. /**
  143127. * The property below is set by the main PBR block prior to calling methods of this class.
  143128. */
  143129. /** @hidden */
  143130. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143131. /**
  143132. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143133. */
  143134. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143135. /**
  143136. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143137. */
  143138. useMetallnessFromMetallicTextureBlue: boolean;
  143139. /**
  143140. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143141. */
  143142. useRoughnessFromMetallicTextureAlpha: boolean;
  143143. /**
  143144. * Specifies if the metallic texture contains the roughness information in its green channel.
  143145. */
  143146. useRoughnessFromMetallicTextureGreen: boolean;
  143147. /**
  143148. * Create a new ReflectivityBlock
  143149. * @param name defines the block name
  143150. */
  143151. constructor(name: string);
  143152. /**
  143153. * Initialize the block and prepare the context for build
  143154. * @param state defines the state that will be used for the build
  143155. */
  143156. initialize(state: NodeMaterialBuildState): void;
  143157. /**
  143158. * Gets the current class name
  143159. * @returns the class name
  143160. */
  143161. getClassName(): string;
  143162. /**
  143163. * Gets the metallic input component
  143164. */
  143165. get metallic(): NodeMaterialConnectionPoint;
  143166. /**
  143167. * Gets the roughness input component
  143168. */
  143169. get roughness(): NodeMaterialConnectionPoint;
  143170. /**
  143171. * Gets the texture input component
  143172. */
  143173. get texture(): NodeMaterialConnectionPoint;
  143174. /**
  143175. * Gets the reflectivity object output component
  143176. */
  143177. get reflectivity(): NodeMaterialConnectionPoint;
  143178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143179. /**
  143180. * Gets the main code of the block (fragment side)
  143181. * @param state current state of the node material building
  143182. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143183. * @returns the shader code
  143184. */
  143185. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143187. protected _buildBlock(state: NodeMaterialBuildState): this;
  143188. protected _dumpPropertiesCode(): string;
  143189. serialize(): any;
  143190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143191. }
  143192. }
  143193. declare module BABYLON {
  143194. /**
  143195. * Block used to implement the anisotropy module of the PBR material
  143196. */
  143197. export class AnisotropyBlock extends NodeMaterialBlock {
  143198. /**
  143199. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143200. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143201. * It's less burden on the user side in the editor part.
  143202. */
  143203. /** @hidden */
  143204. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143205. /** @hidden */
  143206. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143207. /**
  143208. * Create a new AnisotropyBlock
  143209. * @param name defines the block name
  143210. */
  143211. constructor(name: string);
  143212. /**
  143213. * Initialize the block and prepare the context for build
  143214. * @param state defines the state that will be used for the build
  143215. */
  143216. initialize(state: NodeMaterialBuildState): void;
  143217. /**
  143218. * Gets the current class name
  143219. * @returns the class name
  143220. */
  143221. getClassName(): string;
  143222. /**
  143223. * Gets the intensity input component
  143224. */
  143225. get intensity(): NodeMaterialConnectionPoint;
  143226. /**
  143227. * Gets the direction input component
  143228. */
  143229. get direction(): NodeMaterialConnectionPoint;
  143230. /**
  143231. * Gets the texture input component
  143232. */
  143233. get texture(): NodeMaterialConnectionPoint;
  143234. /**
  143235. * Gets the uv input component
  143236. */
  143237. get uv(): NodeMaterialConnectionPoint;
  143238. /**
  143239. * Gets the worldTangent input component
  143240. */
  143241. get worldTangent(): NodeMaterialConnectionPoint;
  143242. /**
  143243. * Gets the anisotropy object output component
  143244. */
  143245. get anisotropy(): NodeMaterialConnectionPoint;
  143246. private _generateTBNSpace;
  143247. /**
  143248. * Gets the main code of the block (fragment side)
  143249. * @param state current state of the node material building
  143250. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143251. * @returns the shader code
  143252. */
  143253. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143255. protected _buildBlock(state: NodeMaterialBuildState): this;
  143256. }
  143257. }
  143258. declare module BABYLON {
  143259. /**
  143260. * Block used to implement the clear coat module of the PBR material
  143261. */
  143262. export class ClearCoatBlock extends NodeMaterialBlock {
  143263. private _scene;
  143264. /**
  143265. * Create a new ClearCoatBlock
  143266. * @param name defines the block name
  143267. */
  143268. constructor(name: string);
  143269. /**
  143270. * Initialize the block and prepare the context for build
  143271. * @param state defines the state that will be used for the build
  143272. */
  143273. initialize(state: NodeMaterialBuildState): void;
  143274. /**
  143275. * Gets the current class name
  143276. * @returns the class name
  143277. */
  143278. getClassName(): string;
  143279. /**
  143280. * Gets the intensity input component
  143281. */
  143282. get intensity(): NodeMaterialConnectionPoint;
  143283. /**
  143284. * Gets the roughness input component
  143285. */
  143286. get roughness(): NodeMaterialConnectionPoint;
  143287. /**
  143288. * Gets the ior input component
  143289. */
  143290. get ior(): NodeMaterialConnectionPoint;
  143291. /**
  143292. * Gets the texture input component
  143293. */
  143294. get texture(): NodeMaterialConnectionPoint;
  143295. /**
  143296. * Gets the bump texture input component
  143297. */
  143298. get bumpTexture(): NodeMaterialConnectionPoint;
  143299. /**
  143300. * Gets the uv input component
  143301. */
  143302. get uv(): NodeMaterialConnectionPoint;
  143303. /**
  143304. * Gets the tint color input component
  143305. */
  143306. get tintColor(): NodeMaterialConnectionPoint;
  143307. /**
  143308. * Gets the tint "at distance" input component
  143309. */
  143310. get tintAtDistance(): NodeMaterialConnectionPoint;
  143311. /**
  143312. * Gets the tint thickness input component
  143313. */
  143314. get tintThickness(): NodeMaterialConnectionPoint;
  143315. /**
  143316. * Gets the world tangent input component
  143317. */
  143318. get worldTangent(): NodeMaterialConnectionPoint;
  143319. /**
  143320. * Gets the clear coat object output component
  143321. */
  143322. get clearcoat(): NodeMaterialConnectionPoint;
  143323. autoConfigure(material: NodeMaterial): void;
  143324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143326. private _generateTBNSpace;
  143327. /**
  143328. * Gets the main code of the block (fragment side)
  143329. * @param state current state of the node material building
  143330. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143331. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143332. * @param worldPosVarName name of the variable holding the world position
  143333. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143334. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143335. * @param worldNormalVarName name of the variable holding the world normal
  143336. * @returns the shader code
  143337. */
  143338. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143339. protected _buildBlock(state: NodeMaterialBuildState): this;
  143340. }
  143341. }
  143342. declare module BABYLON {
  143343. /**
  143344. * Block used to implement the sub surface module of the PBR material
  143345. */
  143346. export class SubSurfaceBlock extends NodeMaterialBlock {
  143347. /**
  143348. * Create a new SubSurfaceBlock
  143349. * @param name defines the block name
  143350. */
  143351. constructor(name: string);
  143352. /**
  143353. * Stores the intensity of the different subsurface effects in the thickness texture.
  143354. * * the green channel is the translucency intensity.
  143355. * * the blue channel is the scattering intensity.
  143356. * * the alpha channel is the refraction intensity.
  143357. */
  143358. useMaskFromThicknessTexture: boolean;
  143359. /**
  143360. * Initialize the block and prepare the context for build
  143361. * @param state defines the state that will be used for the build
  143362. */
  143363. initialize(state: NodeMaterialBuildState): void;
  143364. /**
  143365. * Gets the current class name
  143366. * @returns the class name
  143367. */
  143368. getClassName(): string;
  143369. /**
  143370. * Gets the min thickness input component
  143371. */
  143372. get minThickness(): NodeMaterialConnectionPoint;
  143373. /**
  143374. * Gets the max thickness input component
  143375. */
  143376. get maxThickness(): NodeMaterialConnectionPoint;
  143377. /**
  143378. * Gets the thickness texture component
  143379. */
  143380. get thicknessTexture(): NodeMaterialConnectionPoint;
  143381. /**
  143382. * Gets the tint color input component
  143383. */
  143384. get tintColor(): NodeMaterialConnectionPoint;
  143385. /**
  143386. * Gets the translucency intensity input component
  143387. */
  143388. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143389. /**
  143390. * Gets the translucency diffusion distance input component
  143391. */
  143392. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143393. /**
  143394. * Gets the refraction object parameters
  143395. */
  143396. get refraction(): NodeMaterialConnectionPoint;
  143397. /**
  143398. * Gets the sub surface object output component
  143399. */
  143400. get subsurface(): NodeMaterialConnectionPoint;
  143401. autoConfigure(material: NodeMaterial): void;
  143402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143403. /**
  143404. * Gets the main code of the block (fragment side)
  143405. * @param state current state of the node material building
  143406. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143407. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143408. * @param worldPosVarName name of the variable holding the world position
  143409. * @returns the shader code
  143410. */
  143411. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143412. protected _buildBlock(state: NodeMaterialBuildState): this;
  143413. }
  143414. }
  143415. declare module BABYLON {
  143416. /**
  143417. * Block used to implement the PBR metallic/roughness model
  143418. */
  143419. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143420. /**
  143421. * Gets or sets the light associated with this block
  143422. */
  143423. light: Nullable<Light>;
  143424. private _lightId;
  143425. private _scene;
  143426. private _environmentBRDFTexture;
  143427. private _environmentBrdfSamplerName;
  143428. private _vNormalWName;
  143429. private _invertNormalName;
  143430. /**
  143431. * Create a new ReflectionBlock
  143432. * @param name defines the block name
  143433. */
  143434. constructor(name: string);
  143435. /**
  143436. * Intensity of the direct lights e.g. the four lights available in your scene.
  143437. * This impacts both the direct diffuse and specular highlights.
  143438. */
  143439. directIntensity: number;
  143440. /**
  143441. * Intensity of the environment e.g. how much the environment will light the object
  143442. * either through harmonics for rough material or through the refelction for shiny ones.
  143443. */
  143444. environmentIntensity: number;
  143445. /**
  143446. * This is a special control allowing the reduction of the specular highlights coming from the
  143447. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143448. */
  143449. specularIntensity: number;
  143450. /**
  143451. * Defines the falloff type used in this material.
  143452. * It by default is Physical.
  143453. */
  143454. lightFalloff: number;
  143455. /**
  143456. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143457. */
  143458. useAlphaFromAlbedoTexture: boolean;
  143459. /**
  143460. * Specifies that alpha test should be used
  143461. */
  143462. useAlphaTest: boolean;
  143463. /**
  143464. * Defines the alpha limits in alpha test mode.
  143465. */
  143466. alphaTestCutoff: number;
  143467. /**
  143468. * Specifies that alpha blending should be used
  143469. */
  143470. useAlphaBlending: boolean;
  143471. /**
  143472. * Defines if the alpha value should be determined via the rgb values.
  143473. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143474. */
  143475. opacityRGB: boolean;
  143476. /**
  143477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143479. */
  143480. useRadianceOverAlpha: boolean;
  143481. /**
  143482. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143483. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143484. */
  143485. useSpecularOverAlpha: boolean;
  143486. /**
  143487. * Enables specular anti aliasing in the PBR shader.
  143488. * It will both interacts on the Geometry for analytical and IBL lighting.
  143489. * It also prefilter the roughness map based on the bump values.
  143490. */
  143491. enableSpecularAntiAliasing: boolean;
  143492. /**
  143493. * Enables realtime filtering on the texture.
  143494. */
  143495. realTimeFiltering: boolean;
  143496. /**
  143497. * Quality switch for realtime filtering
  143498. */
  143499. realTimeFilteringQuality: number;
  143500. /**
  143501. * Defines if the material uses energy conservation.
  143502. */
  143503. useEnergyConservation: boolean;
  143504. /**
  143505. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143506. * too much the area relying on ambient texture to define their ambient occlusion.
  143507. */
  143508. useRadianceOcclusion: boolean;
  143509. /**
  143510. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143511. * makes the reflect vector face the model (under horizon).
  143512. */
  143513. useHorizonOcclusion: boolean;
  143514. /**
  143515. * If set to true, no lighting calculations will be applied.
  143516. */
  143517. unlit: boolean;
  143518. /**
  143519. * Force normal to face away from face.
  143520. */
  143521. forceNormalForward: boolean;
  143522. /**
  143523. * Defines the material debug mode.
  143524. * It helps seeing only some components of the material while troubleshooting.
  143525. */
  143526. debugMode: number;
  143527. /**
  143528. * Specify from where on screen the debug mode should start.
  143529. * The value goes from -1 (full screen) to 1 (not visible)
  143530. * It helps with side by side comparison against the final render
  143531. * This defaults to 0
  143532. */
  143533. debugLimit: number;
  143534. /**
  143535. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143536. * You can use the factor to better multiply the final value.
  143537. */
  143538. debugFactor: number;
  143539. /**
  143540. * Initialize the block and prepare the context for build
  143541. * @param state defines the state that will be used for the build
  143542. */
  143543. initialize(state: NodeMaterialBuildState): void;
  143544. /**
  143545. * Gets the current class name
  143546. * @returns the class name
  143547. */
  143548. getClassName(): string;
  143549. /**
  143550. * Gets the world position input component
  143551. */
  143552. get worldPosition(): NodeMaterialConnectionPoint;
  143553. /**
  143554. * Gets the world normal input component
  143555. */
  143556. get worldNormal(): NodeMaterialConnectionPoint;
  143557. /**
  143558. * Gets the perturbed normal input component
  143559. */
  143560. get perturbedNormal(): NodeMaterialConnectionPoint;
  143561. /**
  143562. * Gets the camera position input component
  143563. */
  143564. get cameraPosition(): NodeMaterialConnectionPoint;
  143565. /**
  143566. * Gets the base color input component
  143567. */
  143568. get baseColor(): NodeMaterialConnectionPoint;
  143569. /**
  143570. * Gets the opacity texture input component
  143571. */
  143572. get opacityTexture(): NodeMaterialConnectionPoint;
  143573. /**
  143574. * Gets the ambient color input component
  143575. */
  143576. get ambientColor(): NodeMaterialConnectionPoint;
  143577. /**
  143578. * Gets the reflectivity object parameters
  143579. */
  143580. get reflectivity(): NodeMaterialConnectionPoint;
  143581. /**
  143582. * Gets the ambient occlusion object parameters
  143583. */
  143584. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143585. /**
  143586. * Gets the reflection object parameters
  143587. */
  143588. get reflection(): NodeMaterialConnectionPoint;
  143589. /**
  143590. * Gets the sheen object parameters
  143591. */
  143592. get sheen(): NodeMaterialConnectionPoint;
  143593. /**
  143594. * Gets the clear coat object parameters
  143595. */
  143596. get clearcoat(): NodeMaterialConnectionPoint;
  143597. /**
  143598. * Gets the sub surface object parameters
  143599. */
  143600. get subsurface(): NodeMaterialConnectionPoint;
  143601. /**
  143602. * Gets the anisotropy object parameters
  143603. */
  143604. get anisotropy(): NodeMaterialConnectionPoint;
  143605. /**
  143606. * Gets the ambient output component
  143607. */
  143608. get ambient(): NodeMaterialConnectionPoint;
  143609. /**
  143610. * Gets the diffuse output component
  143611. */
  143612. get diffuse(): NodeMaterialConnectionPoint;
  143613. /**
  143614. * Gets the specular output component
  143615. */
  143616. get specular(): NodeMaterialConnectionPoint;
  143617. /**
  143618. * Gets the sheen output component
  143619. */
  143620. get sheenDir(): NodeMaterialConnectionPoint;
  143621. /**
  143622. * Gets the clear coat output component
  143623. */
  143624. get clearcoatDir(): NodeMaterialConnectionPoint;
  143625. /**
  143626. * Gets the indirect diffuse output component
  143627. */
  143628. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143629. /**
  143630. * Gets the indirect specular output component
  143631. */
  143632. get specularIndirect(): NodeMaterialConnectionPoint;
  143633. /**
  143634. * Gets the indirect sheen output component
  143635. */
  143636. get sheenIndirect(): NodeMaterialConnectionPoint;
  143637. /**
  143638. * Gets the indirect clear coat output component
  143639. */
  143640. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143641. /**
  143642. * Gets the refraction output component
  143643. */
  143644. get refraction(): NodeMaterialConnectionPoint;
  143645. /**
  143646. * Gets the global lighting output component
  143647. */
  143648. get lighting(): NodeMaterialConnectionPoint;
  143649. /**
  143650. * Gets the shadow output component
  143651. */
  143652. get shadow(): NodeMaterialConnectionPoint;
  143653. /**
  143654. * Gets the alpha output component
  143655. */
  143656. get alpha(): NodeMaterialConnectionPoint;
  143657. autoConfigure(material: NodeMaterial): void;
  143658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143659. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143661. private _injectVertexCode;
  143662. /**
  143663. * Gets the code corresponding to the albedo/opacity module
  143664. * @returns the shader code
  143665. */
  143666. getAlbedoOpacityCode(): string;
  143667. protected _buildBlock(state: NodeMaterialBuildState): this;
  143668. protected _dumpPropertiesCode(): string;
  143669. serialize(): any;
  143670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143671. }
  143672. }
  143673. declare module BABYLON {
  143674. /**
  143675. * Block used to compute value of one parameter modulo another
  143676. */
  143677. export class ModBlock extends NodeMaterialBlock {
  143678. /**
  143679. * Creates a new ModBlock
  143680. * @param name defines the block name
  143681. */
  143682. constructor(name: string);
  143683. /**
  143684. * Gets the current class name
  143685. * @returns the class name
  143686. */
  143687. getClassName(): string;
  143688. /**
  143689. * Gets the left operand input component
  143690. */
  143691. get left(): NodeMaterialConnectionPoint;
  143692. /**
  143693. * Gets the right operand input component
  143694. */
  143695. get right(): NodeMaterialConnectionPoint;
  143696. /**
  143697. * Gets the output component
  143698. */
  143699. get output(): NodeMaterialConnectionPoint;
  143700. protected _buildBlock(state: NodeMaterialBuildState): this;
  143701. }
  143702. }
  143703. declare module BABYLON {
  143704. /**
  143705. * Helper class to push actions to a pool of workers.
  143706. */
  143707. export class WorkerPool implements IDisposable {
  143708. private _workerInfos;
  143709. private _pendingActions;
  143710. /**
  143711. * Constructor
  143712. * @param workers Array of workers to use for actions
  143713. */
  143714. constructor(workers: Array<Worker>);
  143715. /**
  143716. * Terminates all workers and clears any pending actions.
  143717. */
  143718. dispose(): void;
  143719. /**
  143720. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143721. * pended until a worker has completed its action.
  143722. * @param action The action to perform. Call onComplete when the action is complete.
  143723. */
  143724. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143725. private _execute;
  143726. }
  143727. }
  143728. declare module BABYLON {
  143729. /**
  143730. * Configuration for Draco compression
  143731. */
  143732. export interface IDracoCompressionConfiguration {
  143733. /**
  143734. * Configuration for the decoder.
  143735. */
  143736. decoder: {
  143737. /**
  143738. * The url to the WebAssembly module.
  143739. */
  143740. wasmUrl?: string;
  143741. /**
  143742. * The url to the WebAssembly binary.
  143743. */
  143744. wasmBinaryUrl?: string;
  143745. /**
  143746. * The url to the fallback JavaScript module.
  143747. */
  143748. fallbackUrl?: string;
  143749. };
  143750. }
  143751. /**
  143752. * Draco compression (https://google.github.io/draco/)
  143753. *
  143754. * This class wraps the Draco module.
  143755. *
  143756. * **Encoder**
  143757. *
  143758. * The encoder is not currently implemented.
  143759. *
  143760. * **Decoder**
  143761. *
  143762. * 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.
  143763. *
  143764. * To update the configuration, use the following code:
  143765. * ```javascript
  143766. * DracoCompression.Configuration = {
  143767. * decoder: {
  143768. * wasmUrl: "<url to the WebAssembly library>",
  143769. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143770. * fallbackUrl: "<url to the fallback JavaScript library>",
  143771. * }
  143772. * };
  143773. * ```
  143774. *
  143775. * 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.
  143776. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143777. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143778. *
  143779. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143780. * ```javascript
  143781. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143782. * ```
  143783. *
  143784. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143785. */
  143786. export class DracoCompression implements IDisposable {
  143787. private _workerPoolPromise?;
  143788. private _decoderModulePromise?;
  143789. /**
  143790. * The configuration. Defaults to the following urls:
  143791. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143792. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143793. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143794. */
  143795. static Configuration: IDracoCompressionConfiguration;
  143796. /**
  143797. * Returns true if the decoder configuration is available.
  143798. */
  143799. static get DecoderAvailable(): boolean;
  143800. /**
  143801. * Default number of workers to create when creating the draco compression object.
  143802. */
  143803. static DefaultNumWorkers: number;
  143804. private static GetDefaultNumWorkers;
  143805. private static _Default;
  143806. /**
  143807. * Default instance for the draco compression object.
  143808. */
  143809. static get Default(): DracoCompression;
  143810. /**
  143811. * Constructor
  143812. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143813. */
  143814. constructor(numWorkers?: number);
  143815. /**
  143816. * Stop all async operations and release resources.
  143817. */
  143818. dispose(): void;
  143819. /**
  143820. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143821. * @returns a promise that resolves when ready
  143822. */
  143823. whenReadyAsync(): Promise<void>;
  143824. /**
  143825. * Decode Draco compressed mesh data to vertex data.
  143826. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143827. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143828. * @returns A promise that resolves with the decoded vertex data
  143829. */
  143830. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143831. [kind: string]: number;
  143832. }): Promise<VertexData>;
  143833. }
  143834. }
  143835. declare module BABYLON {
  143836. /**
  143837. * Class for building Constructive Solid Geometry
  143838. */
  143839. export class CSG {
  143840. private polygons;
  143841. /**
  143842. * The world matrix
  143843. */
  143844. matrix: Matrix;
  143845. /**
  143846. * Stores the position
  143847. */
  143848. position: Vector3;
  143849. /**
  143850. * Stores the rotation
  143851. */
  143852. rotation: Vector3;
  143853. /**
  143854. * Stores the rotation quaternion
  143855. */
  143856. rotationQuaternion: Nullable<Quaternion>;
  143857. /**
  143858. * Stores the scaling vector
  143859. */
  143860. scaling: Vector3;
  143861. /**
  143862. * Convert the Mesh to CSG
  143863. * @param mesh The Mesh to convert to CSG
  143864. * @returns A new CSG from the Mesh
  143865. */
  143866. static FromMesh(mesh: Mesh): CSG;
  143867. /**
  143868. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143869. * @param polygons Polygons used to construct a CSG solid
  143870. */
  143871. private static FromPolygons;
  143872. /**
  143873. * Clones, or makes a deep copy, of the CSG
  143874. * @returns A new CSG
  143875. */
  143876. clone(): CSG;
  143877. /**
  143878. * Unions this CSG with another CSG
  143879. * @param csg The CSG to union against this CSG
  143880. * @returns The unioned CSG
  143881. */
  143882. union(csg: CSG): CSG;
  143883. /**
  143884. * Unions this CSG with another CSG in place
  143885. * @param csg The CSG to union against this CSG
  143886. */
  143887. unionInPlace(csg: CSG): void;
  143888. /**
  143889. * Subtracts this CSG with another CSG
  143890. * @param csg The CSG to subtract against this CSG
  143891. * @returns A new CSG
  143892. */
  143893. subtract(csg: CSG): CSG;
  143894. /**
  143895. * Subtracts this CSG with another CSG in place
  143896. * @param csg The CSG to subtact against this CSG
  143897. */
  143898. subtractInPlace(csg: CSG): void;
  143899. /**
  143900. * Intersect this CSG with another CSG
  143901. * @param csg The CSG to intersect against this CSG
  143902. * @returns A new CSG
  143903. */
  143904. intersect(csg: CSG): CSG;
  143905. /**
  143906. * Intersects this CSG with another CSG in place
  143907. * @param csg The CSG to intersect against this CSG
  143908. */
  143909. intersectInPlace(csg: CSG): void;
  143910. /**
  143911. * Return a new CSG solid with solid and empty space switched. This solid is
  143912. * not modified.
  143913. * @returns A new CSG solid with solid and empty space switched
  143914. */
  143915. inverse(): CSG;
  143916. /**
  143917. * Inverses the CSG in place
  143918. */
  143919. inverseInPlace(): void;
  143920. /**
  143921. * This is used to keep meshes transformations so they can be restored
  143922. * when we build back a Babylon Mesh
  143923. * NB : All CSG operations are performed in world coordinates
  143924. * @param csg The CSG to copy the transform attributes from
  143925. * @returns This CSG
  143926. */
  143927. copyTransformAttributes(csg: CSG): CSG;
  143928. /**
  143929. * Build Raw mesh from CSG
  143930. * Coordinates here are in world space
  143931. * @param name The name of the mesh geometry
  143932. * @param scene The Scene
  143933. * @param keepSubMeshes Specifies if the submeshes should be kept
  143934. * @returns A new Mesh
  143935. */
  143936. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143937. /**
  143938. * Build Mesh from CSG taking material and transforms into account
  143939. * @param name The name of the Mesh
  143940. * @param material The material of the Mesh
  143941. * @param scene The Scene
  143942. * @param keepSubMeshes Specifies if submeshes should be kept
  143943. * @returns The new Mesh
  143944. */
  143945. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143946. }
  143947. }
  143948. declare module BABYLON {
  143949. /**
  143950. * Class used to create a trail following a mesh
  143951. */
  143952. export class TrailMesh extends Mesh {
  143953. private _generator;
  143954. private _autoStart;
  143955. private _running;
  143956. private _diameter;
  143957. private _length;
  143958. private _sectionPolygonPointsCount;
  143959. private _sectionVectors;
  143960. private _sectionNormalVectors;
  143961. private _beforeRenderObserver;
  143962. /**
  143963. * @constructor
  143964. * @param name The value used by scene.getMeshByName() to do a lookup.
  143965. * @param generator The mesh or transform node to generate a trail.
  143966. * @param scene The scene to add this mesh to.
  143967. * @param diameter Diameter of trailing mesh. Default is 1.
  143968. * @param length Length of trailing mesh. Default is 60.
  143969. * @param autoStart Automatically start trailing mesh. Default true.
  143970. */
  143971. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143972. /**
  143973. * "TrailMesh"
  143974. * @returns "TrailMesh"
  143975. */
  143976. getClassName(): string;
  143977. private _createMesh;
  143978. /**
  143979. * Start trailing mesh.
  143980. */
  143981. start(): void;
  143982. /**
  143983. * Stop trailing mesh.
  143984. */
  143985. stop(): void;
  143986. /**
  143987. * Update trailing mesh geometry.
  143988. */
  143989. update(): void;
  143990. /**
  143991. * Returns a new TrailMesh object.
  143992. * @param name is a string, the name given to the new mesh
  143993. * @param newGenerator use new generator object for cloned trail mesh
  143994. * @returns a new mesh
  143995. */
  143996. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143997. /**
  143998. * Serializes this trail mesh
  143999. * @param serializationObject object to write serialization to
  144000. */
  144001. serialize(serializationObject: any): void;
  144002. /**
  144003. * Parses a serialized trail mesh
  144004. * @param parsedMesh the serialized mesh
  144005. * @param scene the scene to create the trail mesh in
  144006. * @returns the created trail mesh
  144007. */
  144008. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144009. }
  144010. }
  144011. declare module BABYLON {
  144012. /**
  144013. * Class containing static functions to help procedurally build meshes
  144014. */
  144015. export class TiledBoxBuilder {
  144016. /**
  144017. * Creates a box mesh
  144018. * 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)
  144019. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144023. * @param name defines the name of the mesh
  144024. * @param options defines the options used to create the mesh
  144025. * @param scene defines the hosting scene
  144026. * @returns the box mesh
  144027. */
  144028. static CreateTiledBox(name: string, options: {
  144029. pattern?: number;
  144030. width?: number;
  144031. height?: number;
  144032. depth?: number;
  144033. tileSize?: number;
  144034. tileWidth?: number;
  144035. tileHeight?: number;
  144036. alignHorizontal?: number;
  144037. alignVertical?: number;
  144038. faceUV?: Vector4[];
  144039. faceColors?: Color4[];
  144040. sideOrientation?: number;
  144041. updatable?: boolean;
  144042. }, scene?: Nullable<Scene>): Mesh;
  144043. }
  144044. }
  144045. declare module BABYLON {
  144046. /**
  144047. * Class containing static functions to help procedurally build meshes
  144048. */
  144049. export class TorusKnotBuilder {
  144050. /**
  144051. * Creates a torus knot mesh
  144052. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144053. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144054. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144055. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144059. * @param name defines the name of the mesh
  144060. * @param options defines the options used to create the mesh
  144061. * @param scene defines the hosting scene
  144062. * @returns the torus knot mesh
  144063. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144064. */
  144065. static CreateTorusKnot(name: string, options: {
  144066. radius?: number;
  144067. tube?: number;
  144068. radialSegments?: number;
  144069. tubularSegments?: number;
  144070. p?: number;
  144071. q?: number;
  144072. updatable?: boolean;
  144073. sideOrientation?: number;
  144074. frontUVs?: Vector4;
  144075. backUVs?: Vector4;
  144076. }, scene: any): Mesh;
  144077. }
  144078. }
  144079. declare module BABYLON {
  144080. /**
  144081. * Polygon
  144082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144083. */
  144084. export class Polygon {
  144085. /**
  144086. * Creates a rectangle
  144087. * @param xmin bottom X coord
  144088. * @param ymin bottom Y coord
  144089. * @param xmax top X coord
  144090. * @param ymax top Y coord
  144091. * @returns points that make the resulting rectation
  144092. */
  144093. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  144094. /**
  144095. * Creates a circle
  144096. * @param radius radius of circle
  144097. * @param cx scale in x
  144098. * @param cy scale in y
  144099. * @param numberOfSides number of sides that make up the circle
  144100. * @returns points that make the resulting circle
  144101. */
  144102. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  144103. /**
  144104. * Creates a polygon from input string
  144105. * @param input Input polygon data
  144106. * @returns the parsed points
  144107. */
  144108. static Parse(input: string): Vector2[];
  144109. /**
  144110. * Starts building a polygon from x and y coordinates
  144111. * @param x x coordinate
  144112. * @param y y coordinate
  144113. * @returns the started path2
  144114. */
  144115. static StartingAt(x: number, y: number): Path2;
  144116. }
  144117. /**
  144118. * Builds a polygon
  144119. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144120. */
  144121. export class PolygonMeshBuilder {
  144122. private _points;
  144123. private _outlinepoints;
  144124. private _holes;
  144125. private _name;
  144126. private _scene;
  144127. private _epoints;
  144128. private _eholes;
  144129. private _addToepoint;
  144130. /**
  144131. * Babylon reference to the earcut plugin.
  144132. */
  144133. bjsEarcut: any;
  144134. /**
  144135. * Creates a PolygonMeshBuilder
  144136. * @param name name of the builder
  144137. * @param contours Path of the polygon
  144138. * @param scene scene to add to when creating the mesh
  144139. * @param earcutInjection can be used to inject your own earcut reference
  144140. */
  144141. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144142. /**
  144143. * Adds a whole within the polygon
  144144. * @param hole Array of points defining the hole
  144145. * @returns this
  144146. */
  144147. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144148. /**
  144149. * Creates the polygon
  144150. * @param updatable If the mesh should be updatable
  144151. * @param depth The depth of the mesh created
  144152. * @returns the created mesh
  144153. */
  144154. build(updatable?: boolean, depth?: number): Mesh;
  144155. /**
  144156. * Creates the polygon
  144157. * @param depth The depth of the mesh created
  144158. * @returns the created VertexData
  144159. */
  144160. buildVertexData(depth?: number): VertexData;
  144161. /**
  144162. * Adds a side to the polygon
  144163. * @param positions points that make the polygon
  144164. * @param normals normals of the polygon
  144165. * @param uvs uvs of the polygon
  144166. * @param indices indices of the polygon
  144167. * @param bounds bounds of the polygon
  144168. * @param points points of the polygon
  144169. * @param depth depth of the polygon
  144170. * @param flip flip of the polygon
  144171. */
  144172. private addSide;
  144173. }
  144174. }
  144175. declare module BABYLON {
  144176. /**
  144177. * Class containing static functions to help procedurally build meshes
  144178. */
  144179. export class PolygonBuilder {
  144180. /**
  144181. * Creates a polygon mesh
  144182. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144183. * * 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
  144184. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144187. * * Remember you can only change the shape positions, not their number when updating a polygon
  144188. * @param name defines the name of the mesh
  144189. * @param options defines the options used to create the mesh
  144190. * @param scene defines the hosting scene
  144191. * @param earcutInjection can be used to inject your own earcut reference
  144192. * @returns the polygon mesh
  144193. */
  144194. static CreatePolygon(name: string, options: {
  144195. shape: Vector3[];
  144196. holes?: Vector3[][];
  144197. depth?: number;
  144198. faceUV?: Vector4[];
  144199. faceColors?: Color4[];
  144200. updatable?: boolean;
  144201. sideOrientation?: number;
  144202. frontUVs?: Vector4;
  144203. backUVs?: Vector4;
  144204. wrap?: boolean;
  144205. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144206. /**
  144207. * Creates an extruded polygon mesh, with depth in the Y direction.
  144208. * * 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)
  144209. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144210. * @param name defines the name of the mesh
  144211. * @param options defines the options used to create the mesh
  144212. * @param scene defines the hosting scene
  144213. * @param earcutInjection can be used to inject your own earcut reference
  144214. * @returns the polygon mesh
  144215. */
  144216. static ExtrudePolygon(name: string, options: {
  144217. shape: Vector3[];
  144218. holes?: Vector3[][];
  144219. depth?: number;
  144220. faceUV?: Vector4[];
  144221. faceColors?: Color4[];
  144222. updatable?: boolean;
  144223. sideOrientation?: number;
  144224. frontUVs?: Vector4;
  144225. backUVs?: Vector4;
  144226. wrap?: boolean;
  144227. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144228. }
  144229. }
  144230. declare module BABYLON {
  144231. /**
  144232. * Class containing static functions to help procedurally build meshes
  144233. */
  144234. export class LatheBuilder {
  144235. /**
  144236. * Creates lathe mesh.
  144237. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144238. * * 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
  144239. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144240. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144241. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144242. * * 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
  144243. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144244. * * 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
  144245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144249. * @param name defines the name of the mesh
  144250. * @param options defines the options used to create the mesh
  144251. * @param scene defines the hosting scene
  144252. * @returns the lathe mesh
  144253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144254. */
  144255. static CreateLathe(name: string, options: {
  144256. shape: Vector3[];
  144257. radius?: number;
  144258. tessellation?: number;
  144259. clip?: number;
  144260. arc?: number;
  144261. closed?: boolean;
  144262. updatable?: boolean;
  144263. sideOrientation?: number;
  144264. frontUVs?: Vector4;
  144265. backUVs?: Vector4;
  144266. cap?: number;
  144267. invertUV?: boolean;
  144268. }, scene?: Nullable<Scene>): Mesh;
  144269. }
  144270. }
  144271. declare module BABYLON {
  144272. /**
  144273. * Class containing static functions to help procedurally build meshes
  144274. */
  144275. export class TiledPlaneBuilder {
  144276. /**
  144277. * Creates a tiled plane mesh
  144278. * * The parameter `pattern` will, depending on value, do nothing or
  144279. * * * flip (reflect about central vertical) alternate tiles across and up
  144280. * * * flip every tile on alternate rows
  144281. * * * rotate (180 degs) alternate tiles across and up
  144282. * * * rotate every tile on alternate rows
  144283. * * * flip and rotate alternate tiles across and up
  144284. * * * flip and rotate every tile on alternate rows
  144285. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144286. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144289. * * 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)
  144290. * * 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)
  144291. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144292. * @param name defines the name of the mesh
  144293. * @param options defines the options used to create the mesh
  144294. * @param scene defines the hosting scene
  144295. * @returns the box mesh
  144296. */
  144297. static CreateTiledPlane(name: string, options: {
  144298. pattern?: number;
  144299. tileSize?: number;
  144300. tileWidth?: number;
  144301. tileHeight?: number;
  144302. size?: number;
  144303. width?: number;
  144304. height?: number;
  144305. alignHorizontal?: number;
  144306. alignVertical?: number;
  144307. sideOrientation?: number;
  144308. frontUVs?: Vector4;
  144309. backUVs?: Vector4;
  144310. updatable?: boolean;
  144311. }, scene?: Nullable<Scene>): Mesh;
  144312. }
  144313. }
  144314. declare module BABYLON {
  144315. /**
  144316. * Class containing static functions to help procedurally build meshes
  144317. */
  144318. export class TubeBuilder {
  144319. /**
  144320. * Creates a tube mesh.
  144321. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144322. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144323. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144324. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144325. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144326. * * 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)
  144327. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144328. * * 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
  144329. * * 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
  144330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144334. * @param name defines the name of the mesh
  144335. * @param options defines the options used to create the mesh
  144336. * @param scene defines the hosting scene
  144337. * @returns the tube mesh
  144338. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144339. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144340. */
  144341. static CreateTube(name: string, options: {
  144342. path: Vector3[];
  144343. radius?: number;
  144344. tessellation?: number;
  144345. radiusFunction?: {
  144346. (i: number, distance: number): number;
  144347. };
  144348. cap?: number;
  144349. arc?: number;
  144350. updatable?: boolean;
  144351. sideOrientation?: number;
  144352. frontUVs?: Vector4;
  144353. backUVs?: Vector4;
  144354. instance?: Mesh;
  144355. invertUV?: boolean;
  144356. }, scene?: Nullable<Scene>): Mesh;
  144357. }
  144358. }
  144359. declare module BABYLON {
  144360. /**
  144361. * Class containing static functions to help procedurally build meshes
  144362. */
  144363. export class IcoSphereBuilder {
  144364. /**
  144365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144367. * * 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`)
  144368. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144369. * * 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
  144370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144373. * @param name defines the name of the mesh
  144374. * @param options defines the options used to create the mesh
  144375. * @param scene defines the hosting scene
  144376. * @returns the icosahedron mesh
  144377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144378. */
  144379. static CreateIcoSphere(name: string, options: {
  144380. radius?: number;
  144381. radiusX?: number;
  144382. radiusY?: number;
  144383. radiusZ?: number;
  144384. flat?: boolean;
  144385. subdivisions?: number;
  144386. sideOrientation?: number;
  144387. frontUVs?: Vector4;
  144388. backUVs?: Vector4;
  144389. updatable?: boolean;
  144390. }, scene?: Nullable<Scene>): Mesh;
  144391. }
  144392. }
  144393. declare module BABYLON {
  144394. /**
  144395. * Class containing static functions to help procedurally build meshes
  144396. */
  144397. export class DecalBuilder {
  144398. /**
  144399. * Creates a decal mesh.
  144400. * 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
  144401. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144402. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144403. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144404. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144405. * @param name defines the name of the mesh
  144406. * @param sourceMesh defines the mesh where the decal must be applied
  144407. * @param options defines the options used to create the mesh
  144408. * @param scene defines the hosting scene
  144409. * @returns the decal mesh
  144410. * @see https://doc.babylonjs.com/how_to/decals
  144411. */
  144412. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144413. position?: Vector3;
  144414. normal?: Vector3;
  144415. size?: Vector3;
  144416. angle?: number;
  144417. }): Mesh;
  144418. }
  144419. }
  144420. declare module BABYLON {
  144421. /**
  144422. * Class containing static functions to help procedurally build meshes
  144423. */
  144424. export class MeshBuilder {
  144425. /**
  144426. * Creates a box mesh
  144427. * * The parameter `size` sets the size (float) of each box side (default 1)
  144428. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144429. * * 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)
  144430. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144434. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144435. * @param name defines the name of the mesh
  144436. * @param options defines the options used to create the mesh
  144437. * @param scene defines the hosting scene
  144438. * @returns the box mesh
  144439. */
  144440. static CreateBox(name: string, options: {
  144441. size?: number;
  144442. width?: number;
  144443. height?: number;
  144444. depth?: number;
  144445. faceUV?: Vector4[];
  144446. faceColors?: Color4[];
  144447. sideOrientation?: number;
  144448. frontUVs?: Vector4;
  144449. backUVs?: Vector4;
  144450. wrap?: boolean;
  144451. topBaseAt?: number;
  144452. bottomBaseAt?: number;
  144453. updatable?: boolean;
  144454. }, scene?: Nullable<Scene>): Mesh;
  144455. /**
  144456. * Creates a tiled box mesh
  144457. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144459. * @param name defines the name of the mesh
  144460. * @param options defines the options used to create the mesh
  144461. * @param scene defines the hosting scene
  144462. * @returns the tiled box mesh
  144463. */
  144464. static CreateTiledBox(name: string, options: {
  144465. pattern?: number;
  144466. size?: number;
  144467. width?: number;
  144468. height?: number;
  144469. depth: number;
  144470. tileSize?: number;
  144471. tileWidth?: number;
  144472. tileHeight?: number;
  144473. faceUV?: Vector4[];
  144474. faceColors?: Color4[];
  144475. alignHorizontal?: number;
  144476. alignVertical?: number;
  144477. sideOrientation?: number;
  144478. updatable?: boolean;
  144479. }, scene?: Nullable<Scene>): Mesh;
  144480. /**
  144481. * Creates a sphere mesh
  144482. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144483. * * 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`)
  144484. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144485. * * 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
  144486. * * 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)
  144487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144490. * @param name defines the name of the mesh
  144491. * @param options defines the options used to create the mesh
  144492. * @param scene defines the hosting scene
  144493. * @returns the sphere mesh
  144494. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144495. */
  144496. static CreateSphere(name: string, options: {
  144497. segments?: number;
  144498. diameter?: number;
  144499. diameterX?: number;
  144500. diameterY?: number;
  144501. diameterZ?: number;
  144502. arc?: number;
  144503. slice?: number;
  144504. sideOrientation?: number;
  144505. frontUVs?: Vector4;
  144506. backUVs?: Vector4;
  144507. updatable?: boolean;
  144508. }, scene?: Nullable<Scene>): Mesh;
  144509. /**
  144510. * Creates a plane polygonal mesh. By default, this is a disc
  144511. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144512. * * 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
  144513. * * 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
  144514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144517. * @param name defines the name of the mesh
  144518. * @param options defines the options used to create the mesh
  144519. * @param scene defines the hosting scene
  144520. * @returns the plane polygonal mesh
  144521. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144522. */
  144523. static CreateDisc(name: string, options: {
  144524. radius?: number;
  144525. tessellation?: number;
  144526. arc?: number;
  144527. updatable?: boolean;
  144528. sideOrientation?: number;
  144529. frontUVs?: Vector4;
  144530. backUVs?: Vector4;
  144531. }, scene?: Nullable<Scene>): Mesh;
  144532. /**
  144533. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144534. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144535. * * 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`)
  144536. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144537. * * 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
  144538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144541. * @param name defines the name of the mesh
  144542. * @param options defines the options used to create the mesh
  144543. * @param scene defines the hosting scene
  144544. * @returns the icosahedron mesh
  144545. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144546. */
  144547. static CreateIcoSphere(name: string, options: {
  144548. radius?: number;
  144549. radiusX?: number;
  144550. radiusY?: number;
  144551. radiusZ?: number;
  144552. flat?: boolean;
  144553. subdivisions?: number;
  144554. sideOrientation?: number;
  144555. frontUVs?: Vector4;
  144556. backUVs?: Vector4;
  144557. updatable?: boolean;
  144558. }, scene?: Nullable<Scene>): Mesh;
  144559. /**
  144560. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144561. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144562. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144563. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144564. * * 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
  144565. * * 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
  144566. * * 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
  144567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144570. * * 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
  144571. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144572. * * 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
  144573. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144575. * @param name defines the name of the mesh
  144576. * @param options defines the options used to create the mesh
  144577. * @param scene defines the hosting scene
  144578. * @returns the ribbon mesh
  144579. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144581. */
  144582. static CreateRibbon(name: string, options: {
  144583. pathArray: Vector3[][];
  144584. closeArray?: boolean;
  144585. closePath?: boolean;
  144586. offset?: number;
  144587. updatable?: boolean;
  144588. sideOrientation?: number;
  144589. frontUVs?: Vector4;
  144590. backUVs?: Vector4;
  144591. instance?: Mesh;
  144592. invertUV?: boolean;
  144593. uvs?: Vector2[];
  144594. colors?: Color4[];
  144595. }, scene?: Nullable<Scene>): Mesh;
  144596. /**
  144597. * Creates a cylinder or a cone mesh
  144598. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144599. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144600. * * 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.
  144601. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144602. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144603. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144604. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144605. * * 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).
  144606. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144607. * * 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).
  144608. * * 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
  144609. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144610. * * 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
  144611. * * 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.
  144612. * * If `enclose` is false, a ring surface is one element.
  144613. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144614. * * 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
  144615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144618. * @param name defines the name of the mesh
  144619. * @param options defines the options used to create the mesh
  144620. * @param scene defines the hosting scene
  144621. * @returns the cylinder mesh
  144622. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144623. */
  144624. static CreateCylinder(name: string, options: {
  144625. height?: number;
  144626. diameterTop?: number;
  144627. diameterBottom?: number;
  144628. diameter?: number;
  144629. tessellation?: number;
  144630. subdivisions?: number;
  144631. arc?: number;
  144632. faceColors?: Color4[];
  144633. faceUV?: Vector4[];
  144634. updatable?: boolean;
  144635. hasRings?: boolean;
  144636. enclose?: boolean;
  144637. cap?: number;
  144638. sideOrientation?: number;
  144639. frontUVs?: Vector4;
  144640. backUVs?: Vector4;
  144641. }, scene?: Nullable<Scene>): Mesh;
  144642. /**
  144643. * Creates a torus mesh
  144644. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144645. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144646. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144648. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144650. * @param name defines the name of the mesh
  144651. * @param options defines the options used to create the mesh
  144652. * @param scene defines the hosting scene
  144653. * @returns the torus mesh
  144654. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144655. */
  144656. static CreateTorus(name: string, options: {
  144657. diameter?: number;
  144658. thickness?: number;
  144659. tessellation?: number;
  144660. updatable?: boolean;
  144661. sideOrientation?: number;
  144662. frontUVs?: Vector4;
  144663. backUVs?: Vector4;
  144664. }, scene?: Nullable<Scene>): Mesh;
  144665. /**
  144666. * Creates a torus knot mesh
  144667. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144668. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144669. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144670. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144674. * @param name defines the name of the mesh
  144675. * @param options defines the options used to create the mesh
  144676. * @param scene defines the hosting scene
  144677. * @returns the torus knot mesh
  144678. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144679. */
  144680. static CreateTorusKnot(name: string, options: {
  144681. radius?: number;
  144682. tube?: number;
  144683. radialSegments?: number;
  144684. tubularSegments?: number;
  144685. p?: number;
  144686. q?: number;
  144687. updatable?: boolean;
  144688. sideOrientation?: number;
  144689. frontUVs?: Vector4;
  144690. backUVs?: Vector4;
  144691. }, scene?: Nullable<Scene>): Mesh;
  144692. /**
  144693. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144694. * * 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
  144695. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144696. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144697. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144698. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144699. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144700. * * 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
  144701. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144704. * @param name defines the name of the new line system
  144705. * @param options defines the options used to create the line system
  144706. * @param scene defines the hosting scene
  144707. * @returns a new line system mesh
  144708. */
  144709. static CreateLineSystem(name: string, options: {
  144710. lines: Vector3[][];
  144711. updatable?: boolean;
  144712. instance?: Nullable<LinesMesh>;
  144713. colors?: Nullable<Color4[][]>;
  144714. useVertexAlpha?: boolean;
  144715. }, scene: Nullable<Scene>): LinesMesh;
  144716. /**
  144717. * Creates a line mesh
  144718. * 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
  144719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144720. * * The parameter `points` is an array successive Vector3
  144721. * * 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
  144722. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144723. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144724. * * When updating an instance, remember that only point positions can change, not the number of points
  144725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144727. * @param name defines the name of the new line system
  144728. * @param options defines the options used to create the line system
  144729. * @param scene defines the hosting scene
  144730. * @returns a new line mesh
  144731. */
  144732. static CreateLines(name: string, options: {
  144733. points: Vector3[];
  144734. updatable?: boolean;
  144735. instance?: Nullable<LinesMesh>;
  144736. colors?: Color4[];
  144737. useVertexAlpha?: boolean;
  144738. }, scene?: Nullable<Scene>): LinesMesh;
  144739. /**
  144740. * Creates a dashed line mesh
  144741. * * 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
  144742. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144743. * * The parameter `points` is an array successive Vector3
  144744. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144745. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144746. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144747. * * 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
  144748. * * When updating an instance, remember that only point positions can change, not the number of points
  144749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144750. * @param name defines the name of the mesh
  144751. * @param options defines the options used to create the mesh
  144752. * @param scene defines the hosting scene
  144753. * @returns the dashed line mesh
  144754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144755. */
  144756. static CreateDashedLines(name: string, options: {
  144757. points: Vector3[];
  144758. dashSize?: number;
  144759. gapSize?: number;
  144760. dashNb?: number;
  144761. updatable?: boolean;
  144762. instance?: LinesMesh;
  144763. }, scene?: Nullable<Scene>): LinesMesh;
  144764. /**
  144765. * 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.
  144766. * * 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.
  144767. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144768. * * 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.
  144769. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144770. * * 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
  144771. * * 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
  144772. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144777. * @param name defines the name of the mesh
  144778. * @param options defines the options used to create the mesh
  144779. * @param scene defines the hosting scene
  144780. * @returns the extruded shape mesh
  144781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144783. */
  144784. static ExtrudeShape(name: string, options: {
  144785. shape: Vector3[];
  144786. path: Vector3[];
  144787. scale?: number;
  144788. rotation?: number;
  144789. cap?: number;
  144790. updatable?: boolean;
  144791. sideOrientation?: number;
  144792. frontUVs?: Vector4;
  144793. backUVs?: Vector4;
  144794. instance?: Mesh;
  144795. invertUV?: boolean;
  144796. }, scene?: Nullable<Scene>): Mesh;
  144797. /**
  144798. * Creates an custom extruded shape mesh.
  144799. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144800. * * 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.
  144801. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144802. * * 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
  144803. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144804. * * 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
  144805. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144806. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144807. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144808. * * 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
  144809. * * 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
  144810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144815. * @param name defines the name of the mesh
  144816. * @param options defines the options used to create the mesh
  144817. * @param scene defines the hosting scene
  144818. * @returns the custom extruded shape mesh
  144819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144822. */
  144823. static ExtrudeShapeCustom(name: string, options: {
  144824. shape: Vector3[];
  144825. path: Vector3[];
  144826. scaleFunction?: any;
  144827. rotationFunction?: any;
  144828. ribbonCloseArray?: boolean;
  144829. ribbonClosePath?: boolean;
  144830. cap?: number;
  144831. updatable?: boolean;
  144832. sideOrientation?: number;
  144833. frontUVs?: Vector4;
  144834. backUVs?: Vector4;
  144835. instance?: Mesh;
  144836. invertUV?: boolean;
  144837. }, scene?: Nullable<Scene>): Mesh;
  144838. /**
  144839. * Creates lathe mesh.
  144840. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144841. * * 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
  144842. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144843. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144844. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144845. * * 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
  144846. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144847. * * 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
  144848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144852. * @param name defines the name of the mesh
  144853. * @param options defines the options used to create the mesh
  144854. * @param scene defines the hosting scene
  144855. * @returns the lathe mesh
  144856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144857. */
  144858. static CreateLathe(name: string, options: {
  144859. shape: Vector3[];
  144860. radius?: number;
  144861. tessellation?: number;
  144862. clip?: number;
  144863. arc?: number;
  144864. closed?: boolean;
  144865. updatable?: boolean;
  144866. sideOrientation?: number;
  144867. frontUVs?: Vector4;
  144868. backUVs?: Vector4;
  144869. cap?: number;
  144870. invertUV?: boolean;
  144871. }, scene?: Nullable<Scene>): Mesh;
  144872. /**
  144873. * Creates a tiled plane mesh
  144874. * * You can set a limited pattern arrangement with the tiles
  144875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144878. * @param name defines the name of the mesh
  144879. * @param options defines the options used to create the mesh
  144880. * @param scene defines the hosting scene
  144881. * @returns the plane mesh
  144882. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144883. */
  144884. static CreateTiledPlane(name: string, options: {
  144885. pattern?: number;
  144886. tileSize?: number;
  144887. tileWidth?: number;
  144888. tileHeight?: number;
  144889. size?: number;
  144890. width?: number;
  144891. height?: number;
  144892. alignHorizontal?: number;
  144893. alignVertical?: number;
  144894. sideOrientation?: number;
  144895. frontUVs?: Vector4;
  144896. backUVs?: Vector4;
  144897. updatable?: boolean;
  144898. }, scene?: Nullable<Scene>): Mesh;
  144899. /**
  144900. * Creates a plane mesh
  144901. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144902. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144903. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144907. * @param name defines the name of the mesh
  144908. * @param options defines the options used to create the mesh
  144909. * @param scene defines the hosting scene
  144910. * @returns the plane mesh
  144911. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144912. */
  144913. static CreatePlane(name: string, options: {
  144914. size?: number;
  144915. width?: number;
  144916. height?: number;
  144917. sideOrientation?: number;
  144918. frontUVs?: Vector4;
  144919. backUVs?: Vector4;
  144920. updatable?: boolean;
  144921. sourcePlane?: Plane;
  144922. }, scene?: Nullable<Scene>): Mesh;
  144923. /**
  144924. * Creates a ground mesh
  144925. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144926. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144928. * @param name defines the name of the mesh
  144929. * @param options defines the options used to create the mesh
  144930. * @param scene defines the hosting scene
  144931. * @returns the ground mesh
  144932. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144933. */
  144934. static CreateGround(name: string, options: {
  144935. width?: number;
  144936. height?: number;
  144937. subdivisions?: number;
  144938. subdivisionsX?: number;
  144939. subdivisionsY?: number;
  144940. updatable?: boolean;
  144941. }, scene?: Nullable<Scene>): Mesh;
  144942. /**
  144943. * Creates a tiled ground mesh
  144944. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144945. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144946. * * 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
  144947. * * 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
  144948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144949. * @param name defines the name of the mesh
  144950. * @param options defines the options used to create the mesh
  144951. * @param scene defines the hosting scene
  144952. * @returns the tiled ground mesh
  144953. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144954. */
  144955. static CreateTiledGround(name: string, options: {
  144956. xmin: number;
  144957. zmin: number;
  144958. xmax: number;
  144959. zmax: number;
  144960. subdivisions?: {
  144961. w: number;
  144962. h: number;
  144963. };
  144964. precision?: {
  144965. w: number;
  144966. h: number;
  144967. };
  144968. updatable?: boolean;
  144969. }, scene?: Nullable<Scene>): Mesh;
  144970. /**
  144971. * Creates a ground mesh from a height map
  144972. * * The parameter `url` sets the URL of the height map image resource.
  144973. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144974. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144975. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144976. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144977. * * 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.
  144978. * * 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).
  144979. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144981. * @param name defines the name of the mesh
  144982. * @param url defines the url to the height map
  144983. * @param options defines the options used to create the mesh
  144984. * @param scene defines the hosting scene
  144985. * @returns the ground mesh
  144986. * @see https://doc.babylonjs.com/babylon101/height_map
  144987. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144988. */
  144989. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144990. width?: number;
  144991. height?: number;
  144992. subdivisions?: number;
  144993. minHeight?: number;
  144994. maxHeight?: number;
  144995. colorFilter?: Color3;
  144996. alphaFilter?: number;
  144997. updatable?: boolean;
  144998. onReady?: (mesh: GroundMesh) => void;
  144999. }, scene?: Nullable<Scene>): GroundMesh;
  145000. /**
  145001. * Creates a polygon mesh
  145002. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145003. * * 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
  145004. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145007. * * Remember you can only change the shape positions, not their number when updating a polygon
  145008. * @param name defines the name of the mesh
  145009. * @param options defines the options used to create the mesh
  145010. * @param scene defines the hosting scene
  145011. * @param earcutInjection can be used to inject your own earcut reference
  145012. * @returns the polygon mesh
  145013. */
  145014. static CreatePolygon(name: string, options: {
  145015. shape: Vector3[];
  145016. holes?: Vector3[][];
  145017. depth?: number;
  145018. faceUV?: Vector4[];
  145019. faceColors?: Color4[];
  145020. updatable?: boolean;
  145021. sideOrientation?: number;
  145022. frontUVs?: Vector4;
  145023. backUVs?: Vector4;
  145024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145025. /**
  145026. * Creates an extruded polygon mesh, with depth in the Y direction.
  145027. * * 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)
  145028. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145029. * @param name defines the name of the mesh
  145030. * @param options defines the options used to create the mesh
  145031. * @param scene defines the hosting scene
  145032. * @param earcutInjection can be used to inject your own earcut reference
  145033. * @returns the polygon mesh
  145034. */
  145035. static ExtrudePolygon(name: string, options: {
  145036. shape: Vector3[];
  145037. holes?: Vector3[][];
  145038. depth?: number;
  145039. faceUV?: Vector4[];
  145040. faceColors?: Color4[];
  145041. updatable?: boolean;
  145042. sideOrientation?: number;
  145043. frontUVs?: Vector4;
  145044. backUVs?: Vector4;
  145045. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145046. /**
  145047. * Creates a tube mesh.
  145048. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145049. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145050. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145051. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145052. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145053. * * 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)
  145054. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145055. * * 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
  145056. * * 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
  145057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145061. * @param name defines the name of the mesh
  145062. * @param options defines the options used to create the mesh
  145063. * @param scene defines the hosting scene
  145064. * @returns the tube mesh
  145065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145066. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145067. */
  145068. static CreateTube(name: string, options: {
  145069. path: Vector3[];
  145070. radius?: number;
  145071. tessellation?: number;
  145072. radiusFunction?: {
  145073. (i: number, distance: number): number;
  145074. };
  145075. cap?: number;
  145076. arc?: number;
  145077. updatable?: boolean;
  145078. sideOrientation?: number;
  145079. frontUVs?: Vector4;
  145080. backUVs?: Vector4;
  145081. instance?: Mesh;
  145082. invertUV?: boolean;
  145083. }, scene?: Nullable<Scene>): Mesh;
  145084. /**
  145085. * Creates a polyhedron mesh
  145086. * * 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
  145087. * * The parameter `size` (positive float, default 1) sets the polygon size
  145088. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145089. * * 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`
  145090. * * 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
  145091. * * 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)`)
  145092. * * 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
  145093. * * 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
  145094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145097. * @param name defines the name of the mesh
  145098. * @param options defines the options used to create the mesh
  145099. * @param scene defines the hosting scene
  145100. * @returns the polyhedron mesh
  145101. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  145102. */
  145103. static CreatePolyhedron(name: string, options: {
  145104. type?: number;
  145105. size?: number;
  145106. sizeX?: number;
  145107. sizeY?: number;
  145108. sizeZ?: number;
  145109. custom?: any;
  145110. faceUV?: Vector4[];
  145111. faceColors?: Color4[];
  145112. flat?: boolean;
  145113. updatable?: boolean;
  145114. sideOrientation?: number;
  145115. frontUVs?: Vector4;
  145116. backUVs?: Vector4;
  145117. }, scene?: Nullable<Scene>): Mesh;
  145118. /**
  145119. * Creates a decal mesh.
  145120. * 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
  145121. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145122. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145123. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145124. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145125. * @param name defines the name of the mesh
  145126. * @param sourceMesh defines the mesh where the decal must be applied
  145127. * @param options defines the options used to create the mesh
  145128. * @param scene defines the hosting scene
  145129. * @returns the decal mesh
  145130. * @see https://doc.babylonjs.com/how_to/decals
  145131. */
  145132. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145133. position?: Vector3;
  145134. normal?: Vector3;
  145135. size?: Vector3;
  145136. angle?: number;
  145137. }): Mesh;
  145138. }
  145139. }
  145140. declare module BABYLON {
  145141. /**
  145142. * A simplifier interface for future simplification implementations
  145143. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145144. */
  145145. export interface ISimplifier {
  145146. /**
  145147. * Simplification of a given mesh according to the given settings.
  145148. * Since this requires computation, it is assumed that the function runs async.
  145149. * @param settings The settings of the simplification, including quality and distance
  145150. * @param successCallback A callback that will be called after the mesh was simplified.
  145151. * @param errorCallback in case of an error, this callback will be called. optional.
  145152. */
  145153. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145154. }
  145155. /**
  145156. * Expected simplification settings.
  145157. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145158. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145159. */
  145160. export interface ISimplificationSettings {
  145161. /**
  145162. * Gets or sets the expected quality
  145163. */
  145164. quality: number;
  145165. /**
  145166. * Gets or sets the distance when this optimized version should be used
  145167. */
  145168. distance: number;
  145169. /**
  145170. * Gets an already optimized mesh
  145171. */
  145172. optimizeMesh?: boolean;
  145173. }
  145174. /**
  145175. * Class used to specify simplification options
  145176. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145177. */
  145178. export class SimplificationSettings implements ISimplificationSettings {
  145179. /** expected quality */
  145180. quality: number;
  145181. /** distance when this optimized version should be used */
  145182. distance: number;
  145183. /** already optimized mesh */
  145184. optimizeMesh?: boolean | undefined;
  145185. /**
  145186. * Creates a SimplificationSettings
  145187. * @param quality expected quality
  145188. * @param distance distance when this optimized version should be used
  145189. * @param optimizeMesh already optimized mesh
  145190. */
  145191. constructor(
  145192. /** expected quality */
  145193. quality: number,
  145194. /** distance when this optimized version should be used */
  145195. distance: number,
  145196. /** already optimized mesh */
  145197. optimizeMesh?: boolean | undefined);
  145198. }
  145199. /**
  145200. * Interface used to define a simplification task
  145201. */
  145202. export interface ISimplificationTask {
  145203. /**
  145204. * Array of settings
  145205. */
  145206. settings: Array<ISimplificationSettings>;
  145207. /**
  145208. * Simplification type
  145209. */
  145210. simplificationType: SimplificationType;
  145211. /**
  145212. * Mesh to simplify
  145213. */
  145214. mesh: Mesh;
  145215. /**
  145216. * Callback called on success
  145217. */
  145218. successCallback?: () => void;
  145219. /**
  145220. * Defines if parallel processing can be used
  145221. */
  145222. parallelProcessing: boolean;
  145223. }
  145224. /**
  145225. * Queue used to order the simplification tasks
  145226. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145227. */
  145228. export class SimplificationQueue {
  145229. private _simplificationArray;
  145230. /**
  145231. * Gets a boolean indicating that the process is still running
  145232. */
  145233. running: boolean;
  145234. /**
  145235. * Creates a new queue
  145236. */
  145237. constructor();
  145238. /**
  145239. * Adds a new simplification task
  145240. * @param task defines a task to add
  145241. */
  145242. addTask(task: ISimplificationTask): void;
  145243. /**
  145244. * Execute next task
  145245. */
  145246. executeNext(): void;
  145247. /**
  145248. * Execute a simplification task
  145249. * @param task defines the task to run
  145250. */
  145251. runSimplification(task: ISimplificationTask): void;
  145252. private getSimplifier;
  145253. }
  145254. /**
  145255. * The implemented types of simplification
  145256. * At the moment only Quadratic Error Decimation is implemented
  145257. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145258. */
  145259. export enum SimplificationType {
  145260. /** Quadratic error decimation */
  145261. QUADRATIC = 0
  145262. }
  145263. /**
  145264. * An implementation of the Quadratic Error simplification algorithm.
  145265. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145266. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145267. * @author RaananW
  145268. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145269. */
  145270. export class QuadraticErrorSimplification implements ISimplifier {
  145271. private _mesh;
  145272. private triangles;
  145273. private vertices;
  145274. private references;
  145275. private _reconstructedMesh;
  145276. /** Gets or sets the number pf sync interations */
  145277. syncIterations: number;
  145278. /** Gets or sets the aggressiveness of the simplifier */
  145279. aggressiveness: number;
  145280. /** Gets or sets the number of allowed iterations for decimation */
  145281. decimationIterations: number;
  145282. /** Gets or sets the espilon to use for bounding box computation */
  145283. boundingBoxEpsilon: number;
  145284. /**
  145285. * Creates a new QuadraticErrorSimplification
  145286. * @param _mesh defines the target mesh
  145287. */
  145288. constructor(_mesh: Mesh);
  145289. /**
  145290. * Simplification of a given mesh according to the given settings.
  145291. * Since this requires computation, it is assumed that the function runs async.
  145292. * @param settings The settings of the simplification, including quality and distance
  145293. * @param successCallback A callback that will be called after the mesh was simplified.
  145294. */
  145295. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145296. private runDecimation;
  145297. private initWithMesh;
  145298. private init;
  145299. private reconstructMesh;
  145300. private initDecimatedMesh;
  145301. private isFlipped;
  145302. private updateTriangles;
  145303. private identifyBorder;
  145304. private updateMesh;
  145305. private vertexError;
  145306. private calculateError;
  145307. }
  145308. }
  145309. declare module BABYLON {
  145310. interface Scene {
  145311. /** @hidden (Backing field) */
  145312. _simplificationQueue: SimplificationQueue;
  145313. /**
  145314. * Gets or sets the simplification queue attached to the scene
  145315. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145316. */
  145317. simplificationQueue: SimplificationQueue;
  145318. }
  145319. interface Mesh {
  145320. /**
  145321. * Simplify the mesh according to the given array of settings.
  145322. * Function will return immediately and will simplify async
  145323. * @param settings a collection of simplification settings
  145324. * @param parallelProcessing should all levels calculate parallel or one after the other
  145325. * @param simplificationType the type of simplification to run
  145326. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145327. * @returns the current mesh
  145328. */
  145329. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145330. }
  145331. /**
  145332. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145333. * created in a scene
  145334. */
  145335. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145336. /**
  145337. * The component name helpfull to identify the component in the list of scene components.
  145338. */
  145339. readonly name: string;
  145340. /**
  145341. * The scene the component belongs to.
  145342. */
  145343. scene: Scene;
  145344. /**
  145345. * Creates a new instance of the component for the given scene
  145346. * @param scene Defines the scene to register the component in
  145347. */
  145348. constructor(scene: Scene);
  145349. /**
  145350. * Registers the component in a given scene
  145351. */
  145352. register(): void;
  145353. /**
  145354. * Rebuilds the elements related to this component in case of
  145355. * context lost for instance.
  145356. */
  145357. rebuild(): void;
  145358. /**
  145359. * Disposes the component and the associated ressources
  145360. */
  145361. dispose(): void;
  145362. private _beforeCameraUpdate;
  145363. }
  145364. }
  145365. declare module BABYLON {
  145366. interface Mesh {
  145367. /**
  145368. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145369. */
  145370. thinInstanceEnablePicking: boolean;
  145371. /**
  145372. * Creates a new thin instance
  145373. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145374. * @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
  145375. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145376. */
  145377. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145378. /**
  145379. * Adds the transformation (matrix) of the current mesh as a thin instance
  145380. * @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
  145381. * @returns the thin instance index number
  145382. */
  145383. thinInstanceAddSelf(refresh: boolean): number;
  145384. /**
  145385. * Registers a custom attribute to be used with thin instances
  145386. * @param kind name of the attribute
  145387. * @param stride size in floats of the attribute
  145388. */
  145389. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145390. /**
  145391. * Sets the matrix of a thin instance
  145392. * @param index index of the thin instance
  145393. * @param matrix matrix to set
  145394. * @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
  145395. */
  145396. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145397. /**
  145398. * Sets the value of a custom attribute for a thin instance
  145399. * @param kind name of the attribute
  145400. * @param index index of the thin instance
  145401. * @param value value to set
  145402. * @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
  145403. */
  145404. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145405. /**
  145406. * 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.
  145407. */
  145408. thinInstanceCount: number;
  145409. /**
  145410. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145411. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145412. * @param buffer buffer to set
  145413. * @param stride size in floats of each value of the buffer
  145414. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145415. */
  145416. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145417. /**
  145418. * Gets the list of world matrices
  145419. * @return an array containing all the world matrices from the thin instances
  145420. */
  145421. thinInstanceGetWorldMatrices(): Matrix[];
  145422. /**
  145423. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145424. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145425. */
  145426. thinInstanceBufferUpdated(kind: string): void;
  145427. /**
  145428. * Refreshes the bounding info, taking into account all the thin instances defined
  145429. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145430. */
  145431. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145432. /** @hidden */
  145433. _thinInstanceInitializeUserStorage(): void;
  145434. /** @hidden */
  145435. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145436. /** @hidden */
  145437. _userThinInstanceBuffersStorage: {
  145438. data: {
  145439. [key: string]: Float32Array;
  145440. };
  145441. sizes: {
  145442. [key: string]: number;
  145443. };
  145444. vertexBuffers: {
  145445. [key: string]: Nullable<VertexBuffer>;
  145446. };
  145447. strides: {
  145448. [key: string]: number;
  145449. };
  145450. };
  145451. }
  145452. }
  145453. declare module BABYLON {
  145454. /**
  145455. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145456. */
  145457. export interface INavigationEnginePlugin {
  145458. /**
  145459. * plugin name
  145460. */
  145461. name: string;
  145462. /**
  145463. * Creates a navigation mesh
  145464. * @param meshes array of all the geometry used to compute the navigatio mesh
  145465. * @param parameters bunch of parameters used to filter geometry
  145466. */
  145467. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145468. /**
  145469. * Create a navigation mesh debug mesh
  145470. * @param scene is where the mesh will be added
  145471. * @returns debug display mesh
  145472. */
  145473. createDebugNavMesh(scene: Scene): Mesh;
  145474. /**
  145475. * Get a navigation mesh constrained position, closest to the parameter position
  145476. * @param position world position
  145477. * @returns the closest point to position constrained by the navigation mesh
  145478. */
  145479. getClosestPoint(position: Vector3): Vector3;
  145480. /**
  145481. * Get a navigation mesh constrained position, closest to the parameter position
  145482. * @param position world position
  145483. * @param result output the closest point to position constrained by the navigation mesh
  145484. */
  145485. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145486. /**
  145487. * Get a navigation mesh constrained position, within a particular radius
  145488. * @param position world position
  145489. * @param maxRadius the maximum distance to the constrained world position
  145490. * @returns the closest point to position constrained by the navigation mesh
  145491. */
  145492. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145493. /**
  145494. * Get a navigation mesh constrained position, within a particular radius
  145495. * @param position world position
  145496. * @param maxRadius the maximum distance to the constrained world position
  145497. * @param result output the closest point to position constrained by the navigation mesh
  145498. */
  145499. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145500. /**
  145501. * Compute the final position from a segment made of destination-position
  145502. * @param position world position
  145503. * @param destination world position
  145504. * @returns the resulting point along the navmesh
  145505. */
  145506. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145507. /**
  145508. * Compute the final position from a segment made of destination-position
  145509. * @param position world position
  145510. * @param destination world position
  145511. * @param result output the resulting point along the navmesh
  145512. */
  145513. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145514. /**
  145515. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145516. * @param start world position
  145517. * @param end world position
  145518. * @returns array containing world position composing the path
  145519. */
  145520. computePath(start: Vector3, end: Vector3): Vector3[];
  145521. /**
  145522. * If this plugin is supported
  145523. * @returns true if plugin is supported
  145524. */
  145525. isSupported(): boolean;
  145526. /**
  145527. * Create a new Crowd so you can add agents
  145528. * @param maxAgents the maximum agent count in the crowd
  145529. * @param maxAgentRadius the maximum radius an agent can have
  145530. * @param scene to attach the crowd to
  145531. * @returns the crowd you can add agents to
  145532. */
  145533. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145534. /**
  145535. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145536. * The queries will try to find a solution within those bounds
  145537. * default is (1,1,1)
  145538. * @param extent x,y,z value that define the extent around the queries point of reference
  145539. */
  145540. setDefaultQueryExtent(extent: Vector3): void;
  145541. /**
  145542. * Get the Bounding box extent specified by setDefaultQueryExtent
  145543. * @returns the box extent values
  145544. */
  145545. getDefaultQueryExtent(): Vector3;
  145546. /**
  145547. * build the navmesh from a previously saved state using getNavmeshData
  145548. * @param data the Uint8Array returned by getNavmeshData
  145549. */
  145550. buildFromNavmeshData(data: Uint8Array): void;
  145551. /**
  145552. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145553. * @returns data the Uint8Array that can be saved and reused
  145554. */
  145555. getNavmeshData(): Uint8Array;
  145556. /**
  145557. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145558. * @param result output the box extent values
  145559. */
  145560. getDefaultQueryExtentToRef(result: Vector3): void;
  145561. /**
  145562. * Release all resources
  145563. */
  145564. dispose(): void;
  145565. }
  145566. /**
  145567. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145568. */
  145569. export interface ICrowd {
  145570. /**
  145571. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145572. * You can attach anything to that node. The node position is updated in the scene update tick.
  145573. * @param pos world position that will be constrained by the navigation mesh
  145574. * @param parameters agent parameters
  145575. * @param transform hooked to the agent that will be update by the scene
  145576. * @returns agent index
  145577. */
  145578. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145579. /**
  145580. * Returns the agent position in world space
  145581. * @param index agent index returned by addAgent
  145582. * @returns world space position
  145583. */
  145584. getAgentPosition(index: number): Vector3;
  145585. /**
  145586. * Gets the agent position result in world space
  145587. * @param index agent index returned by addAgent
  145588. * @param result output world space position
  145589. */
  145590. getAgentPositionToRef(index: number, result: Vector3): void;
  145591. /**
  145592. * Gets the agent velocity in world space
  145593. * @param index agent index returned by addAgent
  145594. * @returns world space velocity
  145595. */
  145596. getAgentVelocity(index: number): Vector3;
  145597. /**
  145598. * Gets the agent velocity result in world space
  145599. * @param index agent index returned by addAgent
  145600. * @param result output world space velocity
  145601. */
  145602. getAgentVelocityToRef(index: number, result: Vector3): void;
  145603. /**
  145604. * remove a particular agent previously created
  145605. * @param index agent index returned by addAgent
  145606. */
  145607. removeAgent(index: number): void;
  145608. /**
  145609. * get the list of all agents attached to this crowd
  145610. * @returns list of agent indices
  145611. */
  145612. getAgents(): number[];
  145613. /**
  145614. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145615. * @param deltaTime in seconds
  145616. */
  145617. update(deltaTime: number): void;
  145618. /**
  145619. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145620. * @param index agent index returned by addAgent
  145621. * @param destination targeted world position
  145622. */
  145623. agentGoto(index: number, destination: Vector3): void;
  145624. /**
  145625. * Teleport the agent to a new position
  145626. * @param index agent index returned by addAgent
  145627. * @param destination targeted world position
  145628. */
  145629. agentTeleport(index: number, destination: Vector3): void;
  145630. /**
  145631. * Update agent parameters
  145632. * @param index agent index returned by addAgent
  145633. * @param parameters agent parameters
  145634. */
  145635. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145636. /**
  145637. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145638. * The queries will try to find a solution within those bounds
  145639. * default is (1,1,1)
  145640. * @param extent x,y,z value that define the extent around the queries point of reference
  145641. */
  145642. setDefaultQueryExtent(extent: Vector3): void;
  145643. /**
  145644. * Get the Bounding box extent specified by setDefaultQueryExtent
  145645. * @returns the box extent values
  145646. */
  145647. getDefaultQueryExtent(): Vector3;
  145648. /**
  145649. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145650. * @param result output the box extent values
  145651. */
  145652. getDefaultQueryExtentToRef(result: Vector3): void;
  145653. /**
  145654. * Release all resources
  145655. */
  145656. dispose(): void;
  145657. }
  145658. /**
  145659. * Configures an agent
  145660. */
  145661. export interface IAgentParameters {
  145662. /**
  145663. * Agent radius. [Limit: >= 0]
  145664. */
  145665. radius: number;
  145666. /**
  145667. * Agent height. [Limit: > 0]
  145668. */
  145669. height: number;
  145670. /**
  145671. * Maximum allowed acceleration. [Limit: >= 0]
  145672. */
  145673. maxAcceleration: number;
  145674. /**
  145675. * Maximum allowed speed. [Limit: >= 0]
  145676. */
  145677. maxSpeed: number;
  145678. /**
  145679. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145680. */
  145681. collisionQueryRange: number;
  145682. /**
  145683. * The path visibility optimization range. [Limit: > 0]
  145684. */
  145685. pathOptimizationRange: number;
  145686. /**
  145687. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145688. */
  145689. separationWeight: number;
  145690. }
  145691. /**
  145692. * Configures the navigation mesh creation
  145693. */
  145694. export interface INavMeshParameters {
  145695. /**
  145696. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145697. */
  145698. cs: number;
  145699. /**
  145700. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145701. */
  145702. ch: number;
  145703. /**
  145704. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145705. */
  145706. walkableSlopeAngle: number;
  145707. /**
  145708. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145709. * be considered walkable. [Limit: >= 3] [Units: vx]
  145710. */
  145711. walkableHeight: number;
  145712. /**
  145713. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145714. */
  145715. walkableClimb: number;
  145716. /**
  145717. * The distance to erode/shrink the walkable area of the heightfield away from
  145718. * obstructions. [Limit: >=0] [Units: vx]
  145719. */
  145720. walkableRadius: number;
  145721. /**
  145722. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145723. */
  145724. maxEdgeLen: number;
  145725. /**
  145726. * The maximum distance a simplfied contour's border edges should deviate
  145727. * the original raw contour. [Limit: >=0] [Units: vx]
  145728. */
  145729. maxSimplificationError: number;
  145730. /**
  145731. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145732. */
  145733. minRegionArea: number;
  145734. /**
  145735. * Any regions with a span count smaller than this value will, if possible,
  145736. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145737. */
  145738. mergeRegionArea: number;
  145739. /**
  145740. * The maximum number of vertices allowed for polygons generated during the
  145741. * contour to polygon conversion process. [Limit: >= 3]
  145742. */
  145743. maxVertsPerPoly: number;
  145744. /**
  145745. * Sets the sampling distance to use when generating the detail mesh.
  145746. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145747. */
  145748. detailSampleDist: number;
  145749. /**
  145750. * The maximum distance the detail mesh surface should deviate from heightfield
  145751. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145752. */
  145753. detailSampleMaxError: number;
  145754. }
  145755. }
  145756. declare module BABYLON {
  145757. /**
  145758. * RecastJS navigation plugin
  145759. */
  145760. export class RecastJSPlugin implements INavigationEnginePlugin {
  145761. /**
  145762. * Reference to the Recast library
  145763. */
  145764. bjsRECAST: any;
  145765. /**
  145766. * plugin name
  145767. */
  145768. name: string;
  145769. /**
  145770. * the first navmesh created. We might extend this to support multiple navmeshes
  145771. */
  145772. navMesh: any;
  145773. /**
  145774. * Initializes the recastJS plugin
  145775. * @param recastInjection can be used to inject your own recast reference
  145776. */
  145777. constructor(recastInjection?: any);
  145778. /**
  145779. * Creates a navigation mesh
  145780. * @param meshes array of all the geometry used to compute the navigatio mesh
  145781. * @param parameters bunch of parameters used to filter geometry
  145782. */
  145783. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145784. /**
  145785. * Create a navigation mesh debug mesh
  145786. * @param scene is where the mesh will be added
  145787. * @returns debug display mesh
  145788. */
  145789. createDebugNavMesh(scene: Scene): Mesh;
  145790. /**
  145791. * Get a navigation mesh constrained position, closest to the parameter position
  145792. * @param position world position
  145793. * @returns the closest point to position constrained by the navigation mesh
  145794. */
  145795. getClosestPoint(position: Vector3): Vector3;
  145796. /**
  145797. * Get a navigation mesh constrained position, closest to the parameter position
  145798. * @param position world position
  145799. * @param result output the closest point to position constrained by the navigation mesh
  145800. */
  145801. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145802. /**
  145803. * Get a navigation mesh constrained position, within a particular radius
  145804. * @param position world position
  145805. * @param maxRadius the maximum distance to the constrained world position
  145806. * @returns the closest point to position constrained by the navigation mesh
  145807. */
  145808. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145809. /**
  145810. * Get a navigation mesh constrained position, within a particular radius
  145811. * @param position world position
  145812. * @param maxRadius the maximum distance to the constrained world position
  145813. * @param result output the closest point to position constrained by the navigation mesh
  145814. */
  145815. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145816. /**
  145817. * Compute the final position from a segment made of destination-position
  145818. * @param position world position
  145819. * @param destination world position
  145820. * @returns the resulting point along the navmesh
  145821. */
  145822. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145823. /**
  145824. * Compute the final position from a segment made of destination-position
  145825. * @param position world position
  145826. * @param destination world position
  145827. * @param result output the resulting point along the navmesh
  145828. */
  145829. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145830. /**
  145831. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145832. * @param start world position
  145833. * @param end world position
  145834. * @returns array containing world position composing the path
  145835. */
  145836. computePath(start: Vector3, end: Vector3): Vector3[];
  145837. /**
  145838. * Create a new Crowd so you can add agents
  145839. * @param maxAgents the maximum agent count in the crowd
  145840. * @param maxAgentRadius the maximum radius an agent can have
  145841. * @param scene to attach the crowd to
  145842. * @returns the crowd you can add agents to
  145843. */
  145844. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145845. /**
  145846. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145847. * The queries will try to find a solution within those bounds
  145848. * default is (1,1,1)
  145849. * @param extent x,y,z value that define the extent around the queries point of reference
  145850. */
  145851. setDefaultQueryExtent(extent: Vector3): void;
  145852. /**
  145853. * Get the Bounding box extent specified by setDefaultQueryExtent
  145854. * @returns the box extent values
  145855. */
  145856. getDefaultQueryExtent(): Vector3;
  145857. /**
  145858. * build the navmesh from a previously saved state using getNavmeshData
  145859. * @param data the Uint8Array returned by getNavmeshData
  145860. */
  145861. buildFromNavmeshData(data: Uint8Array): void;
  145862. /**
  145863. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145864. * @returns data the Uint8Array that can be saved and reused
  145865. */
  145866. getNavmeshData(): Uint8Array;
  145867. /**
  145868. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145869. * @param result output the box extent values
  145870. */
  145871. getDefaultQueryExtentToRef(result: Vector3): void;
  145872. /**
  145873. * Disposes
  145874. */
  145875. dispose(): void;
  145876. /**
  145877. * If this plugin is supported
  145878. * @returns true if plugin is supported
  145879. */
  145880. isSupported(): boolean;
  145881. }
  145882. /**
  145883. * Recast detour crowd implementation
  145884. */
  145885. export class RecastJSCrowd implements ICrowd {
  145886. /**
  145887. * Recast/detour plugin
  145888. */
  145889. bjsRECASTPlugin: RecastJSPlugin;
  145890. /**
  145891. * Link to the detour crowd
  145892. */
  145893. recastCrowd: any;
  145894. /**
  145895. * One transform per agent
  145896. */
  145897. transforms: TransformNode[];
  145898. /**
  145899. * All agents created
  145900. */
  145901. agents: number[];
  145902. /**
  145903. * Link to the scene is kept to unregister the crowd from the scene
  145904. */
  145905. private _scene;
  145906. /**
  145907. * Observer for crowd updates
  145908. */
  145909. private _onBeforeAnimationsObserver;
  145910. /**
  145911. * Constructor
  145912. * @param plugin recastJS plugin
  145913. * @param maxAgents the maximum agent count in the crowd
  145914. * @param maxAgentRadius the maximum radius an agent can have
  145915. * @param scene to attach the crowd to
  145916. * @returns the crowd you can add agents to
  145917. */
  145918. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145919. /**
  145920. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145921. * You can attach anything to that node. The node position is updated in the scene update tick.
  145922. * @param pos world position that will be constrained by the navigation mesh
  145923. * @param parameters agent parameters
  145924. * @param transform hooked to the agent that will be update by the scene
  145925. * @returns agent index
  145926. */
  145927. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145928. /**
  145929. * Returns the agent position in world space
  145930. * @param index agent index returned by addAgent
  145931. * @returns world space position
  145932. */
  145933. getAgentPosition(index: number): Vector3;
  145934. /**
  145935. * Returns the agent position result in world space
  145936. * @param index agent index returned by addAgent
  145937. * @param result output world space position
  145938. */
  145939. getAgentPositionToRef(index: number, result: Vector3): void;
  145940. /**
  145941. * Returns the agent velocity in world space
  145942. * @param index agent index returned by addAgent
  145943. * @returns world space velocity
  145944. */
  145945. getAgentVelocity(index: number): Vector3;
  145946. /**
  145947. * Returns the agent velocity result in world space
  145948. * @param index agent index returned by addAgent
  145949. * @param result output world space velocity
  145950. */
  145951. getAgentVelocityToRef(index: number, result: Vector3): void;
  145952. /**
  145953. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145954. * @param index agent index returned by addAgent
  145955. * @param destination targeted world position
  145956. */
  145957. agentGoto(index: number, destination: Vector3): void;
  145958. /**
  145959. * Teleport the agent to a new position
  145960. * @param index agent index returned by addAgent
  145961. * @param destination targeted world position
  145962. */
  145963. agentTeleport(index: number, destination: Vector3): void;
  145964. /**
  145965. * Update agent parameters
  145966. * @param index agent index returned by addAgent
  145967. * @param parameters agent parameters
  145968. */
  145969. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145970. /**
  145971. * remove a particular agent previously created
  145972. * @param index agent index returned by addAgent
  145973. */
  145974. removeAgent(index: number): void;
  145975. /**
  145976. * get the list of all agents attached to this crowd
  145977. * @returns list of agent indices
  145978. */
  145979. getAgents(): number[];
  145980. /**
  145981. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145982. * @param deltaTime in seconds
  145983. */
  145984. update(deltaTime: number): void;
  145985. /**
  145986. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145987. * The queries will try to find a solution within those bounds
  145988. * default is (1,1,1)
  145989. * @param extent x,y,z value that define the extent around the queries point of reference
  145990. */
  145991. setDefaultQueryExtent(extent: Vector3): void;
  145992. /**
  145993. * Get the Bounding box extent specified by setDefaultQueryExtent
  145994. * @returns the box extent values
  145995. */
  145996. getDefaultQueryExtent(): Vector3;
  145997. /**
  145998. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145999. * @param result output the box extent values
  146000. */
  146001. getDefaultQueryExtentToRef(result: Vector3): void;
  146002. /**
  146003. * Release all resources
  146004. */
  146005. dispose(): void;
  146006. }
  146007. }
  146008. declare module BABYLON {
  146009. /**
  146010. * Class used to enable access to IndexedDB
  146011. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146012. */
  146013. export class Database implements IOfflineProvider {
  146014. private _callbackManifestChecked;
  146015. private _currentSceneUrl;
  146016. private _db;
  146017. private _enableSceneOffline;
  146018. private _enableTexturesOffline;
  146019. private _manifestVersionFound;
  146020. private _mustUpdateRessources;
  146021. private _hasReachedQuota;
  146022. private _isSupported;
  146023. private _idbFactory;
  146024. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146025. private static IsUASupportingBlobStorage;
  146026. /**
  146027. * Gets a boolean indicating if Database storate is enabled (off by default)
  146028. */
  146029. static IDBStorageEnabled: boolean;
  146030. /**
  146031. * Gets a boolean indicating if scene must be saved in the database
  146032. */
  146033. get enableSceneOffline(): boolean;
  146034. /**
  146035. * Gets a boolean indicating if textures must be saved in the database
  146036. */
  146037. get enableTexturesOffline(): boolean;
  146038. /**
  146039. * Creates a new Database
  146040. * @param urlToScene defines the url to load the scene
  146041. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146042. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146043. */
  146044. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146045. private static _ParseURL;
  146046. private static _ReturnFullUrlLocation;
  146047. private _checkManifestFile;
  146048. /**
  146049. * Open the database and make it available
  146050. * @param successCallback defines the callback to call on success
  146051. * @param errorCallback defines the callback to call on error
  146052. */
  146053. open(successCallback: () => void, errorCallback: () => void): void;
  146054. /**
  146055. * Loads an image from the database
  146056. * @param url defines the url to load from
  146057. * @param image defines the target DOM image
  146058. */
  146059. loadImage(url: string, image: HTMLImageElement): void;
  146060. private _loadImageFromDBAsync;
  146061. private _saveImageIntoDBAsync;
  146062. private _checkVersionFromDB;
  146063. private _loadVersionFromDBAsync;
  146064. private _saveVersionIntoDBAsync;
  146065. /**
  146066. * Loads a file from database
  146067. * @param url defines the URL to load from
  146068. * @param sceneLoaded defines a callback to call on success
  146069. * @param progressCallBack defines a callback to call when progress changed
  146070. * @param errorCallback defines a callback to call on error
  146071. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146072. */
  146073. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146074. private _loadFileAsync;
  146075. private _saveFileAsync;
  146076. /**
  146077. * Validates if xhr data is correct
  146078. * @param xhr defines the request to validate
  146079. * @param dataType defines the expected data type
  146080. * @returns true if data is correct
  146081. */
  146082. private static _ValidateXHRData;
  146083. }
  146084. }
  146085. declare module BABYLON {
  146086. /** @hidden */
  146087. export var gpuUpdateParticlesPixelShader: {
  146088. name: string;
  146089. shader: string;
  146090. };
  146091. }
  146092. declare module BABYLON {
  146093. /** @hidden */
  146094. export var gpuUpdateParticlesVertexShader: {
  146095. name: string;
  146096. shader: string;
  146097. };
  146098. }
  146099. declare module BABYLON {
  146100. /** @hidden */
  146101. export var clipPlaneFragmentDeclaration2: {
  146102. name: string;
  146103. shader: string;
  146104. };
  146105. }
  146106. declare module BABYLON {
  146107. /** @hidden */
  146108. export var gpuRenderParticlesPixelShader: {
  146109. name: string;
  146110. shader: string;
  146111. };
  146112. }
  146113. declare module BABYLON {
  146114. /** @hidden */
  146115. export var clipPlaneVertexDeclaration2: {
  146116. name: string;
  146117. shader: string;
  146118. };
  146119. }
  146120. declare module BABYLON {
  146121. /** @hidden */
  146122. export var gpuRenderParticlesVertexShader: {
  146123. name: string;
  146124. shader: string;
  146125. };
  146126. }
  146127. declare module BABYLON {
  146128. /**
  146129. * This represents a GPU particle system in Babylon
  146130. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146131. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146132. */
  146133. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146134. /**
  146135. * The layer mask we are rendering the particles through.
  146136. */
  146137. layerMask: number;
  146138. private _capacity;
  146139. private _activeCount;
  146140. private _currentActiveCount;
  146141. private _accumulatedCount;
  146142. private _renderEffect;
  146143. private _updateEffect;
  146144. private _buffer0;
  146145. private _buffer1;
  146146. private _spriteBuffer;
  146147. private _updateVAO;
  146148. private _renderVAO;
  146149. private _targetIndex;
  146150. private _sourceBuffer;
  146151. private _targetBuffer;
  146152. private _currentRenderId;
  146153. private _started;
  146154. private _stopped;
  146155. private _timeDelta;
  146156. private _randomTexture;
  146157. private _randomTexture2;
  146158. private _attributesStrideSize;
  146159. private _updateEffectOptions;
  146160. private _randomTextureSize;
  146161. private _actualFrame;
  146162. private _customEffect;
  146163. private readonly _rawTextureWidth;
  146164. /**
  146165. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146166. */
  146167. static get IsSupported(): boolean;
  146168. /**
  146169. * An event triggered when the system is disposed.
  146170. */
  146171. onDisposeObservable: Observable<IParticleSystem>;
  146172. /**
  146173. * Gets the maximum number of particles active at the same time.
  146174. * @returns The max number of active particles.
  146175. */
  146176. getCapacity(): number;
  146177. /**
  146178. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146179. * to override the particles.
  146180. */
  146181. forceDepthWrite: boolean;
  146182. /**
  146183. * Gets or set the number of active particles
  146184. */
  146185. get activeParticleCount(): number;
  146186. set activeParticleCount(value: number);
  146187. private _preWarmDone;
  146188. /**
  146189. * Specifies if the particles are updated in emitter local space or world space.
  146190. */
  146191. isLocal: boolean;
  146192. /** Gets or sets a matrix to use to compute projection */
  146193. defaultProjectionMatrix: Matrix;
  146194. /**
  146195. * Is this system ready to be used/rendered
  146196. * @return true if the system is ready
  146197. */
  146198. isReady(): boolean;
  146199. /**
  146200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  146201. * @returns True if it has been started, otherwise false.
  146202. */
  146203. isStarted(): boolean;
  146204. /**
  146205. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  146206. * @returns True if it has been stopped, otherwise false.
  146207. */
  146208. isStopped(): boolean;
  146209. /**
  146210. * Gets a boolean indicating that the system is stopping
  146211. * @returns true if the system is currently stopping
  146212. */
  146213. isStopping(): boolean;
  146214. /**
  146215. * Gets the number of particles active at the same time.
  146216. * @returns The number of active particles.
  146217. */
  146218. getActiveCount(): number;
  146219. /**
  146220. * Starts the particle system and begins to emit
  146221. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  146222. */
  146223. start(delay?: number): void;
  146224. /**
  146225. * Stops the particle system.
  146226. */
  146227. stop(): void;
  146228. /**
  146229. * Remove all active particles
  146230. */
  146231. reset(): void;
  146232. /**
  146233. * Returns the string "GPUParticleSystem"
  146234. * @returns a string containing the class name
  146235. */
  146236. getClassName(): string;
  146237. /**
  146238. * Gets the custom effect used to render the particles
  146239. * @param blendMode Blend mode for which the effect should be retrieved
  146240. * @returns The effect
  146241. */
  146242. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146243. /**
  146244. * Sets the custom effect used to render the particles
  146245. * @param effect The effect to set
  146246. * @param blendMode Blend mode for which the effect should be set
  146247. */
  146248. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146249. /** @hidden */
  146250. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146251. /**
  146252. * Observable that will be called just before the particles are drawn
  146253. */
  146254. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146255. /**
  146256. * Gets the name of the particle vertex shader
  146257. */
  146258. get vertexShaderName(): string;
  146259. private _colorGradientsTexture;
  146260. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146261. /**
  146262. * Adds a new color gradient
  146263. * @param gradient defines the gradient to use (between 0 and 1)
  146264. * @param color1 defines the color to affect to the specified gradient
  146265. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146266. * @returns the current particle system
  146267. */
  146268. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146269. private _refreshColorGradient;
  146270. /** Force the system to rebuild all gradients that need to be resync */
  146271. forceRefreshGradients(): void;
  146272. /**
  146273. * Remove a specific color gradient
  146274. * @param gradient defines the gradient to remove
  146275. * @returns the current particle system
  146276. */
  146277. removeColorGradient(gradient: number): GPUParticleSystem;
  146278. private _angularSpeedGradientsTexture;
  146279. private _sizeGradientsTexture;
  146280. private _velocityGradientsTexture;
  146281. private _limitVelocityGradientsTexture;
  146282. private _dragGradientsTexture;
  146283. private _addFactorGradient;
  146284. /**
  146285. * Adds a new size gradient
  146286. * @param gradient defines the gradient to use (between 0 and 1)
  146287. * @param factor defines the size factor to affect to the specified gradient
  146288. * @returns the current particle system
  146289. */
  146290. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146291. /**
  146292. * Remove a specific size gradient
  146293. * @param gradient defines the gradient to remove
  146294. * @returns the current particle system
  146295. */
  146296. removeSizeGradient(gradient: number): GPUParticleSystem;
  146297. private _refreshFactorGradient;
  146298. /**
  146299. * Adds a new angular speed gradient
  146300. * @param gradient defines the gradient to use (between 0 and 1)
  146301. * @param factor defines the angular speed to affect to the specified gradient
  146302. * @returns the current particle system
  146303. */
  146304. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146305. /**
  146306. * Remove a specific angular speed gradient
  146307. * @param gradient defines the gradient to remove
  146308. * @returns the current particle system
  146309. */
  146310. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146311. /**
  146312. * Adds a new velocity gradient
  146313. * @param gradient defines the gradient to use (between 0 and 1)
  146314. * @param factor defines the velocity to affect to the specified gradient
  146315. * @returns the current particle system
  146316. */
  146317. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146318. /**
  146319. * Remove a specific velocity gradient
  146320. * @param gradient defines the gradient to remove
  146321. * @returns the current particle system
  146322. */
  146323. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146324. /**
  146325. * Adds a new limit velocity gradient
  146326. * @param gradient defines the gradient to use (between 0 and 1)
  146327. * @param factor defines the limit velocity value to affect to the specified gradient
  146328. * @returns the current particle system
  146329. */
  146330. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146331. /**
  146332. * Remove a specific limit velocity gradient
  146333. * @param gradient defines the gradient to remove
  146334. * @returns the current particle system
  146335. */
  146336. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146337. /**
  146338. * Adds a new drag gradient
  146339. * @param gradient defines the gradient to use (between 0 and 1)
  146340. * @param factor defines the drag value to affect to the specified gradient
  146341. * @returns the current particle system
  146342. */
  146343. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146344. /**
  146345. * Remove a specific drag gradient
  146346. * @param gradient defines the gradient to remove
  146347. * @returns the current particle system
  146348. */
  146349. removeDragGradient(gradient: number): GPUParticleSystem;
  146350. /**
  146351. * Not supported by GPUParticleSystem
  146352. * @param gradient defines the gradient to use (between 0 and 1)
  146353. * @param factor defines the emit rate value to affect to the specified gradient
  146354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146355. * @returns the current particle system
  146356. */
  146357. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146358. /**
  146359. * Not supported by GPUParticleSystem
  146360. * @param gradient defines the gradient to remove
  146361. * @returns the current particle system
  146362. */
  146363. removeEmitRateGradient(gradient: number): IParticleSystem;
  146364. /**
  146365. * Not supported by GPUParticleSystem
  146366. * @param gradient defines the gradient to use (between 0 and 1)
  146367. * @param factor defines the start size value to affect to the specified gradient
  146368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146369. * @returns the current particle system
  146370. */
  146371. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146372. /**
  146373. * Not supported by GPUParticleSystem
  146374. * @param gradient defines the gradient to remove
  146375. * @returns the current particle system
  146376. */
  146377. removeStartSizeGradient(gradient: number): IParticleSystem;
  146378. /**
  146379. * Not supported by GPUParticleSystem
  146380. * @param gradient defines the gradient to use (between 0 and 1)
  146381. * @param min defines the color remap minimal range
  146382. * @param max defines the color remap maximal range
  146383. * @returns the current particle system
  146384. */
  146385. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146386. /**
  146387. * Not supported by GPUParticleSystem
  146388. * @param gradient defines the gradient to remove
  146389. * @returns the current particle system
  146390. */
  146391. removeColorRemapGradient(): IParticleSystem;
  146392. /**
  146393. * Not supported by GPUParticleSystem
  146394. * @param gradient defines the gradient to use (between 0 and 1)
  146395. * @param min defines the alpha remap minimal range
  146396. * @param max defines the alpha remap maximal range
  146397. * @returns the current particle system
  146398. */
  146399. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146400. /**
  146401. * Not supported by GPUParticleSystem
  146402. * @param gradient defines the gradient to remove
  146403. * @returns the current particle system
  146404. */
  146405. removeAlphaRemapGradient(): IParticleSystem;
  146406. /**
  146407. * Not supported by GPUParticleSystem
  146408. * @param gradient defines the gradient to use (between 0 and 1)
  146409. * @param color defines the color to affect to the specified gradient
  146410. * @returns the current particle system
  146411. */
  146412. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146413. /**
  146414. * Not supported by GPUParticleSystem
  146415. * @param gradient defines the gradient to remove
  146416. * @returns the current particle system
  146417. */
  146418. removeRampGradient(): IParticleSystem;
  146419. /**
  146420. * Not supported by GPUParticleSystem
  146421. * @returns the list of ramp gradients
  146422. */
  146423. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146424. /**
  146425. * Not supported by GPUParticleSystem
  146426. * Gets or sets a boolean indicating that ramp gradients must be used
  146427. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146428. */
  146429. get useRampGradients(): boolean;
  146430. set useRampGradients(value: boolean);
  146431. /**
  146432. * Not supported by GPUParticleSystem
  146433. * @param gradient defines the gradient to use (between 0 and 1)
  146434. * @param factor defines the life time factor to affect to the specified gradient
  146435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146436. * @returns the current particle system
  146437. */
  146438. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146439. /**
  146440. * Not supported by GPUParticleSystem
  146441. * @param gradient defines the gradient to remove
  146442. * @returns the current particle system
  146443. */
  146444. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146445. /**
  146446. * Instantiates a GPU particle system.
  146447. * 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.
  146448. * @param name The name of the particle system
  146449. * @param options The options used to create the system
  146450. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  146451. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146452. * @param customEffect a custom effect used to change the way particles are rendered by default
  146453. */
  146454. constructor(name: string, options: Partial<{
  146455. capacity: number;
  146456. randomTextureSize: number;
  146457. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146458. protected _reset(): void;
  146459. private _createUpdateVAO;
  146460. private _createRenderVAO;
  146461. private _initialize;
  146462. /** @hidden */
  146463. _recreateUpdateEffect(): void;
  146464. private _getEffect;
  146465. /**
  146466. * Fill the defines array according to the current settings of the particle system
  146467. * @param defines Array to be updated
  146468. * @param blendMode blend mode to take into account when updating the array
  146469. */
  146470. fillDefines(defines: Array<string>, blendMode?: number): void;
  146471. /**
  146472. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146473. * @param uniforms Uniforms array to fill
  146474. * @param attributes Attributes array to fill
  146475. * @param samplers Samplers array to fill
  146476. */
  146477. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146478. /** @hidden */
  146479. _recreateRenderEffect(): Effect;
  146480. /**
  146481. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146482. * @param preWarm defines if we are in the pre-warmimg phase
  146483. */
  146484. animate(preWarm?: boolean): void;
  146485. private _createFactorGradientTexture;
  146486. private _createSizeGradientTexture;
  146487. private _createAngularSpeedGradientTexture;
  146488. private _createVelocityGradientTexture;
  146489. private _createLimitVelocityGradientTexture;
  146490. private _createDragGradientTexture;
  146491. private _createColorGradientTexture;
  146492. /**
  146493. * Renders the particle system in its current state
  146494. * @param preWarm defines if the system should only update the particles but not render them
  146495. * @returns the current number of particles
  146496. */
  146497. render(preWarm?: boolean): number;
  146498. /**
  146499. * Rebuilds the particle system
  146500. */
  146501. rebuild(): void;
  146502. private _releaseBuffers;
  146503. private _releaseVAOs;
  146504. /**
  146505. * Disposes the particle system and free the associated resources
  146506. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146507. */
  146508. dispose(disposeTexture?: boolean): void;
  146509. /**
  146510. * Clones the particle system.
  146511. * @param name The name of the cloned object
  146512. * @param newEmitter The new emitter to use
  146513. * @returns the cloned particle system
  146514. */
  146515. clone(name: string, newEmitter: any): GPUParticleSystem;
  146516. /**
  146517. * Serializes the particle system to a JSON object
  146518. * @param serializeTexture defines if the texture must be serialized as well
  146519. * @returns the JSON object
  146520. */
  146521. serialize(serializeTexture?: boolean): any;
  146522. /**
  146523. * Parses a JSON object to create a GPU particle system.
  146524. * @param parsedParticleSystem The JSON object to parse
  146525. * @param sceneOrEngine The scene or the engine to create the particle system in
  146526. * @param rootUrl The root url to use to load external dependencies like texture
  146527. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146528. * @returns the parsed GPU particle system
  146529. */
  146530. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146531. }
  146532. }
  146533. declare module BABYLON {
  146534. /**
  146535. * Represents a set of particle systems working together to create a specific effect
  146536. */
  146537. export class ParticleSystemSet implements IDisposable {
  146538. /**
  146539. * Gets or sets base Assets URL
  146540. */
  146541. static BaseAssetsUrl: string;
  146542. private _emitterCreationOptions;
  146543. private _emitterNode;
  146544. /**
  146545. * Gets the particle system list
  146546. */
  146547. systems: IParticleSystem[];
  146548. /**
  146549. * Gets the emitter node used with this set
  146550. */
  146551. get emitterNode(): Nullable<TransformNode>;
  146552. /**
  146553. * Creates a new emitter mesh as a sphere
  146554. * @param options defines the options used to create the sphere
  146555. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146556. * @param scene defines the hosting scene
  146557. */
  146558. setEmitterAsSphere(options: {
  146559. diameter: number;
  146560. segments: number;
  146561. color: Color3;
  146562. }, renderingGroupId: number, scene: Scene): void;
  146563. /**
  146564. * Starts all particle systems of the set
  146565. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146566. */
  146567. start(emitter?: AbstractMesh): void;
  146568. /**
  146569. * Release all associated resources
  146570. */
  146571. dispose(): void;
  146572. /**
  146573. * Serialize the set into a JSON compatible object
  146574. * @param serializeTexture defines if the texture must be serialized as well
  146575. * @returns a JSON compatible representation of the set
  146576. */
  146577. serialize(serializeTexture?: boolean): any;
  146578. /**
  146579. * Parse a new ParticleSystemSet from a serialized source
  146580. * @param data defines a JSON compatible representation of the set
  146581. * @param scene defines the hosting scene
  146582. * @param gpu defines if we want GPU particles or CPU particles
  146583. * @returns a new ParticleSystemSet
  146584. */
  146585. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146586. }
  146587. }
  146588. declare module BABYLON {
  146589. /**
  146590. * This class is made for on one-liner static method to help creating particle system set.
  146591. */
  146592. export class ParticleHelper {
  146593. /**
  146594. * Gets or sets base Assets URL
  146595. */
  146596. static BaseAssetsUrl: string;
  146597. /** Define the Url to load snippets */
  146598. static SnippetUrl: string;
  146599. /**
  146600. * Create a default particle system that you can tweak
  146601. * @param emitter defines the emitter to use
  146602. * @param capacity defines the system capacity (default is 500 particles)
  146603. * @param scene defines the hosting scene
  146604. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146605. * @returns the new Particle system
  146606. */
  146607. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146608. /**
  146609. * This is the main static method (one-liner) of this helper to create different particle systems
  146610. * @param type This string represents the type to the particle system to create
  146611. * @param scene The scene where the particle system should live
  146612. * @param gpu If the system will use gpu
  146613. * @returns the ParticleSystemSet created
  146614. */
  146615. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146616. /**
  146617. * Static function used to export a particle system to a ParticleSystemSet variable.
  146618. * Please note that the emitter shape is not exported
  146619. * @param systems defines the particle systems to export
  146620. * @returns the created particle system set
  146621. */
  146622. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146623. /**
  146624. * Creates a particle system from a snippet saved in a remote file
  146625. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146626. * @param url defines the url to load from
  146627. * @param scene defines the hosting scene
  146628. * @param gpu If the system will use gpu
  146629. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146630. * @returns a promise that will resolve to the new particle system
  146631. */
  146632. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146633. /**
  146634. * Creates a particle system from a snippet saved by the particle system editor
  146635. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146636. * @param scene defines the hosting scene
  146637. * @param gpu If the system will use gpu
  146638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146639. * @returns a promise that will resolve to the new particle system
  146640. */
  146641. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146642. }
  146643. }
  146644. declare module BABYLON {
  146645. interface Engine {
  146646. /**
  146647. * Create an effect to use with particle systems.
  146648. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146649. * the particle system for which you want to create a custom effect in the last parameter
  146650. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146651. * @param uniformsNames defines a list of attribute names
  146652. * @param samplers defines an array of string used to represent textures
  146653. * @param defines defines the string containing the defines to use to compile the shaders
  146654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146655. * @param onCompiled defines a function to call when the effect creation is successful
  146656. * @param onError defines a function to call when the effect creation has failed
  146657. * @param particleSystem the particle system you want to create the effect for
  146658. * @returns the new Effect
  146659. */
  146660. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146661. }
  146662. interface Mesh {
  146663. /**
  146664. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146665. * @returns an array of IParticleSystem
  146666. */
  146667. getEmittedParticleSystems(): IParticleSystem[];
  146668. /**
  146669. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146670. * @returns an array of IParticleSystem
  146671. */
  146672. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146673. }
  146674. }
  146675. declare module BABYLON {
  146676. /** Defines the 4 color options */
  146677. export enum PointColor {
  146678. /** color value */
  146679. Color = 2,
  146680. /** uv value */
  146681. UV = 1,
  146682. /** random value */
  146683. Random = 0,
  146684. /** stated value */
  146685. Stated = 3
  146686. }
  146687. /**
  146688. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146689. * 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.
  146690. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146691. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146692. *
  146693. * Full documentation here : TO BE ENTERED
  146694. */
  146695. export class PointsCloudSystem implements IDisposable {
  146696. /**
  146697. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146698. * Example : var p = SPS.particles[i];
  146699. */
  146700. particles: CloudPoint[];
  146701. /**
  146702. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146703. */
  146704. nbParticles: number;
  146705. /**
  146706. * This a counter for your own usage. It's not set by any SPS functions.
  146707. */
  146708. counter: number;
  146709. /**
  146710. * The PCS name. This name is also given to the underlying mesh.
  146711. */
  146712. name: string;
  146713. /**
  146714. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146715. */
  146716. mesh: Mesh;
  146717. /**
  146718. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146719. * Please read :
  146720. */
  146721. vars: any;
  146722. /**
  146723. * @hidden
  146724. */
  146725. _size: number;
  146726. private _scene;
  146727. private _promises;
  146728. private _positions;
  146729. private _indices;
  146730. private _normals;
  146731. private _colors;
  146732. private _uvs;
  146733. private _indices32;
  146734. private _positions32;
  146735. private _colors32;
  146736. private _uvs32;
  146737. private _updatable;
  146738. private _isVisibilityBoxLocked;
  146739. private _alwaysVisible;
  146740. private _groups;
  146741. private _groupCounter;
  146742. private _computeParticleColor;
  146743. private _computeParticleTexture;
  146744. private _computeParticleRotation;
  146745. private _computeBoundingBox;
  146746. private _isReady;
  146747. /**
  146748. * Creates a PCS (Points Cloud System) object
  146749. * @param name (String) is the PCS name, this will be the underlying mesh name
  146750. * @param pointSize (number) is the size for each point
  146751. * @param scene (Scene) is the scene in which the PCS is added
  146752. * @param options defines the options of the PCS e.g.
  146753. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146754. */
  146755. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146756. updatable?: boolean;
  146757. });
  146758. /**
  146759. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146760. * If no points were added to the PCS, the returned mesh is just a single point.
  146761. * @returns a promise for the created mesh
  146762. */
  146763. buildMeshAsync(): Promise<Mesh>;
  146764. /**
  146765. * @hidden
  146766. */
  146767. private _buildMesh;
  146768. private _addParticle;
  146769. private _randomUnitVector;
  146770. private _getColorIndicesForCoord;
  146771. private _setPointsColorOrUV;
  146772. private _colorFromTexture;
  146773. private _calculateDensity;
  146774. /**
  146775. * Adds points to the PCS in random positions within a unit sphere
  146776. * @param nb (positive integer) the number of particles to be created from this model
  146777. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146778. * @returns the number of groups in the system
  146779. */
  146780. addPoints(nb: number, pointFunction?: any): number;
  146781. /**
  146782. * Adds points to the PCS from the surface of the model shape
  146783. * @param mesh is any Mesh object that will be used as a surface model for the points
  146784. * @param nb (positive integer) the number of particles to be created from this model
  146785. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146786. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146787. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146788. * @returns the number of groups in the system
  146789. */
  146790. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146791. /**
  146792. * Adds points to the PCS inside the model shape
  146793. * @param mesh is any Mesh object that will be used as a surface model for the points
  146794. * @param nb (positive integer) the number of particles to be created from this model
  146795. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146796. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146797. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146798. * @returns the number of groups in the system
  146799. */
  146800. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146801. /**
  146802. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146803. * This method calls `updateParticle()` for each particle of the SPS.
  146804. * For an animated SPS, it is usually called within the render loop.
  146805. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146806. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146807. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146808. * @returns the PCS.
  146809. */
  146810. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146811. /**
  146812. * Disposes the PCS.
  146813. */
  146814. dispose(): void;
  146815. /**
  146816. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146817. * doc :
  146818. * @returns the PCS.
  146819. */
  146820. refreshVisibleSize(): PointsCloudSystem;
  146821. /**
  146822. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146823. * @param size the size (float) of the visibility box
  146824. * note : this doesn't lock the PCS mesh bounding box.
  146825. * doc :
  146826. */
  146827. setVisibilityBox(size: number): void;
  146828. /**
  146829. * Gets whether the PCS is always visible or not
  146830. * doc :
  146831. */
  146832. get isAlwaysVisible(): boolean;
  146833. /**
  146834. * Sets the PCS as always visible or not
  146835. * doc :
  146836. */
  146837. set isAlwaysVisible(val: boolean);
  146838. /**
  146839. * Tells to `setParticles()` to compute the particle rotations or not
  146840. * Default value : false. The PCS is faster when it's set to false
  146841. * Note : particle rotations are only applied to parent particles
  146842. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146843. */
  146844. set computeParticleRotation(val: boolean);
  146845. /**
  146846. * Tells to `setParticles()` to compute the particle colors or not.
  146847. * Default value : true. The PCS is faster when it's set to false.
  146848. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146849. */
  146850. set computeParticleColor(val: boolean);
  146851. set computeParticleTexture(val: boolean);
  146852. /**
  146853. * Gets if `setParticles()` computes the particle colors or not.
  146854. * Default value : false. The PCS is faster when it's set to false.
  146855. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146856. */
  146857. get computeParticleColor(): boolean;
  146858. /**
  146859. * Gets if `setParticles()` computes the particle textures or not.
  146860. * Default value : false. The PCS is faster when it's set to false.
  146861. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146862. */
  146863. get computeParticleTexture(): boolean;
  146864. /**
  146865. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146866. */
  146867. set computeBoundingBox(val: boolean);
  146868. /**
  146869. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146870. */
  146871. get computeBoundingBox(): boolean;
  146872. /**
  146873. * This function does nothing. It may be overwritten to set all the particle first values.
  146874. * The PCS doesn't call this function, you may have to call it by your own.
  146875. * doc :
  146876. */
  146877. initParticles(): void;
  146878. /**
  146879. * This function does nothing. It may be overwritten to recycle a particle
  146880. * The PCS doesn't call this function, you can to call it
  146881. * doc :
  146882. * @param particle The particle to recycle
  146883. * @returns the recycled particle
  146884. */
  146885. recycleParticle(particle: CloudPoint): CloudPoint;
  146886. /**
  146887. * Updates a particle : this function should be overwritten by the user.
  146888. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146889. * doc :
  146890. * @example : just set a particle position or velocity and recycle conditions
  146891. * @param particle The particle to update
  146892. * @returns the updated particle
  146893. */
  146894. updateParticle(particle: CloudPoint): CloudPoint;
  146895. /**
  146896. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146897. * This does nothing and may be overwritten by the user.
  146898. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146899. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146900. * @param update the boolean update value actually passed to setParticles()
  146901. */
  146902. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146903. /**
  146904. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146905. * This will be passed three parameters.
  146906. * This does nothing and may be overwritten by the user.
  146907. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146908. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146909. * @param update the boolean update value actually passed to setParticles()
  146910. */
  146911. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146912. }
  146913. }
  146914. declare module BABYLON {
  146915. /**
  146916. * Represents one particle of a points cloud system.
  146917. */
  146918. export class CloudPoint {
  146919. /**
  146920. * particle global index
  146921. */
  146922. idx: number;
  146923. /**
  146924. * The color of the particle
  146925. */
  146926. color: Nullable<Color4>;
  146927. /**
  146928. * The world space position of the particle.
  146929. */
  146930. position: Vector3;
  146931. /**
  146932. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146933. */
  146934. rotation: Vector3;
  146935. /**
  146936. * The world space rotation quaternion of the particle.
  146937. */
  146938. rotationQuaternion: Nullable<Quaternion>;
  146939. /**
  146940. * The uv of the particle.
  146941. */
  146942. uv: Nullable<Vector2>;
  146943. /**
  146944. * The current speed of the particle.
  146945. */
  146946. velocity: Vector3;
  146947. /**
  146948. * The pivot point in the particle local space.
  146949. */
  146950. pivot: Vector3;
  146951. /**
  146952. * Must the particle be translated from its pivot point in its local space ?
  146953. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146954. * Default : false
  146955. */
  146956. translateFromPivot: boolean;
  146957. /**
  146958. * Index of this particle in the global "positions" array (Internal use)
  146959. * @hidden
  146960. */
  146961. _pos: number;
  146962. /**
  146963. * @hidden Index of this particle in the global "indices" array (Internal use)
  146964. */
  146965. _ind: number;
  146966. /**
  146967. * Group this particle belongs to
  146968. */
  146969. _group: PointsGroup;
  146970. /**
  146971. * Group id of this particle
  146972. */
  146973. groupId: number;
  146974. /**
  146975. * Index of the particle in its group id (Internal use)
  146976. */
  146977. idxInGroup: number;
  146978. /**
  146979. * @hidden Particle BoundingInfo object (Internal use)
  146980. */
  146981. _boundingInfo: BoundingInfo;
  146982. /**
  146983. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146984. */
  146985. _pcs: PointsCloudSystem;
  146986. /**
  146987. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146988. */
  146989. _stillInvisible: boolean;
  146990. /**
  146991. * @hidden Last computed particle rotation matrix
  146992. */
  146993. _rotationMatrix: number[];
  146994. /**
  146995. * Parent particle Id, if any.
  146996. * Default null.
  146997. */
  146998. parentId: Nullable<number>;
  146999. /**
  147000. * @hidden Internal global position in the PCS.
  147001. */
  147002. _globalPosition: Vector3;
  147003. /**
  147004. * Creates a Point Cloud object.
  147005. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147006. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147007. * @param group (PointsGroup) is the group the particle belongs to
  147008. * @param groupId (integer) is the group identifier in the PCS.
  147009. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147010. * @param pcs defines the PCS it is associated to
  147011. */
  147012. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147013. /**
  147014. * get point size
  147015. */
  147016. get size(): Vector3;
  147017. /**
  147018. * Set point size
  147019. */
  147020. set size(scale: Vector3);
  147021. /**
  147022. * Legacy support, changed quaternion to rotationQuaternion
  147023. */
  147024. get quaternion(): Nullable<Quaternion>;
  147025. /**
  147026. * Legacy support, changed quaternion to rotationQuaternion
  147027. */
  147028. set quaternion(q: Nullable<Quaternion>);
  147029. /**
  147030. * Returns a boolean. True if the particle intersects a mesh, else false
  147031. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147032. * @param target is the object (point or mesh) what the intersection is computed against
  147033. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147034. * @returns true if it intersects
  147035. */
  147036. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147037. /**
  147038. * get the rotation matrix of the particle
  147039. * @hidden
  147040. */
  147041. getRotationMatrix(m: Matrix): void;
  147042. }
  147043. /**
  147044. * Represents a group of points in a points cloud system
  147045. * * PCS internal tool, don't use it manually.
  147046. */
  147047. export class PointsGroup {
  147048. /**
  147049. * The group id
  147050. * @hidden
  147051. */
  147052. groupID: number;
  147053. /**
  147054. * image data for group (internal use)
  147055. * @hidden
  147056. */
  147057. _groupImageData: Nullable<ArrayBufferView>;
  147058. /**
  147059. * Image Width (internal use)
  147060. * @hidden
  147061. */
  147062. _groupImgWidth: number;
  147063. /**
  147064. * Image Height (internal use)
  147065. * @hidden
  147066. */
  147067. _groupImgHeight: number;
  147068. /**
  147069. * Custom position function (internal use)
  147070. * @hidden
  147071. */
  147072. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147073. /**
  147074. * density per facet for surface points
  147075. * @hidden
  147076. */
  147077. _groupDensity: number[];
  147078. /**
  147079. * Only when points are colored by texture carries pointer to texture list array
  147080. * @hidden
  147081. */
  147082. _textureNb: number;
  147083. /**
  147084. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  147085. * PCS internal tool, don't use it manually.
  147086. * @hidden
  147087. */
  147088. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  147089. }
  147090. }
  147091. declare module BABYLON {
  147092. interface Scene {
  147093. /** @hidden (Backing field) */
  147094. _physicsEngine: Nullable<IPhysicsEngine>;
  147095. /** @hidden */
  147096. _physicsTimeAccumulator: number;
  147097. /**
  147098. * Gets the current physics engine
  147099. * @returns a IPhysicsEngine or null if none attached
  147100. */
  147101. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  147102. /**
  147103. * Enables physics to the current scene
  147104. * @param gravity defines the scene's gravity for the physics engine
  147105. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  147106. * @return a boolean indicating if the physics engine was initialized
  147107. */
  147108. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  147109. /**
  147110. * Disables and disposes the physics engine associated with the scene
  147111. */
  147112. disablePhysicsEngine(): void;
  147113. /**
  147114. * Gets a boolean indicating if there is an active physics engine
  147115. * @returns a boolean indicating if there is an active physics engine
  147116. */
  147117. isPhysicsEnabled(): boolean;
  147118. /**
  147119. * Deletes a physics compound impostor
  147120. * @param compound defines the compound to delete
  147121. */
  147122. deleteCompoundImpostor(compound: any): void;
  147123. /**
  147124. * An event triggered when physic simulation is about to be run
  147125. */
  147126. onBeforePhysicsObservable: Observable<Scene>;
  147127. /**
  147128. * An event triggered when physic simulation has been done
  147129. */
  147130. onAfterPhysicsObservable: Observable<Scene>;
  147131. }
  147132. interface AbstractMesh {
  147133. /** @hidden */
  147134. _physicsImpostor: Nullable<PhysicsImpostor>;
  147135. /**
  147136. * Gets or sets impostor used for physic simulation
  147137. * @see https://doc.babylonjs.com/features/physics_engine
  147138. */
  147139. physicsImpostor: Nullable<PhysicsImpostor>;
  147140. /**
  147141. * Gets the current physics impostor
  147142. * @see https://doc.babylonjs.com/features/physics_engine
  147143. * @returns a physics impostor or null
  147144. */
  147145. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147146. /** Apply a physic impulse to the mesh
  147147. * @param force defines the force to apply
  147148. * @param contactPoint defines where to apply the force
  147149. * @returns the current mesh
  147150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147151. */
  147152. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147153. /**
  147154. * Creates a physic joint between two meshes
  147155. * @param otherMesh defines the other mesh to use
  147156. * @param pivot1 defines the pivot to use on this mesh
  147157. * @param pivot2 defines the pivot to use on the other mesh
  147158. * @param options defines additional options (can be plugin dependent)
  147159. * @returns the current mesh
  147160. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147161. */
  147162. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147163. /** @hidden */
  147164. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147165. }
  147166. /**
  147167. * Defines the physics engine scene component responsible to manage a physics engine
  147168. */
  147169. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147170. /**
  147171. * The component name helpful to identify the component in the list of scene components.
  147172. */
  147173. readonly name: string;
  147174. /**
  147175. * The scene the component belongs to.
  147176. */
  147177. scene: Scene;
  147178. /**
  147179. * Creates a new instance of the component for the given scene
  147180. * @param scene Defines the scene to register the component in
  147181. */
  147182. constructor(scene: Scene);
  147183. /**
  147184. * Registers the component in a given scene
  147185. */
  147186. register(): void;
  147187. /**
  147188. * Rebuilds the elements related to this component in case of
  147189. * context lost for instance.
  147190. */
  147191. rebuild(): void;
  147192. /**
  147193. * Disposes the component and the associated ressources
  147194. */
  147195. dispose(): void;
  147196. }
  147197. }
  147198. declare module BABYLON {
  147199. /**
  147200. * A helper for physics simulations
  147201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147202. */
  147203. export class PhysicsHelper {
  147204. private _scene;
  147205. private _physicsEngine;
  147206. /**
  147207. * Initializes the Physics helper
  147208. * @param scene Babylon.js scene
  147209. */
  147210. constructor(scene: Scene);
  147211. /**
  147212. * Applies a radial explosion impulse
  147213. * @param origin the origin of the explosion
  147214. * @param radiusOrEventOptions the radius or the options of radial explosion
  147215. * @param strength the explosion strength
  147216. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147217. * @returns A physics radial explosion event, or null
  147218. */
  147219. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147220. /**
  147221. * Applies a radial explosion force
  147222. * @param origin the origin of the explosion
  147223. * @param radiusOrEventOptions the radius or the options of radial explosion
  147224. * @param strength the explosion strength
  147225. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147226. * @returns A physics radial explosion event, or null
  147227. */
  147228. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147229. /**
  147230. * Creates a gravitational field
  147231. * @param origin the origin of the explosion
  147232. * @param radiusOrEventOptions the radius or the options of radial explosion
  147233. * @param strength the explosion strength
  147234. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147235. * @returns A physics gravitational field event, or null
  147236. */
  147237. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147238. /**
  147239. * Creates a physics updraft event
  147240. * @param origin the origin of the updraft
  147241. * @param radiusOrEventOptions the radius or the options of the updraft
  147242. * @param strength the strength of the updraft
  147243. * @param height the height of the updraft
  147244. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147245. * @returns A physics updraft event, or null
  147246. */
  147247. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147248. /**
  147249. * Creates a physics vortex event
  147250. * @param origin the of the vortex
  147251. * @param radiusOrEventOptions the radius or the options of the vortex
  147252. * @param strength the strength of the vortex
  147253. * @param height the height of the vortex
  147254. * @returns a Physics vortex event, or null
  147255. * A physics vortex event or null
  147256. */
  147257. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147258. }
  147259. /**
  147260. * Represents a physics radial explosion event
  147261. */
  147262. class PhysicsRadialExplosionEvent {
  147263. private _scene;
  147264. private _options;
  147265. private _sphere;
  147266. private _dataFetched;
  147267. /**
  147268. * Initializes a radial explosioin event
  147269. * @param _scene BabylonJS scene
  147270. * @param _options The options for the vortex event
  147271. */
  147272. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147273. /**
  147274. * Returns the data related to the radial explosion event (sphere).
  147275. * @returns The radial explosion event data
  147276. */
  147277. getData(): PhysicsRadialExplosionEventData;
  147278. /**
  147279. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147280. * @param impostor A physics imposter
  147281. * @param origin the origin of the explosion
  147282. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147283. */
  147284. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147285. /**
  147286. * Triggers affecterd impostors callbacks
  147287. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147288. */
  147289. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147290. /**
  147291. * Disposes the sphere.
  147292. * @param force Specifies if the sphere should be disposed by force
  147293. */
  147294. dispose(force?: boolean): void;
  147295. /*** Helpers ***/
  147296. private _prepareSphere;
  147297. private _intersectsWithSphere;
  147298. }
  147299. /**
  147300. * Represents a gravitational field event
  147301. */
  147302. class PhysicsGravitationalFieldEvent {
  147303. private _physicsHelper;
  147304. private _scene;
  147305. private _origin;
  147306. private _options;
  147307. private _tickCallback;
  147308. private _sphere;
  147309. private _dataFetched;
  147310. /**
  147311. * Initializes the physics gravitational field event
  147312. * @param _physicsHelper A physics helper
  147313. * @param _scene BabylonJS scene
  147314. * @param _origin The origin position of the gravitational field event
  147315. * @param _options The options for the vortex event
  147316. */
  147317. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147318. /**
  147319. * Returns the data related to the gravitational field event (sphere).
  147320. * @returns A gravitational field event
  147321. */
  147322. getData(): PhysicsGravitationalFieldEventData;
  147323. /**
  147324. * Enables the gravitational field.
  147325. */
  147326. enable(): void;
  147327. /**
  147328. * Disables the gravitational field.
  147329. */
  147330. disable(): void;
  147331. /**
  147332. * Disposes the sphere.
  147333. * @param force The force to dispose from the gravitational field event
  147334. */
  147335. dispose(force?: boolean): void;
  147336. private _tick;
  147337. }
  147338. /**
  147339. * Represents a physics updraft event
  147340. */
  147341. class PhysicsUpdraftEvent {
  147342. private _scene;
  147343. private _origin;
  147344. private _options;
  147345. private _physicsEngine;
  147346. private _originTop;
  147347. private _originDirection;
  147348. private _tickCallback;
  147349. private _cylinder;
  147350. private _cylinderPosition;
  147351. private _dataFetched;
  147352. /**
  147353. * Initializes the physics updraft event
  147354. * @param _scene BabylonJS scene
  147355. * @param _origin The origin position of the updraft
  147356. * @param _options The options for the updraft event
  147357. */
  147358. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147359. /**
  147360. * Returns the data related to the updraft event (cylinder).
  147361. * @returns A physics updraft event
  147362. */
  147363. getData(): PhysicsUpdraftEventData;
  147364. /**
  147365. * Enables the updraft.
  147366. */
  147367. enable(): void;
  147368. /**
  147369. * Disables the updraft.
  147370. */
  147371. disable(): void;
  147372. /**
  147373. * Disposes the cylinder.
  147374. * @param force Specifies if the updraft should be disposed by force
  147375. */
  147376. dispose(force?: boolean): void;
  147377. private getImpostorHitData;
  147378. private _tick;
  147379. /*** Helpers ***/
  147380. private _prepareCylinder;
  147381. private _intersectsWithCylinder;
  147382. }
  147383. /**
  147384. * Represents a physics vortex event
  147385. */
  147386. class PhysicsVortexEvent {
  147387. private _scene;
  147388. private _origin;
  147389. private _options;
  147390. private _physicsEngine;
  147391. private _originTop;
  147392. private _tickCallback;
  147393. private _cylinder;
  147394. private _cylinderPosition;
  147395. private _dataFetched;
  147396. /**
  147397. * Initializes the physics vortex event
  147398. * @param _scene The BabylonJS scene
  147399. * @param _origin The origin position of the vortex
  147400. * @param _options The options for the vortex event
  147401. */
  147402. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147403. /**
  147404. * Returns the data related to the vortex event (cylinder).
  147405. * @returns The physics vortex event data
  147406. */
  147407. getData(): PhysicsVortexEventData;
  147408. /**
  147409. * Enables the vortex.
  147410. */
  147411. enable(): void;
  147412. /**
  147413. * Disables the cortex.
  147414. */
  147415. disable(): void;
  147416. /**
  147417. * Disposes the sphere.
  147418. * @param force
  147419. */
  147420. dispose(force?: boolean): void;
  147421. private getImpostorHitData;
  147422. private _tick;
  147423. /*** Helpers ***/
  147424. private _prepareCylinder;
  147425. private _intersectsWithCylinder;
  147426. }
  147427. /**
  147428. * Options fot the radial explosion event
  147429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147430. */
  147431. export class PhysicsRadialExplosionEventOptions {
  147432. /**
  147433. * The radius of the sphere for the radial explosion.
  147434. */
  147435. radius: number;
  147436. /**
  147437. * The strenth of the explosion.
  147438. */
  147439. strength: number;
  147440. /**
  147441. * The strenght of the force in correspondence to the distance of the affected object
  147442. */
  147443. falloff: PhysicsRadialImpulseFalloff;
  147444. /**
  147445. * Sphere options for the radial explosion.
  147446. */
  147447. sphere: {
  147448. segments: number;
  147449. diameter: number;
  147450. };
  147451. /**
  147452. * Sphere options for the radial explosion.
  147453. */
  147454. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147455. }
  147456. /**
  147457. * Options fot the updraft event
  147458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147459. */
  147460. export class PhysicsUpdraftEventOptions {
  147461. /**
  147462. * The radius of the cylinder for the vortex
  147463. */
  147464. radius: number;
  147465. /**
  147466. * The strenth of the updraft.
  147467. */
  147468. strength: number;
  147469. /**
  147470. * The height of the cylinder for the updraft.
  147471. */
  147472. height: number;
  147473. /**
  147474. * The mode for the the updraft.
  147475. */
  147476. updraftMode: PhysicsUpdraftMode;
  147477. }
  147478. /**
  147479. * Options fot the vortex event
  147480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147481. */
  147482. export class PhysicsVortexEventOptions {
  147483. /**
  147484. * The radius of the cylinder for the vortex
  147485. */
  147486. radius: number;
  147487. /**
  147488. * The strenth of the vortex.
  147489. */
  147490. strength: number;
  147491. /**
  147492. * The height of the cylinder for the vortex.
  147493. */
  147494. height: number;
  147495. /**
  147496. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147497. */
  147498. centripetalForceThreshold: number;
  147499. /**
  147500. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147501. */
  147502. centripetalForceMultiplier: number;
  147503. /**
  147504. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147505. */
  147506. centrifugalForceMultiplier: number;
  147507. /**
  147508. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147509. */
  147510. updraftForceMultiplier: number;
  147511. }
  147512. /**
  147513. * The strenght of the force in correspondence to the distance of the affected object
  147514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147515. */
  147516. export enum PhysicsRadialImpulseFalloff {
  147517. /** Defines that impulse is constant in strength across it's whole radius */
  147518. Constant = 0,
  147519. /** Defines that impulse gets weaker if it's further from the origin */
  147520. Linear = 1
  147521. }
  147522. /**
  147523. * The strength of the force in correspondence to the distance of the affected object
  147524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147525. */
  147526. export enum PhysicsUpdraftMode {
  147527. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147528. Center = 0,
  147529. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147530. Perpendicular = 1
  147531. }
  147532. /**
  147533. * Interface for a physics hit data
  147534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147535. */
  147536. export interface PhysicsHitData {
  147537. /**
  147538. * The force applied at the contact point
  147539. */
  147540. force: Vector3;
  147541. /**
  147542. * The contact point
  147543. */
  147544. contactPoint: Vector3;
  147545. /**
  147546. * The distance from the origin to the contact point
  147547. */
  147548. distanceFromOrigin: number;
  147549. }
  147550. /**
  147551. * Interface for radial explosion event data
  147552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147553. */
  147554. export interface PhysicsRadialExplosionEventData {
  147555. /**
  147556. * A sphere used for the radial explosion event
  147557. */
  147558. sphere: Mesh;
  147559. }
  147560. /**
  147561. * Interface for gravitational field event data
  147562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147563. */
  147564. export interface PhysicsGravitationalFieldEventData {
  147565. /**
  147566. * A sphere mesh used for the gravitational field event
  147567. */
  147568. sphere: Mesh;
  147569. }
  147570. /**
  147571. * Interface for updraft event data
  147572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147573. */
  147574. export interface PhysicsUpdraftEventData {
  147575. /**
  147576. * A cylinder used for the updraft event
  147577. */
  147578. cylinder: Mesh;
  147579. }
  147580. /**
  147581. * Interface for vortex event data
  147582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147583. */
  147584. export interface PhysicsVortexEventData {
  147585. /**
  147586. * A cylinder used for the vortex event
  147587. */
  147588. cylinder: Mesh;
  147589. }
  147590. /**
  147591. * Interface for an affected physics impostor
  147592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147593. */
  147594. export interface PhysicsAffectedImpostorWithData {
  147595. /**
  147596. * The impostor affected by the effect
  147597. */
  147598. impostor: PhysicsImpostor;
  147599. /**
  147600. * The data about the hit/horce from the explosion
  147601. */
  147602. hitData: PhysicsHitData;
  147603. }
  147604. }
  147605. declare module BABYLON {
  147606. /** @hidden */
  147607. export var blackAndWhitePixelShader: {
  147608. name: string;
  147609. shader: string;
  147610. };
  147611. }
  147612. declare module BABYLON {
  147613. /**
  147614. * Post process used to render in black and white
  147615. */
  147616. export class BlackAndWhitePostProcess extends PostProcess {
  147617. /**
  147618. * Linear about to convert he result to black and white (default: 1)
  147619. */
  147620. degree: number;
  147621. /**
  147622. * Creates a black and white post process
  147623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147624. * @param name The name of the effect.
  147625. * @param options The required width/height ratio to downsize to before computing the render pass.
  147626. * @param camera The camera to apply the render pass to.
  147627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147628. * @param engine The engine which the post process will be applied. (default: current engine)
  147629. * @param reusable If the post process can be reused on the same frame. (default: false)
  147630. */
  147631. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147632. }
  147633. }
  147634. declare module BABYLON {
  147635. /**
  147636. * This represents a set of one or more post processes in Babylon.
  147637. * A post process can be used to apply a shader to a texture after it is rendered.
  147638. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147639. */
  147640. export class PostProcessRenderEffect {
  147641. private _postProcesses;
  147642. private _getPostProcesses;
  147643. private _singleInstance;
  147644. private _cameras;
  147645. private _indicesForCamera;
  147646. /**
  147647. * Name of the effect
  147648. * @hidden
  147649. */
  147650. _name: string;
  147651. /**
  147652. * Instantiates a post process render effect.
  147653. * A post process can be used to apply a shader to a texture after it is rendered.
  147654. * @param engine The engine the effect is tied to
  147655. * @param name The name of the effect
  147656. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147657. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147658. */
  147659. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147660. /**
  147661. * Checks if all the post processes in the effect are supported.
  147662. */
  147663. get isSupported(): boolean;
  147664. /**
  147665. * Updates the current state of the effect
  147666. * @hidden
  147667. */
  147668. _update(): void;
  147669. /**
  147670. * Attaches the effect on cameras
  147671. * @param cameras The camera to attach to.
  147672. * @hidden
  147673. */
  147674. _attachCameras(cameras: Camera): void;
  147675. /**
  147676. * Attaches the effect on cameras
  147677. * @param cameras The camera to attach to.
  147678. * @hidden
  147679. */
  147680. _attachCameras(cameras: Camera[]): void;
  147681. /**
  147682. * Detaches the effect on cameras
  147683. * @param cameras The camera to detatch from.
  147684. * @hidden
  147685. */
  147686. _detachCameras(cameras: Camera): void;
  147687. /**
  147688. * Detatches the effect on cameras
  147689. * @param cameras The camera to detatch from.
  147690. * @hidden
  147691. */
  147692. _detachCameras(cameras: Camera[]): void;
  147693. /**
  147694. * Enables the effect on given cameras
  147695. * @param cameras The camera to enable.
  147696. * @hidden
  147697. */
  147698. _enable(cameras: Camera): void;
  147699. /**
  147700. * Enables the effect on given cameras
  147701. * @param cameras The camera to enable.
  147702. * @hidden
  147703. */
  147704. _enable(cameras: Nullable<Camera[]>): void;
  147705. /**
  147706. * Disables the effect on the given cameras
  147707. * @param cameras The camera to disable.
  147708. * @hidden
  147709. */
  147710. _disable(cameras: Camera): void;
  147711. /**
  147712. * Disables the effect on the given cameras
  147713. * @param cameras The camera to disable.
  147714. * @hidden
  147715. */
  147716. _disable(cameras: Nullable<Camera[]>): void;
  147717. /**
  147718. * Gets a list of the post processes contained in the effect.
  147719. * @param camera The camera to get the post processes on.
  147720. * @returns The list of the post processes in the effect.
  147721. */
  147722. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147723. }
  147724. }
  147725. declare module BABYLON {
  147726. /** @hidden */
  147727. export var extractHighlightsPixelShader: {
  147728. name: string;
  147729. shader: string;
  147730. };
  147731. }
  147732. declare module BABYLON {
  147733. /**
  147734. * 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.
  147735. */
  147736. export class ExtractHighlightsPostProcess extends PostProcess {
  147737. /**
  147738. * The luminance threshold, pixels below this value will be set to black.
  147739. */
  147740. threshold: number;
  147741. /** @hidden */
  147742. _exposure: number;
  147743. /**
  147744. * Post process which has the input texture to be used when performing highlight extraction
  147745. * @hidden
  147746. */
  147747. _inputPostProcess: Nullable<PostProcess>;
  147748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147749. }
  147750. }
  147751. declare module BABYLON {
  147752. /** @hidden */
  147753. export var bloomMergePixelShader: {
  147754. name: string;
  147755. shader: string;
  147756. };
  147757. }
  147758. declare module BABYLON {
  147759. /**
  147760. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147761. */
  147762. export class BloomMergePostProcess extends PostProcess {
  147763. /** Weight of the bloom to be added to the original input. */
  147764. weight: number;
  147765. /**
  147766. * Creates a new instance of @see BloomMergePostProcess
  147767. * @param name The name of the effect.
  147768. * @param originalFromInput Post process which's input will be used for the merge.
  147769. * @param blurred Blurred highlights post process which's output will be used.
  147770. * @param weight Weight of the bloom to be added to the original input.
  147771. * @param options The required width/height ratio to downsize to before computing the render pass.
  147772. * @param camera The camera to apply the render pass to.
  147773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147774. * @param engine The engine which the post process will be applied. (default: current engine)
  147775. * @param reusable If the post process can be reused on the same frame. (default: false)
  147776. * @param textureType Type of textures used when performing the post process. (default: 0)
  147777. * @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)
  147778. */
  147779. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147780. /** Weight of the bloom to be added to the original input. */
  147781. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147782. }
  147783. }
  147784. declare module BABYLON {
  147785. /**
  147786. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147787. */
  147788. export class BloomEffect extends PostProcessRenderEffect {
  147789. private bloomScale;
  147790. /**
  147791. * @hidden Internal
  147792. */
  147793. _effects: Array<PostProcess>;
  147794. /**
  147795. * @hidden Internal
  147796. */
  147797. _downscale: ExtractHighlightsPostProcess;
  147798. private _blurX;
  147799. private _blurY;
  147800. private _merge;
  147801. /**
  147802. * The luminance threshold to find bright areas of the image to bloom.
  147803. */
  147804. get threshold(): number;
  147805. set threshold(value: number);
  147806. /**
  147807. * The strength of the bloom.
  147808. */
  147809. get weight(): number;
  147810. set weight(value: number);
  147811. /**
  147812. * Specifies the size of the bloom blur kernel, relative to the final output size
  147813. */
  147814. get kernel(): number;
  147815. set kernel(value: number);
  147816. /**
  147817. * Creates a new instance of @see BloomEffect
  147818. * @param scene The scene the effect belongs to.
  147819. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147820. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147821. * @param bloomWeight The the strength of bloom.
  147822. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147823. * @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)
  147824. */
  147825. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147826. /**
  147827. * Disposes each of the internal effects for a given camera.
  147828. * @param camera The camera to dispose the effect on.
  147829. */
  147830. disposeEffects(camera: Camera): void;
  147831. /**
  147832. * @hidden Internal
  147833. */
  147834. _updateEffects(): void;
  147835. /**
  147836. * Internal
  147837. * @returns if all the contained post processes are ready.
  147838. * @hidden
  147839. */
  147840. _isReady(): boolean;
  147841. }
  147842. }
  147843. declare module BABYLON {
  147844. /** @hidden */
  147845. export var chromaticAberrationPixelShader: {
  147846. name: string;
  147847. shader: string;
  147848. };
  147849. }
  147850. declare module BABYLON {
  147851. /**
  147852. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147853. */
  147854. export class ChromaticAberrationPostProcess extends PostProcess {
  147855. /**
  147856. * The amount of seperation of rgb channels (default: 30)
  147857. */
  147858. aberrationAmount: number;
  147859. /**
  147860. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147861. */
  147862. radialIntensity: number;
  147863. /**
  147864. * 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))
  147865. */
  147866. direction: Vector2;
  147867. /**
  147868. * 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))
  147869. */
  147870. centerPosition: Vector2;
  147871. /**
  147872. * Creates a new instance ChromaticAberrationPostProcess
  147873. * @param name The name of the effect.
  147874. * @param screenWidth The width of the screen to apply the effect on.
  147875. * @param screenHeight The height of the screen to apply the effect on.
  147876. * @param options The required width/height ratio to downsize to before computing the render pass.
  147877. * @param camera The camera to apply the render pass to.
  147878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147879. * @param engine The engine which the post process will be applied. (default: current engine)
  147880. * @param reusable If the post process can be reused on the same frame. (default: false)
  147881. * @param textureType Type of textures used when performing the post process. (default: 0)
  147882. * @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)
  147883. */
  147884. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147885. }
  147886. }
  147887. declare module BABYLON {
  147888. /** @hidden */
  147889. export var circleOfConfusionPixelShader: {
  147890. name: string;
  147891. shader: string;
  147892. };
  147893. }
  147894. declare module BABYLON {
  147895. /**
  147896. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147897. */
  147898. export class CircleOfConfusionPostProcess extends PostProcess {
  147899. /**
  147900. * 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.
  147901. */
  147902. lensSize: number;
  147903. /**
  147904. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147905. */
  147906. fStop: number;
  147907. /**
  147908. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147909. */
  147910. focusDistance: number;
  147911. /**
  147912. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147913. */
  147914. focalLength: number;
  147915. private _depthTexture;
  147916. /**
  147917. * Creates a new instance CircleOfConfusionPostProcess
  147918. * @param name The name of the effect.
  147919. * @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.
  147920. * @param options The required width/height ratio to downsize to before computing the render pass.
  147921. * @param camera The camera to apply the render pass to.
  147922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147923. * @param engine The engine which the post process will be applied. (default: current engine)
  147924. * @param reusable If the post process can be reused on the same frame. (default: false)
  147925. * @param textureType Type of textures used when performing the post process. (default: 0)
  147926. * @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)
  147927. */
  147928. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147929. /**
  147930. * 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.
  147931. */
  147932. set depthTexture(value: RenderTargetTexture);
  147933. }
  147934. }
  147935. declare module BABYLON {
  147936. /** @hidden */
  147937. export var colorCorrectionPixelShader: {
  147938. name: string;
  147939. shader: string;
  147940. };
  147941. }
  147942. declare module BABYLON {
  147943. /**
  147944. *
  147945. * This post-process allows the modification of rendered colors by using
  147946. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147947. *
  147948. * The object needs to be provided an url to a texture containing the color
  147949. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147950. * Use an image editing software to tweak the LUT to match your needs.
  147951. *
  147952. * For an example of a color LUT, see here:
  147953. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147954. * For explanations on color grading, see here:
  147955. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147956. *
  147957. */
  147958. export class ColorCorrectionPostProcess extends PostProcess {
  147959. private _colorTableTexture;
  147960. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147961. }
  147962. }
  147963. declare module BABYLON {
  147964. /** @hidden */
  147965. export var convolutionPixelShader: {
  147966. name: string;
  147967. shader: string;
  147968. };
  147969. }
  147970. declare module BABYLON {
  147971. /**
  147972. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147973. * input texture to perform effects such as edge detection or sharpening
  147974. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147975. */
  147976. export class ConvolutionPostProcess extends PostProcess {
  147977. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147978. kernel: number[];
  147979. /**
  147980. * Creates a new instance ConvolutionPostProcess
  147981. * @param name The name of the effect.
  147982. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147983. * @param options The required width/height ratio to downsize to before computing the render pass.
  147984. * @param camera The camera to apply the render pass to.
  147985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147986. * @param engine The engine which the post process will be applied. (default: current engine)
  147987. * @param reusable If the post process can be reused on the same frame. (default: false)
  147988. * @param textureType Type of textures used when performing the post process. (default: 0)
  147989. */
  147990. constructor(name: string,
  147991. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147992. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147993. /**
  147994. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147995. */
  147996. static EdgeDetect0Kernel: number[];
  147997. /**
  147998. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147999. */
  148000. static EdgeDetect1Kernel: number[];
  148001. /**
  148002. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148003. */
  148004. static EdgeDetect2Kernel: number[];
  148005. /**
  148006. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148007. */
  148008. static SharpenKernel: number[];
  148009. /**
  148010. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148011. */
  148012. static EmbossKernel: number[];
  148013. /**
  148014. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148015. */
  148016. static GaussianKernel: number[];
  148017. }
  148018. }
  148019. declare module BABYLON {
  148020. /**
  148021. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148022. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148023. * based on samples that have a large difference in distance than the center pixel.
  148024. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148025. */
  148026. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148027. direction: Vector2;
  148028. /**
  148029. * Creates a new instance CircleOfConfusionPostProcess
  148030. * @param name The name of the effect.
  148031. * @param scene The scene the effect belongs to.
  148032. * @param direction The direction the blur should be applied.
  148033. * @param kernel The size of the kernel used to blur.
  148034. * @param options The required width/height ratio to downsize to before computing the render pass.
  148035. * @param camera The camera to apply the render pass to.
  148036. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  148037. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  148038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148039. * @param engine The engine which the post process will be applied. (default: current engine)
  148040. * @param reusable If the post process can be reused on the same frame. (default: false)
  148041. * @param textureType Type of textures used when performing the post process. (default: 0)
  148042. * @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)
  148043. */
  148044. 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);
  148045. }
  148046. }
  148047. declare module BABYLON {
  148048. /** @hidden */
  148049. export var depthOfFieldMergePixelShader: {
  148050. name: string;
  148051. shader: string;
  148052. };
  148053. }
  148054. declare module BABYLON {
  148055. /**
  148056. * Options to be set when merging outputs from the default pipeline.
  148057. */
  148058. export class DepthOfFieldMergePostProcessOptions {
  148059. /**
  148060. * The original image to merge on top of
  148061. */
  148062. originalFromInput: PostProcess;
  148063. /**
  148064. * Parameters to perform the merge of the depth of field effect
  148065. */
  148066. depthOfField?: {
  148067. circleOfConfusion: PostProcess;
  148068. blurSteps: Array<PostProcess>;
  148069. };
  148070. /**
  148071. * Parameters to perform the merge of bloom effect
  148072. */
  148073. bloom?: {
  148074. blurred: PostProcess;
  148075. weight: number;
  148076. };
  148077. }
  148078. /**
  148079. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148080. */
  148081. export class DepthOfFieldMergePostProcess extends PostProcess {
  148082. private blurSteps;
  148083. /**
  148084. * Creates a new instance of DepthOfFieldMergePostProcess
  148085. * @param name The name of the effect.
  148086. * @param originalFromInput Post process which's input will be used for the merge.
  148087. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  148088. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  148089. * @param options The required width/height ratio to downsize to before computing the render pass.
  148090. * @param camera The camera to apply the render pass to.
  148091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148092. * @param engine The engine which the post process will be applied. (default: current engine)
  148093. * @param reusable If the post process can be reused on the same frame. (default: false)
  148094. * @param textureType Type of textures used when performing the post process. (default: 0)
  148095. * @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)
  148096. */
  148097. 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);
  148098. /**
  148099. * Updates the effect with the current post process compile time values and recompiles the shader.
  148100. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  148101. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  148102. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  148103. * @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
  148104. * @param onCompiled Called when the shader has been compiled.
  148105. * @param onError Called if there is an error when compiling a shader.
  148106. */
  148107. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  148108. }
  148109. }
  148110. declare module BABYLON {
  148111. /**
  148112. * Specifies the level of max blur that should be applied when using the depth of field effect
  148113. */
  148114. export enum DepthOfFieldEffectBlurLevel {
  148115. /**
  148116. * Subtle blur
  148117. */
  148118. Low = 0,
  148119. /**
  148120. * Medium blur
  148121. */
  148122. Medium = 1,
  148123. /**
  148124. * Large blur
  148125. */
  148126. High = 2
  148127. }
  148128. /**
  148129. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148130. */
  148131. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148132. private _circleOfConfusion;
  148133. /**
  148134. * @hidden Internal, blurs from high to low
  148135. */
  148136. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148137. private _depthOfFieldBlurY;
  148138. private _dofMerge;
  148139. /**
  148140. * @hidden Internal post processes in depth of field effect
  148141. */
  148142. _effects: Array<PostProcess>;
  148143. /**
  148144. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  148145. */
  148146. set focalLength(value: number);
  148147. get focalLength(): number;
  148148. /**
  148149. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148150. */
  148151. set fStop(value: number);
  148152. get fStop(): number;
  148153. /**
  148154. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148155. */
  148156. set focusDistance(value: number);
  148157. get focusDistance(): number;
  148158. /**
  148159. * 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.
  148160. */
  148161. set lensSize(value: number);
  148162. get lensSize(): number;
  148163. /**
  148164. * Creates a new instance DepthOfFieldEffect
  148165. * @param scene The scene the effect belongs to.
  148166. * @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.
  148167. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148168. * @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)
  148169. */
  148170. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  148171. /**
  148172. * Get the current class name of the current effet
  148173. * @returns "DepthOfFieldEffect"
  148174. */
  148175. getClassName(): string;
  148176. /**
  148177. * 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.
  148178. */
  148179. set depthTexture(value: RenderTargetTexture);
  148180. /**
  148181. * Disposes each of the internal effects for a given camera.
  148182. * @param camera The camera to dispose the effect on.
  148183. */
  148184. disposeEffects(camera: Camera): void;
  148185. /**
  148186. * @hidden Internal
  148187. */
  148188. _updateEffects(): void;
  148189. /**
  148190. * Internal
  148191. * @returns if all the contained post processes are ready.
  148192. * @hidden
  148193. */
  148194. _isReady(): boolean;
  148195. }
  148196. }
  148197. declare module BABYLON {
  148198. /** @hidden */
  148199. export var displayPassPixelShader: {
  148200. name: string;
  148201. shader: string;
  148202. };
  148203. }
  148204. declare module BABYLON {
  148205. /**
  148206. * DisplayPassPostProcess which produces an output the same as it's input
  148207. */
  148208. export class DisplayPassPostProcess extends PostProcess {
  148209. /**
  148210. * Creates the DisplayPassPostProcess
  148211. * @param name The name of the effect.
  148212. * @param options The required width/height ratio to downsize to before computing the render pass.
  148213. * @param camera The camera to apply the render pass to.
  148214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148215. * @param engine The engine which the post process will be applied. (default: current engine)
  148216. * @param reusable If the post process can be reused on the same frame. (default: false)
  148217. */
  148218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148219. }
  148220. }
  148221. declare module BABYLON {
  148222. /** @hidden */
  148223. export var filterPixelShader: {
  148224. name: string;
  148225. shader: string;
  148226. };
  148227. }
  148228. declare module BABYLON {
  148229. /**
  148230. * Applies a kernel filter to the image
  148231. */
  148232. export class FilterPostProcess extends PostProcess {
  148233. /** The matrix to be applied to the image */
  148234. kernelMatrix: Matrix;
  148235. /**
  148236. *
  148237. * @param name The name of the effect.
  148238. * @param kernelMatrix The matrix to be applied to the image
  148239. * @param options The required width/height ratio to downsize to before computing the render pass.
  148240. * @param camera The camera to apply the render pass to.
  148241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148242. * @param engine The engine which the post process will be applied. (default: current engine)
  148243. * @param reusable If the post process can be reused on the same frame. (default: false)
  148244. */
  148245. constructor(name: string,
  148246. /** The matrix to be applied to the image */
  148247. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148248. }
  148249. }
  148250. declare module BABYLON {
  148251. /** @hidden */
  148252. export var fxaaPixelShader: {
  148253. name: string;
  148254. shader: string;
  148255. };
  148256. }
  148257. declare module BABYLON {
  148258. /** @hidden */
  148259. export var fxaaVertexShader: {
  148260. name: string;
  148261. shader: string;
  148262. };
  148263. }
  148264. declare module BABYLON {
  148265. /**
  148266. * Fxaa post process
  148267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148268. */
  148269. export class FxaaPostProcess extends PostProcess {
  148270. /** @hidden */
  148271. texelWidth: number;
  148272. /** @hidden */
  148273. texelHeight: number;
  148274. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148275. private _getDefines;
  148276. }
  148277. }
  148278. declare module BABYLON {
  148279. /** @hidden */
  148280. export var grainPixelShader: {
  148281. name: string;
  148282. shader: string;
  148283. };
  148284. }
  148285. declare module BABYLON {
  148286. /**
  148287. * The GrainPostProcess adds noise to the image at mid luminance levels
  148288. */
  148289. export class GrainPostProcess extends PostProcess {
  148290. /**
  148291. * The intensity of the grain added (default: 30)
  148292. */
  148293. intensity: number;
  148294. /**
  148295. * If the grain should be randomized on every frame
  148296. */
  148297. animated: boolean;
  148298. /**
  148299. * Creates a new instance of @see GrainPostProcess
  148300. * @param name The name of the effect.
  148301. * @param options The required width/height ratio to downsize to before computing the render pass.
  148302. * @param camera The camera to apply the render pass to.
  148303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148304. * @param engine The engine which the post process will be applied. (default: current engine)
  148305. * @param reusable If the post process can be reused on the same frame. (default: false)
  148306. * @param textureType Type of textures used when performing the post process. (default: 0)
  148307. * @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)
  148308. */
  148309. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148310. }
  148311. }
  148312. declare module BABYLON {
  148313. /** @hidden */
  148314. export var highlightsPixelShader: {
  148315. name: string;
  148316. shader: string;
  148317. };
  148318. }
  148319. declare module BABYLON {
  148320. /**
  148321. * Extracts highlights from the image
  148322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148323. */
  148324. export class HighlightsPostProcess extends PostProcess {
  148325. /**
  148326. * Extracts highlights from the image
  148327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148328. * @param name The name of the effect.
  148329. * @param options The required width/height ratio to downsize to before computing the render pass.
  148330. * @param camera The camera to apply the render pass to.
  148331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148332. * @param engine The engine which the post process will be applied. (default: current engine)
  148333. * @param reusable If the post process can be reused on the same frame. (default: false)
  148334. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148335. */
  148336. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148337. }
  148338. }
  148339. declare module BABYLON {
  148340. /** @hidden */
  148341. export var mrtFragmentDeclaration: {
  148342. name: string;
  148343. shader: string;
  148344. };
  148345. }
  148346. declare module BABYLON {
  148347. /** @hidden */
  148348. export var geometryPixelShader: {
  148349. name: string;
  148350. shader: string;
  148351. };
  148352. }
  148353. declare module BABYLON {
  148354. /** @hidden */
  148355. export var geometryVertexShader: {
  148356. name: string;
  148357. shader: string;
  148358. };
  148359. }
  148360. declare module BABYLON {
  148361. /** @hidden */
  148362. interface ISavedTransformationMatrix {
  148363. world: Matrix;
  148364. viewProjection: Matrix;
  148365. }
  148366. /**
  148367. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148368. */
  148369. export class GeometryBufferRenderer {
  148370. /**
  148371. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148372. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148373. */
  148374. static readonly POSITION_TEXTURE_TYPE: number;
  148375. /**
  148376. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148377. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148378. */
  148379. static readonly VELOCITY_TEXTURE_TYPE: number;
  148380. /**
  148381. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148382. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148383. */
  148384. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148385. /**
  148386. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148387. * in order to compute objects velocities when enableVelocity is set to "true"
  148388. * @hidden
  148389. */
  148390. _previousTransformationMatrices: {
  148391. [index: number]: ISavedTransformationMatrix;
  148392. };
  148393. /**
  148394. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148395. * in order to compute objects velocities when enableVelocity is set to "true"
  148396. * @hidden
  148397. */
  148398. _previousBonesTransformationMatrices: {
  148399. [index: number]: Float32Array;
  148400. };
  148401. /**
  148402. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148403. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148404. */
  148405. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148406. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148407. renderTransparentMeshes: boolean;
  148408. private _scene;
  148409. private _resizeObserver;
  148410. private _multiRenderTarget;
  148411. private _ratio;
  148412. private _enablePosition;
  148413. private _enableVelocity;
  148414. private _enableReflectivity;
  148415. private _positionIndex;
  148416. private _velocityIndex;
  148417. private _reflectivityIndex;
  148418. protected _effect: Effect;
  148419. protected _cachedDefines: string;
  148420. /**
  148421. * Set the render list (meshes to be rendered) used in the G buffer.
  148422. */
  148423. set renderList(meshes: Mesh[]);
  148424. /**
  148425. * Gets wether or not G buffer are supported by the running hardware.
  148426. * This requires draw buffer supports
  148427. */
  148428. get isSupported(): boolean;
  148429. /**
  148430. * Returns the index of the given texture type in the G-Buffer textures array
  148431. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148432. * @returns the index of the given texture type in the G-Buffer textures array
  148433. */
  148434. getTextureIndex(textureType: number): number;
  148435. /**
  148436. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148437. */
  148438. get enablePosition(): boolean;
  148439. /**
  148440. * Sets whether or not objects positions are enabled for the G buffer.
  148441. */
  148442. set enablePosition(enable: boolean);
  148443. /**
  148444. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148445. */
  148446. get enableVelocity(): boolean;
  148447. /**
  148448. * Sets wether or not objects velocities are enabled for the G buffer.
  148449. */
  148450. set enableVelocity(enable: boolean);
  148451. /**
  148452. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148453. */
  148454. get enableReflectivity(): boolean;
  148455. /**
  148456. * Sets wether or not objects roughness are enabled for the G buffer.
  148457. */
  148458. set enableReflectivity(enable: boolean);
  148459. /**
  148460. * Gets the scene associated with the buffer.
  148461. */
  148462. get scene(): Scene;
  148463. /**
  148464. * Gets the ratio used by the buffer during its creation.
  148465. * How big is the buffer related to the main canvas.
  148466. */
  148467. get ratio(): number;
  148468. /** @hidden */
  148469. static _SceneComponentInitialization: (scene: Scene) => void;
  148470. /**
  148471. * Creates a new G Buffer for the scene
  148472. * @param scene The scene the buffer belongs to
  148473. * @param ratio How big is the buffer related to the main canvas.
  148474. */
  148475. constructor(scene: Scene, ratio?: number);
  148476. /**
  148477. * Checks wether everything is ready to render a submesh to the G buffer.
  148478. * @param subMesh the submesh to check readiness for
  148479. * @param useInstances is the mesh drawn using instance or not
  148480. * @returns true if ready otherwise false
  148481. */
  148482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148483. /**
  148484. * Gets the current underlying G Buffer.
  148485. * @returns the buffer
  148486. */
  148487. getGBuffer(): MultiRenderTarget;
  148488. /**
  148489. * Gets the number of samples used to render the buffer (anti aliasing).
  148490. */
  148491. get samples(): number;
  148492. /**
  148493. * Sets the number of samples used to render the buffer (anti aliasing).
  148494. */
  148495. set samples(value: number);
  148496. /**
  148497. * Disposes the renderer and frees up associated resources.
  148498. */
  148499. dispose(): void;
  148500. protected _createRenderTargets(): void;
  148501. private _copyBonesTransformationMatrices;
  148502. }
  148503. }
  148504. declare module BABYLON {
  148505. interface Scene {
  148506. /** @hidden (Backing field) */
  148507. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148508. /**
  148509. * Gets or Sets the current geometry buffer associated to the scene.
  148510. */
  148511. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148512. /**
  148513. * Enables a GeometryBufferRender and associates it with the scene
  148514. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148515. * @returns the GeometryBufferRenderer
  148516. */
  148517. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148518. /**
  148519. * Disables the GeometryBufferRender associated with the scene
  148520. */
  148521. disableGeometryBufferRenderer(): void;
  148522. }
  148523. /**
  148524. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148525. * in several rendering techniques.
  148526. */
  148527. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148528. /**
  148529. * The component name helpful to identify the component in the list of scene components.
  148530. */
  148531. readonly name: string;
  148532. /**
  148533. * The scene the component belongs to.
  148534. */
  148535. scene: Scene;
  148536. /**
  148537. * Creates a new instance of the component for the given scene
  148538. * @param scene Defines the scene to register the component in
  148539. */
  148540. constructor(scene: Scene);
  148541. /**
  148542. * Registers the component in a given scene
  148543. */
  148544. register(): void;
  148545. /**
  148546. * Rebuilds the elements related to this component in case of
  148547. * context lost for instance.
  148548. */
  148549. rebuild(): void;
  148550. /**
  148551. * Disposes the component and the associated ressources
  148552. */
  148553. dispose(): void;
  148554. private _gatherRenderTargets;
  148555. }
  148556. }
  148557. declare module BABYLON {
  148558. /** @hidden */
  148559. export var motionBlurPixelShader: {
  148560. name: string;
  148561. shader: string;
  148562. };
  148563. }
  148564. declare module BABYLON {
  148565. /**
  148566. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148567. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148568. * As an example, all you have to do is to create the post-process:
  148569. * var mb = new BABYLON.MotionBlurPostProcess(
  148570. * 'mb', // The name of the effect.
  148571. * scene, // The scene containing the objects to blur according to their velocity.
  148572. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148573. * camera // The camera to apply the render pass to.
  148574. * );
  148575. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148576. */
  148577. export class MotionBlurPostProcess extends PostProcess {
  148578. /**
  148579. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148580. */
  148581. motionStrength: number;
  148582. /**
  148583. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148584. */
  148585. get motionBlurSamples(): number;
  148586. /**
  148587. * Sets the number of iterations to be used for motion blur quality
  148588. */
  148589. set motionBlurSamples(samples: number);
  148590. private _motionBlurSamples;
  148591. private _geometryBufferRenderer;
  148592. /**
  148593. * Creates a new instance MotionBlurPostProcess
  148594. * @param name The name of the effect.
  148595. * @param scene The scene containing the objects to blur according to their velocity.
  148596. * @param options The required width/height ratio to downsize to before computing the render pass.
  148597. * @param camera The camera to apply the render pass to.
  148598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148599. * @param engine The engine which the post process will be applied. (default: current engine)
  148600. * @param reusable If the post process can be reused on the same frame. (default: false)
  148601. * @param textureType Type of textures used when performing the post process. (default: 0)
  148602. * @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)
  148603. */
  148604. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148605. /**
  148606. * Excludes the given skinned mesh from computing bones velocities.
  148607. * 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.
  148608. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148609. */
  148610. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148611. /**
  148612. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148613. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148614. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148615. */
  148616. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148617. /**
  148618. * Disposes the post process.
  148619. * @param camera The camera to dispose the post process on.
  148620. */
  148621. dispose(camera?: Camera): void;
  148622. }
  148623. }
  148624. declare module BABYLON {
  148625. /** @hidden */
  148626. export var refractionPixelShader: {
  148627. name: string;
  148628. shader: string;
  148629. };
  148630. }
  148631. declare module BABYLON {
  148632. /**
  148633. * Post process which applies a refractin texture
  148634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148635. */
  148636. export class RefractionPostProcess extends PostProcess {
  148637. /** the base color of the refraction (used to taint the rendering) */
  148638. color: Color3;
  148639. /** simulated refraction depth */
  148640. depth: number;
  148641. /** the coefficient of the base color (0 to remove base color tainting) */
  148642. colorLevel: number;
  148643. private _refTexture;
  148644. private _ownRefractionTexture;
  148645. /**
  148646. * Gets or sets the refraction texture
  148647. * Please note that you are responsible for disposing the texture if you set it manually
  148648. */
  148649. get refractionTexture(): Texture;
  148650. set refractionTexture(value: Texture);
  148651. /**
  148652. * Initializes the RefractionPostProcess
  148653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148654. * @param name The name of the effect.
  148655. * @param refractionTextureUrl Url of the refraction texture to use
  148656. * @param color the base color of the refraction (used to taint the rendering)
  148657. * @param depth simulated refraction depth
  148658. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148659. * @param camera The camera to apply the render pass to.
  148660. * @param options The required width/height ratio to downsize to before computing the render pass.
  148661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148662. * @param engine The engine which the post process will be applied. (default: current engine)
  148663. * @param reusable If the post process can be reused on the same frame. (default: false)
  148664. */
  148665. constructor(name: string, refractionTextureUrl: string,
  148666. /** the base color of the refraction (used to taint the rendering) */
  148667. color: Color3,
  148668. /** simulated refraction depth */
  148669. depth: number,
  148670. /** the coefficient of the base color (0 to remove base color tainting) */
  148671. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148672. /**
  148673. * Disposes of the post process
  148674. * @param camera Camera to dispose post process on
  148675. */
  148676. dispose(camera: Camera): void;
  148677. }
  148678. }
  148679. declare module BABYLON {
  148680. /** @hidden */
  148681. export var sharpenPixelShader: {
  148682. name: string;
  148683. shader: string;
  148684. };
  148685. }
  148686. declare module BABYLON {
  148687. /**
  148688. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148689. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148690. */
  148691. export class SharpenPostProcess extends PostProcess {
  148692. /**
  148693. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148694. */
  148695. colorAmount: number;
  148696. /**
  148697. * How much sharpness should be applied (default: 0.3)
  148698. */
  148699. edgeAmount: number;
  148700. /**
  148701. * Creates a new instance ConvolutionPostProcess
  148702. * @param name The name of the effect.
  148703. * @param options The required width/height ratio to downsize to before computing the render pass.
  148704. * @param camera The camera to apply the render pass to.
  148705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148706. * @param engine The engine which the post process will be applied. (default: current engine)
  148707. * @param reusable If the post process can be reused on the same frame. (default: false)
  148708. * @param textureType Type of textures used when performing the post process. (default: 0)
  148709. * @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)
  148710. */
  148711. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148712. }
  148713. }
  148714. declare module BABYLON {
  148715. /**
  148716. * PostProcessRenderPipeline
  148717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148718. */
  148719. export class PostProcessRenderPipeline {
  148720. private engine;
  148721. private _renderEffects;
  148722. private _renderEffectsForIsolatedPass;
  148723. /**
  148724. * List of inspectable custom properties (used by the Inspector)
  148725. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148726. */
  148727. inspectableCustomProperties: IInspectable[];
  148728. /**
  148729. * @hidden
  148730. */
  148731. protected _cameras: Camera[];
  148732. /** @hidden */
  148733. _name: string;
  148734. /**
  148735. * Gets pipeline name
  148736. */
  148737. get name(): string;
  148738. /** Gets the list of attached cameras */
  148739. get cameras(): Camera[];
  148740. /**
  148741. * Initializes a PostProcessRenderPipeline
  148742. * @param engine engine to add the pipeline to
  148743. * @param name name of the pipeline
  148744. */
  148745. constructor(engine: Engine, name: string);
  148746. /**
  148747. * Gets the class name
  148748. * @returns "PostProcessRenderPipeline"
  148749. */
  148750. getClassName(): string;
  148751. /**
  148752. * If all the render effects in the pipeline are supported
  148753. */
  148754. get isSupported(): boolean;
  148755. /**
  148756. * Adds an effect to the pipeline
  148757. * @param renderEffect the effect to add
  148758. */
  148759. addEffect(renderEffect: PostProcessRenderEffect): void;
  148760. /** @hidden */
  148761. _rebuild(): void;
  148762. /** @hidden */
  148763. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148764. /** @hidden */
  148765. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148766. /** @hidden */
  148767. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148768. /** @hidden */
  148769. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148770. /** @hidden */
  148771. _attachCameras(cameras: Camera, unique: boolean): void;
  148772. /** @hidden */
  148773. _attachCameras(cameras: Camera[], unique: boolean): void;
  148774. /** @hidden */
  148775. _detachCameras(cameras: Camera): void;
  148776. /** @hidden */
  148777. _detachCameras(cameras: Nullable<Camera[]>): void;
  148778. /** @hidden */
  148779. _update(): void;
  148780. /** @hidden */
  148781. _reset(): void;
  148782. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148783. /**
  148784. * Sets the required values to the prepass renderer.
  148785. * @param prePassRenderer defines the prepass renderer to setup.
  148786. * @returns true if the pre pass is needed.
  148787. */
  148788. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148789. /**
  148790. * Disposes of the pipeline
  148791. */
  148792. dispose(): void;
  148793. }
  148794. }
  148795. declare module BABYLON {
  148796. /**
  148797. * PostProcessRenderPipelineManager class
  148798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148799. */
  148800. export class PostProcessRenderPipelineManager {
  148801. private _renderPipelines;
  148802. /**
  148803. * Initializes a PostProcessRenderPipelineManager
  148804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148805. */
  148806. constructor();
  148807. /**
  148808. * Gets the list of supported render pipelines
  148809. */
  148810. get supportedPipelines(): PostProcessRenderPipeline[];
  148811. /**
  148812. * Adds a pipeline to the manager
  148813. * @param renderPipeline The pipeline to add
  148814. */
  148815. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148816. /**
  148817. * Attaches a camera to the pipeline
  148818. * @param renderPipelineName The name of the pipeline to attach to
  148819. * @param cameras the camera to attach
  148820. * @param unique if the camera can be attached multiple times to the pipeline
  148821. */
  148822. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148823. /**
  148824. * Detaches a camera from the pipeline
  148825. * @param renderPipelineName The name of the pipeline to detach from
  148826. * @param cameras the camera to detach
  148827. */
  148828. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148829. /**
  148830. * Enables an effect by name on a pipeline
  148831. * @param renderPipelineName the name of the pipeline to enable the effect in
  148832. * @param renderEffectName the name of the effect to enable
  148833. * @param cameras the cameras that the effect should be enabled on
  148834. */
  148835. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148836. /**
  148837. * Disables an effect by name on a pipeline
  148838. * @param renderPipelineName the name of the pipeline to disable the effect in
  148839. * @param renderEffectName the name of the effect to disable
  148840. * @param cameras the cameras that the effect should be disabled on
  148841. */
  148842. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148843. /**
  148844. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148845. */
  148846. update(): void;
  148847. /** @hidden */
  148848. _rebuild(): void;
  148849. /**
  148850. * Disposes of the manager and pipelines
  148851. */
  148852. dispose(): void;
  148853. }
  148854. }
  148855. declare module BABYLON {
  148856. interface Scene {
  148857. /** @hidden (Backing field) */
  148858. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148859. /**
  148860. * Gets the postprocess render pipeline manager
  148861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148862. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148863. */
  148864. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148865. }
  148866. /**
  148867. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148868. */
  148869. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148870. /**
  148871. * The component name helpfull to identify the component in the list of scene components.
  148872. */
  148873. readonly name: string;
  148874. /**
  148875. * The scene the component belongs to.
  148876. */
  148877. scene: Scene;
  148878. /**
  148879. * Creates a new instance of the component for the given scene
  148880. * @param scene Defines the scene to register the component in
  148881. */
  148882. constructor(scene: Scene);
  148883. /**
  148884. * Registers the component in a given scene
  148885. */
  148886. register(): void;
  148887. /**
  148888. * Rebuilds the elements related to this component in case of
  148889. * context lost for instance.
  148890. */
  148891. rebuild(): void;
  148892. /**
  148893. * Disposes the component and the associated ressources
  148894. */
  148895. dispose(): void;
  148896. private _gatherRenderTargets;
  148897. }
  148898. }
  148899. declare module BABYLON {
  148900. /**
  148901. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148902. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148903. */
  148904. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148905. private _scene;
  148906. private _camerasToBeAttached;
  148907. /**
  148908. * ID of the sharpen post process,
  148909. */
  148910. private readonly SharpenPostProcessId;
  148911. /**
  148912. * @ignore
  148913. * ID of the image processing post process;
  148914. */
  148915. readonly ImageProcessingPostProcessId: string;
  148916. /**
  148917. * @ignore
  148918. * ID of the Fast Approximate Anti-Aliasing post process;
  148919. */
  148920. readonly FxaaPostProcessId: string;
  148921. /**
  148922. * ID of the chromatic aberration post process,
  148923. */
  148924. private readonly ChromaticAberrationPostProcessId;
  148925. /**
  148926. * ID of the grain post process
  148927. */
  148928. private readonly GrainPostProcessId;
  148929. /**
  148930. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148931. */
  148932. sharpen: SharpenPostProcess;
  148933. private _sharpenEffect;
  148934. private bloom;
  148935. /**
  148936. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148937. */
  148938. depthOfField: DepthOfFieldEffect;
  148939. /**
  148940. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148941. */
  148942. fxaa: FxaaPostProcess;
  148943. /**
  148944. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148945. */
  148946. imageProcessing: ImageProcessingPostProcess;
  148947. /**
  148948. * Chromatic aberration post process which will shift rgb colors in the image
  148949. */
  148950. chromaticAberration: ChromaticAberrationPostProcess;
  148951. private _chromaticAberrationEffect;
  148952. /**
  148953. * Grain post process which add noise to the image
  148954. */
  148955. grain: GrainPostProcess;
  148956. private _grainEffect;
  148957. /**
  148958. * Glow post process which adds a glow to emissive areas of the image
  148959. */
  148960. private _glowLayer;
  148961. /**
  148962. * Animations which can be used to tweak settings over a period of time
  148963. */
  148964. animations: Animation[];
  148965. private _imageProcessingConfigurationObserver;
  148966. private _sharpenEnabled;
  148967. private _bloomEnabled;
  148968. private _depthOfFieldEnabled;
  148969. private _depthOfFieldBlurLevel;
  148970. private _fxaaEnabled;
  148971. private _imageProcessingEnabled;
  148972. private _defaultPipelineTextureType;
  148973. private _bloomScale;
  148974. private _chromaticAberrationEnabled;
  148975. private _grainEnabled;
  148976. private _buildAllowed;
  148977. /**
  148978. * Gets active scene
  148979. */
  148980. get scene(): Scene;
  148981. /**
  148982. * Enable or disable the sharpen process from the pipeline
  148983. */
  148984. set sharpenEnabled(enabled: boolean);
  148985. get sharpenEnabled(): boolean;
  148986. private _resizeObserver;
  148987. private _hardwareScaleLevel;
  148988. private _bloomKernel;
  148989. /**
  148990. * Specifies the size of the bloom blur kernel, relative to the final output size
  148991. */
  148992. get bloomKernel(): number;
  148993. set bloomKernel(value: number);
  148994. /**
  148995. * Specifies the weight of the bloom in the final rendering
  148996. */
  148997. private _bloomWeight;
  148998. /**
  148999. * Specifies the luma threshold for the area that will be blurred by the bloom
  149000. */
  149001. private _bloomThreshold;
  149002. private _hdr;
  149003. /**
  149004. * The strength of the bloom.
  149005. */
  149006. set bloomWeight(value: number);
  149007. get bloomWeight(): number;
  149008. /**
  149009. * The strength of the bloom.
  149010. */
  149011. set bloomThreshold(value: number);
  149012. get bloomThreshold(): number;
  149013. /**
  149014. * The scale of the bloom, lower value will provide better performance.
  149015. */
  149016. set bloomScale(value: number);
  149017. get bloomScale(): number;
  149018. /**
  149019. * Enable or disable the bloom from the pipeline
  149020. */
  149021. set bloomEnabled(enabled: boolean);
  149022. get bloomEnabled(): boolean;
  149023. private _rebuildBloom;
  149024. /**
  149025. * If the depth of field is enabled.
  149026. */
  149027. get depthOfFieldEnabled(): boolean;
  149028. set depthOfFieldEnabled(enabled: boolean);
  149029. /**
  149030. * Blur level of the depth of field effect. (Higher blur will effect performance)
  149031. */
  149032. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  149033. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  149034. /**
  149035. * If the anti aliasing is enabled.
  149036. */
  149037. set fxaaEnabled(enabled: boolean);
  149038. get fxaaEnabled(): boolean;
  149039. private _samples;
  149040. /**
  149041. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149042. */
  149043. set samples(sampleCount: number);
  149044. get samples(): number;
  149045. /**
  149046. * If image processing is enabled.
  149047. */
  149048. set imageProcessingEnabled(enabled: boolean);
  149049. get imageProcessingEnabled(): boolean;
  149050. /**
  149051. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  149052. */
  149053. set glowLayerEnabled(enabled: boolean);
  149054. get glowLayerEnabled(): boolean;
  149055. /**
  149056. * Gets the glow layer (or null if not defined)
  149057. */
  149058. get glowLayer(): Nullable<GlowLayer>;
  149059. /**
  149060. * Enable or disable the chromaticAberration process from the pipeline
  149061. */
  149062. set chromaticAberrationEnabled(enabled: boolean);
  149063. get chromaticAberrationEnabled(): boolean;
  149064. /**
  149065. * Enable or disable the grain process from the pipeline
  149066. */
  149067. set grainEnabled(enabled: boolean);
  149068. get grainEnabled(): boolean;
  149069. /**
  149070. * @constructor
  149071. * @param name - The rendering pipeline name (default: "")
  149072. * @param hdr - If high dynamic range textures should be used (default: true)
  149073. * @param scene - The scene linked to this pipeline (default: the last created scene)
  149074. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  149075. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  149076. */
  149077. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  149078. /**
  149079. * Get the class name
  149080. * @returns "DefaultRenderingPipeline"
  149081. */
  149082. getClassName(): string;
  149083. /**
  149084. * Force the compilation of the entire pipeline.
  149085. */
  149086. prepare(): void;
  149087. private _hasCleared;
  149088. private _prevPostProcess;
  149089. private _prevPrevPostProcess;
  149090. private _setAutoClearAndTextureSharing;
  149091. private _depthOfFieldSceneObserver;
  149092. private _buildPipeline;
  149093. private _disposePostProcesses;
  149094. /**
  149095. * Adds a camera to the pipeline
  149096. * @param camera the camera to be added
  149097. */
  149098. addCamera(camera: Camera): void;
  149099. /**
  149100. * Removes a camera from the pipeline
  149101. * @param camera the camera to remove
  149102. */
  149103. removeCamera(camera: Camera): void;
  149104. /**
  149105. * Dispose of the pipeline and stop all post processes
  149106. */
  149107. dispose(): void;
  149108. /**
  149109. * Serialize the rendering pipeline (Used when exporting)
  149110. * @returns the serialized object
  149111. */
  149112. serialize(): any;
  149113. /**
  149114. * Parse the serialized pipeline
  149115. * @param source Source pipeline.
  149116. * @param scene The scene to load the pipeline to.
  149117. * @param rootUrl The URL of the serialized pipeline.
  149118. * @returns An instantiated pipeline from the serialized object.
  149119. */
  149120. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  149121. }
  149122. }
  149123. declare module BABYLON {
  149124. /** @hidden */
  149125. export var lensHighlightsPixelShader: {
  149126. name: string;
  149127. shader: string;
  149128. };
  149129. }
  149130. declare module BABYLON {
  149131. /** @hidden */
  149132. export var depthOfFieldPixelShader: {
  149133. name: string;
  149134. shader: string;
  149135. };
  149136. }
  149137. declare module BABYLON {
  149138. /**
  149139. * BABYLON.JS Chromatic Aberration GLSL Shader
  149140. * Author: Olivier Guyot
  149141. * Separates very slightly R, G and B colors on the edges of the screen
  149142. * Inspired by Francois Tarlier & Martins Upitis
  149143. */
  149144. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  149145. /**
  149146. * @ignore
  149147. * The chromatic aberration PostProcess id in the pipeline
  149148. */
  149149. LensChromaticAberrationEffect: string;
  149150. /**
  149151. * @ignore
  149152. * The highlights enhancing PostProcess id in the pipeline
  149153. */
  149154. HighlightsEnhancingEffect: string;
  149155. /**
  149156. * @ignore
  149157. * The depth-of-field PostProcess id in the pipeline
  149158. */
  149159. LensDepthOfFieldEffect: string;
  149160. private _scene;
  149161. private _depthTexture;
  149162. private _grainTexture;
  149163. private _chromaticAberrationPostProcess;
  149164. private _highlightsPostProcess;
  149165. private _depthOfFieldPostProcess;
  149166. private _edgeBlur;
  149167. private _grainAmount;
  149168. private _chromaticAberration;
  149169. private _distortion;
  149170. private _highlightsGain;
  149171. private _highlightsThreshold;
  149172. private _dofDistance;
  149173. private _dofAperture;
  149174. private _dofDarken;
  149175. private _dofPentagon;
  149176. private _blurNoise;
  149177. /**
  149178. * @constructor
  149179. *
  149180. * Effect parameters are as follow:
  149181. * {
  149182. * chromatic_aberration: number; // from 0 to x (1 for realism)
  149183. * edge_blur: number; // from 0 to x (1 for realism)
  149184. * distortion: number; // from 0 to x (1 for realism)
  149185. * grain_amount: number; // from 0 to 1
  149186. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  149187. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  149188. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  149189. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  149190. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  149191. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  149192. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  149193. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  149194. * }
  149195. * Note: if an effect parameter is unset, effect is disabled
  149196. *
  149197. * @param name The rendering pipeline name
  149198. * @param parameters - An object containing all parameters (see above)
  149199. * @param scene The scene linked to this pipeline
  149200. * @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)
  149201. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149202. */
  149203. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  149204. /**
  149205. * Get the class name
  149206. * @returns "LensRenderingPipeline"
  149207. */
  149208. getClassName(): string;
  149209. /**
  149210. * Gets associated scene
  149211. */
  149212. get scene(): Scene;
  149213. /**
  149214. * Gets or sets the edge blur
  149215. */
  149216. get edgeBlur(): number;
  149217. set edgeBlur(value: number);
  149218. /**
  149219. * Gets or sets the grain amount
  149220. */
  149221. get grainAmount(): number;
  149222. set grainAmount(value: number);
  149223. /**
  149224. * Gets or sets the chromatic aberration amount
  149225. */
  149226. get chromaticAberration(): number;
  149227. set chromaticAberration(value: number);
  149228. /**
  149229. * Gets or sets the depth of field aperture
  149230. */
  149231. get dofAperture(): number;
  149232. set dofAperture(value: number);
  149233. /**
  149234. * Gets or sets the edge distortion
  149235. */
  149236. get edgeDistortion(): number;
  149237. set edgeDistortion(value: number);
  149238. /**
  149239. * Gets or sets the depth of field distortion
  149240. */
  149241. get dofDistortion(): number;
  149242. set dofDistortion(value: number);
  149243. /**
  149244. * Gets or sets the darken out of focus amount
  149245. */
  149246. get darkenOutOfFocus(): number;
  149247. set darkenOutOfFocus(value: number);
  149248. /**
  149249. * Gets or sets a boolean indicating if blur noise is enabled
  149250. */
  149251. get blurNoise(): boolean;
  149252. set blurNoise(value: boolean);
  149253. /**
  149254. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149255. */
  149256. get pentagonBokeh(): boolean;
  149257. set pentagonBokeh(value: boolean);
  149258. /**
  149259. * Gets or sets the highlight grain amount
  149260. */
  149261. get highlightsGain(): number;
  149262. set highlightsGain(value: number);
  149263. /**
  149264. * Gets or sets the highlight threshold
  149265. */
  149266. get highlightsThreshold(): number;
  149267. set highlightsThreshold(value: number);
  149268. /**
  149269. * Sets the amount of blur at the edges
  149270. * @param amount blur amount
  149271. */
  149272. setEdgeBlur(amount: number): void;
  149273. /**
  149274. * Sets edge blur to 0
  149275. */
  149276. disableEdgeBlur(): void;
  149277. /**
  149278. * Sets the amout of grain
  149279. * @param amount Amount of grain
  149280. */
  149281. setGrainAmount(amount: number): void;
  149282. /**
  149283. * Set grain amount to 0
  149284. */
  149285. disableGrain(): void;
  149286. /**
  149287. * Sets the chromatic aberration amount
  149288. * @param amount amount of chromatic aberration
  149289. */
  149290. setChromaticAberration(amount: number): void;
  149291. /**
  149292. * Sets chromatic aberration amount to 0
  149293. */
  149294. disableChromaticAberration(): void;
  149295. /**
  149296. * Sets the EdgeDistortion amount
  149297. * @param amount amount of EdgeDistortion
  149298. */
  149299. setEdgeDistortion(amount: number): void;
  149300. /**
  149301. * Sets edge distortion to 0
  149302. */
  149303. disableEdgeDistortion(): void;
  149304. /**
  149305. * Sets the FocusDistance amount
  149306. * @param amount amount of FocusDistance
  149307. */
  149308. setFocusDistance(amount: number): void;
  149309. /**
  149310. * Disables depth of field
  149311. */
  149312. disableDepthOfField(): void;
  149313. /**
  149314. * Sets the Aperture amount
  149315. * @param amount amount of Aperture
  149316. */
  149317. setAperture(amount: number): void;
  149318. /**
  149319. * Sets the DarkenOutOfFocus amount
  149320. * @param amount amount of DarkenOutOfFocus
  149321. */
  149322. setDarkenOutOfFocus(amount: number): void;
  149323. private _pentagonBokehIsEnabled;
  149324. /**
  149325. * Creates a pentagon bokeh effect
  149326. */
  149327. enablePentagonBokeh(): void;
  149328. /**
  149329. * Disables the pentagon bokeh effect
  149330. */
  149331. disablePentagonBokeh(): void;
  149332. /**
  149333. * Enables noise blur
  149334. */
  149335. enableNoiseBlur(): void;
  149336. /**
  149337. * Disables noise blur
  149338. */
  149339. disableNoiseBlur(): void;
  149340. /**
  149341. * Sets the HighlightsGain amount
  149342. * @param amount amount of HighlightsGain
  149343. */
  149344. setHighlightsGain(amount: number): void;
  149345. /**
  149346. * Sets the HighlightsThreshold amount
  149347. * @param amount amount of HighlightsThreshold
  149348. */
  149349. setHighlightsThreshold(amount: number): void;
  149350. /**
  149351. * Disables highlights
  149352. */
  149353. disableHighlights(): void;
  149354. /**
  149355. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149356. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149357. */
  149358. dispose(disableDepthRender?: boolean): void;
  149359. private _createChromaticAberrationPostProcess;
  149360. private _createHighlightsPostProcess;
  149361. private _createDepthOfFieldPostProcess;
  149362. private _createGrainTexture;
  149363. }
  149364. }
  149365. declare module BABYLON {
  149366. /** @hidden */
  149367. export var ssao2PixelShader: {
  149368. name: string;
  149369. shader: string;
  149370. };
  149371. }
  149372. declare module BABYLON {
  149373. /** @hidden */
  149374. export var ssaoCombinePixelShader: {
  149375. name: string;
  149376. shader: string;
  149377. };
  149378. }
  149379. declare module BABYLON {
  149380. /**
  149381. * Render pipeline to produce ssao effect
  149382. */
  149383. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149384. /**
  149385. * @ignore
  149386. * The PassPostProcess id in the pipeline that contains the original scene color
  149387. */
  149388. SSAOOriginalSceneColorEffect: string;
  149389. /**
  149390. * @ignore
  149391. * The SSAO PostProcess id in the pipeline
  149392. */
  149393. SSAORenderEffect: string;
  149394. /**
  149395. * @ignore
  149396. * The horizontal blur PostProcess id in the pipeline
  149397. */
  149398. SSAOBlurHRenderEffect: string;
  149399. /**
  149400. * @ignore
  149401. * The vertical blur PostProcess id in the pipeline
  149402. */
  149403. SSAOBlurVRenderEffect: string;
  149404. /**
  149405. * @ignore
  149406. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149407. */
  149408. SSAOCombineRenderEffect: string;
  149409. /**
  149410. * The output strength of the SSAO post-process. Default value is 1.0.
  149411. */
  149412. totalStrength: number;
  149413. /**
  149414. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149415. */
  149416. maxZ: number;
  149417. /**
  149418. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149419. */
  149420. minZAspect: number;
  149421. private _samples;
  149422. /**
  149423. * Number of samples used for the SSAO calculations. Default value is 8
  149424. */
  149425. set samples(n: number);
  149426. get samples(): number;
  149427. private _textureSamples;
  149428. /**
  149429. * Number of samples to use for antialiasing
  149430. */
  149431. set textureSamples(n: number);
  149432. get textureSamples(): number;
  149433. /**
  149434. * Force rendering the geometry through geometry buffer
  149435. */
  149436. private _forceGeometryBuffer;
  149437. /**
  149438. * Ratio object used for SSAO ratio and blur ratio
  149439. */
  149440. private _ratio;
  149441. /**
  149442. * Dynamically generated sphere sampler.
  149443. */
  149444. private _sampleSphere;
  149445. /**
  149446. * Blur filter offsets
  149447. */
  149448. private _samplerOffsets;
  149449. private _expensiveBlur;
  149450. /**
  149451. * If bilateral blur should be used
  149452. */
  149453. set expensiveBlur(b: boolean);
  149454. get expensiveBlur(): boolean;
  149455. /**
  149456. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149457. */
  149458. radius: number;
  149459. /**
  149460. * The base color of the SSAO post-process
  149461. * The final result is "base + ssao" between [0, 1]
  149462. */
  149463. base: number;
  149464. /**
  149465. * Support test.
  149466. */
  149467. static get IsSupported(): boolean;
  149468. private _scene;
  149469. private _randomTexture;
  149470. private _originalColorPostProcess;
  149471. private _ssaoPostProcess;
  149472. private _blurHPostProcess;
  149473. private _blurVPostProcess;
  149474. private _ssaoCombinePostProcess;
  149475. private _prePassRenderer;
  149476. /**
  149477. * Gets active scene
  149478. */
  149479. get scene(): Scene;
  149480. /**
  149481. * @constructor
  149482. * @param name The rendering pipeline name
  149483. * @param scene The scene linked to this pipeline
  149484. * @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 }
  149485. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149486. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149487. */
  149488. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149489. /**
  149490. * Get the class name
  149491. * @returns "SSAO2RenderingPipeline"
  149492. */
  149493. getClassName(): string;
  149494. /**
  149495. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149496. */
  149497. dispose(disableGeometryBufferRenderer?: boolean): void;
  149498. private _createBlurPostProcess;
  149499. /** @hidden */
  149500. _rebuild(): void;
  149501. private _bits;
  149502. private _radicalInverse_VdC;
  149503. private _hammersley;
  149504. private _hemisphereSample_uniform;
  149505. private _generateHemisphere;
  149506. private _getDefinesForSSAO;
  149507. private _createSSAOPostProcess;
  149508. private _createSSAOCombinePostProcess;
  149509. private _createRandomTexture;
  149510. /**
  149511. * Serialize the rendering pipeline (Used when exporting)
  149512. * @returns the serialized object
  149513. */
  149514. serialize(): any;
  149515. /**
  149516. * Parse the serialized pipeline
  149517. * @param source Source pipeline.
  149518. * @param scene The scene to load the pipeline to.
  149519. * @param rootUrl The URL of the serialized pipeline.
  149520. * @returns An instantiated pipeline from the serialized object.
  149521. */
  149522. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149523. /**
  149524. * Sets the required values to the prepass renderer.
  149525. * @param prePassRenderer defines the prepass renderer to setup
  149526. * @returns true if the pre pass is needed.
  149527. */
  149528. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149529. }
  149530. }
  149531. declare module BABYLON {
  149532. /** @hidden */
  149533. export var ssaoPixelShader: {
  149534. name: string;
  149535. shader: string;
  149536. };
  149537. }
  149538. declare module BABYLON {
  149539. /**
  149540. * Render pipeline to produce ssao effect
  149541. */
  149542. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149543. /**
  149544. * @ignore
  149545. * The PassPostProcess id in the pipeline that contains the original scene color
  149546. */
  149547. SSAOOriginalSceneColorEffect: string;
  149548. /**
  149549. * @ignore
  149550. * The SSAO PostProcess id in the pipeline
  149551. */
  149552. SSAORenderEffect: string;
  149553. /**
  149554. * @ignore
  149555. * The horizontal blur PostProcess id in the pipeline
  149556. */
  149557. SSAOBlurHRenderEffect: string;
  149558. /**
  149559. * @ignore
  149560. * The vertical blur PostProcess id in the pipeline
  149561. */
  149562. SSAOBlurVRenderEffect: string;
  149563. /**
  149564. * @ignore
  149565. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149566. */
  149567. SSAOCombineRenderEffect: string;
  149568. /**
  149569. * The output strength of the SSAO post-process. Default value is 1.0.
  149570. */
  149571. totalStrength: number;
  149572. /**
  149573. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149574. */
  149575. radius: number;
  149576. /**
  149577. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149578. * Must not be equal to fallOff and superior to fallOff.
  149579. * Default value is 0.0075
  149580. */
  149581. area: number;
  149582. /**
  149583. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149584. * Must not be equal to area and inferior to area.
  149585. * Default value is 0.000001
  149586. */
  149587. fallOff: number;
  149588. /**
  149589. * The base color of the SSAO post-process
  149590. * The final result is "base + ssao" between [0, 1]
  149591. */
  149592. base: number;
  149593. private _scene;
  149594. private _depthTexture;
  149595. private _randomTexture;
  149596. private _originalColorPostProcess;
  149597. private _ssaoPostProcess;
  149598. private _blurHPostProcess;
  149599. private _blurVPostProcess;
  149600. private _ssaoCombinePostProcess;
  149601. private _firstUpdate;
  149602. /**
  149603. * Gets active scene
  149604. */
  149605. get scene(): Scene;
  149606. /**
  149607. * @constructor
  149608. * @param name - The rendering pipeline name
  149609. * @param scene - The scene linked to this pipeline
  149610. * @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 }
  149611. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149612. */
  149613. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149614. /**
  149615. * Get the class name
  149616. * @returns "SSAORenderingPipeline"
  149617. */
  149618. getClassName(): string;
  149619. /**
  149620. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149621. */
  149622. dispose(disableDepthRender?: boolean): void;
  149623. private _createBlurPostProcess;
  149624. /** @hidden */
  149625. _rebuild(): void;
  149626. private _createSSAOPostProcess;
  149627. private _createSSAOCombinePostProcess;
  149628. private _createRandomTexture;
  149629. }
  149630. }
  149631. declare module BABYLON {
  149632. /** @hidden */
  149633. export var screenSpaceReflectionPixelShader: {
  149634. name: string;
  149635. shader: string;
  149636. };
  149637. }
  149638. declare module BABYLON {
  149639. /**
  149640. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149641. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149642. */
  149643. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149644. /**
  149645. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149646. */
  149647. threshold: number;
  149648. /**
  149649. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149650. */
  149651. strength: number;
  149652. /**
  149653. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149654. */
  149655. reflectionSpecularFalloffExponent: number;
  149656. /**
  149657. * 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]
  149658. */
  149659. step: number;
  149660. /**
  149661. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149662. */
  149663. roughnessFactor: number;
  149664. private _geometryBufferRenderer;
  149665. private _enableSmoothReflections;
  149666. private _reflectionSamples;
  149667. private _smoothSteps;
  149668. /**
  149669. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149670. * @param name The name of the effect.
  149671. * @param scene The scene containing the objects to calculate reflections.
  149672. * @param options The required width/height ratio to downsize to before computing the render pass.
  149673. * @param camera The camera to apply the render pass to.
  149674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149675. * @param engine The engine which the post process will be applied. (default: current engine)
  149676. * @param reusable If the post process can be reused on the same frame. (default: false)
  149677. * @param textureType Type of textures used when performing the post process. (default: 0)
  149678. * @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)
  149679. */
  149680. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149681. /**
  149682. * Gets wether or not smoothing reflections is enabled.
  149683. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149684. */
  149685. get enableSmoothReflections(): boolean;
  149686. /**
  149687. * Sets wether or not smoothing reflections is enabled.
  149688. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149689. */
  149690. set enableSmoothReflections(enabled: boolean);
  149691. /**
  149692. * Gets the number of samples taken while computing reflections. More samples count is high,
  149693. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149694. */
  149695. get reflectionSamples(): number;
  149696. /**
  149697. * Sets the number of samples taken while computing reflections. More samples count is high,
  149698. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149699. */
  149700. set reflectionSamples(samples: number);
  149701. /**
  149702. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149703. * more the post-process will require GPU power and can generate a drop in FPS.
  149704. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149705. */
  149706. get smoothSteps(): number;
  149707. set smoothSteps(steps: number);
  149708. private _updateEffectDefines;
  149709. }
  149710. }
  149711. declare module BABYLON {
  149712. /** @hidden */
  149713. export var standardPixelShader: {
  149714. name: string;
  149715. shader: string;
  149716. };
  149717. }
  149718. declare module BABYLON {
  149719. /**
  149720. * Standard rendering pipeline
  149721. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149722. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149723. */
  149724. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149725. /**
  149726. * Public members
  149727. */
  149728. /**
  149729. * Post-process which contains the original scene color before the pipeline applies all the effects
  149730. */
  149731. originalPostProcess: Nullable<PostProcess>;
  149732. /**
  149733. * Post-process used to down scale an image x4
  149734. */
  149735. downSampleX4PostProcess: Nullable<PostProcess>;
  149736. /**
  149737. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149738. */
  149739. brightPassPostProcess: Nullable<PostProcess>;
  149740. /**
  149741. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149742. */
  149743. blurHPostProcesses: PostProcess[];
  149744. /**
  149745. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149746. */
  149747. blurVPostProcesses: PostProcess[];
  149748. /**
  149749. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149750. */
  149751. textureAdderPostProcess: Nullable<PostProcess>;
  149752. /**
  149753. * Post-process used to create volumetric lighting effect
  149754. */
  149755. volumetricLightPostProcess: Nullable<PostProcess>;
  149756. /**
  149757. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149758. */
  149759. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149760. /**
  149761. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149762. */
  149763. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149764. /**
  149765. * Post-process used to merge the volumetric light effect and the real scene color
  149766. */
  149767. volumetricLightMergePostProces: Nullable<PostProcess>;
  149768. /**
  149769. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149770. */
  149771. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149772. /**
  149773. * Base post-process used to calculate the average luminance of the final image for HDR
  149774. */
  149775. luminancePostProcess: Nullable<PostProcess>;
  149776. /**
  149777. * Post-processes used to create down sample post-processes in order to get
  149778. * the average luminance of the final image for HDR
  149779. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149780. */
  149781. luminanceDownSamplePostProcesses: PostProcess[];
  149782. /**
  149783. * Post-process used to create a HDR effect (light adaptation)
  149784. */
  149785. hdrPostProcess: Nullable<PostProcess>;
  149786. /**
  149787. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149788. */
  149789. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149790. /**
  149791. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149792. */
  149793. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149794. /**
  149795. * Post-process used to merge the final HDR post-process and the real scene color
  149796. */
  149797. hdrFinalPostProcess: Nullable<PostProcess>;
  149798. /**
  149799. * Post-process used to create a lens flare effect
  149800. */
  149801. lensFlarePostProcess: Nullable<PostProcess>;
  149802. /**
  149803. * Post-process that merges the result of the lens flare post-process and the real scene color
  149804. */
  149805. lensFlareComposePostProcess: Nullable<PostProcess>;
  149806. /**
  149807. * Post-process used to create a motion blur effect
  149808. */
  149809. motionBlurPostProcess: Nullable<PostProcess>;
  149810. /**
  149811. * Post-process used to create a depth of field effect
  149812. */
  149813. depthOfFieldPostProcess: Nullable<PostProcess>;
  149814. /**
  149815. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149816. */
  149817. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149818. /**
  149819. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149820. */
  149821. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149822. /**
  149823. * Represents the brightness threshold in order to configure the illuminated surfaces
  149824. */
  149825. brightThreshold: number;
  149826. /**
  149827. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149828. */
  149829. blurWidth: number;
  149830. /**
  149831. * Sets if the blur for highlighted surfaces must be only horizontal
  149832. */
  149833. horizontalBlur: boolean;
  149834. /**
  149835. * Gets the overall exposure used by the pipeline
  149836. */
  149837. get exposure(): number;
  149838. /**
  149839. * Sets the overall exposure used by the pipeline
  149840. */
  149841. set exposure(value: number);
  149842. /**
  149843. * Texture used typically to simulate "dirty" on camera lens
  149844. */
  149845. lensTexture: Nullable<Texture>;
  149846. /**
  149847. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149848. */
  149849. volumetricLightCoefficient: number;
  149850. /**
  149851. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149852. */
  149853. volumetricLightPower: number;
  149854. /**
  149855. * Used the set the blur intensity to smooth the volumetric lights
  149856. */
  149857. volumetricLightBlurScale: number;
  149858. /**
  149859. * Light (spot or directional) used to generate the volumetric lights rays
  149860. * The source light must have a shadow generate so the pipeline can get its
  149861. * depth map
  149862. */
  149863. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149864. /**
  149865. * For eye adaptation, represents the minimum luminance the eye can see
  149866. */
  149867. hdrMinimumLuminance: number;
  149868. /**
  149869. * For eye adaptation, represents the decrease luminance speed
  149870. */
  149871. hdrDecreaseRate: number;
  149872. /**
  149873. * For eye adaptation, represents the increase luminance speed
  149874. */
  149875. hdrIncreaseRate: number;
  149876. /**
  149877. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149878. */
  149879. get hdrAutoExposure(): boolean;
  149880. /**
  149881. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149882. */
  149883. set hdrAutoExposure(value: boolean);
  149884. /**
  149885. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149886. */
  149887. lensColorTexture: Nullable<Texture>;
  149888. /**
  149889. * The overall strengh for the lens flare effect
  149890. */
  149891. lensFlareStrength: number;
  149892. /**
  149893. * Dispersion coefficient for lens flare ghosts
  149894. */
  149895. lensFlareGhostDispersal: number;
  149896. /**
  149897. * Main lens flare halo width
  149898. */
  149899. lensFlareHaloWidth: number;
  149900. /**
  149901. * Based on the lens distortion effect, defines how much the lens flare result
  149902. * is distorted
  149903. */
  149904. lensFlareDistortionStrength: number;
  149905. /**
  149906. * Configures the blur intensity used for for lens flare (halo)
  149907. */
  149908. lensFlareBlurWidth: number;
  149909. /**
  149910. * Lens star texture must be used to simulate rays on the flares and is available
  149911. * in the documentation
  149912. */
  149913. lensStarTexture: Nullable<Texture>;
  149914. /**
  149915. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149916. * flare effect by taking account of the dirt texture
  149917. */
  149918. lensFlareDirtTexture: Nullable<Texture>;
  149919. /**
  149920. * Represents the focal length for the depth of field effect
  149921. */
  149922. depthOfFieldDistance: number;
  149923. /**
  149924. * Represents the blur intensity for the blurred part of the depth of field effect
  149925. */
  149926. depthOfFieldBlurWidth: number;
  149927. /**
  149928. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149929. */
  149930. get motionStrength(): number;
  149931. /**
  149932. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149933. */
  149934. set motionStrength(strength: number);
  149935. /**
  149936. * Gets wether or not the motion blur post-process is object based or screen based.
  149937. */
  149938. get objectBasedMotionBlur(): boolean;
  149939. /**
  149940. * Sets wether or not the motion blur post-process should be object based or screen based
  149941. */
  149942. set objectBasedMotionBlur(value: boolean);
  149943. /**
  149944. * List of animations for the pipeline (IAnimatable implementation)
  149945. */
  149946. animations: Animation[];
  149947. /**
  149948. * Private members
  149949. */
  149950. private _scene;
  149951. private _currentDepthOfFieldSource;
  149952. private _basePostProcess;
  149953. private _fixedExposure;
  149954. private _currentExposure;
  149955. private _hdrAutoExposure;
  149956. private _hdrCurrentLuminance;
  149957. private _motionStrength;
  149958. private _isObjectBasedMotionBlur;
  149959. private _floatTextureType;
  149960. private _camerasToBeAttached;
  149961. private _ratio;
  149962. private _bloomEnabled;
  149963. private _depthOfFieldEnabled;
  149964. private _vlsEnabled;
  149965. private _lensFlareEnabled;
  149966. private _hdrEnabled;
  149967. private _motionBlurEnabled;
  149968. private _fxaaEnabled;
  149969. private _screenSpaceReflectionsEnabled;
  149970. private _motionBlurSamples;
  149971. private _volumetricLightStepsCount;
  149972. private _samples;
  149973. /**
  149974. * @ignore
  149975. * Specifies if the bloom pipeline is enabled
  149976. */
  149977. get BloomEnabled(): boolean;
  149978. set BloomEnabled(enabled: boolean);
  149979. /**
  149980. * @ignore
  149981. * Specifies if the depth of field pipeline is enabed
  149982. */
  149983. get DepthOfFieldEnabled(): boolean;
  149984. set DepthOfFieldEnabled(enabled: boolean);
  149985. /**
  149986. * @ignore
  149987. * Specifies if the lens flare pipeline is enabed
  149988. */
  149989. get LensFlareEnabled(): boolean;
  149990. set LensFlareEnabled(enabled: boolean);
  149991. /**
  149992. * @ignore
  149993. * Specifies if the HDR pipeline is enabled
  149994. */
  149995. get HDREnabled(): boolean;
  149996. set HDREnabled(enabled: boolean);
  149997. /**
  149998. * @ignore
  149999. * Specifies if the volumetric lights scattering effect is enabled
  150000. */
  150001. get VLSEnabled(): boolean;
  150002. set VLSEnabled(enabled: boolean);
  150003. /**
  150004. * @ignore
  150005. * Specifies if the motion blur effect is enabled
  150006. */
  150007. get MotionBlurEnabled(): boolean;
  150008. set MotionBlurEnabled(enabled: boolean);
  150009. /**
  150010. * Specifies if anti-aliasing is enabled
  150011. */
  150012. get fxaaEnabled(): boolean;
  150013. set fxaaEnabled(enabled: boolean);
  150014. /**
  150015. * Specifies if screen space reflections are enabled.
  150016. */
  150017. get screenSpaceReflectionsEnabled(): boolean;
  150018. set screenSpaceReflectionsEnabled(enabled: boolean);
  150019. /**
  150020. * Specifies the number of steps used to calculate the volumetric lights
  150021. * Typically in interval [50, 200]
  150022. */
  150023. get volumetricLightStepsCount(): number;
  150024. set volumetricLightStepsCount(count: number);
  150025. /**
  150026. * Specifies the number of samples used for the motion blur effect
  150027. * Typically in interval [16, 64]
  150028. */
  150029. get motionBlurSamples(): number;
  150030. set motionBlurSamples(samples: number);
  150031. /**
  150032. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150033. */
  150034. get samples(): number;
  150035. set samples(sampleCount: number);
  150036. /**
  150037. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150038. * @constructor
  150039. * @param name The rendering pipeline name
  150040. * @param scene The scene linked to this pipeline
  150041. * @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)
  150042. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  150043. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150044. */
  150045. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  150046. private _buildPipeline;
  150047. private _createDownSampleX4PostProcess;
  150048. private _createBrightPassPostProcess;
  150049. private _createBlurPostProcesses;
  150050. private _createTextureAdderPostProcess;
  150051. private _createVolumetricLightPostProcess;
  150052. private _createLuminancePostProcesses;
  150053. private _createHdrPostProcess;
  150054. private _createLensFlarePostProcess;
  150055. private _createDepthOfFieldPostProcess;
  150056. private _createMotionBlurPostProcess;
  150057. private _getDepthTexture;
  150058. private _disposePostProcesses;
  150059. /**
  150060. * Dispose of the pipeline and stop all post processes
  150061. */
  150062. dispose(): void;
  150063. /**
  150064. * Serialize the rendering pipeline (Used when exporting)
  150065. * @returns the serialized object
  150066. */
  150067. serialize(): any;
  150068. /**
  150069. * Parse the serialized pipeline
  150070. * @param source Source pipeline.
  150071. * @param scene The scene to load the pipeline to.
  150072. * @param rootUrl The URL of the serialized pipeline.
  150073. * @returns An instantiated pipeline from the serialized object.
  150074. */
  150075. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  150076. /**
  150077. * Luminance steps
  150078. */
  150079. static LuminanceSteps: number;
  150080. }
  150081. }
  150082. declare module BABYLON {
  150083. /** @hidden */
  150084. export var stereoscopicInterlacePixelShader: {
  150085. name: string;
  150086. shader: string;
  150087. };
  150088. }
  150089. declare module BABYLON {
  150090. /**
  150091. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  150092. */
  150093. export class StereoscopicInterlacePostProcessI extends PostProcess {
  150094. private _stepSize;
  150095. private _passedProcess;
  150096. /**
  150097. * Initializes a StereoscopicInterlacePostProcessI
  150098. * @param name The name of the effect.
  150099. * @param rigCameras The rig cameras to be appled to the post process
  150100. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  150101. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  150102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150103. * @param engine The engine which the post process will be applied. (default: current engine)
  150104. * @param reusable If the post process can be reused on the same frame. (default: false)
  150105. */
  150106. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150107. }
  150108. /**
  150109. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  150110. */
  150111. export class StereoscopicInterlacePostProcess extends PostProcess {
  150112. private _stepSize;
  150113. private _passedProcess;
  150114. /**
  150115. * Initializes a StereoscopicInterlacePostProcess
  150116. * @param name The name of the effect.
  150117. * @param rigCameras The rig cameras to be appled to the post process
  150118. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  150119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150120. * @param engine The engine which the post process will be applied. (default: current engine)
  150121. * @param reusable If the post process can be reused on the same frame. (default: false)
  150122. */
  150123. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150124. }
  150125. }
  150126. declare module BABYLON {
  150127. /** @hidden */
  150128. export var tonemapPixelShader: {
  150129. name: string;
  150130. shader: string;
  150131. };
  150132. }
  150133. declare module BABYLON {
  150134. /** Defines operator used for tonemapping */
  150135. export enum TonemappingOperator {
  150136. /** Hable */
  150137. Hable = 0,
  150138. /** Reinhard */
  150139. Reinhard = 1,
  150140. /** HejiDawson */
  150141. HejiDawson = 2,
  150142. /** Photographic */
  150143. Photographic = 3
  150144. }
  150145. /**
  150146. * Defines a post process to apply tone mapping
  150147. */
  150148. export class TonemapPostProcess extends PostProcess {
  150149. private _operator;
  150150. /** Defines the required exposure adjustement */
  150151. exposureAdjustment: number;
  150152. /**
  150153. * Creates a new TonemapPostProcess
  150154. * @param name defines the name of the postprocess
  150155. * @param _operator defines the operator to use
  150156. * @param exposureAdjustment defines the required exposure adjustement
  150157. * @param camera defines the camera to use (can be null)
  150158. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  150159. * @param engine defines the hosting engine (can be ignore if camera is set)
  150160. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150161. */
  150162. constructor(name: string, _operator: TonemappingOperator,
  150163. /** Defines the required exposure adjustement */
  150164. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  150165. }
  150166. }
  150167. declare module BABYLON {
  150168. /** @hidden */
  150169. export var volumetricLightScatteringPixelShader: {
  150170. name: string;
  150171. shader: string;
  150172. };
  150173. }
  150174. declare module BABYLON {
  150175. /** @hidden */
  150176. export var volumetricLightScatteringPassVertexShader: {
  150177. name: string;
  150178. shader: string;
  150179. };
  150180. }
  150181. declare module BABYLON {
  150182. /** @hidden */
  150183. export var volumetricLightScatteringPassPixelShader: {
  150184. name: string;
  150185. shader: string;
  150186. };
  150187. }
  150188. declare module BABYLON {
  150189. /**
  150190. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  150191. */
  150192. export class VolumetricLightScatteringPostProcess extends PostProcess {
  150193. private _volumetricLightScatteringPass;
  150194. private _volumetricLightScatteringRTT;
  150195. private _viewPort;
  150196. private _screenCoordinates;
  150197. private _cachedDefines;
  150198. /**
  150199. * If not undefined, the mesh position is computed from the attached node position
  150200. */
  150201. attachedNode: {
  150202. position: Vector3;
  150203. };
  150204. /**
  150205. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  150206. */
  150207. customMeshPosition: Vector3;
  150208. /**
  150209. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  150210. */
  150211. useCustomMeshPosition: boolean;
  150212. /**
  150213. * If the post-process should inverse the light scattering direction
  150214. */
  150215. invert: boolean;
  150216. /**
  150217. * The internal mesh used by the post-process
  150218. */
  150219. mesh: Mesh;
  150220. /**
  150221. * @hidden
  150222. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  150223. */
  150224. get useDiffuseColor(): boolean;
  150225. set useDiffuseColor(useDiffuseColor: boolean);
  150226. /**
  150227. * Array containing the excluded meshes not rendered in the internal pass
  150228. */
  150229. excludedMeshes: AbstractMesh[];
  150230. /**
  150231. * Controls the overall intensity of the post-process
  150232. */
  150233. exposure: number;
  150234. /**
  150235. * Dissipates each sample's contribution in range [0, 1]
  150236. */
  150237. decay: number;
  150238. /**
  150239. * Controls the overall intensity of each sample
  150240. */
  150241. weight: number;
  150242. /**
  150243. * Controls the density of each sample
  150244. */
  150245. density: number;
  150246. /**
  150247. * @constructor
  150248. * @param name The post-process name
  150249. * @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)
  150250. * @param camera The camera that the post-process will be attached to
  150251. * @param mesh The mesh used to create the light scattering
  150252. * @param samples The post-process quality, default 100
  150253. * @param samplingModeThe post-process filtering mode
  150254. * @param engine The babylon engine
  150255. * @param reusable If the post-process is reusable
  150256. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150257. */
  150258. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150259. /**
  150260. * Returns the string "VolumetricLightScatteringPostProcess"
  150261. * @returns "VolumetricLightScatteringPostProcess"
  150262. */
  150263. getClassName(): string;
  150264. private _isReady;
  150265. /**
  150266. * Sets the new light position for light scattering effect
  150267. * @param position The new custom light position
  150268. */
  150269. setCustomMeshPosition(position: Vector3): void;
  150270. /**
  150271. * Returns the light position for light scattering effect
  150272. * @return Vector3 The custom light position
  150273. */
  150274. getCustomMeshPosition(): Vector3;
  150275. /**
  150276. * Disposes the internal assets and detaches the post-process from the camera
  150277. */
  150278. dispose(camera: Camera): void;
  150279. /**
  150280. * Returns the render target texture used by the post-process
  150281. * @return the render target texture used by the post-process
  150282. */
  150283. getPass(): RenderTargetTexture;
  150284. private _meshExcluded;
  150285. private _createPass;
  150286. private _updateMeshScreenCoordinates;
  150287. /**
  150288. * Creates a default mesh for the Volumeric Light Scattering post-process
  150289. * @param name The mesh name
  150290. * @param scene The scene where to create the mesh
  150291. * @return the default mesh
  150292. */
  150293. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150294. }
  150295. }
  150296. declare module BABYLON {
  150297. /** @hidden */
  150298. export var screenSpaceCurvaturePixelShader: {
  150299. name: string;
  150300. shader: string;
  150301. };
  150302. }
  150303. declare module BABYLON {
  150304. /**
  150305. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150306. */
  150307. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150308. /**
  150309. * Defines how much ridge the curvature effect displays.
  150310. */
  150311. ridge: number;
  150312. /**
  150313. * Defines how much valley the curvature effect displays.
  150314. */
  150315. valley: number;
  150316. private _geometryBufferRenderer;
  150317. /**
  150318. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150319. * @param name The name of the effect.
  150320. * @param scene The scene containing the objects to blur according to their velocity.
  150321. * @param options The required width/height ratio to downsize to before computing the render pass.
  150322. * @param camera The camera to apply the render pass to.
  150323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150324. * @param engine The engine which the post process will be applied. (default: current engine)
  150325. * @param reusable If the post process can be reused on the same frame. (default: false)
  150326. * @param textureType Type of textures used when performing the post process. (default: 0)
  150327. * @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)
  150328. */
  150329. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150330. /**
  150331. * Support test.
  150332. */
  150333. static get IsSupported(): boolean;
  150334. }
  150335. }
  150336. declare module BABYLON {
  150337. interface Scene {
  150338. /** @hidden (Backing field) */
  150339. _boundingBoxRenderer: BoundingBoxRenderer;
  150340. /** @hidden (Backing field) */
  150341. _forceShowBoundingBoxes: boolean;
  150342. /**
  150343. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150344. */
  150345. forceShowBoundingBoxes: boolean;
  150346. /**
  150347. * Gets the bounding box renderer associated with the scene
  150348. * @returns a BoundingBoxRenderer
  150349. */
  150350. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150351. }
  150352. interface AbstractMesh {
  150353. /** @hidden (Backing field) */
  150354. _showBoundingBox: boolean;
  150355. /**
  150356. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150357. */
  150358. showBoundingBox: boolean;
  150359. }
  150360. /**
  150361. * Component responsible of rendering the bounding box of the meshes in a scene.
  150362. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150363. */
  150364. export class BoundingBoxRenderer implements ISceneComponent {
  150365. /**
  150366. * The component name helpfull to identify the component in the list of scene components.
  150367. */
  150368. readonly name: string;
  150369. /**
  150370. * The scene the component belongs to.
  150371. */
  150372. scene: Scene;
  150373. /**
  150374. * Color of the bounding box lines placed in front of an object
  150375. */
  150376. frontColor: Color3;
  150377. /**
  150378. * Color of the bounding box lines placed behind an object
  150379. */
  150380. backColor: Color3;
  150381. /**
  150382. * Defines if the renderer should show the back lines or not
  150383. */
  150384. showBackLines: boolean;
  150385. /**
  150386. * Observable raised before rendering a bounding box
  150387. */
  150388. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150389. /**
  150390. * Observable raised after rendering a bounding box
  150391. */
  150392. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150393. /**
  150394. * @hidden
  150395. */
  150396. renderList: SmartArray<BoundingBox>;
  150397. private _colorShader;
  150398. private _vertexBuffers;
  150399. private _indexBuffer;
  150400. private _fillIndexBuffer;
  150401. private _fillIndexData;
  150402. /**
  150403. * Instantiates a new bounding box renderer in a scene.
  150404. * @param scene the scene the renderer renders in
  150405. */
  150406. constructor(scene: Scene);
  150407. /**
  150408. * Registers the component in a given scene
  150409. */
  150410. register(): void;
  150411. private _evaluateSubMesh;
  150412. private _activeMesh;
  150413. private _prepareRessources;
  150414. private _createIndexBuffer;
  150415. /**
  150416. * Rebuilds the elements related to this component in case of
  150417. * context lost for instance.
  150418. */
  150419. rebuild(): void;
  150420. /**
  150421. * @hidden
  150422. */
  150423. reset(): void;
  150424. /**
  150425. * Render the bounding boxes of a specific rendering group
  150426. * @param renderingGroupId defines the rendering group to render
  150427. */
  150428. render(renderingGroupId: number): void;
  150429. /**
  150430. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150431. * @param mesh Define the mesh to render the occlusion bounding box for
  150432. */
  150433. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150434. /**
  150435. * Dispose and release the resources attached to this renderer.
  150436. */
  150437. dispose(): void;
  150438. }
  150439. }
  150440. declare module BABYLON {
  150441. interface Scene {
  150442. /** @hidden (Backing field) */
  150443. _depthRenderer: {
  150444. [id: string]: DepthRenderer;
  150445. };
  150446. /**
  150447. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150448. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150449. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150450. * @returns the created depth renderer
  150451. */
  150452. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150453. /**
  150454. * Disables a depth renderer for a given camera
  150455. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150456. */
  150457. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150458. }
  150459. /**
  150460. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150461. * in several rendering techniques.
  150462. */
  150463. export class DepthRendererSceneComponent implements ISceneComponent {
  150464. /**
  150465. * The component name helpfull to identify the component in the list of scene components.
  150466. */
  150467. readonly name: string;
  150468. /**
  150469. * The scene the component belongs to.
  150470. */
  150471. scene: Scene;
  150472. /**
  150473. * Creates a new instance of the component for the given scene
  150474. * @param scene Defines the scene to register the component in
  150475. */
  150476. constructor(scene: Scene);
  150477. /**
  150478. * Registers the component in a given scene
  150479. */
  150480. register(): void;
  150481. /**
  150482. * Rebuilds the elements related to this component in case of
  150483. * context lost for instance.
  150484. */
  150485. rebuild(): void;
  150486. /**
  150487. * Disposes the component and the associated ressources
  150488. */
  150489. dispose(): void;
  150490. private _gatherRenderTargets;
  150491. private _gatherActiveCameraRenderTargets;
  150492. }
  150493. }
  150494. declare module BABYLON {
  150495. interface AbstractScene {
  150496. /** @hidden (Backing field) */
  150497. _prePassRenderer: Nullable<PrePassRenderer>;
  150498. /**
  150499. * Gets or Sets the current prepass renderer associated to the scene.
  150500. */
  150501. prePassRenderer: Nullable<PrePassRenderer>;
  150502. /**
  150503. * Enables the prepass and associates it with the scene
  150504. * @returns the PrePassRenderer
  150505. */
  150506. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150507. /**
  150508. * Disables the prepass associated with the scene
  150509. */
  150510. disablePrePassRenderer(): void;
  150511. }
  150512. /**
  150513. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150514. * in several rendering techniques.
  150515. */
  150516. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150517. /**
  150518. * The component name helpful to identify the component in the list of scene components.
  150519. */
  150520. readonly name: string;
  150521. /**
  150522. * The scene the component belongs to.
  150523. */
  150524. scene: Scene;
  150525. /**
  150526. * Creates a new instance of the component for the given scene
  150527. * @param scene Defines the scene to register the component in
  150528. */
  150529. constructor(scene: Scene);
  150530. /**
  150531. * Registers the component in a given scene
  150532. */
  150533. register(): void;
  150534. private _beforeCameraDraw;
  150535. private _afterCameraDraw;
  150536. private _beforeClearStage;
  150537. /**
  150538. * Serializes the component data to the specified json object
  150539. * @param serializationObject The object to serialize to
  150540. */
  150541. serialize(serializationObject: any): void;
  150542. /**
  150543. * Adds all the elements from the container to the scene
  150544. * @param container the container holding the elements
  150545. */
  150546. addFromContainer(container: AbstractScene): void;
  150547. /**
  150548. * Removes all the elements in the container from the scene
  150549. * @param container contains the elements to remove
  150550. * @param dispose if the removed element should be disposed (default: false)
  150551. */
  150552. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150553. /**
  150554. * Rebuilds the elements related to this component in case of
  150555. * context lost for instance.
  150556. */
  150557. rebuild(): void;
  150558. /**
  150559. * Disposes the component and the associated ressources
  150560. */
  150561. dispose(): void;
  150562. }
  150563. }
  150564. declare module BABYLON {
  150565. /** @hidden */
  150566. export var outlinePixelShader: {
  150567. name: string;
  150568. shader: string;
  150569. };
  150570. }
  150571. declare module BABYLON {
  150572. /** @hidden */
  150573. export var outlineVertexShader: {
  150574. name: string;
  150575. shader: string;
  150576. };
  150577. }
  150578. declare module BABYLON {
  150579. interface Scene {
  150580. /** @hidden */
  150581. _outlineRenderer: OutlineRenderer;
  150582. /**
  150583. * Gets the outline renderer associated with the scene
  150584. * @returns a OutlineRenderer
  150585. */
  150586. getOutlineRenderer(): OutlineRenderer;
  150587. }
  150588. interface AbstractMesh {
  150589. /** @hidden (Backing field) */
  150590. _renderOutline: boolean;
  150591. /**
  150592. * Gets or sets a boolean indicating if the outline must be rendered as well
  150593. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150594. */
  150595. renderOutline: boolean;
  150596. /** @hidden (Backing field) */
  150597. _renderOverlay: boolean;
  150598. /**
  150599. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150600. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150601. */
  150602. renderOverlay: boolean;
  150603. }
  150604. /**
  150605. * This class is responsible to draw bothe outline/overlay of meshes.
  150606. * It should not be used directly but through the available method on mesh.
  150607. */
  150608. export class OutlineRenderer implements ISceneComponent {
  150609. /**
  150610. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150611. */
  150612. private static _StencilReference;
  150613. /**
  150614. * The name of the component. Each component must have a unique name.
  150615. */
  150616. name: string;
  150617. /**
  150618. * The scene the component belongs to.
  150619. */
  150620. scene: Scene;
  150621. /**
  150622. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150623. */
  150624. zOffset: number;
  150625. private _engine;
  150626. private _effect;
  150627. private _cachedDefines;
  150628. private _savedDepthWrite;
  150629. /**
  150630. * Instantiates a new outline renderer. (There could be only one per scene).
  150631. * @param scene Defines the scene it belongs to
  150632. */
  150633. constructor(scene: Scene);
  150634. /**
  150635. * Register the component to one instance of a scene.
  150636. */
  150637. register(): void;
  150638. /**
  150639. * Rebuilds the elements related to this component in case of
  150640. * context lost for instance.
  150641. */
  150642. rebuild(): void;
  150643. /**
  150644. * Disposes the component and the associated ressources.
  150645. */
  150646. dispose(): void;
  150647. /**
  150648. * Renders the outline in the canvas.
  150649. * @param subMesh Defines the sumesh to render
  150650. * @param batch Defines the batch of meshes in case of instances
  150651. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150652. */
  150653. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150654. /**
  150655. * Returns whether or not the outline renderer is ready for a given submesh.
  150656. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150657. * @param subMesh Defines the submesh to check readyness for
  150658. * @param useInstances Defines wheter wee are trying to render instances or not
  150659. * @returns true if ready otherwise false
  150660. */
  150661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150662. private _beforeRenderingMesh;
  150663. private _afterRenderingMesh;
  150664. }
  150665. }
  150666. declare module BABYLON {
  150667. /**
  150668. * Defines the basic options interface of a Sprite Frame Source Size.
  150669. */
  150670. export interface ISpriteJSONSpriteSourceSize {
  150671. /**
  150672. * number of the original width of the Frame
  150673. */
  150674. w: number;
  150675. /**
  150676. * number of the original height of the Frame
  150677. */
  150678. h: number;
  150679. }
  150680. /**
  150681. * Defines the basic options interface of a Sprite Frame Data.
  150682. */
  150683. export interface ISpriteJSONSpriteFrameData {
  150684. /**
  150685. * number of the x offset of the Frame
  150686. */
  150687. x: number;
  150688. /**
  150689. * number of the y offset of the Frame
  150690. */
  150691. y: number;
  150692. /**
  150693. * number of the width of the Frame
  150694. */
  150695. w: number;
  150696. /**
  150697. * number of the height of the Frame
  150698. */
  150699. h: number;
  150700. }
  150701. /**
  150702. * Defines the basic options interface of a JSON Sprite.
  150703. */
  150704. export interface ISpriteJSONSprite {
  150705. /**
  150706. * string name of the Frame
  150707. */
  150708. filename: string;
  150709. /**
  150710. * ISpriteJSONSpriteFrame basic object of the frame data
  150711. */
  150712. frame: ISpriteJSONSpriteFrameData;
  150713. /**
  150714. * boolean to flag is the frame was rotated.
  150715. */
  150716. rotated: boolean;
  150717. /**
  150718. * boolean to flag is the frame was trimmed.
  150719. */
  150720. trimmed: boolean;
  150721. /**
  150722. * ISpriteJSONSpriteFrame basic object of the source data
  150723. */
  150724. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150725. /**
  150726. * ISpriteJSONSpriteFrame basic object of the source data
  150727. */
  150728. sourceSize: ISpriteJSONSpriteSourceSize;
  150729. }
  150730. /**
  150731. * Defines the basic options interface of a JSON atlas.
  150732. */
  150733. export interface ISpriteJSONAtlas {
  150734. /**
  150735. * Array of objects that contain the frame data.
  150736. */
  150737. frames: Array<ISpriteJSONSprite>;
  150738. /**
  150739. * object basic object containing the sprite meta data.
  150740. */
  150741. meta?: object;
  150742. }
  150743. }
  150744. declare module BABYLON {
  150745. /** @hidden */
  150746. export var spriteMapPixelShader: {
  150747. name: string;
  150748. shader: string;
  150749. };
  150750. }
  150751. declare module BABYLON {
  150752. /** @hidden */
  150753. export var spriteMapVertexShader: {
  150754. name: string;
  150755. shader: string;
  150756. };
  150757. }
  150758. declare module BABYLON {
  150759. /**
  150760. * Defines the basic options interface of a SpriteMap
  150761. */
  150762. export interface ISpriteMapOptions {
  150763. /**
  150764. * Vector2 of the number of cells in the grid.
  150765. */
  150766. stageSize?: Vector2;
  150767. /**
  150768. * Vector2 of the size of the output plane in World Units.
  150769. */
  150770. outputSize?: Vector2;
  150771. /**
  150772. * Vector3 of the position of the output plane in World Units.
  150773. */
  150774. outputPosition?: Vector3;
  150775. /**
  150776. * Vector3 of the rotation of the output plane.
  150777. */
  150778. outputRotation?: Vector3;
  150779. /**
  150780. * number of layers that the system will reserve in resources.
  150781. */
  150782. layerCount?: number;
  150783. /**
  150784. * number of max animation frames a single cell will reserve in resources.
  150785. */
  150786. maxAnimationFrames?: number;
  150787. /**
  150788. * number cell index of the base tile when the system compiles.
  150789. */
  150790. baseTile?: number;
  150791. /**
  150792. * boolean flip the sprite after its been repositioned by the framing data.
  150793. */
  150794. flipU?: boolean;
  150795. /**
  150796. * Vector3 scalar of the global RGB values of the SpriteMap.
  150797. */
  150798. colorMultiply?: Vector3;
  150799. }
  150800. /**
  150801. * Defines the IDisposable interface in order to be cleanable from resources.
  150802. */
  150803. export interface ISpriteMap extends IDisposable {
  150804. /**
  150805. * String name of the SpriteMap.
  150806. */
  150807. name: string;
  150808. /**
  150809. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150810. */
  150811. atlasJSON: ISpriteJSONAtlas;
  150812. /**
  150813. * Texture of the SpriteMap.
  150814. */
  150815. spriteSheet: Texture;
  150816. /**
  150817. * The parameters to initialize the SpriteMap with.
  150818. */
  150819. options: ISpriteMapOptions;
  150820. }
  150821. /**
  150822. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150823. */
  150824. export class SpriteMap implements ISpriteMap {
  150825. /** The Name of the spriteMap */
  150826. name: string;
  150827. /** The JSON file with the frame and meta data */
  150828. atlasJSON: ISpriteJSONAtlas;
  150829. /** The systems Sprite Sheet Texture */
  150830. spriteSheet: Texture;
  150831. /** Arguments passed with the Constructor */
  150832. options: ISpriteMapOptions;
  150833. /** Public Sprite Storage array, parsed from atlasJSON */
  150834. sprites: Array<ISpriteJSONSprite>;
  150835. /** Returns the Number of Sprites in the System */
  150836. get spriteCount(): number;
  150837. /** Returns the Position of Output Plane*/
  150838. get position(): Vector3;
  150839. /** Returns the Position of Output Plane*/
  150840. set position(v: Vector3);
  150841. /** Returns the Rotation of Output Plane*/
  150842. get rotation(): Vector3;
  150843. /** Returns the Rotation of Output Plane*/
  150844. set rotation(v: Vector3);
  150845. /** Sets the AnimationMap*/
  150846. get animationMap(): RawTexture;
  150847. /** Sets the AnimationMap*/
  150848. set animationMap(v: RawTexture);
  150849. /** Scene that the SpriteMap was created in */
  150850. private _scene;
  150851. /** Texture Buffer of Float32 that holds tile frame data*/
  150852. private _frameMap;
  150853. /** Texture Buffers of Float32 that holds tileMap data*/
  150854. private _tileMaps;
  150855. /** Texture Buffer of Float32 that holds Animation Data*/
  150856. private _animationMap;
  150857. /** Custom ShaderMaterial Central to the System*/
  150858. private _material;
  150859. /** Custom ShaderMaterial Central to the System*/
  150860. private _output;
  150861. /** Systems Time Ticker*/
  150862. private _time;
  150863. /**
  150864. * Creates a new SpriteMap
  150865. * @param name defines the SpriteMaps Name
  150866. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150867. * @param spriteSheet is the Texture that the Sprites are on.
  150868. * @param options a basic deployment configuration
  150869. * @param scene The Scene that the map is deployed on
  150870. */
  150871. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150872. /**
  150873. * Returns tileID location
  150874. * @returns Vector2 the cell position ID
  150875. */
  150876. getTileID(): Vector2;
  150877. /**
  150878. * Gets the UV location of the mouse over the SpriteMap.
  150879. * @returns Vector2 the UV position of the mouse interaction
  150880. */
  150881. getMousePosition(): Vector2;
  150882. /**
  150883. * Creates the "frame" texture Buffer
  150884. * -------------------------------------
  150885. * Structure of frames
  150886. * "filename": "Falling-Water-2.png",
  150887. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150888. * "rotated": true,
  150889. * "trimmed": true,
  150890. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150891. * "sourceSize": {"w":32,"h":32}
  150892. * @returns RawTexture of the frameMap
  150893. */
  150894. private _createFrameBuffer;
  150895. /**
  150896. * Creates the tileMap texture Buffer
  150897. * @param buffer normally and array of numbers, or a false to generate from scratch
  150898. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150899. * @returns RawTexture of the tileMap
  150900. */
  150901. private _createTileBuffer;
  150902. /**
  150903. * Modifies the data of the tileMaps
  150904. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150905. * @param pos is the iVector2 Coordinates of the Tile
  150906. * @param tile The SpriteIndex of the new Tile
  150907. */
  150908. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150909. /**
  150910. * Creates the animationMap texture Buffer
  150911. * @param buffer normally and array of numbers, or a false to generate from scratch
  150912. * @returns RawTexture of the animationMap
  150913. */
  150914. private _createTileAnimationBuffer;
  150915. /**
  150916. * Modifies the data of the animationMap
  150917. * @param cellID is the Index of the Sprite
  150918. * @param _frame is the target Animation frame
  150919. * @param toCell is the Target Index of the next frame of the animation
  150920. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150921. * @param speed is a global scalar of the time variable on the map.
  150922. */
  150923. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150924. /**
  150925. * Exports the .tilemaps file
  150926. */
  150927. saveTileMaps(): void;
  150928. /**
  150929. * Imports the .tilemaps file
  150930. * @param url of the .tilemaps file
  150931. */
  150932. loadTileMaps(url: string): void;
  150933. /**
  150934. * Release associated resources
  150935. */
  150936. dispose(): void;
  150937. }
  150938. }
  150939. declare module BABYLON {
  150940. /**
  150941. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150942. * @see https://doc.babylonjs.com/babylon101/sprites
  150943. */
  150944. export class SpritePackedManager extends SpriteManager {
  150945. /** defines the packed manager's name */
  150946. name: string;
  150947. /**
  150948. * Creates a new sprite manager from a packed sprite sheet
  150949. * @param name defines the manager's name
  150950. * @param imgUrl defines the sprite sheet url
  150951. * @param capacity defines the maximum allowed number of sprites
  150952. * @param scene defines the hosting scene
  150953. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150954. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150955. * @param samplingMode defines the smapling mode to use with spritesheet
  150956. * @param fromPacked set to true; do not alter
  150957. */
  150958. constructor(
  150959. /** defines the packed manager's name */
  150960. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150961. }
  150962. }
  150963. declare module BABYLON {
  150964. /**
  150965. * Defines the list of states available for a task inside a AssetsManager
  150966. */
  150967. export enum AssetTaskState {
  150968. /**
  150969. * Initialization
  150970. */
  150971. INIT = 0,
  150972. /**
  150973. * Running
  150974. */
  150975. RUNNING = 1,
  150976. /**
  150977. * Done
  150978. */
  150979. DONE = 2,
  150980. /**
  150981. * Error
  150982. */
  150983. ERROR = 3
  150984. }
  150985. /**
  150986. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150987. */
  150988. export abstract class AbstractAssetTask {
  150989. /**
  150990. * Task name
  150991. */ name: string;
  150992. /**
  150993. * Callback called when the task is successful
  150994. */
  150995. onSuccess: (task: any) => void;
  150996. /**
  150997. * Callback called when the task is not successful
  150998. */
  150999. onError: (task: any, message?: string, exception?: any) => void;
  151000. /**
  151001. * Creates a new AssetsManager
  151002. * @param name defines the name of the task
  151003. */
  151004. constructor(
  151005. /**
  151006. * Task name
  151007. */ name: string);
  151008. private _isCompleted;
  151009. private _taskState;
  151010. private _errorObject;
  151011. /**
  151012. * Get if the task is completed
  151013. */
  151014. get isCompleted(): boolean;
  151015. /**
  151016. * Gets the current state of the task
  151017. */
  151018. get taskState(): AssetTaskState;
  151019. /**
  151020. * Gets the current error object (if task is in error)
  151021. */
  151022. get errorObject(): {
  151023. message?: string;
  151024. exception?: any;
  151025. };
  151026. /**
  151027. * Internal only
  151028. * @hidden
  151029. */
  151030. _setErrorObject(message?: string, exception?: any): void;
  151031. /**
  151032. * Execute the current task
  151033. * @param scene defines the scene where you want your assets to be loaded
  151034. * @param onSuccess is a callback called when the task is successfully executed
  151035. * @param onError is a callback called if an error occurs
  151036. */
  151037. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151038. /**
  151039. * Execute the current task
  151040. * @param scene defines the scene where you want your assets to be loaded
  151041. * @param onSuccess is a callback called when the task is successfully executed
  151042. * @param onError is a callback called if an error occurs
  151043. */
  151044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151045. /**
  151046. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  151047. * This can be used with failed tasks that have the reason for failure fixed.
  151048. */
  151049. reset(): void;
  151050. private onErrorCallback;
  151051. private onDoneCallback;
  151052. }
  151053. /**
  151054. * Define the interface used by progress events raised during assets loading
  151055. */
  151056. export interface IAssetsProgressEvent {
  151057. /**
  151058. * Defines the number of remaining tasks to process
  151059. */
  151060. remainingCount: number;
  151061. /**
  151062. * Defines the total number of tasks
  151063. */
  151064. totalCount: number;
  151065. /**
  151066. * Defines the task that was just processed
  151067. */
  151068. task: AbstractAssetTask;
  151069. }
  151070. /**
  151071. * Class used to share progress information about assets loading
  151072. */
  151073. export class AssetsProgressEvent implements IAssetsProgressEvent {
  151074. /**
  151075. * Defines the number of remaining tasks to process
  151076. */
  151077. remainingCount: number;
  151078. /**
  151079. * Defines the total number of tasks
  151080. */
  151081. totalCount: number;
  151082. /**
  151083. * Defines the task that was just processed
  151084. */
  151085. task: AbstractAssetTask;
  151086. /**
  151087. * Creates a AssetsProgressEvent
  151088. * @param remainingCount defines the number of remaining tasks to process
  151089. * @param totalCount defines the total number of tasks
  151090. * @param task defines the task that was just processed
  151091. */
  151092. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  151093. }
  151094. /**
  151095. * Define a task used by AssetsManager to load assets into a container
  151096. */
  151097. export class ContainerAssetTask extends AbstractAssetTask {
  151098. /**
  151099. * Defines the name of the task
  151100. */
  151101. name: string;
  151102. /**
  151103. * Defines the list of mesh's names you want to load
  151104. */
  151105. meshesNames: any;
  151106. /**
  151107. * Defines the root url to use as a base to load your meshes and associated resources
  151108. */
  151109. rootUrl: string;
  151110. /**
  151111. * Defines the filename or File of the scene to load from
  151112. */
  151113. sceneFilename: string | File;
  151114. /**
  151115. * Get the loaded asset container
  151116. */
  151117. loadedContainer: AssetContainer;
  151118. /**
  151119. * Gets the list of loaded meshes
  151120. */
  151121. loadedMeshes: Array<AbstractMesh>;
  151122. /**
  151123. * Gets the list of loaded particle systems
  151124. */
  151125. loadedParticleSystems: Array<IParticleSystem>;
  151126. /**
  151127. * Gets the list of loaded skeletons
  151128. */
  151129. loadedSkeletons: Array<Skeleton>;
  151130. /**
  151131. * Gets the list of loaded animation groups
  151132. */
  151133. loadedAnimationGroups: Array<AnimationGroup>;
  151134. /**
  151135. * Callback called when the task is successful
  151136. */
  151137. onSuccess: (task: ContainerAssetTask) => void;
  151138. /**
  151139. * Callback called when the task is successful
  151140. */
  151141. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  151142. /**
  151143. * Creates a new ContainerAssetTask
  151144. * @param name defines the name of the task
  151145. * @param meshesNames defines the list of mesh's names you want to load
  151146. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151147. * @param sceneFilename defines the filename or File of the scene to load from
  151148. */
  151149. constructor(
  151150. /**
  151151. * Defines the name of the task
  151152. */
  151153. name: string,
  151154. /**
  151155. * Defines the list of mesh's names you want to load
  151156. */
  151157. meshesNames: any,
  151158. /**
  151159. * Defines the root url to use as a base to load your meshes and associated resources
  151160. */
  151161. rootUrl: string,
  151162. /**
  151163. * Defines the filename or File of the scene to load from
  151164. */
  151165. sceneFilename: string | File);
  151166. /**
  151167. * Execute the current task
  151168. * @param scene defines the scene where you want your assets to be loaded
  151169. * @param onSuccess is a callback called when the task is successfully executed
  151170. * @param onError is a callback called if an error occurs
  151171. */
  151172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151173. }
  151174. /**
  151175. * Define a task used by AssetsManager to load meshes
  151176. */
  151177. export class MeshAssetTask extends AbstractAssetTask {
  151178. /**
  151179. * Defines the name of the task
  151180. */
  151181. name: string;
  151182. /**
  151183. * Defines the list of mesh's names you want to load
  151184. */
  151185. meshesNames: any;
  151186. /**
  151187. * Defines the root url to use as a base to load your meshes and associated resources
  151188. */
  151189. rootUrl: string;
  151190. /**
  151191. * Defines the filename or File of the scene to load from
  151192. */
  151193. sceneFilename: string | File;
  151194. /**
  151195. * Gets the list of loaded meshes
  151196. */
  151197. loadedMeshes: Array<AbstractMesh>;
  151198. /**
  151199. * Gets the list of loaded particle systems
  151200. */
  151201. loadedParticleSystems: Array<IParticleSystem>;
  151202. /**
  151203. * Gets the list of loaded skeletons
  151204. */
  151205. loadedSkeletons: Array<Skeleton>;
  151206. /**
  151207. * Gets the list of loaded animation groups
  151208. */
  151209. loadedAnimationGroups: Array<AnimationGroup>;
  151210. /**
  151211. * Callback called when the task is successful
  151212. */
  151213. onSuccess: (task: MeshAssetTask) => void;
  151214. /**
  151215. * Callback called when the task is successful
  151216. */
  151217. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  151218. /**
  151219. * Creates a new MeshAssetTask
  151220. * @param name defines the name of the task
  151221. * @param meshesNames defines the list of mesh's names you want to load
  151222. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151223. * @param sceneFilename defines the filename or File of the scene to load from
  151224. */
  151225. constructor(
  151226. /**
  151227. * Defines the name of the task
  151228. */
  151229. name: string,
  151230. /**
  151231. * Defines the list of mesh's names you want to load
  151232. */
  151233. meshesNames: any,
  151234. /**
  151235. * Defines the root url to use as a base to load your meshes and associated resources
  151236. */
  151237. rootUrl: string,
  151238. /**
  151239. * Defines the filename or File of the scene to load from
  151240. */
  151241. sceneFilename: string | File);
  151242. /**
  151243. * Execute the current task
  151244. * @param scene defines the scene where you want your assets to be loaded
  151245. * @param onSuccess is a callback called when the task is successfully executed
  151246. * @param onError is a callback called if an error occurs
  151247. */
  151248. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151249. }
  151250. /**
  151251. * Define a task used by AssetsManager to load text content
  151252. */
  151253. export class TextFileAssetTask extends AbstractAssetTask {
  151254. /**
  151255. * Defines the name of the task
  151256. */
  151257. name: string;
  151258. /**
  151259. * Defines the location of the file to load
  151260. */
  151261. url: string;
  151262. /**
  151263. * Gets the loaded text string
  151264. */
  151265. text: string;
  151266. /**
  151267. * Callback called when the task is successful
  151268. */
  151269. onSuccess: (task: TextFileAssetTask) => void;
  151270. /**
  151271. * Callback called when the task is successful
  151272. */
  151273. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151274. /**
  151275. * Creates a new TextFileAssetTask object
  151276. * @param name defines the name of the task
  151277. * @param url defines the location of the file to load
  151278. */
  151279. constructor(
  151280. /**
  151281. * Defines the name of the task
  151282. */
  151283. name: string,
  151284. /**
  151285. * Defines the location of the file to load
  151286. */
  151287. url: string);
  151288. /**
  151289. * Execute the current task
  151290. * @param scene defines the scene where you want your assets to be loaded
  151291. * @param onSuccess is a callback called when the task is successfully executed
  151292. * @param onError is a callback called if an error occurs
  151293. */
  151294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151295. }
  151296. /**
  151297. * Define a task used by AssetsManager to load binary data
  151298. */
  151299. export class BinaryFileAssetTask extends AbstractAssetTask {
  151300. /**
  151301. * Defines the name of the task
  151302. */
  151303. name: string;
  151304. /**
  151305. * Defines the location of the file to load
  151306. */
  151307. url: string;
  151308. /**
  151309. * Gets the lodaded data (as an array buffer)
  151310. */
  151311. data: ArrayBuffer;
  151312. /**
  151313. * Callback called when the task is successful
  151314. */
  151315. onSuccess: (task: BinaryFileAssetTask) => void;
  151316. /**
  151317. * Callback called when the task is successful
  151318. */
  151319. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151320. /**
  151321. * Creates a new BinaryFileAssetTask object
  151322. * @param name defines the name of the new task
  151323. * @param url defines the location of the file to load
  151324. */
  151325. constructor(
  151326. /**
  151327. * Defines the name of the task
  151328. */
  151329. name: string,
  151330. /**
  151331. * Defines the location of the file to load
  151332. */
  151333. url: string);
  151334. /**
  151335. * Execute the current task
  151336. * @param scene defines the scene where you want your assets to be loaded
  151337. * @param onSuccess is a callback called when the task is successfully executed
  151338. * @param onError is a callback called if an error occurs
  151339. */
  151340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151341. }
  151342. /**
  151343. * Define a task used by AssetsManager to load images
  151344. */
  151345. export class ImageAssetTask extends AbstractAssetTask {
  151346. /**
  151347. * Defines the name of the task
  151348. */
  151349. name: string;
  151350. /**
  151351. * Defines the location of the image to load
  151352. */
  151353. url: string;
  151354. /**
  151355. * Gets the loaded images
  151356. */
  151357. image: HTMLImageElement;
  151358. /**
  151359. * Callback called when the task is successful
  151360. */
  151361. onSuccess: (task: ImageAssetTask) => void;
  151362. /**
  151363. * Callback called when the task is successful
  151364. */
  151365. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151366. /**
  151367. * Creates a new ImageAssetTask
  151368. * @param name defines the name of the task
  151369. * @param url defines the location of the image to load
  151370. */
  151371. constructor(
  151372. /**
  151373. * Defines the name of the task
  151374. */
  151375. name: string,
  151376. /**
  151377. * Defines the location of the image to load
  151378. */
  151379. url: string);
  151380. /**
  151381. * Execute the current task
  151382. * @param scene defines the scene where you want your assets to be loaded
  151383. * @param onSuccess is a callback called when the task is successfully executed
  151384. * @param onError is a callback called if an error occurs
  151385. */
  151386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151387. }
  151388. /**
  151389. * Defines the interface used by texture loading tasks
  151390. */
  151391. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151392. /**
  151393. * Gets the loaded texture
  151394. */
  151395. texture: TEX;
  151396. }
  151397. /**
  151398. * Define a task used by AssetsManager to load 2D textures
  151399. */
  151400. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151401. /**
  151402. * Defines the name of the task
  151403. */
  151404. name: string;
  151405. /**
  151406. * Defines the location of the file to load
  151407. */
  151408. url: string;
  151409. /**
  151410. * Defines if mipmap should not be generated (default is false)
  151411. */
  151412. noMipmap?: boolean | undefined;
  151413. /**
  151414. * Defines if texture must be inverted on Y axis (default is true)
  151415. */
  151416. invertY: boolean;
  151417. /**
  151418. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151419. */
  151420. samplingMode: number;
  151421. /**
  151422. * Gets the loaded texture
  151423. */
  151424. texture: Texture;
  151425. /**
  151426. * Callback called when the task is successful
  151427. */
  151428. onSuccess: (task: TextureAssetTask) => void;
  151429. /**
  151430. * Callback called when the task is successful
  151431. */
  151432. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151433. /**
  151434. * Creates a new TextureAssetTask object
  151435. * @param name defines the name of the task
  151436. * @param url defines the location of the file to load
  151437. * @param noMipmap defines if mipmap should not be generated (default is false)
  151438. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151439. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151440. */
  151441. constructor(
  151442. /**
  151443. * Defines the name of the task
  151444. */
  151445. name: string,
  151446. /**
  151447. * Defines the location of the file to load
  151448. */
  151449. url: string,
  151450. /**
  151451. * Defines if mipmap should not be generated (default is false)
  151452. */
  151453. noMipmap?: boolean | undefined,
  151454. /**
  151455. * Defines if texture must be inverted on Y axis (default is true)
  151456. */
  151457. invertY?: boolean,
  151458. /**
  151459. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151460. */
  151461. samplingMode?: number);
  151462. /**
  151463. * Execute the current task
  151464. * @param scene defines the scene where you want your assets to be loaded
  151465. * @param onSuccess is a callback called when the task is successfully executed
  151466. * @param onError is a callback called if an error occurs
  151467. */
  151468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151469. }
  151470. /**
  151471. * Define a task used by AssetsManager to load cube textures
  151472. */
  151473. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151474. /**
  151475. * Defines the name of the task
  151476. */
  151477. name: string;
  151478. /**
  151479. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151480. */
  151481. url: string;
  151482. /**
  151483. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151484. */
  151485. extensions?: string[] | undefined;
  151486. /**
  151487. * Defines if mipmaps should not be generated (default is false)
  151488. */
  151489. noMipmap?: boolean | undefined;
  151490. /**
  151491. * Defines the explicit list of files (undefined by default)
  151492. */
  151493. files?: string[] | undefined;
  151494. /**
  151495. * Gets the loaded texture
  151496. */
  151497. texture: CubeTexture;
  151498. /**
  151499. * Callback called when the task is successful
  151500. */
  151501. onSuccess: (task: CubeTextureAssetTask) => void;
  151502. /**
  151503. * Callback called when the task is successful
  151504. */
  151505. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151506. /**
  151507. * Creates a new CubeTextureAssetTask
  151508. * @param name defines the name of the task
  151509. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151510. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151511. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151512. * @param files defines the explicit list of files (undefined by default)
  151513. */
  151514. constructor(
  151515. /**
  151516. * Defines the name of the task
  151517. */
  151518. name: string,
  151519. /**
  151520. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151521. */
  151522. url: string,
  151523. /**
  151524. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151525. */
  151526. extensions?: string[] | undefined,
  151527. /**
  151528. * Defines if mipmaps should not be generated (default is false)
  151529. */
  151530. noMipmap?: boolean | undefined,
  151531. /**
  151532. * Defines the explicit list of files (undefined by default)
  151533. */
  151534. files?: string[] | undefined);
  151535. /**
  151536. * Execute the current task
  151537. * @param scene defines the scene where you want your assets to be loaded
  151538. * @param onSuccess is a callback called when the task is successfully executed
  151539. * @param onError is a callback called if an error occurs
  151540. */
  151541. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151542. }
  151543. /**
  151544. * Define a task used by AssetsManager to load HDR cube textures
  151545. */
  151546. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151547. /**
  151548. * Defines the name of the task
  151549. */
  151550. name: string;
  151551. /**
  151552. * Defines the location of the file to load
  151553. */
  151554. url: string;
  151555. /**
  151556. * Defines the desired size (the more it increases the longer the generation will be)
  151557. */
  151558. size: number;
  151559. /**
  151560. * Defines if mipmaps should not be generated (default is false)
  151561. */
  151562. noMipmap: boolean;
  151563. /**
  151564. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151565. */
  151566. generateHarmonics: boolean;
  151567. /**
  151568. * 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)
  151569. */
  151570. gammaSpace: boolean;
  151571. /**
  151572. * Internal Use Only
  151573. */
  151574. reserved: boolean;
  151575. /**
  151576. * Gets the loaded texture
  151577. */
  151578. texture: HDRCubeTexture;
  151579. /**
  151580. * Callback called when the task is successful
  151581. */
  151582. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151583. /**
  151584. * Callback called when the task is successful
  151585. */
  151586. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151587. /**
  151588. * Creates a new HDRCubeTextureAssetTask object
  151589. * @param name defines the name of the task
  151590. * @param url defines the location of the file to load
  151591. * @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.
  151592. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151593. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151594. * @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)
  151595. * @param reserved Internal use only
  151596. */
  151597. constructor(
  151598. /**
  151599. * Defines the name of the task
  151600. */
  151601. name: string,
  151602. /**
  151603. * Defines the location of the file to load
  151604. */
  151605. url: string,
  151606. /**
  151607. * Defines the desired size (the more it increases the longer the generation will be)
  151608. */
  151609. size: number,
  151610. /**
  151611. * Defines if mipmaps should not be generated (default is false)
  151612. */
  151613. noMipmap?: boolean,
  151614. /**
  151615. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151616. */
  151617. generateHarmonics?: boolean,
  151618. /**
  151619. * 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)
  151620. */
  151621. gammaSpace?: boolean,
  151622. /**
  151623. * Internal Use Only
  151624. */
  151625. reserved?: boolean);
  151626. /**
  151627. * Execute the current task
  151628. * @param scene defines the scene where you want your assets to be loaded
  151629. * @param onSuccess is a callback called when the task is successfully executed
  151630. * @param onError is a callback called if an error occurs
  151631. */
  151632. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151633. }
  151634. /**
  151635. * Define a task used by AssetsManager to load Equirectangular cube textures
  151636. */
  151637. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151638. /**
  151639. * Defines the name of the task
  151640. */
  151641. name: string;
  151642. /**
  151643. * Defines the location of the file to load
  151644. */
  151645. url: string;
  151646. /**
  151647. * Defines the desired size (the more it increases the longer the generation will be)
  151648. */
  151649. size: number;
  151650. /**
  151651. * Defines if mipmaps should not be generated (default is false)
  151652. */
  151653. noMipmap: boolean;
  151654. /**
  151655. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151656. * but the standard material would require them in Gamma space) (default is true)
  151657. */
  151658. gammaSpace: boolean;
  151659. /**
  151660. * Gets the loaded texture
  151661. */
  151662. texture: EquiRectangularCubeTexture;
  151663. /**
  151664. * Callback called when the task is successful
  151665. */
  151666. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151667. /**
  151668. * Callback called when the task is successful
  151669. */
  151670. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151671. /**
  151672. * Creates a new EquiRectangularCubeTextureAssetTask object
  151673. * @param name defines the name of the task
  151674. * @param url defines the location of the file to load
  151675. * @param size defines the desired size (the more it increases the longer the generation will be)
  151676. * If the size is omitted this implies you are using a preprocessed cubemap.
  151677. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151678. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151679. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151680. * (default is true)
  151681. */
  151682. constructor(
  151683. /**
  151684. * Defines the name of the task
  151685. */
  151686. name: string,
  151687. /**
  151688. * Defines the location of the file to load
  151689. */
  151690. url: string,
  151691. /**
  151692. * Defines the desired size (the more it increases the longer the generation will be)
  151693. */
  151694. size: number,
  151695. /**
  151696. * Defines if mipmaps should not be generated (default is false)
  151697. */
  151698. noMipmap?: boolean,
  151699. /**
  151700. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151701. * but the standard material would require them in Gamma space) (default is true)
  151702. */
  151703. gammaSpace?: boolean);
  151704. /**
  151705. * Execute the current task
  151706. * @param scene defines the scene where you want your assets to be loaded
  151707. * @param onSuccess is a callback called when the task is successfully executed
  151708. * @param onError is a callback called if an error occurs
  151709. */
  151710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151711. }
  151712. /**
  151713. * This class can be used to easily import assets into a scene
  151714. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151715. */
  151716. export class AssetsManager {
  151717. private _scene;
  151718. private _isLoading;
  151719. protected _tasks: AbstractAssetTask[];
  151720. protected _waitingTasksCount: number;
  151721. protected _totalTasksCount: number;
  151722. /**
  151723. * Callback called when all tasks are processed
  151724. */
  151725. onFinish: (tasks: AbstractAssetTask[]) => void;
  151726. /**
  151727. * Callback called when a task is successful
  151728. */
  151729. onTaskSuccess: (task: AbstractAssetTask) => void;
  151730. /**
  151731. * Callback called when a task had an error
  151732. */
  151733. onTaskError: (task: AbstractAssetTask) => void;
  151734. /**
  151735. * Callback called when a task is done (whatever the result is)
  151736. */
  151737. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151738. /**
  151739. * Observable called when all tasks are processed
  151740. */
  151741. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151742. /**
  151743. * Observable called when a task had an error
  151744. */
  151745. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151746. /**
  151747. * Observable called when all tasks were executed
  151748. */
  151749. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151750. /**
  151751. * Observable called when a task is done (whatever the result is)
  151752. */
  151753. onProgressObservable: Observable<IAssetsProgressEvent>;
  151754. /**
  151755. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151756. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151757. */
  151758. useDefaultLoadingScreen: boolean;
  151759. /**
  151760. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151761. * when all assets have been downloaded.
  151762. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151763. */
  151764. autoHideLoadingUI: boolean;
  151765. /**
  151766. * Creates a new AssetsManager
  151767. * @param scene defines the scene to work on
  151768. */
  151769. constructor(scene: Scene);
  151770. /**
  151771. * Add a ContainerAssetTask to the list of active tasks
  151772. * @param taskName defines the name of the new task
  151773. * @param meshesNames defines the name of meshes to load
  151774. * @param rootUrl defines the root url to use to locate files
  151775. * @param sceneFilename defines the filename of the scene file
  151776. * @returns a new ContainerAssetTask object
  151777. */
  151778. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151779. /**
  151780. * Add a MeshAssetTask to the list of active tasks
  151781. * @param taskName defines the name of the new task
  151782. * @param meshesNames defines the name of meshes to load
  151783. * @param rootUrl defines the root url to use to locate files
  151784. * @param sceneFilename defines the filename of the scene file
  151785. * @returns a new MeshAssetTask object
  151786. */
  151787. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151788. /**
  151789. * Add a TextFileAssetTask to the list of active tasks
  151790. * @param taskName defines the name of the new task
  151791. * @param url defines the url of the file to load
  151792. * @returns a new TextFileAssetTask object
  151793. */
  151794. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151795. /**
  151796. * Add a BinaryFileAssetTask to the list of active tasks
  151797. * @param taskName defines the name of the new task
  151798. * @param url defines the url of the file to load
  151799. * @returns a new BinaryFileAssetTask object
  151800. */
  151801. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151802. /**
  151803. * Add a ImageAssetTask to the list of active tasks
  151804. * @param taskName defines the name of the new task
  151805. * @param url defines the url of the file to load
  151806. * @returns a new ImageAssetTask object
  151807. */
  151808. addImageTask(taskName: string, url: string): ImageAssetTask;
  151809. /**
  151810. * Add a TextureAssetTask to the list of active tasks
  151811. * @param taskName defines the name of the new task
  151812. * @param url defines the url of the file to load
  151813. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151814. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151816. * @returns a new TextureAssetTask object
  151817. */
  151818. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151819. /**
  151820. * Add a CubeTextureAssetTask to the list of active tasks
  151821. * @param taskName defines the name of the new task
  151822. * @param url defines the url of the file to load
  151823. * @param extensions defines the extension to use to load the cube map (can be null)
  151824. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151825. * @param files defines the list of files to load (can be null)
  151826. * @returns a new CubeTextureAssetTask object
  151827. */
  151828. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151829. /**
  151830. *
  151831. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151832. * @param taskName defines the name of the new task
  151833. * @param url defines the url of the file to load
  151834. * @param size defines the size you want for the cubemap (can be null)
  151835. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151836. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151837. * @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)
  151838. * @param reserved Internal use only
  151839. * @returns a new HDRCubeTextureAssetTask object
  151840. */
  151841. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151842. /**
  151843. *
  151844. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151845. * @param taskName defines the name of the new task
  151846. * @param url defines the url of the file to load
  151847. * @param size defines the size you want for the cubemap (can be null)
  151848. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151849. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151850. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151851. * @returns a new EquiRectangularCubeTextureAssetTask object
  151852. */
  151853. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151854. /**
  151855. * Remove a task from the assets manager.
  151856. * @param task the task to remove
  151857. */
  151858. removeTask(task: AbstractAssetTask): void;
  151859. private _decreaseWaitingTasksCount;
  151860. private _runTask;
  151861. /**
  151862. * Reset the AssetsManager and remove all tasks
  151863. * @return the current instance of the AssetsManager
  151864. */
  151865. reset(): AssetsManager;
  151866. /**
  151867. * Start the loading process
  151868. * @return the current instance of the AssetsManager
  151869. */
  151870. load(): AssetsManager;
  151871. /**
  151872. * Start the loading process as an async operation
  151873. * @return a promise returning the list of failed tasks
  151874. */
  151875. loadAsync(): Promise<void>;
  151876. }
  151877. }
  151878. declare module BABYLON {
  151879. /**
  151880. * Wrapper class for promise with external resolve and reject.
  151881. */
  151882. export class Deferred<T> {
  151883. /**
  151884. * The promise associated with this deferred object.
  151885. */
  151886. readonly promise: Promise<T>;
  151887. private _resolve;
  151888. private _reject;
  151889. /**
  151890. * The resolve method of the promise associated with this deferred object.
  151891. */
  151892. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151893. /**
  151894. * The reject method of the promise associated with this deferred object.
  151895. */
  151896. get reject(): (reason?: any) => void;
  151897. /**
  151898. * Constructor for this deferred object.
  151899. */
  151900. constructor();
  151901. }
  151902. }
  151903. declare module BABYLON {
  151904. /**
  151905. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151906. */
  151907. export class MeshExploder {
  151908. private _centerMesh;
  151909. private _meshes;
  151910. private _meshesOrigins;
  151911. private _toCenterVectors;
  151912. private _scaledDirection;
  151913. private _newPosition;
  151914. private _centerPosition;
  151915. /**
  151916. * Explodes meshes from a center mesh.
  151917. * @param meshes The meshes to explode.
  151918. * @param centerMesh The mesh to be center of explosion.
  151919. */
  151920. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151921. private _setCenterMesh;
  151922. /**
  151923. * Get class name
  151924. * @returns "MeshExploder"
  151925. */
  151926. getClassName(): string;
  151927. /**
  151928. * "Exploded meshes"
  151929. * @returns Array of meshes with the centerMesh at index 0.
  151930. */
  151931. getMeshes(): Array<Mesh>;
  151932. /**
  151933. * Explodes meshes giving a specific direction
  151934. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151935. */
  151936. explode(direction?: number): void;
  151937. }
  151938. }
  151939. declare module BABYLON {
  151940. /**
  151941. * Class used to help managing file picking and drag'n'drop
  151942. */
  151943. export class FilesInput {
  151944. /**
  151945. * List of files ready to be loaded
  151946. */
  151947. static get FilesToLoad(): {
  151948. [key: string]: File;
  151949. };
  151950. /**
  151951. * Callback called when a file is processed
  151952. */
  151953. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151954. private _engine;
  151955. private _currentScene;
  151956. private _sceneLoadedCallback;
  151957. private _progressCallback;
  151958. private _additionalRenderLoopLogicCallback;
  151959. private _textureLoadingCallback;
  151960. private _startingProcessingFilesCallback;
  151961. private _onReloadCallback;
  151962. private _errorCallback;
  151963. private _elementToMonitor;
  151964. private _sceneFileToLoad;
  151965. private _filesToLoad;
  151966. /**
  151967. * Creates a new FilesInput
  151968. * @param engine defines the rendering engine
  151969. * @param scene defines the hosting scene
  151970. * @param sceneLoadedCallback callback called when scene is loaded
  151971. * @param progressCallback callback called to track progress
  151972. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151973. * @param textureLoadingCallback callback called when a texture is loading
  151974. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151975. * @param onReloadCallback callback called when a reload is requested
  151976. * @param errorCallback callback call if an error occurs
  151977. */
  151978. 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>);
  151979. private _dragEnterHandler;
  151980. private _dragOverHandler;
  151981. private _dropHandler;
  151982. /**
  151983. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151984. * @param elementToMonitor defines the DOM element to track
  151985. */
  151986. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151987. /** Gets the current list of files to load */
  151988. get filesToLoad(): File[];
  151989. /**
  151990. * Release all associated resources
  151991. */
  151992. dispose(): void;
  151993. private renderFunction;
  151994. private drag;
  151995. private drop;
  151996. private _traverseFolder;
  151997. private _processFiles;
  151998. /**
  151999. * Load files from a drop event
  152000. * @param event defines the drop event to use as source
  152001. */
  152002. loadFiles(event: any): void;
  152003. private _processReload;
  152004. /**
  152005. * Reload the current scene from the loaded files
  152006. */
  152007. reload(): void;
  152008. }
  152009. }
  152010. declare module BABYLON {
  152011. /**
  152012. * Defines the root class used to create scene optimization to use with SceneOptimizer
  152013. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152014. */
  152015. export class SceneOptimization {
  152016. /**
  152017. * Defines the priority of this optimization (0 by default which means first in the list)
  152018. */
  152019. priority: number;
  152020. /**
  152021. * Gets a string describing the action executed by the current optimization
  152022. * @returns description string
  152023. */
  152024. getDescription(): string;
  152025. /**
  152026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152027. * @param scene defines the current scene where to apply this optimization
  152028. * @param optimizer defines the current optimizer
  152029. * @returns true if everything that can be done was applied
  152030. */
  152031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152032. /**
  152033. * Creates the SceneOptimization object
  152034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152035. * @param desc defines the description associated with the optimization
  152036. */
  152037. constructor(
  152038. /**
  152039. * Defines the priority of this optimization (0 by default which means first in the list)
  152040. */
  152041. priority?: number);
  152042. }
  152043. /**
  152044. * Defines an optimization used to reduce the size of render target textures
  152045. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152046. */
  152047. export class TextureOptimization extends SceneOptimization {
  152048. /**
  152049. * Defines the priority of this optimization (0 by default which means first in the list)
  152050. */
  152051. priority: number;
  152052. /**
  152053. * 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
  152054. */
  152055. maximumSize: number;
  152056. /**
  152057. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152058. */
  152059. step: number;
  152060. /**
  152061. * Gets a string describing the action executed by the current optimization
  152062. * @returns description string
  152063. */
  152064. getDescription(): string;
  152065. /**
  152066. * Creates the TextureOptimization object
  152067. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152068. * @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
  152069. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152070. */
  152071. constructor(
  152072. /**
  152073. * Defines the priority of this optimization (0 by default which means first in the list)
  152074. */
  152075. priority?: number,
  152076. /**
  152077. * 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
  152078. */
  152079. maximumSize?: number,
  152080. /**
  152081. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152082. */
  152083. step?: number);
  152084. /**
  152085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152086. * @param scene defines the current scene where to apply this optimization
  152087. * @param optimizer defines the current optimizer
  152088. * @returns true if everything that can be done was applied
  152089. */
  152090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152091. }
  152092. /**
  152093. * Defines an optimization used to increase or decrease the rendering resolution
  152094. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152095. */
  152096. export class HardwareScalingOptimization extends SceneOptimization {
  152097. /**
  152098. * Defines the priority of this optimization (0 by default which means first in the list)
  152099. */
  152100. priority: number;
  152101. /**
  152102. * Defines the maximum scale to use (2 by default)
  152103. */
  152104. maximumScale: number;
  152105. /**
  152106. * Defines the step to use between two passes (0.5 by default)
  152107. */
  152108. step: number;
  152109. private _currentScale;
  152110. private _directionOffset;
  152111. /**
  152112. * Gets a string describing the action executed by the current optimization
  152113. * @return description string
  152114. */
  152115. getDescription(): string;
  152116. /**
  152117. * Creates the HardwareScalingOptimization object
  152118. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152119. * @param maximumScale defines the maximum scale to use (2 by default)
  152120. * @param step defines the step to use between two passes (0.5 by default)
  152121. */
  152122. constructor(
  152123. /**
  152124. * Defines the priority of this optimization (0 by default which means first in the list)
  152125. */
  152126. priority?: number,
  152127. /**
  152128. * Defines the maximum scale to use (2 by default)
  152129. */
  152130. maximumScale?: number,
  152131. /**
  152132. * Defines the step to use between two passes (0.5 by default)
  152133. */
  152134. step?: number);
  152135. /**
  152136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152137. * @param scene defines the current scene where to apply this optimization
  152138. * @param optimizer defines the current optimizer
  152139. * @returns true if everything that can be done was applied
  152140. */
  152141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152142. }
  152143. /**
  152144. * Defines an optimization used to remove shadows
  152145. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152146. */
  152147. export class ShadowsOptimization extends SceneOptimization {
  152148. /**
  152149. * Gets a string describing the action executed by the current optimization
  152150. * @return description string
  152151. */
  152152. getDescription(): string;
  152153. /**
  152154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152155. * @param scene defines the current scene where to apply this optimization
  152156. * @param optimizer defines the current optimizer
  152157. * @returns true if everything that can be done was applied
  152158. */
  152159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152160. }
  152161. /**
  152162. * Defines an optimization used to turn post-processes off
  152163. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152164. */
  152165. export class PostProcessesOptimization extends SceneOptimization {
  152166. /**
  152167. * Gets a string describing the action executed by the current optimization
  152168. * @return description string
  152169. */
  152170. getDescription(): string;
  152171. /**
  152172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152173. * @param scene defines the current scene where to apply this optimization
  152174. * @param optimizer defines the current optimizer
  152175. * @returns true if everything that can be done was applied
  152176. */
  152177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152178. }
  152179. /**
  152180. * Defines an optimization used to turn lens flares off
  152181. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152182. */
  152183. export class LensFlaresOptimization extends SceneOptimization {
  152184. /**
  152185. * Gets a string describing the action executed by the current optimization
  152186. * @return description string
  152187. */
  152188. getDescription(): string;
  152189. /**
  152190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152191. * @param scene defines the current scene where to apply this optimization
  152192. * @param optimizer defines the current optimizer
  152193. * @returns true if everything that can be done was applied
  152194. */
  152195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152196. }
  152197. /**
  152198. * Defines an optimization based on user defined callback.
  152199. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152200. */
  152201. export class CustomOptimization extends SceneOptimization {
  152202. /**
  152203. * Callback called to apply the custom optimization.
  152204. */
  152205. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  152206. /**
  152207. * Callback called to get custom description
  152208. */
  152209. onGetDescription: () => string;
  152210. /**
  152211. * Gets a string describing the action executed by the current optimization
  152212. * @returns description string
  152213. */
  152214. getDescription(): string;
  152215. /**
  152216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152217. * @param scene defines the current scene where to apply this optimization
  152218. * @param optimizer defines the current optimizer
  152219. * @returns true if everything that can be done was applied
  152220. */
  152221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152222. }
  152223. /**
  152224. * Defines an optimization used to turn particles off
  152225. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152226. */
  152227. export class ParticlesOptimization extends SceneOptimization {
  152228. /**
  152229. * Gets a string describing the action executed by the current optimization
  152230. * @return description string
  152231. */
  152232. getDescription(): string;
  152233. /**
  152234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152235. * @param scene defines the current scene where to apply this optimization
  152236. * @param optimizer defines the current optimizer
  152237. * @returns true if everything that can be done was applied
  152238. */
  152239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152240. }
  152241. /**
  152242. * Defines an optimization used to turn render targets off
  152243. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152244. */
  152245. export class RenderTargetsOptimization extends SceneOptimization {
  152246. /**
  152247. * Gets a string describing the action executed by the current optimization
  152248. * @return description string
  152249. */
  152250. getDescription(): string;
  152251. /**
  152252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152253. * @param scene defines the current scene where to apply this optimization
  152254. * @param optimizer defines the current optimizer
  152255. * @returns true if everything that can be done was applied
  152256. */
  152257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152258. }
  152259. /**
  152260. * Defines an optimization used to merge meshes with compatible materials
  152261. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152262. */
  152263. export class MergeMeshesOptimization extends SceneOptimization {
  152264. private static _UpdateSelectionTree;
  152265. /**
  152266. * Gets or sets a boolean which defines if optimization octree has to be updated
  152267. */
  152268. static get UpdateSelectionTree(): boolean;
  152269. /**
  152270. * Gets or sets a boolean which defines if optimization octree has to be updated
  152271. */
  152272. static set UpdateSelectionTree(value: boolean);
  152273. /**
  152274. * Gets a string describing the action executed by the current optimization
  152275. * @return description string
  152276. */
  152277. getDescription(): string;
  152278. private _canBeMerged;
  152279. /**
  152280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152281. * @param scene defines the current scene where to apply this optimization
  152282. * @param optimizer defines the current optimizer
  152283. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152284. * @returns true if everything that can be done was applied
  152285. */
  152286. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152287. }
  152288. /**
  152289. * Defines a list of options used by SceneOptimizer
  152290. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152291. */
  152292. export class SceneOptimizerOptions {
  152293. /**
  152294. * Defines the target frame rate to reach (60 by default)
  152295. */
  152296. targetFrameRate: number;
  152297. /**
  152298. * Defines the interval between two checkes (2000ms by default)
  152299. */
  152300. trackerDuration: number;
  152301. /**
  152302. * Gets the list of optimizations to apply
  152303. */
  152304. optimizations: SceneOptimization[];
  152305. /**
  152306. * Creates a new list of options used by SceneOptimizer
  152307. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152308. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152309. */
  152310. constructor(
  152311. /**
  152312. * Defines the target frame rate to reach (60 by default)
  152313. */
  152314. targetFrameRate?: number,
  152315. /**
  152316. * Defines the interval between two checkes (2000ms by default)
  152317. */
  152318. trackerDuration?: number);
  152319. /**
  152320. * Add a new optimization
  152321. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152322. * @returns the current SceneOptimizerOptions
  152323. */
  152324. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152325. /**
  152326. * Add a new custom optimization
  152327. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152328. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152329. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152330. * @returns the current SceneOptimizerOptions
  152331. */
  152332. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152333. /**
  152334. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152335. * @param targetFrameRate defines the target frame rate (60 by default)
  152336. * @returns a SceneOptimizerOptions object
  152337. */
  152338. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152339. /**
  152340. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152341. * @param targetFrameRate defines the target frame rate (60 by default)
  152342. * @returns a SceneOptimizerOptions object
  152343. */
  152344. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152345. /**
  152346. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152347. * @param targetFrameRate defines the target frame rate (60 by default)
  152348. * @returns a SceneOptimizerOptions object
  152349. */
  152350. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152351. }
  152352. /**
  152353. * Class used to run optimizations in order to reach a target frame rate
  152354. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152355. */
  152356. export class SceneOptimizer implements IDisposable {
  152357. private _isRunning;
  152358. private _options;
  152359. private _scene;
  152360. private _currentPriorityLevel;
  152361. private _targetFrameRate;
  152362. private _trackerDuration;
  152363. private _currentFrameRate;
  152364. private _sceneDisposeObserver;
  152365. private _improvementMode;
  152366. /**
  152367. * Defines an observable called when the optimizer reaches the target frame rate
  152368. */
  152369. onSuccessObservable: Observable<SceneOptimizer>;
  152370. /**
  152371. * Defines an observable called when the optimizer enables an optimization
  152372. */
  152373. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152374. /**
  152375. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152376. */
  152377. onFailureObservable: Observable<SceneOptimizer>;
  152378. /**
  152379. * Gets a boolean indicating if the optimizer is in improvement mode
  152380. */
  152381. get isInImprovementMode(): boolean;
  152382. /**
  152383. * Gets the current priority level (0 at start)
  152384. */
  152385. get currentPriorityLevel(): number;
  152386. /**
  152387. * Gets the current frame rate checked by the SceneOptimizer
  152388. */
  152389. get currentFrameRate(): number;
  152390. /**
  152391. * Gets or sets the current target frame rate (60 by default)
  152392. */
  152393. get targetFrameRate(): number;
  152394. /**
  152395. * Gets or sets the current target frame rate (60 by default)
  152396. */
  152397. set targetFrameRate(value: number);
  152398. /**
  152399. * Gets or sets the current interval between two checks (every 2000ms by default)
  152400. */
  152401. get trackerDuration(): number;
  152402. /**
  152403. * Gets or sets the current interval between two checks (every 2000ms by default)
  152404. */
  152405. set trackerDuration(value: number);
  152406. /**
  152407. * Gets the list of active optimizations
  152408. */
  152409. get optimizations(): SceneOptimization[];
  152410. /**
  152411. * Creates a new SceneOptimizer
  152412. * @param scene defines the scene to work on
  152413. * @param options defines the options to use with the SceneOptimizer
  152414. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152415. * @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)
  152416. */
  152417. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152418. /**
  152419. * Stops the current optimizer
  152420. */
  152421. stop(): void;
  152422. /**
  152423. * Reset the optimizer to initial step (current priority level = 0)
  152424. */
  152425. reset(): void;
  152426. /**
  152427. * Start the optimizer. By default it will try to reach a specific framerate
  152428. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152429. */
  152430. start(): void;
  152431. private _checkCurrentState;
  152432. /**
  152433. * Release all resources
  152434. */
  152435. dispose(): void;
  152436. /**
  152437. * Helper function to create a SceneOptimizer with one single line of code
  152438. * @param scene defines the scene to work on
  152439. * @param options defines the options to use with the SceneOptimizer
  152440. * @param onSuccess defines a callback to call on success
  152441. * @param onFailure defines a callback to call on failure
  152442. * @returns the new SceneOptimizer object
  152443. */
  152444. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152445. }
  152446. }
  152447. declare module BABYLON {
  152448. /**
  152449. * Class used to serialize a scene into a string
  152450. */
  152451. export class SceneSerializer {
  152452. /**
  152453. * Clear cache used by a previous serialization
  152454. */
  152455. static ClearCache(): void;
  152456. /**
  152457. * Serialize a scene into a JSON compatible object
  152458. * @param scene defines the scene to serialize
  152459. * @returns a JSON compatible object
  152460. */
  152461. static Serialize(scene: Scene): any;
  152462. /**
  152463. * Serialize a mesh into a JSON compatible object
  152464. * @param toSerialize defines the mesh to serialize
  152465. * @param withParents defines if parents must be serialized as well
  152466. * @param withChildren defines if children must be serialized as well
  152467. * @returns a JSON compatible object
  152468. */
  152469. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152470. }
  152471. }
  152472. declare module BABYLON {
  152473. /**
  152474. * Class used to host texture specific utilities
  152475. */
  152476. export class TextureTools {
  152477. /**
  152478. * Uses the GPU to create a copy texture rescaled at a given size
  152479. * @param texture Texture to copy from
  152480. * @param width defines the desired width
  152481. * @param height defines the desired height
  152482. * @param useBilinearMode defines if bilinear mode has to be used
  152483. * @return the generated texture
  152484. */
  152485. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152486. }
  152487. }
  152488. declare module BABYLON {
  152489. /**
  152490. * This represents the different options available for the video capture.
  152491. */
  152492. export interface VideoRecorderOptions {
  152493. /** Defines the mime type of the video. */
  152494. mimeType: string;
  152495. /** Defines the FPS the video should be recorded at. */
  152496. fps: number;
  152497. /** Defines the chunk size for the recording data. */
  152498. recordChunckSize: number;
  152499. /** The audio tracks to attach to the recording. */
  152500. audioTracks?: MediaStreamTrack[];
  152501. }
  152502. /**
  152503. * This can help with recording videos from BabylonJS.
  152504. * This is based on the available WebRTC functionalities of the browser.
  152505. *
  152506. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152507. */
  152508. export class VideoRecorder {
  152509. private static readonly _defaultOptions;
  152510. /**
  152511. * Returns whether or not the VideoRecorder is available in your browser.
  152512. * @param engine Defines the Babylon Engine.
  152513. * @returns true if supported otherwise false.
  152514. */
  152515. static IsSupported(engine: Engine): boolean;
  152516. private readonly _options;
  152517. private _canvas;
  152518. private _mediaRecorder;
  152519. private _recordedChunks;
  152520. private _fileName;
  152521. private _resolve;
  152522. private _reject;
  152523. /**
  152524. * True when a recording is already in progress.
  152525. */
  152526. get isRecording(): boolean;
  152527. /**
  152528. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152529. * @param engine Defines the BabylonJS Engine you wish to record.
  152530. * @param options Defines options that can be used to customize the capture.
  152531. */
  152532. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152533. /**
  152534. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152535. */
  152536. stopRecording(): void;
  152537. /**
  152538. * Starts recording the canvas for a max duration specified in parameters.
  152539. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152540. * If null no automatic download will start and you can rely on the promise to get the data back.
  152541. * @param maxDuration Defines the maximum recording time in seconds.
  152542. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152543. * @return A promise callback at the end of the recording with the video data in Blob.
  152544. */
  152545. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152546. /**
  152547. * Releases internal resources used during the recording.
  152548. */
  152549. dispose(): void;
  152550. private _handleDataAvailable;
  152551. private _handleError;
  152552. private _handleStop;
  152553. }
  152554. }
  152555. declare module BABYLON {
  152556. /**
  152557. * Class containing a set of static utilities functions for screenshots
  152558. */
  152559. export class ScreenshotTools {
  152560. /**
  152561. * Captures a screenshot of the current rendering
  152562. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152563. * @param engine defines the rendering engine
  152564. * @param camera defines the source camera
  152565. * @param size This parameter can be set to a single number or to an object with the
  152566. * following (optional) properties: precision, width, height. If a single number is passed,
  152567. * it will be used for both width and height. If an object is passed, the screenshot size
  152568. * will be derived from the parameters. The precision property is a multiplier allowing
  152569. * rendering at a higher or lower resolution
  152570. * @param successCallback defines the callback receives a single parameter which contains the
  152571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152572. * src parameter of an <img> to display it
  152573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152574. * Check your browser for supported MIME types
  152575. */
  152576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152577. /**
  152578. * Captures a screenshot of the current rendering
  152579. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152580. * @param engine defines the rendering engine
  152581. * @param camera defines the source camera
  152582. * @param size This parameter can be set to a single number or to an object with the
  152583. * following (optional) properties: precision, width, height. If a single number is passed,
  152584. * it will be used for both width and height. If an object is passed, the screenshot size
  152585. * will be derived from the parameters. The precision property is a multiplier allowing
  152586. * rendering at a higher or lower resolution
  152587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152588. * Check your browser for supported MIME types
  152589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152590. * to the src parameter of an <img> to display it
  152591. */
  152592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152593. /**
  152594. * Generates an image screenshot from the specified camera.
  152595. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152596. * @param engine The engine to use for rendering
  152597. * @param camera The camera to use for rendering
  152598. * @param size This parameter can be set to a single number or to an object with the
  152599. * following (optional) properties: precision, width, height. If a single number is passed,
  152600. * it will be used for both width and height. If an object is passed, the screenshot size
  152601. * will be derived from the parameters. The precision property is a multiplier allowing
  152602. * rendering at a higher or lower resolution
  152603. * @param successCallback The callback receives a single parameter which contains the
  152604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152605. * src parameter of an <img> to display it
  152606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152607. * Check your browser for supported MIME types
  152608. * @param samples Texture samples (default: 1)
  152609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152610. * @param fileName A name for for the downloaded file.
  152611. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152612. */
  152613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152614. /**
  152615. * Generates an image screenshot from the specified camera.
  152616. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152617. * @param engine The engine to use for rendering
  152618. * @param camera The camera to use for rendering
  152619. * @param size This parameter can be set to a single number or to an object with the
  152620. * following (optional) properties: precision, width, height. If a single number is passed,
  152621. * it will be used for both width and height. If an object is passed, the screenshot size
  152622. * will be derived from the parameters. The precision property is a multiplier allowing
  152623. * rendering at a higher or lower resolution
  152624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152625. * Check your browser for supported MIME types
  152626. * @param samples Texture samples (default: 1)
  152627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152628. * @param fileName A name for for the downloaded file.
  152629. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152630. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152631. * to the src parameter of an <img> to display it
  152632. */
  152633. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152634. /**
  152635. * Gets height and width for screenshot size
  152636. * @private
  152637. */
  152638. private static _getScreenshotSize;
  152639. }
  152640. }
  152641. declare module BABYLON {
  152642. /**
  152643. * Interface for a data buffer
  152644. */
  152645. export interface IDataBuffer {
  152646. /**
  152647. * Reads bytes from the data buffer.
  152648. * @param byteOffset The byte offset to read
  152649. * @param byteLength The byte length to read
  152650. * @returns A promise that resolves when the bytes are read
  152651. */
  152652. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152653. /**
  152654. * The byte length of the buffer.
  152655. */
  152656. readonly byteLength: number;
  152657. }
  152658. /**
  152659. * Utility class for reading from a data buffer
  152660. */
  152661. export class DataReader {
  152662. /**
  152663. * The data buffer associated with this data reader.
  152664. */
  152665. readonly buffer: IDataBuffer;
  152666. /**
  152667. * The current byte offset from the beginning of the data buffer.
  152668. */
  152669. byteOffset: number;
  152670. private _dataView;
  152671. private _dataByteOffset;
  152672. /**
  152673. * Constructor
  152674. * @param buffer The buffer to read
  152675. */
  152676. constructor(buffer: IDataBuffer);
  152677. /**
  152678. * Loads the given byte length.
  152679. * @param byteLength The byte length to load
  152680. * @returns A promise that resolves when the load is complete
  152681. */
  152682. loadAsync(byteLength: number): Promise<void>;
  152683. /**
  152684. * Read a unsigned 32-bit integer from the currently loaded data range.
  152685. * @returns The 32-bit integer read
  152686. */
  152687. readUint32(): number;
  152688. /**
  152689. * Read a byte array from the currently loaded data range.
  152690. * @param byteLength The byte length to read
  152691. * @returns The byte array read
  152692. */
  152693. readUint8Array(byteLength: number): Uint8Array;
  152694. /**
  152695. * Read a string from the currently loaded data range.
  152696. * @param byteLength The byte length to read
  152697. * @returns The string read
  152698. */
  152699. readString(byteLength: number): string;
  152700. /**
  152701. * Skips the given byte length the currently loaded data range.
  152702. * @param byteLength The byte length to skip
  152703. */
  152704. skipBytes(byteLength: number): void;
  152705. }
  152706. }
  152707. declare module BABYLON {
  152708. /**
  152709. * Class for storing data to local storage if available or in-memory storage otherwise
  152710. */
  152711. export class DataStorage {
  152712. private static _Storage;
  152713. private static _GetStorage;
  152714. /**
  152715. * Reads a string from the data storage
  152716. * @param key The key to read
  152717. * @param defaultValue The value if the key doesn't exist
  152718. * @returns The string value
  152719. */
  152720. static ReadString(key: string, defaultValue: string): string;
  152721. /**
  152722. * Writes a string to the data storage
  152723. * @param key The key to write
  152724. * @param value The value to write
  152725. */
  152726. static WriteString(key: string, value: string): void;
  152727. /**
  152728. * Reads a boolean from the data storage
  152729. * @param key The key to read
  152730. * @param defaultValue The value if the key doesn't exist
  152731. * @returns The boolean value
  152732. */
  152733. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152734. /**
  152735. * Writes a boolean to the data storage
  152736. * @param key The key to write
  152737. * @param value The value to write
  152738. */
  152739. static WriteBoolean(key: string, value: boolean): void;
  152740. /**
  152741. * Reads a number from the data storage
  152742. * @param key The key to read
  152743. * @param defaultValue The value if the key doesn't exist
  152744. * @returns The number value
  152745. */
  152746. static ReadNumber(key: string, defaultValue: number): number;
  152747. /**
  152748. * Writes a number to the data storage
  152749. * @param key The key to write
  152750. * @param value The value to write
  152751. */
  152752. static WriteNumber(key: string, value: number): void;
  152753. }
  152754. }
  152755. declare module BABYLON {
  152756. /**
  152757. * Class used to record delta files between 2 scene states
  152758. */
  152759. export class SceneRecorder {
  152760. private _trackedScene;
  152761. private _savedJSON;
  152762. /**
  152763. * Track a given scene. This means the current scene state will be considered the original state
  152764. * @param scene defines the scene to track
  152765. */
  152766. track(scene: Scene): void;
  152767. /**
  152768. * Get the delta between current state and original state
  152769. * @returns a string containing the delta
  152770. */
  152771. getDelta(): any;
  152772. private _compareArray;
  152773. private _compareObjects;
  152774. private _compareCollections;
  152775. private static GetShadowGeneratorById;
  152776. /**
  152777. * Apply a given delta to a given scene
  152778. * @param deltaJSON defines the JSON containing the delta
  152779. * @param scene defines the scene to apply the delta to
  152780. */
  152781. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152782. private static _ApplyPropertiesToEntity;
  152783. private static _ApplyDeltaForEntity;
  152784. }
  152785. }
  152786. declare module BABYLON {
  152787. /**
  152788. * An interface for all Hit test features
  152789. */
  152790. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152791. /**
  152792. * Triggered when new babylon (transformed) hit test results are available
  152793. */
  152794. onHitTestResultObservable: Observable<T[]>;
  152795. }
  152796. /**
  152797. * Options used for hit testing
  152798. */
  152799. export interface IWebXRLegacyHitTestOptions {
  152800. /**
  152801. * Only test when user interacted with the scene. Default - hit test every frame
  152802. */
  152803. testOnPointerDownOnly?: boolean;
  152804. /**
  152805. * The node to use to transform the local results to world coordinates
  152806. */
  152807. worldParentNode?: TransformNode;
  152808. }
  152809. /**
  152810. * Interface defining the babylon result of raycasting/hit-test
  152811. */
  152812. export interface IWebXRLegacyHitResult {
  152813. /**
  152814. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152815. */
  152816. transformationMatrix: Matrix;
  152817. /**
  152818. * The native hit test result
  152819. */
  152820. xrHitResult: XRHitResult | XRHitTestResult;
  152821. }
  152822. /**
  152823. * The currently-working hit-test module.
  152824. * Hit test (or Ray-casting) is used to interact with the real world.
  152825. * For further information read here - https://github.com/immersive-web/hit-test
  152826. */
  152827. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152828. /**
  152829. * options to use when constructing this feature
  152830. */
  152831. readonly options: IWebXRLegacyHitTestOptions;
  152832. private _direction;
  152833. private _mat;
  152834. private _onSelectEnabled;
  152835. private _origin;
  152836. /**
  152837. * The module's name
  152838. */
  152839. static readonly Name: string;
  152840. /**
  152841. * The (Babylon) version of this module.
  152842. * This is an integer representing the implementation version.
  152843. * This number does not correspond to the WebXR specs version
  152844. */
  152845. static readonly Version: number;
  152846. /**
  152847. * Populated with the last native XR Hit Results
  152848. */
  152849. lastNativeXRHitResults: XRHitResult[];
  152850. /**
  152851. * Triggered when new babylon (transformed) hit test results are available
  152852. */
  152853. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152854. /**
  152855. * Creates a new instance of the (legacy version) hit test feature
  152856. * @param _xrSessionManager an instance of WebXRSessionManager
  152857. * @param options options to use when constructing this feature
  152858. */
  152859. constructor(_xrSessionManager: WebXRSessionManager,
  152860. /**
  152861. * options to use when constructing this feature
  152862. */
  152863. options?: IWebXRLegacyHitTestOptions);
  152864. /**
  152865. * execute a hit test with an XR Ray
  152866. *
  152867. * @param xrSession a native xrSession that will execute this hit test
  152868. * @param xrRay the ray (position and direction) to use for ray-casting
  152869. * @param referenceSpace native XR reference space to use for the hit-test
  152870. * @param filter filter function that will filter the results
  152871. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152872. */
  152873. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152874. /**
  152875. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152876. * @param event the (select) event to use to select with
  152877. * @param referenceSpace the reference space to use for this hit test
  152878. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152879. */
  152880. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152881. /**
  152882. * attach this feature
  152883. * Will usually be called by the features manager
  152884. *
  152885. * @returns true if successful.
  152886. */
  152887. attach(): boolean;
  152888. /**
  152889. * detach this feature.
  152890. * Will usually be called by the features manager
  152891. *
  152892. * @returns true if successful.
  152893. */
  152894. detach(): boolean;
  152895. /**
  152896. * Dispose this feature and all of the resources attached
  152897. */
  152898. dispose(): void;
  152899. protected _onXRFrame(frame: XRFrame): void;
  152900. private _onHitTestResults;
  152901. private _onSelect;
  152902. }
  152903. }
  152904. declare module BABYLON {
  152905. /**
  152906. * Options used for hit testing (version 2)
  152907. */
  152908. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152909. /**
  152910. * Do not create a permanent hit test. Will usually be used when only
  152911. * transient inputs are needed.
  152912. */
  152913. disablePermanentHitTest?: boolean;
  152914. /**
  152915. * Enable transient (for example touch-based) hit test inspections
  152916. */
  152917. enableTransientHitTest?: boolean;
  152918. /**
  152919. * Offset ray for the permanent hit test
  152920. */
  152921. offsetRay?: Vector3;
  152922. /**
  152923. * Offset ray for the transient hit test
  152924. */
  152925. transientOffsetRay?: Vector3;
  152926. /**
  152927. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152928. */
  152929. useReferenceSpace?: boolean;
  152930. }
  152931. /**
  152932. * Interface defining the babylon result of hit-test
  152933. */
  152934. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152935. /**
  152936. * The input source that generated this hit test (if transient)
  152937. */
  152938. inputSource?: XRInputSource;
  152939. /**
  152940. * Is this a transient hit test
  152941. */
  152942. isTransient?: boolean;
  152943. /**
  152944. * Position of the hit test result
  152945. */
  152946. position: Vector3;
  152947. /**
  152948. * Rotation of the hit test result
  152949. */
  152950. rotationQuaternion: Quaternion;
  152951. /**
  152952. * The native hit test result
  152953. */
  152954. xrHitResult: XRHitTestResult;
  152955. }
  152956. /**
  152957. * The currently-working hit-test module.
  152958. * Hit test (or Ray-casting) is used to interact with the real world.
  152959. * For further information read here - https://github.com/immersive-web/hit-test
  152960. *
  152961. * Tested on chrome (mobile) 80.
  152962. */
  152963. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152964. /**
  152965. * options to use when constructing this feature
  152966. */
  152967. readonly options: IWebXRHitTestOptions;
  152968. private _tmpMat;
  152969. private _tmpPos;
  152970. private _tmpQuat;
  152971. private _transientXrHitTestSource;
  152972. private _xrHitTestSource;
  152973. private initHitTestSource;
  152974. /**
  152975. * The module's name
  152976. */
  152977. static readonly Name: string;
  152978. /**
  152979. * The (Babylon) version of this module.
  152980. * This is an integer representing the implementation version.
  152981. * This number does not correspond to the WebXR specs version
  152982. */
  152983. static readonly Version: number;
  152984. /**
  152985. * When set to true, each hit test will have its own position/rotation objects
  152986. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152987. * the developers will clone them or copy them as they see fit.
  152988. */
  152989. autoCloneTransformation: boolean;
  152990. /**
  152991. * Triggered when new babylon (transformed) hit test results are available
  152992. */
  152993. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152994. /**
  152995. * Use this to temporarily pause hit test checks.
  152996. */
  152997. paused: boolean;
  152998. /**
  152999. * Creates a new instance of the hit test feature
  153000. * @param _xrSessionManager an instance of WebXRSessionManager
  153001. * @param options options to use when constructing this feature
  153002. */
  153003. constructor(_xrSessionManager: WebXRSessionManager,
  153004. /**
  153005. * options to use when constructing this feature
  153006. */
  153007. options?: IWebXRHitTestOptions);
  153008. /**
  153009. * attach this feature
  153010. * Will usually be called by the features manager
  153011. *
  153012. * @returns true if successful.
  153013. */
  153014. attach(): boolean;
  153015. /**
  153016. * detach this feature.
  153017. * Will usually be called by the features manager
  153018. *
  153019. * @returns true if successful.
  153020. */
  153021. detach(): boolean;
  153022. /**
  153023. * Dispose this feature and all of the resources attached
  153024. */
  153025. dispose(): void;
  153026. protected _onXRFrame(frame: XRFrame): void;
  153027. private _processWebXRHitTestResult;
  153028. }
  153029. }
  153030. declare module BABYLON {
  153031. /**
  153032. * Configuration options of the anchor system
  153033. */
  153034. export interface IWebXRAnchorSystemOptions {
  153035. /**
  153036. * a node that will be used to convert local to world coordinates
  153037. */
  153038. worldParentNode?: TransformNode;
  153039. /**
  153040. * If set to true a reference of the created anchors will be kept until the next session starts
  153041. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  153042. */
  153043. doNotRemoveAnchorsOnSessionEnded?: boolean;
  153044. }
  153045. /**
  153046. * A babylon container for an XR Anchor
  153047. */
  153048. export interface IWebXRAnchor {
  153049. /**
  153050. * A babylon-assigned ID for this anchor
  153051. */
  153052. id: number;
  153053. /**
  153054. * Transformation matrix to apply to an object attached to this anchor
  153055. */
  153056. transformationMatrix: Matrix;
  153057. /**
  153058. * The native anchor object
  153059. */
  153060. xrAnchor: XRAnchor;
  153061. /**
  153062. * if defined, this object will be constantly updated by the anchor's position and rotation
  153063. */
  153064. attachedNode?: TransformNode;
  153065. }
  153066. /**
  153067. * An implementation of the anchor system for WebXR.
  153068. * For further information see https://github.com/immersive-web/anchors/
  153069. */
  153070. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  153071. private _options;
  153072. private _lastFrameDetected;
  153073. private _trackedAnchors;
  153074. private _referenceSpaceForFrameAnchors;
  153075. private _futureAnchors;
  153076. /**
  153077. * The module's name
  153078. */
  153079. static readonly Name: string;
  153080. /**
  153081. * The (Babylon) version of this module.
  153082. * This is an integer representing the implementation version.
  153083. * This number does not correspond to the WebXR specs version
  153084. */
  153085. static readonly Version: number;
  153086. /**
  153087. * Observers registered here will be executed when a new anchor was added to the session
  153088. */
  153089. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  153090. /**
  153091. * Observers registered here will be executed when an anchor was removed from the session
  153092. */
  153093. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  153094. /**
  153095. * Observers registered here will be executed when an existing anchor updates
  153096. * This can execute N times every frame
  153097. */
  153098. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  153099. /**
  153100. * Set the reference space to use for anchor creation, when not using a hit test.
  153101. * Will default to the session's reference space if not defined
  153102. */
  153103. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  153104. /**
  153105. * constructs a new anchor system
  153106. * @param _xrSessionManager an instance of WebXRSessionManager
  153107. * @param _options configuration object for this feature
  153108. */
  153109. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  153110. private _tmpVector;
  153111. private _tmpQuaternion;
  153112. private _populateTmpTransformation;
  153113. /**
  153114. * Create a new anchor point using a hit test result at a specific point in the scene
  153115. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153116. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153117. *
  153118. * @param hitTestResult The hit test result to use for this anchor creation
  153119. * @param position an optional position offset for this anchor
  153120. * @param rotationQuaternion an optional rotation offset for this anchor
  153121. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153122. */
  153123. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  153124. /**
  153125. * Add a new anchor at a specific position and rotation
  153126. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  153127. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  153128. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153129. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153130. *
  153131. * @param position the position in which to add an anchor
  153132. * @param rotationQuaternion an optional rotation for the anchor transformation
  153133. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  153134. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153135. */
  153136. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  153137. /**
  153138. * detach this feature.
  153139. * Will usually be called by the features manager
  153140. *
  153141. * @returns true if successful.
  153142. */
  153143. detach(): boolean;
  153144. /**
  153145. * Dispose this feature and all of the resources attached
  153146. */
  153147. dispose(): void;
  153148. protected _onXRFrame(frame: XRFrame): void;
  153149. /**
  153150. * avoiding using Array.find for global support.
  153151. * @param xrAnchor the plane to find in the array
  153152. */
  153153. private _findIndexInAnchorArray;
  153154. private _updateAnchorWithXRFrame;
  153155. private _createAnchorAtTransformation;
  153156. }
  153157. }
  153158. declare module BABYLON {
  153159. /**
  153160. * Options used in the plane detector module
  153161. */
  153162. export interface IWebXRPlaneDetectorOptions {
  153163. /**
  153164. * The node to use to transform the local results to world coordinates
  153165. */
  153166. worldParentNode?: TransformNode;
  153167. /**
  153168. * If set to true a reference of the created planes will be kept until the next session starts
  153169. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  153170. */
  153171. doNotRemovePlanesOnSessionEnded?: boolean;
  153172. }
  153173. /**
  153174. * A babylon interface for a WebXR plane.
  153175. * A Plane is actually a polygon, built from N points in space
  153176. *
  153177. * Supported in chrome 79, not supported in canary 81 ATM
  153178. */
  153179. export interface IWebXRPlane {
  153180. /**
  153181. * a babylon-assigned ID for this polygon
  153182. */
  153183. id: number;
  153184. /**
  153185. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  153186. */
  153187. polygonDefinition: Array<Vector3>;
  153188. /**
  153189. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  153190. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  153191. */
  153192. transformationMatrix: Matrix;
  153193. /**
  153194. * the native xr-plane object
  153195. */
  153196. xrPlane: XRPlane;
  153197. }
  153198. /**
  153199. * The plane detector is used to detect planes in the real world when in AR
  153200. * For more information see https://github.com/immersive-web/real-world-geometry/
  153201. */
  153202. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  153203. private _options;
  153204. private _detectedPlanes;
  153205. private _enabled;
  153206. private _lastFrameDetected;
  153207. /**
  153208. * The module's name
  153209. */
  153210. static readonly Name: string;
  153211. /**
  153212. * The (Babylon) version of this module.
  153213. * This is an integer representing the implementation version.
  153214. * This number does not correspond to the WebXR specs version
  153215. */
  153216. static readonly Version: number;
  153217. /**
  153218. * Observers registered here will be executed when a new plane was added to the session
  153219. */
  153220. onPlaneAddedObservable: Observable<IWebXRPlane>;
  153221. /**
  153222. * Observers registered here will be executed when a plane is no longer detected in the session
  153223. */
  153224. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153225. /**
  153226. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153227. * This can execute N times every frame
  153228. */
  153229. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153230. /**
  153231. * construct a new Plane Detector
  153232. * @param _xrSessionManager an instance of xr Session manager
  153233. * @param _options configuration to use when constructing this feature
  153234. */
  153235. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153236. /**
  153237. * detach this feature.
  153238. * Will usually be called by the features manager
  153239. *
  153240. * @returns true if successful.
  153241. */
  153242. detach(): boolean;
  153243. /**
  153244. * Dispose this feature and all of the resources attached
  153245. */
  153246. dispose(): void;
  153247. protected _onXRFrame(frame: XRFrame): void;
  153248. private _init;
  153249. private _updatePlaneWithXRPlane;
  153250. /**
  153251. * avoiding using Array.find for global support.
  153252. * @param xrPlane the plane to find in the array
  153253. */
  153254. private findIndexInPlaneArray;
  153255. }
  153256. }
  153257. declare module BABYLON {
  153258. /**
  153259. * Options interface for the background remover plugin
  153260. */
  153261. export interface IWebXRBackgroundRemoverOptions {
  153262. /**
  153263. * Further background meshes to disable when entering AR
  153264. */
  153265. backgroundMeshes?: AbstractMesh[];
  153266. /**
  153267. * flags to configure the removal of the environment helper.
  153268. * If not set, the entire background will be removed. If set, flags should be set as well.
  153269. */
  153270. environmentHelperRemovalFlags?: {
  153271. /**
  153272. * Should the skybox be removed (default false)
  153273. */
  153274. skyBox?: boolean;
  153275. /**
  153276. * Should the ground be removed (default false)
  153277. */
  153278. ground?: boolean;
  153279. };
  153280. /**
  153281. * don't disable the environment helper
  153282. */
  153283. ignoreEnvironmentHelper?: boolean;
  153284. }
  153285. /**
  153286. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153287. */
  153288. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153289. /**
  153290. * read-only options to be used in this module
  153291. */
  153292. readonly options: IWebXRBackgroundRemoverOptions;
  153293. /**
  153294. * The module's name
  153295. */
  153296. static readonly Name: string;
  153297. /**
  153298. * The (Babylon) version of this module.
  153299. * This is an integer representing the implementation version.
  153300. * This number does not correspond to the WebXR specs version
  153301. */
  153302. static readonly Version: number;
  153303. /**
  153304. * registered observers will be triggered when the background state changes
  153305. */
  153306. onBackgroundStateChangedObservable: Observable<boolean>;
  153307. /**
  153308. * constructs a new background remover module
  153309. * @param _xrSessionManager the session manager for this module
  153310. * @param options read-only options to be used in this module
  153311. */
  153312. constructor(_xrSessionManager: WebXRSessionManager,
  153313. /**
  153314. * read-only options to be used in this module
  153315. */
  153316. options?: IWebXRBackgroundRemoverOptions);
  153317. /**
  153318. * attach this feature
  153319. * Will usually be called by the features manager
  153320. *
  153321. * @returns true if successful.
  153322. */
  153323. attach(): boolean;
  153324. /**
  153325. * detach this feature.
  153326. * Will usually be called by the features manager
  153327. *
  153328. * @returns true if successful.
  153329. */
  153330. detach(): boolean;
  153331. /**
  153332. * Dispose this feature and all of the resources attached
  153333. */
  153334. dispose(): void;
  153335. protected _onXRFrame(_xrFrame: XRFrame): void;
  153336. private _setBackgroundState;
  153337. }
  153338. }
  153339. declare module BABYLON {
  153340. /**
  153341. * Options for the controller physics feature
  153342. */
  153343. export class IWebXRControllerPhysicsOptions {
  153344. /**
  153345. * Should the headset get its own impostor
  153346. */
  153347. enableHeadsetImpostor?: boolean;
  153348. /**
  153349. * Optional parameters for the headset impostor
  153350. */
  153351. headsetImpostorParams?: {
  153352. /**
  153353. * The type of impostor to create. Default is sphere
  153354. */
  153355. impostorType: number;
  153356. /**
  153357. * the size of the impostor. Defaults to 10cm
  153358. */
  153359. impostorSize?: number | {
  153360. width: number;
  153361. height: number;
  153362. depth: number;
  153363. };
  153364. /**
  153365. * Friction definitions
  153366. */
  153367. friction?: number;
  153368. /**
  153369. * Restitution
  153370. */
  153371. restitution?: number;
  153372. };
  153373. /**
  153374. * The physics properties of the future impostors
  153375. */
  153376. physicsProperties?: {
  153377. /**
  153378. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153379. * Note that this requires a physics engine that supports mesh impostors!
  153380. */
  153381. useControllerMesh?: boolean;
  153382. /**
  153383. * The type of impostor to create. Default is sphere
  153384. */
  153385. impostorType?: number;
  153386. /**
  153387. * the size of the impostor. Defaults to 10cm
  153388. */
  153389. impostorSize?: number | {
  153390. width: number;
  153391. height: number;
  153392. depth: number;
  153393. };
  153394. /**
  153395. * Friction definitions
  153396. */
  153397. friction?: number;
  153398. /**
  153399. * Restitution
  153400. */
  153401. restitution?: number;
  153402. };
  153403. /**
  153404. * the xr input to use with this pointer selection
  153405. */
  153406. xrInput: WebXRInput;
  153407. }
  153408. /**
  153409. * Add physics impostor to your webxr controllers,
  153410. * including naive calculation of their linear and angular velocity
  153411. */
  153412. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153413. private readonly _options;
  153414. private _attachController;
  153415. private _controllers;
  153416. private _debugMode;
  153417. private _delta;
  153418. private _headsetImpostor?;
  153419. private _headsetMesh?;
  153420. private _lastTimestamp;
  153421. private _tmpQuaternion;
  153422. private _tmpVector;
  153423. /**
  153424. * The module's name
  153425. */
  153426. static readonly Name: string;
  153427. /**
  153428. * The (Babylon) version of this module.
  153429. * This is an integer representing the implementation version.
  153430. * This number does not correspond to the webxr specs version
  153431. */
  153432. static readonly Version: number;
  153433. /**
  153434. * Construct a new Controller Physics Feature
  153435. * @param _xrSessionManager the corresponding xr session manager
  153436. * @param _options options to create this feature with
  153437. */
  153438. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153439. /**
  153440. * @hidden
  153441. * enable debugging - will show console outputs and the impostor mesh
  153442. */
  153443. _enablePhysicsDebug(): void;
  153444. /**
  153445. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153446. * @param xrController the controller to add
  153447. */
  153448. addController(xrController: WebXRInputSource): void;
  153449. /**
  153450. * attach this feature
  153451. * Will usually be called by the features manager
  153452. *
  153453. * @returns true if successful.
  153454. */
  153455. attach(): boolean;
  153456. /**
  153457. * detach this feature.
  153458. * Will usually be called by the features manager
  153459. *
  153460. * @returns true if successful.
  153461. */
  153462. detach(): boolean;
  153463. /**
  153464. * Get the headset impostor, if enabled
  153465. * @returns the impostor
  153466. */
  153467. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153468. /**
  153469. * Get the physics impostor of a specific controller.
  153470. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153471. * @param controller the controller or the controller id of which to get the impostor
  153472. * @returns the impostor or null
  153473. */
  153474. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153475. /**
  153476. * Update the physics properties provided in the constructor
  153477. * @param newProperties the new properties object
  153478. */
  153479. setPhysicsProperties(newProperties: {
  153480. impostorType?: number;
  153481. impostorSize?: number | {
  153482. width: number;
  153483. height: number;
  153484. depth: number;
  153485. };
  153486. friction?: number;
  153487. restitution?: number;
  153488. }): void;
  153489. protected _onXRFrame(_xrFrame: any): void;
  153490. private _detachController;
  153491. }
  153492. }
  153493. declare module BABYLON {
  153494. /**
  153495. * The motion controller class for all microsoft mixed reality controllers
  153496. */
  153497. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153498. protected readonly _mapping: {
  153499. defaultButton: {
  153500. valueNodeName: string;
  153501. unpressedNodeName: string;
  153502. pressedNodeName: string;
  153503. };
  153504. defaultAxis: {
  153505. valueNodeName: string;
  153506. minNodeName: string;
  153507. maxNodeName: string;
  153508. };
  153509. buttons: {
  153510. "xr-standard-trigger": {
  153511. rootNodeName: string;
  153512. componentProperty: string;
  153513. states: string[];
  153514. };
  153515. "xr-standard-squeeze": {
  153516. rootNodeName: string;
  153517. componentProperty: string;
  153518. states: string[];
  153519. };
  153520. "xr-standard-touchpad": {
  153521. rootNodeName: string;
  153522. labelAnchorNodeName: string;
  153523. touchPointNodeName: string;
  153524. };
  153525. "xr-standard-thumbstick": {
  153526. rootNodeName: string;
  153527. componentProperty: string;
  153528. states: string[];
  153529. };
  153530. };
  153531. axes: {
  153532. "xr-standard-touchpad": {
  153533. "x-axis": {
  153534. rootNodeName: string;
  153535. };
  153536. "y-axis": {
  153537. rootNodeName: string;
  153538. };
  153539. };
  153540. "xr-standard-thumbstick": {
  153541. "x-axis": {
  153542. rootNodeName: string;
  153543. };
  153544. "y-axis": {
  153545. rootNodeName: string;
  153546. };
  153547. };
  153548. };
  153549. };
  153550. /**
  153551. * The base url used to load the left and right controller models
  153552. */
  153553. static MODEL_BASE_URL: string;
  153554. /**
  153555. * The name of the left controller model file
  153556. */
  153557. static MODEL_LEFT_FILENAME: string;
  153558. /**
  153559. * The name of the right controller model file
  153560. */
  153561. static MODEL_RIGHT_FILENAME: string;
  153562. profileId: string;
  153563. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153564. protected _getFilenameAndPath(): {
  153565. filename: string;
  153566. path: string;
  153567. };
  153568. protected _getModelLoadingConstraints(): boolean;
  153569. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153570. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153571. protected _updateModel(): void;
  153572. }
  153573. }
  153574. declare module BABYLON {
  153575. /**
  153576. * The motion controller class for oculus touch (quest, rift).
  153577. * This class supports legacy mapping as well the standard xr mapping
  153578. */
  153579. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153580. private _forceLegacyControllers;
  153581. private _modelRootNode;
  153582. /**
  153583. * The base url used to load the left and right controller models
  153584. */
  153585. static MODEL_BASE_URL: string;
  153586. /**
  153587. * The name of the left controller model file
  153588. */
  153589. static MODEL_LEFT_FILENAME: string;
  153590. /**
  153591. * The name of the right controller model file
  153592. */
  153593. static MODEL_RIGHT_FILENAME: string;
  153594. /**
  153595. * Base Url for the Quest controller model.
  153596. */
  153597. static QUEST_MODEL_BASE_URL: string;
  153598. profileId: string;
  153599. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153600. protected _getFilenameAndPath(): {
  153601. filename: string;
  153602. path: string;
  153603. };
  153604. protected _getModelLoadingConstraints(): boolean;
  153605. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153606. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153607. protected _updateModel(): void;
  153608. /**
  153609. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153610. * between the touch and touch 2.
  153611. */
  153612. private _isQuest;
  153613. }
  153614. }
  153615. declare module BABYLON {
  153616. /**
  153617. * The motion controller class for the standard HTC-Vive controllers
  153618. */
  153619. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153620. private _modelRootNode;
  153621. /**
  153622. * The base url used to load the left and right controller models
  153623. */
  153624. static MODEL_BASE_URL: string;
  153625. /**
  153626. * File name for the controller model.
  153627. */
  153628. static MODEL_FILENAME: string;
  153629. profileId: string;
  153630. /**
  153631. * Create a new Vive motion controller object
  153632. * @param scene the scene to use to create this controller
  153633. * @param gamepadObject the corresponding gamepad object
  153634. * @param handedness the handedness of the controller
  153635. */
  153636. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153637. protected _getFilenameAndPath(): {
  153638. filename: string;
  153639. path: string;
  153640. };
  153641. protected _getModelLoadingConstraints(): boolean;
  153642. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153643. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153644. protected _updateModel(): void;
  153645. }
  153646. }
  153647. declare module BABYLON {
  153648. /**
  153649. * A cursor which tracks a point on a path
  153650. */
  153651. export class PathCursor {
  153652. private path;
  153653. /**
  153654. * Stores path cursor callbacks for when an onchange event is triggered
  153655. */
  153656. private _onchange;
  153657. /**
  153658. * The value of the path cursor
  153659. */
  153660. value: number;
  153661. /**
  153662. * The animation array of the path cursor
  153663. */
  153664. animations: Animation[];
  153665. /**
  153666. * Initializes the path cursor
  153667. * @param path The path to track
  153668. */
  153669. constructor(path: Path2);
  153670. /**
  153671. * Gets the cursor point on the path
  153672. * @returns A point on the path cursor at the cursor location
  153673. */
  153674. getPoint(): Vector3;
  153675. /**
  153676. * Moves the cursor ahead by the step amount
  153677. * @param step The amount to move the cursor forward
  153678. * @returns This path cursor
  153679. */
  153680. moveAhead(step?: number): PathCursor;
  153681. /**
  153682. * Moves the cursor behind by the step amount
  153683. * @param step The amount to move the cursor back
  153684. * @returns This path cursor
  153685. */
  153686. moveBack(step?: number): PathCursor;
  153687. /**
  153688. * Moves the cursor by the step amount
  153689. * If the step amount is greater than one, an exception is thrown
  153690. * @param step The amount to move the cursor
  153691. * @returns This path cursor
  153692. */
  153693. move(step: number): PathCursor;
  153694. /**
  153695. * Ensures that the value is limited between zero and one
  153696. * @returns This path cursor
  153697. */
  153698. private ensureLimits;
  153699. /**
  153700. * Runs onchange callbacks on change (used by the animation engine)
  153701. * @returns This path cursor
  153702. */
  153703. private raiseOnChange;
  153704. /**
  153705. * Executes a function on change
  153706. * @param f A path cursor onchange callback
  153707. * @returns This path cursor
  153708. */
  153709. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153710. }
  153711. }
  153712. declare module BABYLON {
  153713. /** @hidden */
  153714. export var blurPixelShader: {
  153715. name: string;
  153716. shader: string;
  153717. };
  153718. }
  153719. declare module BABYLON {
  153720. /** @hidden */
  153721. export var pointCloudVertexDeclaration: {
  153722. name: string;
  153723. shader: string;
  153724. };
  153725. }
  153726. // Mixins
  153727. interface Window {
  153728. mozIndexedDB: IDBFactory;
  153729. webkitIndexedDB: IDBFactory;
  153730. msIndexedDB: IDBFactory;
  153731. webkitURL: typeof URL;
  153732. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153733. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153734. WebGLRenderingContext: WebGLRenderingContext;
  153735. MSGesture: MSGesture;
  153736. CANNON: any;
  153737. AudioContext: AudioContext;
  153738. webkitAudioContext: AudioContext;
  153739. PointerEvent: any;
  153740. Math: Math;
  153741. Uint8Array: Uint8ArrayConstructor;
  153742. Float32Array: Float32ArrayConstructor;
  153743. mozURL: typeof URL;
  153744. msURL: typeof URL;
  153745. VRFrameData: any; // WebVR, from specs 1.1
  153746. DracoDecoderModule: any;
  153747. setImmediate(handler: (...args: any[]) => void): number;
  153748. }
  153749. interface HTMLCanvasElement {
  153750. requestPointerLock(): void;
  153751. msRequestPointerLock?(): void;
  153752. mozRequestPointerLock?(): void;
  153753. webkitRequestPointerLock?(): void;
  153754. /** Track wether a record is in progress */
  153755. isRecording: boolean;
  153756. /** Capture Stream method defined by some browsers */
  153757. captureStream(fps?: number): MediaStream;
  153758. }
  153759. interface CanvasRenderingContext2D {
  153760. msImageSmoothingEnabled: boolean;
  153761. }
  153762. interface MouseEvent {
  153763. mozMovementX: number;
  153764. mozMovementY: number;
  153765. webkitMovementX: number;
  153766. webkitMovementY: number;
  153767. msMovementX: number;
  153768. msMovementY: number;
  153769. }
  153770. interface Navigator {
  153771. mozGetVRDevices: (any: any) => any;
  153772. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153773. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153774. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153775. webkitGetGamepads(): Gamepad[];
  153776. msGetGamepads(): Gamepad[];
  153777. webkitGamepads(): Gamepad[];
  153778. }
  153779. interface HTMLVideoElement {
  153780. mozSrcObject: any;
  153781. }
  153782. interface Math {
  153783. fround(x: number): number;
  153784. imul(a: number, b: number): number;
  153785. }
  153786. interface WebGLRenderingContext {
  153787. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153788. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153789. vertexAttribDivisor(index: number, divisor: number): void;
  153790. createVertexArray(): any;
  153791. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153792. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153793. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153794. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153795. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153796. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153797. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153798. // Queries
  153799. createQuery(): WebGLQuery;
  153800. deleteQuery(query: WebGLQuery): void;
  153801. beginQuery(target: number, query: WebGLQuery): void;
  153802. endQuery(target: number): void;
  153803. getQueryParameter(query: WebGLQuery, pname: number): any;
  153804. getQuery(target: number, pname: number): any;
  153805. MAX_SAMPLES: number;
  153806. RGBA8: number;
  153807. READ_FRAMEBUFFER: number;
  153808. DRAW_FRAMEBUFFER: number;
  153809. UNIFORM_BUFFER: number;
  153810. HALF_FLOAT_OES: number;
  153811. RGBA16F: number;
  153812. RGBA32F: number;
  153813. R32F: number;
  153814. RG32F: number;
  153815. RGB32F: number;
  153816. R16F: number;
  153817. RG16F: number;
  153818. RGB16F: number;
  153819. RED: number;
  153820. RG: number;
  153821. R8: number;
  153822. RG8: number;
  153823. UNSIGNED_INT_24_8: number;
  153824. DEPTH24_STENCIL8: number;
  153825. MIN: number;
  153826. MAX: number;
  153827. /* Multiple Render Targets */
  153828. drawBuffers(buffers: number[]): void;
  153829. readBuffer(src: number): void;
  153830. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153831. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153832. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153833. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153834. // Occlusion Query
  153835. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153836. ANY_SAMPLES_PASSED: number;
  153837. QUERY_RESULT_AVAILABLE: number;
  153838. QUERY_RESULT: number;
  153839. }
  153840. interface WebGLProgram {
  153841. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153842. }
  153843. interface EXT_disjoint_timer_query {
  153844. QUERY_COUNTER_BITS_EXT: number;
  153845. TIME_ELAPSED_EXT: number;
  153846. TIMESTAMP_EXT: number;
  153847. GPU_DISJOINT_EXT: number;
  153848. QUERY_RESULT_EXT: number;
  153849. QUERY_RESULT_AVAILABLE_EXT: number;
  153850. queryCounterEXT(query: WebGLQuery, target: number): void;
  153851. createQueryEXT(): WebGLQuery;
  153852. beginQueryEXT(target: number, query: WebGLQuery): void;
  153853. endQueryEXT(target: number): void;
  153854. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153855. deleteQueryEXT(query: WebGLQuery): void;
  153856. }
  153857. interface WebGLUniformLocation {
  153858. _currentState: any;
  153859. }
  153860. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153861. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153862. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153863. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153864. interface WebGLRenderingContext {
  153865. readonly RASTERIZER_DISCARD: number;
  153866. readonly DEPTH_COMPONENT24: number;
  153867. readonly TEXTURE_3D: number;
  153868. readonly TEXTURE_2D_ARRAY: number;
  153869. readonly TEXTURE_COMPARE_FUNC: number;
  153870. readonly TEXTURE_COMPARE_MODE: number;
  153871. readonly COMPARE_REF_TO_TEXTURE: number;
  153872. readonly TEXTURE_WRAP_R: number;
  153873. readonly HALF_FLOAT: number;
  153874. readonly RGB8: number;
  153875. readonly RED_INTEGER: number;
  153876. readonly RG_INTEGER: number;
  153877. readonly RGB_INTEGER: number;
  153878. readonly RGBA_INTEGER: number;
  153879. readonly R8_SNORM: number;
  153880. readonly RG8_SNORM: number;
  153881. readonly RGB8_SNORM: number;
  153882. readonly RGBA8_SNORM: number;
  153883. readonly R8I: number;
  153884. readonly RG8I: number;
  153885. readonly RGB8I: number;
  153886. readonly RGBA8I: number;
  153887. readonly R8UI: number;
  153888. readonly RG8UI: number;
  153889. readonly RGB8UI: number;
  153890. readonly RGBA8UI: number;
  153891. readonly R16I: number;
  153892. readonly RG16I: number;
  153893. readonly RGB16I: number;
  153894. readonly RGBA16I: number;
  153895. readonly R16UI: number;
  153896. readonly RG16UI: number;
  153897. readonly RGB16UI: number;
  153898. readonly RGBA16UI: number;
  153899. readonly R32I: number;
  153900. readonly RG32I: number;
  153901. readonly RGB32I: number;
  153902. readonly RGBA32I: number;
  153903. readonly R32UI: number;
  153904. readonly RG32UI: number;
  153905. readonly RGB32UI: number;
  153906. readonly RGBA32UI: number;
  153907. readonly RGB10_A2UI: number;
  153908. readonly R11F_G11F_B10F: number;
  153909. readonly RGB9_E5: number;
  153910. readonly RGB10_A2: number;
  153911. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153912. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153913. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153914. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153915. readonly DEPTH_COMPONENT32F: number;
  153916. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153917. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153918. 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;
  153919. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153920. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153921. readonly TRANSFORM_FEEDBACK: number;
  153922. readonly INTERLEAVED_ATTRIBS: number;
  153923. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153924. createTransformFeedback(): WebGLTransformFeedback;
  153925. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153926. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153927. beginTransformFeedback(primitiveMode: number): void;
  153928. endTransformFeedback(): void;
  153929. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153930. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153931. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153932. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153933. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153934. }
  153935. interface ImageBitmap {
  153936. readonly width: number;
  153937. readonly height: number;
  153938. close(): void;
  153939. }
  153940. interface WebGLQuery extends WebGLObject {
  153941. }
  153942. declare var WebGLQuery: {
  153943. prototype: WebGLQuery;
  153944. new(): WebGLQuery;
  153945. };
  153946. interface WebGLSampler extends WebGLObject {
  153947. }
  153948. declare var WebGLSampler: {
  153949. prototype: WebGLSampler;
  153950. new(): WebGLSampler;
  153951. };
  153952. interface WebGLSync extends WebGLObject {
  153953. }
  153954. declare var WebGLSync: {
  153955. prototype: WebGLSync;
  153956. new(): WebGLSync;
  153957. };
  153958. interface WebGLTransformFeedback extends WebGLObject {
  153959. }
  153960. declare var WebGLTransformFeedback: {
  153961. prototype: WebGLTransformFeedback;
  153962. new(): WebGLTransformFeedback;
  153963. };
  153964. interface WebGLVertexArrayObject extends WebGLObject {
  153965. }
  153966. declare var WebGLVertexArrayObject: {
  153967. prototype: WebGLVertexArrayObject;
  153968. new(): WebGLVertexArrayObject;
  153969. };
  153970. // Type definitions for WebVR API
  153971. // Project: https://w3c.github.io/webvr/
  153972. // Definitions by: six a <https://github.com/lostfictions>
  153973. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153974. interface VRDisplay extends EventTarget {
  153975. /**
  153976. * Dictionary of capabilities describing the VRDisplay.
  153977. */
  153978. readonly capabilities: VRDisplayCapabilities;
  153979. /**
  153980. * z-depth defining the far plane of the eye view frustum
  153981. * enables mapping of values in the render target depth
  153982. * attachment to scene coordinates. Initially set to 10000.0.
  153983. */
  153984. depthFar: number;
  153985. /**
  153986. * z-depth defining the near plane of the eye view frustum
  153987. * enables mapping of values in the render target depth
  153988. * attachment to scene coordinates. Initially set to 0.01.
  153989. */
  153990. depthNear: number;
  153991. /**
  153992. * An identifier for this distinct VRDisplay. Used as an
  153993. * association point in the Gamepad API.
  153994. */
  153995. readonly displayId: number;
  153996. /**
  153997. * A display name, a user-readable name identifying it.
  153998. */
  153999. readonly displayName: string;
  154000. readonly isConnected: boolean;
  154001. readonly isPresenting: boolean;
  154002. /**
  154003. * If this VRDisplay supports room-scale experiences, the optional
  154004. * stage attribute contains details on the room-scale parameters.
  154005. */
  154006. readonly stageParameters: VRStageParameters | null;
  154007. /**
  154008. * Passing the value returned by `requestAnimationFrame` to
  154009. * `cancelAnimationFrame` will unregister the callback.
  154010. * @param handle Define the hanle of the request to cancel
  154011. */
  154012. cancelAnimationFrame(handle: number): void;
  154013. /**
  154014. * Stops presenting to the VRDisplay.
  154015. * @returns a promise to know when it stopped
  154016. */
  154017. exitPresent(): Promise<void>;
  154018. /**
  154019. * Return the current VREyeParameters for the given eye.
  154020. * @param whichEye Define the eye we want the parameter for
  154021. * @returns the eye parameters
  154022. */
  154023. getEyeParameters(whichEye: string): VREyeParameters;
  154024. /**
  154025. * Populates the passed VRFrameData with the information required to render
  154026. * the current frame.
  154027. * @param frameData Define the data structure to populate
  154028. * @returns true if ok otherwise false
  154029. */
  154030. getFrameData(frameData: VRFrameData): boolean;
  154031. /**
  154032. * Get the layers currently being presented.
  154033. * @returns the list of VR layers
  154034. */
  154035. getLayers(): VRLayer[];
  154036. /**
  154037. * Return a VRPose containing the future predicted pose of the VRDisplay
  154038. * when the current frame will be presented. The value returned will not
  154039. * change until JavaScript has returned control to the browser.
  154040. *
  154041. * The VRPose will contain the position, orientation, velocity,
  154042. * and acceleration of each of these properties.
  154043. * @returns the pose object
  154044. */
  154045. getPose(): VRPose;
  154046. /**
  154047. * Return the current instantaneous pose of the VRDisplay, with no
  154048. * prediction applied.
  154049. * @returns the current instantaneous pose
  154050. */
  154051. getImmediatePose(): VRPose;
  154052. /**
  154053. * The callback passed to `requestAnimationFrame` will be called
  154054. * any time a new frame should be rendered. When the VRDisplay is
  154055. * presenting the callback will be called at the native refresh
  154056. * rate of the HMD. When not presenting this function acts
  154057. * identically to how window.requestAnimationFrame acts. Content should
  154058. * make no assumptions of frame rate or vsync behavior as the HMD runs
  154059. * asynchronously from other displays and at differing refresh rates.
  154060. * @param callback Define the eaction to run next frame
  154061. * @returns the request handle it
  154062. */
  154063. requestAnimationFrame(callback: FrameRequestCallback): number;
  154064. /**
  154065. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  154066. * Repeat calls while already presenting will update the VRLayers being displayed.
  154067. * @param layers Define the list of layer to present
  154068. * @returns a promise to know when the request has been fulfilled
  154069. */
  154070. requestPresent(layers: VRLayer[]): Promise<void>;
  154071. /**
  154072. * Reset the pose for this display, treating its current position and
  154073. * orientation as the "origin/zero" values. VRPose.position,
  154074. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  154075. * updated when calling resetPose(). This should be called in only
  154076. * sitting-space experiences.
  154077. */
  154078. resetPose(): void;
  154079. /**
  154080. * The VRLayer provided to the VRDisplay will be captured and presented
  154081. * in the HMD. Calling this function has the same effect on the source
  154082. * canvas as any other operation that uses its source image, and canvases
  154083. * created without preserveDrawingBuffer set to true will be cleared.
  154084. * @param pose Define the pose to submit
  154085. */
  154086. submitFrame(pose?: VRPose): void;
  154087. }
  154088. declare var VRDisplay: {
  154089. prototype: VRDisplay;
  154090. new(): VRDisplay;
  154091. };
  154092. interface VRLayer {
  154093. leftBounds?: number[] | Float32Array | null;
  154094. rightBounds?: number[] | Float32Array | null;
  154095. source?: HTMLCanvasElement | null;
  154096. }
  154097. interface VRDisplayCapabilities {
  154098. readonly canPresent: boolean;
  154099. readonly hasExternalDisplay: boolean;
  154100. readonly hasOrientation: boolean;
  154101. readonly hasPosition: boolean;
  154102. readonly maxLayers: number;
  154103. }
  154104. interface VREyeParameters {
  154105. /** @deprecated */
  154106. readonly fieldOfView: VRFieldOfView;
  154107. readonly offset: Float32Array;
  154108. readonly renderHeight: number;
  154109. readonly renderWidth: number;
  154110. }
  154111. interface VRFieldOfView {
  154112. readonly downDegrees: number;
  154113. readonly leftDegrees: number;
  154114. readonly rightDegrees: number;
  154115. readonly upDegrees: number;
  154116. }
  154117. interface VRFrameData {
  154118. readonly leftProjectionMatrix: Float32Array;
  154119. readonly leftViewMatrix: Float32Array;
  154120. readonly pose: VRPose;
  154121. readonly rightProjectionMatrix: Float32Array;
  154122. readonly rightViewMatrix: Float32Array;
  154123. readonly timestamp: number;
  154124. }
  154125. interface VRPose {
  154126. readonly angularAcceleration: Float32Array | null;
  154127. readonly angularVelocity: Float32Array | null;
  154128. readonly linearAcceleration: Float32Array | null;
  154129. readonly linearVelocity: Float32Array | null;
  154130. readonly orientation: Float32Array | null;
  154131. readonly position: Float32Array | null;
  154132. readonly timestamp: number;
  154133. }
  154134. interface VRStageParameters {
  154135. sittingToStandingTransform?: Float32Array;
  154136. sizeX?: number;
  154137. sizeY?: number;
  154138. }
  154139. interface Navigator {
  154140. getVRDisplays(): Promise<VRDisplay[]>;
  154141. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  154142. }
  154143. interface Window {
  154144. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  154145. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  154146. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  154147. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154148. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154149. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  154150. }
  154151. interface Gamepad {
  154152. readonly displayId: number;
  154153. }
  154154. type XRSessionMode =
  154155. | "inline"
  154156. | "immersive-vr"
  154157. | "immersive-ar";
  154158. type XRReferenceSpaceType =
  154159. | "viewer"
  154160. | "local"
  154161. | "local-floor"
  154162. | "bounded-floor"
  154163. | "unbounded";
  154164. type XREnvironmentBlendMode =
  154165. | "opaque"
  154166. | "additive"
  154167. | "alpha-blend";
  154168. type XRVisibilityState =
  154169. | "visible"
  154170. | "visible-blurred"
  154171. | "hidden";
  154172. type XRHandedness =
  154173. | "none"
  154174. | "left"
  154175. | "right";
  154176. type XRTargetRayMode =
  154177. | "gaze"
  154178. | "tracked-pointer"
  154179. | "screen";
  154180. type XREye =
  154181. | "none"
  154182. | "left"
  154183. | "right";
  154184. type XREventType =
  154185. | "devicechange"
  154186. | "visibilitychange"
  154187. | "end"
  154188. | "inputsourceschange"
  154189. | "select"
  154190. | "selectstart"
  154191. | "selectend"
  154192. | "squeeze"
  154193. | "squeezestart"
  154194. | "squeezeend"
  154195. | "reset";
  154196. interface XRSpace extends EventTarget {
  154197. }
  154198. interface XRRenderState {
  154199. depthNear?: number;
  154200. depthFar?: number;
  154201. inlineVerticalFieldOfView?: number;
  154202. baseLayer?: XRWebGLLayer;
  154203. }
  154204. interface XRInputSource {
  154205. handedness: XRHandedness;
  154206. targetRayMode: XRTargetRayMode;
  154207. targetRaySpace: XRSpace;
  154208. gripSpace: XRSpace | undefined;
  154209. gamepad: Gamepad | undefined;
  154210. profiles: Array<string>;
  154211. }
  154212. interface XRSessionInit {
  154213. optionalFeatures?: string[];
  154214. requiredFeatures?: string[];
  154215. }
  154216. interface XRSession {
  154217. addEventListener: Function;
  154218. removeEventListener: Function;
  154219. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  154220. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  154221. requestAnimationFrame: Function;
  154222. end(): Promise<void>;
  154223. renderState: XRRenderState;
  154224. inputSources: Array<XRInputSource>;
  154225. // hit test
  154226. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154227. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154228. // legacy AR hit test
  154229. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154230. // legacy plane detection
  154231. updateWorldTrackingState(options: {
  154232. planeDetectionState?: { enabled: boolean; }
  154233. }): void;
  154234. }
  154235. interface XRReferenceSpace extends XRSpace {
  154236. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154237. onreset: any;
  154238. }
  154239. type XRPlaneSet = Set<XRPlane>;
  154240. type XRAnchorSet = Set<XRAnchor>;
  154241. interface XRFrame {
  154242. session: XRSession;
  154243. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154244. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154245. // AR
  154246. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154247. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154248. // Anchors
  154249. trackedAnchors?: XRAnchorSet;
  154250. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154251. // Planes
  154252. worldInformation: {
  154253. detectedPlanes?: XRPlaneSet;
  154254. };
  154255. }
  154256. interface XRViewerPose extends XRPose {
  154257. views: Array<XRView>;
  154258. }
  154259. interface XRPose {
  154260. transform: XRRigidTransform;
  154261. emulatedPosition: boolean;
  154262. }
  154263. interface XRWebGLLayerOptions {
  154264. antialias?: boolean;
  154265. depth?: boolean;
  154266. stencil?: boolean;
  154267. alpha?: boolean;
  154268. multiview?: boolean;
  154269. framebufferScaleFactor?: number;
  154270. }
  154271. declare var XRWebGLLayer: {
  154272. prototype: XRWebGLLayer;
  154273. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154274. };
  154275. interface XRWebGLLayer {
  154276. framebuffer: WebGLFramebuffer;
  154277. framebufferWidth: number;
  154278. framebufferHeight: number;
  154279. getViewport: Function;
  154280. }
  154281. declare class XRRigidTransform {
  154282. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154283. position: DOMPointReadOnly;
  154284. orientation: DOMPointReadOnly;
  154285. matrix: Float32Array;
  154286. inverse: XRRigidTransform;
  154287. }
  154288. interface XRView {
  154289. eye: XREye;
  154290. projectionMatrix: Float32Array;
  154291. transform: XRRigidTransform;
  154292. }
  154293. interface XRInputSourceChangeEvent {
  154294. session: XRSession;
  154295. removed: Array<XRInputSource>;
  154296. added: Array<XRInputSource>;
  154297. }
  154298. interface XRInputSourceEvent extends Event {
  154299. readonly frame: XRFrame;
  154300. readonly inputSource: XRInputSource;
  154301. }
  154302. // Experimental(er) features
  154303. declare class XRRay {
  154304. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154305. origin: DOMPointReadOnly;
  154306. direction: DOMPointReadOnly;
  154307. matrix: Float32Array;
  154308. }
  154309. declare enum XRHitTestTrackableType {
  154310. "point",
  154311. "plane"
  154312. }
  154313. interface XRHitResult {
  154314. hitMatrix: Float32Array;
  154315. }
  154316. interface XRTransientInputHitTestResult {
  154317. readonly inputSource: XRInputSource;
  154318. readonly results: Array<XRHitTestResult>;
  154319. }
  154320. interface XRHitTestResult {
  154321. getPose(baseSpace: XRSpace): XRPose | undefined;
  154322. // When anchor system is enabled
  154323. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154324. }
  154325. interface XRHitTestSource {
  154326. cancel(): void;
  154327. }
  154328. interface XRTransientInputHitTestSource {
  154329. cancel(): void;
  154330. }
  154331. interface XRHitTestOptionsInit {
  154332. space: XRSpace;
  154333. entityTypes?: Array<XRHitTestTrackableType>;
  154334. offsetRay?: XRRay;
  154335. }
  154336. interface XRTransientInputHitTestOptionsInit {
  154337. profile: string;
  154338. entityTypes?: Array<XRHitTestTrackableType>;
  154339. offsetRay?: XRRay;
  154340. }
  154341. interface XRAnchor {
  154342. anchorSpace: XRSpace;
  154343. delete(): void;
  154344. }
  154345. interface XRPlane {
  154346. orientation: "Horizontal" | "Vertical";
  154347. planeSpace: XRSpace;
  154348. polygon: Array<DOMPointReadOnly>;
  154349. lastChangedTime: number;
  154350. }